From: Matthieu Baerts <matttbe@kernel.org>
To: sashiko-reviews@lists.linux.dev, MPTCP Linux <mptcp@lists.linux.dev>
Subject: Re: [PATCH mptcp-net] mptcp: disconnect: reset first subflow's local_id
Date: Thu, 15 Oct 2026 17:26:18 +0200 [thread overview]
Message-ID: <aaf47447-d27f-4a08-98ce-72815f9401ea@kernel.org> (raw)
In-Reply-To: <sashiko-outbox-172945@kernel.org>
On 15/10/2026 16:05, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Critical] mptcp: NULL pointer dereference in mptcp_disconnect() on unconnected socket
> --
>
> commit 79fba9c250462a2f6852b46cf0562a508bcae604
> Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>
>
> mptcp: disconnect: reset first subflow's local_id
>
> This commit resets the local_id of the first subflow to 0 when disconnecting.
> This ensures the value is correctly initialized if the subflow is reused
> after a reconnect.
>
> Link: https://lore.kernel.org/179198834484.434549.4616694240552704738@kernel.org
>
>> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
>> --- a/net/mptcp/protocol.c
>> +++ b/net/mptcp/protocol.c
>> @@ -3654,6 +3654,7 @@ static int mptcp_disconnect(struct sock *sk, int flags)
>> */
>> mptcp_do_fastclose(sk);
>> mptcp_destroy_common(msk);
>> + WRITE_ONCE(mptcp_subflow_ctx(msk->first)->local_id, 0);
>
> [Severity: Critical]
> Does this code cause a NULL pointer dereference in mptcp_disconnect() on an
> unconnected socket?
>
> If a user creates an MPTCP socket via socket(AF_MPTCP, SOCK_STREAM, 0),
What? AF_MPTCP???
> msk->first is initially NULL. If the user then calls connect() with
> AF_UNSPEC before any connection is made, the networking core handles
> AF_UNSPEC by directly invoking the socket's disconnect handler,
> mptcp_disconnect().
Arf, I forgot about this weird path... I checked with shutdown() (which
is not allowed for unconnected sockets). I will add a check and add a
packetdrill test for this.
> At this point, msk->first is still NULL. Passing it to mptcp_subflow_ctx()
> yields an invalid pointer, leading to an immediate page fault when local_id
> is written.
>
>>
>> /* The first subflow is already in TCP_CLOSE status, the following
>> * can't overlap with a fallback anymore
>
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2026-10-15 15:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 13:54 [PATCH mptcp-net] mptcp: disconnect: reset first subflow's local_id Matthieu Baerts (NGI0)
2026-10-15 14:05 ` sashiko-bot
2026-10-15 15:26 ` Matthieu Baerts [this message]
2026-10-15 15:28 ` MPTCP CI
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=aaf47447-d27f-4a08-98ce-72815f9401ea@kernel.org \
--to=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.