Skip to content

Commit 692d7b5

Browse files
nxa22042davem330
authored andcommitted
tls: Fix recvmsg() to be able to peek across multiple records
This fixes recvmsg() to be able to peek across multiple tls records. Without this patch, the tls's selftests test case 'recv_peek_large_buf_mult_recs' fails. Each tls receive context now maintains a 'rx_list' to retain incoming skb carrying tls records. If a tls record needs to be retained e.g. for peek case or for the case when the buffer passed to recvmsg() has a length smaller than decrypted record length, then it is added to 'rx_list'. Additionally, records are added in 'rx_list' if the crypto operation runs in async mode. The records are dequeued from 'rx_list' after the decrypted data is consumed by copying into the buffer passed to recvmsg(). In case, the MSG_PEEK flag is used in recvmsg(), then records are not consumed or removed from the 'rx_list'. Signed-off-by: Vakul Garg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fb73d62 commit 692d7b5

File tree

2 files changed

+198
-71
lines changed

2 files changed

+198
-71
lines changed

include/net/tls.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,13 @@ struct tls_sw_context_tx {
145145
struct tls_sw_context_rx {
146146
struct crypto_aead *aead_recv;
147147
struct crypto_wait async_wait;
148-
149148
struct strparser strp;
149+
struct sk_buff_head rx_list; /* list of decrypted 'data' records */
150150
void (*saved_data_ready)(struct sock *sk);
151151

152152
struct sk_buff *recv_pkt;
153153
u8 control;
154+
int async_capable;
154155
bool decrypted;
155156
atomic_t decrypt_pending;
156157
bool async_notify;

0 commit comments

Comments
 (0)