Skip to content

Commit f19e995

Browse files
qsngregkh
authored andcommitted
tls: adjust recv return with async crypto and failed copy to userspace
[ Upstream commit 85eef9a ] process_rx_list may not copy as many bytes as we want to the userspace buffer, for example in case we hit an EFAULT during the copy. If this happens, we should only count the bytes that were actually copied, which may be 0. Subtracting async_copy_bytes is correct in both peek and !peek cases, because decrypted == async_copy_bytes + peeked for the peek case: peek is always !ZC, and we can go through either the sync or async path. In the async case, we add chunk to both decrypted and async_copy_bytes. In the sync case, we add chunk to both decrypted and peeked. I missed that in commit 6caaf10 ("tls: fix peeking with sync+async decryption"). Fixes: 4d42cd6 ("tls: rx: fix return value for async crypto") Signed-off-by: Sabrina Dubroca <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/1b5a1eaab3c088a9dd5d9f1059ceecd7afe888d1.1711120964.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent dc4bce2 commit f19e995

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/tls/tls_sw.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,6 +2158,9 @@ int tls_sw_recvmsg(struct sock *sk,
21582158
else
21592159
err = process_rx_list(ctx, msg, &control, 0,
21602160
async_copy_bytes, is_peek, NULL);
2161+
2162+
/* we could have copied less than we wanted, and possibly nothing */
2163+
decrypted += max(err, 0) - async_copy_bytes;
21612164
}
21622165

21632166
copied += decrypted;

0 commit comments

Comments
 (0)