Skip to contentSkip to conversation

tls: Return type of non-data records retrieved using MSG_PEEK in recvmsg

PATCH Applied Vakul Garg 2 participants 3 messages Feb 23, 2019 – Feb 25, 2019

Subsystems (3)
lore
Share & tools
lore

Vakul Garg

author
#0 lore raw

PATCH v3 1/1 tls: Return type of non-data records retrieved using MSG_PEEK in recvmsg

The patch enables returning 'type' in msghdr for records that are retrieved with MSG_PEEK in recvmsg. Further it prevents records peeked from socket from getting clubbed with any other record of different type when records are subsequently dequeued from strparser.

For each record, we now retain its type in sk_buff's control buffer cb[]. Inside control buffer, record's full length and offset are already stored by strparser in 'struct strp_msg'. We store record type after 'struct strp_msg' inside 'struct tls_msg'. For tls1.2, the type is stored just after record dequeue. For tls1.3, the type is stored after record has been decrypted.

Inside process_rx_list(), before processing a non-data record, we check that we must be able to return back the record type to the user application. If not, the decrypted records in tls context's rx_list is left there without consuming any data.

Fixes 692d7b5d1f912 ("tls: Fix recvmsg() to be able to peek across

multiple records")

---

Changes in v2:
- Modified 'Fixed:' line to use full commit header line.
Changes in v3:
- Added a missing ' " ' in Fixed: line.

 include/net/tls.h | 10 +++++++
 net/tls/tls_sw.c  | 78 +++++++++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 77 insertions(+), 11 deletions(-)
include/net/tls.h +10 -0
index a8b37226a287..9f4117ae2297 100644
@@ -129,6 +129,11 @@ struct tls_rec {
 	u8 aead_req_ctx[];
 };
 
+struct tls_msg {
+	struct strp_msg rxm;
+	u8 control;
+};
+
 struct tx_work {
 	struct delayed_work work;
 	struct sock *sk;
@@ -333,6 +338,11 @@ int tls_push_partial_record(struct sock *sk, struct tls_context *ctx,
 int tls_push_pending_closed_record(struct sock *sk, struct tls_context *ctx,
 				   int flags, long *timeo);
 
+static inline struct tls_msg *tls_msg(struct sk_buff *skb)
+{
+	return (struct tls_msg *)strp_msg(skb);
+}
+
 static inline bool tls_is_pending_closed_record(struct tls_context *ctx)
 {
 	return test_bit(TLS_PENDING_CLOSED_RECORD, &ctx->flags);
net/tls/tls_sw.c +67 -11

160 lines not on this page · raw message

Signature · 1 line
2.13.6
maintainer Applied
#1 lore raw

From: Vakul Garg <[email protected]>
Date: Sat, 23 Feb 2019 08:42:37 +0000

Quoted 12 lines

The patch enables returning 'type' in msghdr for records that are retrieved with MSG_PEEK in recvmsg. Further it prevents records peeked from socket from getting clubbed with any other record of different type when records are subsequently dequeued from strparser.

For each record, we now retain its type in sk_buff's control buffer cb[]. Inside control buffer, record's full length and offset are already stored by strparser in 'struct strp_msg'. We store record type after 'struct strp_msg' inside 'struct tls_msg'. For tls1.2, the type is stored just after record dequeue. For tls1.3, the type is stored after record has been decrypted.

Quoted 8 lines

Inside process_rx_list(), before processing a non-data record, we check that we must be able to return back the record type to the user application. If not, the decrypted records in tls context's rx_list is left there without consuming any data.

Fixes 692d7b5d1f912 ("tls: Fix recvmsg() to be able to peek across

multiple records")

Applied, but please don't break up long Fixes: lines into multiple lines. Always keep it all on one single line.

author
#2 lore raw
Quoted 32 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of David Miller
Sent: Monday, February 25, 2019 11:29 AM
To: Vakul Garg <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCHv3 net-next] tls: Return type of non-data records retrieved using MSG_PEEK in recvmsg

From: Vakul Garg <[email protected]>
Date: Sat, 23 Feb 2019 08:42:37 +0000

Quoted 17 lines

The patch enables returning 'type' in msghdr for records that are retrieved with MSG_PEEK in recvmsg. Further it prevents records peeked from socket from getting clubbed with any other record of different type when records are subsequently dequeued from strparser.

For each record, we now retain its type in sk_buff's control buffer cb[]. Inside control buffer, record's full length and offset are already stored by strparser in 'struct strp_msg'. We store record type after 'struct strp_msg' inside 'struct tls_msg'. For tls1.2, the type is stored just after record dequeue. For tls1.3, the type is stored after record has been decrypted.

Inside process_rx_list(), before processing a non-data record, we check that we must be able to return back the record type to the user application. If not, the decrypted records in tls context's rx_list is left there without consuming any data.

Quoted 6 lines
Quoted 3 lines
Fixes 692d7b5d1f912 ("tls: Fix recvmsg() to be able to peek across

multiple records")

Applied, but please don't break up long Fixes: lines into multiple lines. Always keep it all on one single line.

I am sorry.
Since I fixed this problem in v3 patch, did you still find it? I am confused.