Skip to contentSkip to conversation

tls: Fix recvmsg() to be able to peek across multiple records

PATCH Applied Vakul Garg 2 participants 2 messages Jan 16, 2019 – Jan 17, 2019

Subsystems (3)
lore
Share & tools
lore

Vakul Garg

author
#0 lore raw

PATCH v2 1/1 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'.

---
Changes since v1:

1. Added comments for function process_rx_list().
2. Fixed tls_decrypt_done() to adjust record offset & len only when decryption is successful.

 include/net/tls.h |   3 +-
 net/tls/tls_sw.c  | 266 ++++++++++++++++++++++++++++++++++++++++--------------
 2 files changed, 198 insertions(+), 71 deletions(-)
include/net/tls.h +2 -1
index 2a6ac8d642af..90bf52db573e 100644
@@ -145,12 +145,13 @@ struct tls_sw_context_tx {
 struct tls_sw_context_rx {
 	struct crypto_aead *aead_recv;
 	struct crypto_wait async_wait;
-
 	struct strparser strp;
+	struct sk_buff_head rx_list;	/* list of decrypted 'data' records */
 	void (*saved_data_ready)(struct sock *sk);
 
 	struct sk_buff *recv_pkt;
 	u8 control;
+	int async_capable;
 	bool decrypted;
 	atomic_t decrypt_pending;
 	bool async_notify;
net/tls/tls_sw.c +196 -70

424 lines not on this page · raw message

Signature · 1 line
2.13.6
maintainer Applied
#1 lore raw

From: Vakul Garg <[email protected]>
Date: Wed, 16 Jan 2019 10:40:16 +0000

Quoted 13 lines

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'.

Quoted 7 lines

---
Changes since v1:

1. Added comments for function process_rx_list().
2. Fixed tls_decrypt_done() to adjust record offset & len only when decryption is successful.

Applied.