From: Kuniyuki Iwashima <kuniyu@google.com>
To: Jiayuan Chen <jiayuan.chen@linux.dev>
Cc: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>,
Eric Dumazet <edumazet@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>,
Mat Martineau <martineau@kernel.org>,
Geliang Tang <geliang@kernel.org>,
Christoph Paasch <cpaasch@openai.com>,
Florian Westphal <fw@strlen.de>,
netdev@vger.kernel.org, mptcp@lists.linux.dev,
Davide Caratti <dcaratti@redhat.com>,
Chris Mason <mason@kernel.org>,
stable@vger.kernel.org, Neal Cardwell <ncardwell@google.com>,
Martin KaFai Lau <kafai@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Alexei Starovoitov <ast@kernel.org>,
Martin KaFai Lau <martin.lau@kernel.org>,
bpf@vger.kernel.org
Subject: Re: [PATCH net 10/10] tcp: do not pass a BPF reqsk to an MPTCP listener
Date: Tue, 1 Dec 2026 09:19:35 +0900 [thread overview]
Message-ID: <aw4Q1x1eN4yPZ8ZH@google.com> (raw)
In-Reply-To: <da0323dd-441a-46a6-ad9a-39def5fc08dc@linux.dev>
On Fri, 27 Nov 2026 19:10:01 +0800, Jiayuan Chen wrote:
>
>
> 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.
Hmm... do we want to support this setup ... ?
Maybe only useful when someone wants to migrate TCP to MPTCP gradually ?
> > 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;
> > }
>
next prev parent reply other threads:[~2026-12-01 0:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
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 01/10] tcp: drain the queues of a listen() that fails Matthieu Baerts (NGI0)
2026-11-30 18:15 ` Paolo Abeni
2026-12-01 0:08 ` Kuniyuki Iwashima
2026-11-23 13:24 ` [PATCH net 02/10] mptcp: " Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 03/10] mptcp: clear inet_opt in the child of an IPv6 listener Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 04/10] mptcp: fix use-after-free of the subflow context on the delegated list Matthieu Baerts (NGI0)
2026-11-24 14:26 ` netdev-bot+sashiko
2026-11-23 13:24 ` [PATCH net 05/10] mptcp: leave an orphan's DATA_FIN to the worker Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 06/10] mptcp: don't leak an orphan when the PM closes its last subflow Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 07/10] net: add __sk_net_refcnt_upgrade() with a GFP mask Matthieu Baerts (NGI0)
2026-12-01 0:09 ` Kuniyuki Iwashima
2026-11-23 13:24 ` [PATCH net 08/10] mptcp: pm: don't let listeners pin their netns Matthieu Baerts (NGI0)
2026-11-23 19:00 ` Matthieu Baerts
2026-11-24 13:26 ` sashiko-bot
2026-11-24 14:26 ` netdev-bot+sashiko
2026-11-24 16:58 ` Matthieu Baerts
2026-11-23 13:24 ` [PATCH net 09/10] mptcp: initialize drop_req in subflow_init_req() 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-12-01 0:19 ` Kuniyuki Iwashima [this message]
2026-11-24 16:58 ` [PATCH net 00/10] mptcp: misc fixes for v7.4-rc5 Matthieu Baerts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aw4Q1x1eN4yPZ8ZH@google.com \
--to=kuniyu@google.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cpaasch@openai.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--cc=edumazet@kernel.org \
--cc=fw@strlen.de \
--cc=geliang@kernel.org \
--cc=horms@kernel.org \
--cc=jiayuan.chen@linux.dev \
--cc=kafai@fb.com \
--cc=kuba@kernel.org \
--cc=martin.lau@kernel.org \
--cc=martineau@kernel.org \
--cc=mason@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox