From: sashiko-bot@kernel.org
To: "Geliang Tang" <geliang@kernel.org>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v4 2/3] mptcp: inherit sk_reuse and fix dev bind override
Date: Tue, 20 Oct 2026 08:44:28 +0000 [thread overview]
Message-ID: <sashiko-outbox-178606@kernel.org> (raw)
In-Reply-To: <4adf96455e63a35be3228434cfe2ba79ea99bcb0.1792470313.git.tanggeliang@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mptcp: wrong sk_uid during subflow bind when syncing sk_reuseport
--
commit 1d41a74d8cd4f5351a1f4186bfb92fe0ffeada01
Author: Geliang Tang <geliang@kernel.org>
mptcp: inherit sk_reuse and fix dev bind override
This commit propagates sk_reuse and sk_reuseport from the master socket to
subflows, increments setsockopt_seq when SOL_SOCKET options are set, and
avoids overriding sk_bound_dev_if in __mptcp_subflow_connect() when
local->ifindex is zero.
> diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
> index 922f6ae5c80cb..952bc015eee87 100644
> --- a/net/mptcp/sockopt.c
> +++ b/net/mptcp/sockopt.c
[ ... ]
> @@ -1706,6 +1708,9 @@ static void sync_socket_options(struct mptcp_sock *msk, struct sock *ssk)
> assign_bit(b, &inet_sk(ssk)->inet_flags, src & BIT(b));
>
> WRITE_ONCE(inet_sk(ssk)->local_port_range, READ_ONCE(inet_sk(sk)->local_port_range));
> +
> + ssk->sk_reuse = sk->sk_reuse;
> + ssk->sk_reuseport = sk->sk_reuseport;
> }
>
> void mptcp_sockopt_sync_locked(struct mptcp_sock *msk, struct sock *ssk)
[Severity: High]
When syncing sk_reuseport to ssk here in sync_socket_options(), does ssk
have the right sk_uid before kernel_bind() runs in
__mptcp_subflow_connect()?
In mptcp_subflow_create_socket(), sock_create_kern() initializes
SOCK_INODE(sf)->i_uid to current_fsuid(), and sock_init_data() copies that
into sf->sk->sk_uid. Although mptcp_subflow_create_socket() then updates
SOCK_INODE(sf)->i_uid to the master socket's UID:
net/mptcp/subflow.c:mptcp_subflow_create_socket() {
...
SOCK_INODE(sf)->i_ino = SOCK_INODE(sk->sk_socket)->i_ino;
SOCK_INODE(sf)->i_uid = SOCK_INODE(sk->sk_socket)->i_uid;
SOCK_INODE(sf)->i_gid = SOCK_INODE(sk->sk_socket)->i_gid;
...
}
ssk->sk_uid is not updated until mptcp_sock_graft() calls sk_set_socket()
at the end of __mptcp_subflow_connect(), after kernel_bind() and
kernel_connect():
net/mptcp/subflow.c:__mptcp_subflow_connect() {
...
err = mptcp_subflow_create_socket(sk, local->addr.family, &sf);
...
err = kernel_bind(sf, (struct sockaddr_unsized *)&addr, addrlen);
...
err = kernel_connect(sf, (struct sockaddr_unsized *)&addr, addrlen, O_NONBLOCK);
...
mptcp_sock_graft(ssk, sk->sk_socket);
}
When additional subflows are created asynchronously via mptcp_worker or a
privileged path manager daemon, current_fsuid() is 0 (root) rather than the
UID of the owning MPTCP socket.
During kernel_bind() -> inet_csk_get_port(), the SO_REUSEPORT checks in
sk_reuseport_match(), inet_csk_bind_conflict() -> inet_bind_conflict(), and
inet_csk_update_fastreuse() all read sk_uid(ssk):
net/ipv4/inet_connection_sock.c:inet_bind_conflict() {
...
} else if (!reuseport_ok || !sk->sk_reuseport ||
!sk2->sk_reuseport || !reuseport_cb_ok ||
(sk2->sk_state != TCP_TIME_WAIT &&
!uid_eq(uid, sk_uid(sk2)))) {
return true;
}
...
}
Because sk_uid(ssk) is still 0 during kernel_bind(), won't an unprivileged
user's subflow fail with -EADDRINUSE when binding to the same port as the
initial subflow or another SO_REUSEPORT socket owned by that user, while
also matching against root-owned SO_REUSEPORT sockets and recording
tb->fastuid as 0 in inet_csk_update_fastreuse()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1792470313.git.tanggeliang@kylinos.cn?part=2
next prev parent reply other threads:[~2026-10-20 8:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 4:34 [PATCH mptcp-next v4 0/3] add distinct lockdep class for MPTCP sockets Geliang Tang
2026-10-20 4:34 ` [PATCH mptcp-next v4 1/3] mptcp: give MPTCP sockets a distinct lockdep class Geliang Tang
2026-10-20 4:34 ` [PATCH mptcp-next v4 2/3] mptcp: inherit sk_reuse and fix dev bind override Geliang Tang
2026-10-20 8:44 ` sashiko-bot [this message]
2026-10-20 4:34 ` [PATCH mptcp-next v4 3/3] mptcp: kunit: add sockopt test Geliang Tang
2026-10-20 8:55 ` sashiko-bot
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=sashiko-outbox-178606@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=geliang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox