Commit 692d7b5d authored by Vakul Garg's avatar Vakul Garg Committed by David S. Miller

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: default avatarVakul Garg <vakul.garg@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fb73d620
...@@ -145,12 +145,13 @@ struct tls_sw_context_tx { ...@@ -145,12 +145,13 @@ struct tls_sw_context_tx {
struct tls_sw_context_rx { struct tls_sw_context_rx {
struct crypto_aead *aead_recv; struct crypto_aead *aead_recv;
struct crypto_wait async_wait; struct crypto_wait async_wait;
struct strparser strp; struct strparser strp;
struct sk_buff_head rx_list; /* list of decrypted 'data' records */
void (*saved_data_ready)(struct sock *sk); void (*saved_data_ready)(struct sock *sk);
struct sk_buff *recv_pkt; struct sk_buff *recv_pkt;
u8 control; u8 control;
int async_capable;
bool decrypted; bool decrypted;
atomic_t decrypt_pending; atomic_t decrypt_pending;
bool async_notify; bool async_notify;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment