* [PATCH net 00/10] mptcp: misc fixes for v7.4-rc5
@ 2026-11-23 13:24 Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 10/10] tcp: do not pass a BPF reqsk to an MPTCP listener Matthieu Baerts (NGI0)
2026-11-24 16:58 ` [PATCH net 00/10] mptcp: misc fixes for v7.4-rc5 Matthieu Baerts
0 siblings, 2 replies; 4+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-23 13:24 UTC (permalink / raw)
To: Eric Dumazet, David S. Miller, Jakub Kicinski, Paolo Abeni,
Willem de Bruijn, Simon Horman, Mat Martineau, Geliang Tang,
Christoph Paasch, Florian Westphal
Cc: netdev, mptcp, Davide Caratti, Matthieu Baerts (NGI0),
Chris Mason, stable, Neal Cardwell, Kuniyuki Iwashima,
Hyunwoo Kim, Josef Bacik, Martin KaFai Lau, Daniel Borkmann,
Alexei Starovoitov, Martin KaFai Lau, bpf
Here are some unrelated fixes:
- Patches 1-2: drain the queues of a TCP or MPTCP socket when listen()
fails, not to leak sockets and their netns. Fixes for v4.4 and v5.11.
- Patch 3: clear inet_opt in the child of an IPv6 listener, to avoid a
double free with SELinux and NetLabel. A fix for v5.6.
- Patch 4: fix UaF in corner cases from delegated actions. A fix for
v5.12.
- Patches 5-6: do not leak an orphan moved to the CLOSE state outside
the worker. Fixes for v6.15, and for another fix introduced in v6.6
and targeting v5.11.
- Patches 7-8: do not let PM listeners pin their netns, leaked
otherwise. A fix for v5.12.
- Patch 9: initialize drop_req, not to leak sockets with SO_REUSEPORT
migration. A fix for v5.14.
- Patch 10: do not pass a BPF request sock to an MPTCP listener, to
avoid a slab-out-of-bounds write. A fix for v6.9.
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Chris Mason (6):
tcp: drain the queues of a listen() that fails
mptcp: drain the queues of a listen() that fails
mptcp: clear inet_opt in the child of an IPv6 listener
mptcp: leave an orphan's DATA_FIN to the worker
mptcp: initialize drop_req in subflow_init_req()
tcp: do not pass a BPF reqsk to an MPTCP listener
Hyunwoo Kim (1):
mptcp: fix use-after-free of the subflow context on the delegated list
Josef Bacik (1):
mptcp: pm: don't let listeners pin their netns
Matthieu Baerts (NGI0) (2):
mptcp: don't leak an orphan when the PM closes its last subflow
net: add __sk_net_refcnt_upgrade() with a GFP mask
include/net/sock.h | 1 +
net/core/sock.c | 9 +++++++--
net/ipv4/inet_connection_sock.c | 12 ++++++++----
net/ipv4/syncookies.c | 3 ++-
net/mptcp/protocol.c | 42 +++++++++++++++++++++++++++++++++--------
net/mptcp/protocol.h | 18 ++++++++++++++++--
net/mptcp/subflow.c | 32 ++++++++++++++++++++++++++++---
7 files changed, 97 insertions(+), 20 deletions(-)
---
base-commit: 3896ae4adf5ffc11ffd0f7f42c3923e8dc195e75
change-id: 20261123-net-mptcp-misc-fixes-7-4-rc5-965d6b4fb777
Best regards,
--
Matthieu Baerts (NGI0) <matttbe@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net 10/10] tcp: do not pass a BPF reqsk to an MPTCP listener
2026-11-23 13:24 [PATCH net 00/10] mptcp: misc fixes for v7.4-rc5 Matthieu Baerts (NGI0)
@ 2026-11-23 13:24 ` Matthieu Baerts (NGI0)
2026-11-27 11:10 ` Jiayuan Chen
2026-11-24 16:58 ` [PATCH net 00/10] mptcp: misc fixes for v7.4-rc5 Matthieu Baerts
1 sibling, 1 reply; 4+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-23 13:24 UTC (permalink / raw)
To: Eric Dumazet, David S. Miller, Jakub Kicinski, Paolo Abeni,
Willem de Bruijn, Simon Horman, Mat Martineau, Geliang Tang,
Christoph Paasch, Florian Westphal
Cc: netdev, mptcp, Davide Caratti, Matthieu Baerts (NGI0),
Chris Mason, stable, Neal Cardwell, Kuniyuki Iwashima,
Martin KaFai Lau, Daniel Borkmann, Alexei Starovoitov,
Martin KaFai Lau, bpf
From: Chris Mason <mason@kernel.org>
A slab-out-of-bounds write and a panic can occur if a tc BPF program
that validates SYN cookies assigns an ACK to a TCP listener, and the ACK
then goes to an MPTCP listener of the same SO_REUSEPORT group.
bpf_sk_assign_tcp_reqsk() attaches a plain TCP request sock to the skb,
and returns -EINVAL if the program passes in an MPTCP listener. But
inet_steal_sock() and inet6_steal_sock() select a listener again from
the SO_REUSEPORT group of the listener that was passed in, and the
result can be an MPTCP listener. cookie_bpf_check() then passes the
request sock to mptcp_subflow_init_cookie_req(), which writes to members
of the larger struct mptcp_subflow_request_sock, so the writes can land
in the next object of the slab.
The fix used here is to drop the segment in cookie_bpf_check() if the
listener is an MPTCP listener. The connection then fails, instead of
corrupting the memory.
This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch:
a tc BPF program validating SYN cookies -- the one from the BPF
selftests -- and an SO_REUSEPORT group with a TCP listener and an MPTCP
one, the latter being selected. With KASAN, the original version of this
patch reported:
BUG: KASAN: slab-out-of-bounds in mptcp_subflow_init_cookie_req
Write of size 1 at addr ... by task python3
mptcp_subflow_init_cookie_req
cookie_bpf_check
cookie_v4_check
tcp_v4_do_rcv
tcp_v4_rcv
Without debug options, and with request sockets of half-open connections
next to the corrupted one, the kernel panicked a second later, when the
timer of a request socket fired:
BUG: kernel NULL pointer dereference, address: 000000000000058f
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
Oops: Oops: 0000 [#1] SMP NOPTI
CPU: 3 UID: 0 PID: 0 Comm: swapper/3 Not tainted 7.4.0-rc1+ #1 PREEMPT(lazy)
RIP: 0010:tcp_syn_ack_timeout+0xd/0x30
Call Trace:
<IRQ>
reqsk_timer_handler+0x22e/0x500
call_timer_fn+0x2a/0x140
__run_timers+0x1f7/0x280
run_timer_softirq+0x49/0xf0
handle_softirqs+0xfa/0x300
__irq_exit_rcu+0xb5/0xf0
sysvec_apic_timer_interrupt+0x73/0x80
</IRQ>
Kernel panic - not syncing: Fatal exception in interrupt
Fixes: e472f88891ab ("bpf: tcp: Support arbitrary SYN Cookie.")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comment. Commit message: how the issue was found, its
symptoms, and that the connection then fails. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Kuniyuki Iwashima <kuniyu@google.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Martin KaFai Lau <martin.lau@kernel.org>
Cc: bpf@vger.kernel.org
---
net/ipv4/syncookies.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 89169c82431c..f39600ee3f17 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -312,7 +312,8 @@ struct request_sock *cookie_bpf_check(struct sock *sk, struct sk_buff *skb)
skb->sk = NULL;
skb->destructor = NULL;
- if (cookie_tcp_reqsk_init(sk, skb, req)) {
+ /* reuseport can pick an MPTCP listener: req is too small for it */
+ if (sk_is_mptcp(sk) || cookie_tcp_reqsk_init(sk, skb, req)) {
reqsk_free(req);
req = NULL;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net 00/10] mptcp: misc fixes for v7.4-rc5
2026-11-23 13:24 [PATCH net 00/10] mptcp: misc fixes for v7.4-rc5 Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 10/10] tcp: do not pass a BPF reqsk to an MPTCP listener Matthieu Baerts (NGI0)
@ 2026-11-24 16:58 ` Matthieu Baerts
1 sibling, 0 replies; 4+ messages in thread
From: Matthieu Baerts @ 2026-11-24 16:58 UTC (permalink / raw)
To: netdev
Cc: Eric Dumazet, David S. Miller, Jakub Kicinski, Paolo Abeni,
Willem de Bruijn, Simon Horman, Mat Martineau, Geliang Tang,
Christoph Paasch, Florian Westphal, mptcp, Davide Caratti,
Chris Mason, stable, Neal Cardwell, Kuniyuki Iwashima,
Hyunwoo Kim, Josef Bacik, Martin KaFai Lau, Daniel Borkmann,
Alexei Starovoitov, Martin KaFai Lau, bpf
Hello,
On 23/11/2026 14:24, Matthieu Baerts (NGI0) wrote:
> Here are some unrelated fixes:
>
> - Patches 1-2: drain the queues of a TCP or MPTCP socket when listen()
> fails, not to leak sockets and their netns. Fixes for v4.4 and v5.11.
>
> - Patch 3: clear inet_opt in the child of an IPv6 listener, to avoid a
> double free with SELinux and NetLabel. A fix for v5.6.
>
> - Patch 4: fix UaF in corner cases from delegated actions. A fix for
> v5.12.
>
> - Patches 5-6: do not leak an orphan moved to the CLOSE state outside
> the worker. Fixes for v6.15, and for another fix introduced in v6.6
> and targeting v5.11.
>
> - Patches 7-8: do not let PM listeners pin their netns, leaked
> otherwise. A fix for v5.12.
>
> - Patch 9: initialize drop_req, not to leak sockets with SO_REUSEPORT
> migration. A fix for v5.14.
>
> - Patch 10: do not pass a BPF request sock to an MPTCP listener, to
> avoid a slab-out-of-bounds write. A fix for v6.9.
TL;DR regarding Clashiko's reviews: no new versions needed I think.
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net 10/10] tcp: do not pass a BPF reqsk to an MPTCP listener
2026-11-23 13:24 ` [PATCH net 10/10] tcp: do not pass a BPF reqsk to an MPTCP listener Matthieu Baerts (NGI0)
@ 2026-11-27 11:10 ` Jiayuan Chen
0 siblings, 0 replies; 4+ messages in thread
From: Jiayuan Chen @ 2026-11-27 11:10 UTC (permalink / raw)
To: Matthieu Baerts (NGI0), Eric Dumazet, David S. Miller,
Jakub Kicinski, Paolo Abeni, Willem de Bruijn, Simon Horman,
Mat Martineau, Geliang Tang, Christoph Paasch, Florian Westphal
Cc: netdev, mptcp, Davide Caratti, Chris Mason, stable, Neal Cardwell,
Kuniyuki Iwashima, Martin KaFai Lau, Daniel Borkmann,
Alexei Starovoitov, Martin KaFai Lau, bpf
On 11/23/26 9:24 PM, Matthieu Baerts (NGI0) wrote:
> From: Chris Mason <mason@kernel.org>
>
> A slab-out-of-bounds write and a panic can occur if a tc BPF program
> that validates SYN cookies assigns an ACK to a TCP listener, and the ACK
> then goes to an MPTCP listener of the same SO_REUSEPORT group.
>
> bpf_sk_assign_tcp_reqsk() attaches a plain TCP request sock to the skb,
> and returns -EINVAL if the program passes in an MPTCP listener. But
> inet_steal_sock() and inet6_steal_sock() select a listener again from
> the SO_REUSEPORT group of the listener that was passed in, and the
> result can be an MPTCP listener. cookie_bpf_check() then passes the
> request sock to mptcp_subflow_init_cookie_req(), which writes to members
> of the larger struct mptcp_subflow_request_sock, so the writes can land
> in the next object of the slab.
>
> The fix used here is to drop the segment in cookie_bpf_check() if the
> listener is an MPTCP listener. The connection then fails, instead of
> corrupting the memory.
>
> This issue has been found with the help of an LLM, and reproduced in a
> VM, with the reproducer shared with the original version of this patch:
> a tc BPF program validating SYN cookies -- the one from the BPF
> selftests -- and an SO_REUSEPORT group with a TCP listener and an MPTCP
> one, the latter being selected. With KASAN, the original version of this
> patch reported:
>
> BUG: KASAN: slab-out-of-bounds in mptcp_subflow_init_cookie_req
> Write of size 1 at addr ... by task python3
> mptcp_subflow_init_cookie_req
> cookie_bpf_check
> cookie_v4_check
> tcp_v4_do_rcv
> tcp_v4_rcv
>
> Without debug options, and with request sockets of half-open connections
> next to the corrupted one, the kernel panicked a second later, when the
> timer of a request socket fired:
>
> BUG: kernel NULL pointer dereference, address: 000000000000058f
> #PF: supervisor read access in kernel mode
> #PF: error_code(0x0000) - not-present page
> Oops: Oops: 0000 [#1] SMP NOPTI
> CPU: 3 UID: 0 PID: 0 Comm: swapper/3 Not tainted 7.4.0-rc1+ #1 PREEMPT(lazy)
> RIP: 0010:tcp_syn_ack_timeout+0xd/0x30
> Call Trace:
> <IRQ>
> reqsk_timer_handler+0x22e/0x500
> call_timer_fn+0x2a/0x140
> __run_timers+0x1f7/0x280
> run_timer_softirq+0x49/0xf0
> handle_softirqs+0xfa/0x300
> __irq_exit_rcu+0xb5/0xf0
> sysvec_apic_timer_interrupt+0x73/0x80
> </IRQ>
> Kernel panic - not syncing: Fatal exception in interrupt
>
> Fixes: e472f88891ab ("bpf: tcp: Support arbitrary SYN Cookie.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Chris Mason <mason@kernel.org>
> [ Shorter comment. Commit message: how the issue was found, its
> symptoms, and that the connection then fails. ]
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Actually, we still have a few issues with bpf_sk_assign semantics...
> ---
> Cc: Neal Cardwell <ncardwell@google.com>
> Cc: Kuniyuki Iwashima <kuniyu@google.com>
> Cc: Martin KaFai Lau <kafai@fb.com>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Martin KaFai Lau <martin.lau@kernel.org>
> Cc: bpf@vger.kernel.org
> ---
> net/ipv4/syncookies.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
> index 89169c82431c..f39600ee3f17 100644
> --- a/net/ipv4/syncookies.c
> +++ b/net/ipv4/syncookies.c
> @@ -312,7 +312,8 @@ struct request_sock *cookie_bpf_check(struct sock *sk, struct sk_buff *skb)
> skb->sk = NULL;
> skb->destructor = NULL;
>
> - if (cookie_tcp_reqsk_init(sk, skb, req)) {
> + /* reuseport can pick an MPTCP listener: req is too small for it */
> + if (sk_is_mptcp(sk) || cookie_tcp_reqsk_init(sk, skb, req)) {
> reqsk_free(req);
> req = NULL;
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-27 11:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 13:24 [PATCH net 00/10] mptcp: misc fixes for v7.4-rc5 Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 10/10] tcp: do not pass a BPF reqsk to an MPTCP listener Matthieu Baerts (NGI0)
2026-11-27 11:10 ` Jiayuan Chen
2026-11-24 16:58 ` [PATCH net 00/10] mptcp: misc fixes for v7.4-rc5 Matthieu Baerts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox