net: tls: fix messing up lists when bpf enabled
Subsystems (3)
Jakub Kicinski
maintainerPATCH 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.
---
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
@@ -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
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")Reported-by Artem Savkov <[email protected]>
Quoted 35 lines
Signed-off-by Jakub Kicinski <[email protected]>---
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@@ -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
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")Reported-by Artem Savkov <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>[...]
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