Skip to contentSkip to conversation

net: tls: fix messing up lists when bpf enabled

PATCH Applied Jakub Kicinski 3 participants 3 messages May 18, 2022 – May 20, 2022

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 net: tls: fix messing up lists when bpf enabled

Artem points out that skb may try to take over the skb and queue it to its own list. Unlink the skb before calling out.

Fixes b1a2c1786330 ("tls: rx: clear ctx->recv_pkt earlier")

---
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 net/tls/tls_sw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/tls/tls_sw.c +3 -1
index 939d1673f508..0513f82b8537 100644
@@ -1837,15 +1837,17 @@ int tls_sw_recvmsg(struct sock *sk,
 			bool partially_consumed = chunk > len;
 
 			if (bpf_strp_enabled) {
+				/* BPF may try to queue the skb */
+				__skb_unlink(skb, &ctx->rx_list);
 				err = sk_psock_tls_strp_read(psock, skb);
 				if (err != __SK_PASS) {
 					rxm->offset = rxm->offset + rxm->full_len;
 					rxm->full_len = 0;
-					__skb_unlink(skb, &ctx->rx_list);
 					if (err == __SK_DROP)
 						consume_skb(skb);
 					continue;
 				}
+				__skb_queue_tail(&ctx->rx_list, skb);
 			}
 
 			if (partially_consumed)
Signature · 1 line
2.34.3
Tested-by on v1 1/1
#1 lore raw
Quoted 1 line · Jakub Kicinski

Artem points out that skb may try to take over the skb and

^^^ I think you meant "bpf"

Quoted 4 lines

queue it to its own list. Unlink the skb before calling out.

Fixes b1a2c1786330 ("tls: rx: clear ctx->recv_pkt earlier")
Quoted 35 lines

---
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 net/tls/tls_sw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/tls/tls_sw.c +3 -1
index 939d1673f508..0513f82b8537 100644
@@ -1837,15 +1837,17 @@ int tls_sw_recvmsg(struct sock *sk,
 			bool partially_consumed = chunk > len;
 
 			if (bpf_strp_enabled) {
+				/* BPF may try to queue the skb */
+				__skb_unlink(skb, &ctx->rx_list);
 				err = sk_psock_tls_strp_read(psock, skb);
 				if (err != __SK_PASS) {
 					rxm->offset = rxm->offset + rxm->full_len;
 					rxm->full_len = 0;
-					__skb_unlink(skb, &ctx->rx_list);
 					if (err == __SK_DROP)
 						consume_skb(skb);
 					continue;
 				}
+				__skb_queue_tail(&ctx->rx_list, skb);
 			}
 
 			if (partially_consumed)
Signature · 1 line
2.34.3
Signature · 1 line
 Artem
#2 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Wed, 18 May 2022 13:56:44 -0700 you wrote:

Artem points out that skb may try to take over the skb and queue it to its own list. Unlink the skb before calling out.

Fixes b1a2c1786330 ("tls: rx: clear ctx->recv_pkt earlier")

[...]

Here is the summary with links:
- [net-next] net: tls: fix messing up lists when bpf enabled

    https://git.kernel.org/netdev/net-next/c/1c2133114d2d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html