Article View: linux.kernel.netdev
Article #24975Re: [PATCH net v2 1/3] udp: Keep the bound device on disconnect unless connect() set it
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 05:29
Date: Tue, 01 Dec 2026 05:29
90 lines
11629 bytes
11629 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] After the whole series, disconnect can still widen a
connect()-narrowed device back to 'all devices' with no conflict…
--
udp: Keep the bound device on disconnect unless connect() set it
When __ip6_datagram_connect() sets the device of a socket that had none,
this commit records that in sk_userlocks as SOCK_CONNECT_DEV.
__udp_disconnect() then clears sk_bound_dev_if only when that flag is set.
IPv6 ping, raw and L2TP sockets now use a new ip6_datagram_disconnect(),
which takes the socket lock around __udp_disconnect().
> diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
> index bdaae1b64d25a..36f79b098113b 100644
> --- a/net/l2tp/l2tp_ip6.c
> +++ b/net/l2tp/l2tp_ip6.c
> @@ -441,7 +441,7 @@ static int l2tp_ip6_disconnect(struct sock *sk, int flags)
> if (sock_flag(sk, SOCK_ZAPPED))
> return 0;
>
> - return __udp_disconnect(sk, flags);
> + return ip6_datagram_disconnect(sk, flags);
> }
[Severity: High]
Can L2TP/IPv6 sockets still be used for the takeover that the commit
message describes?
This path clears a device set by connect() without a conflict check. That
is only safe if every bind conflict check ignores devices set by connect().
__l2tp_ip6_bind_lookup() still compares against the live device:
net/l2tp/l2tp_ip6.c:__l2tp_ip6_bind_lookup() {
...
bound_dev_if = READ_ONCE(sk->sk_bound_dev_if);
if (bound_dev_if && dif && bound_dev_if != dif)
continue;
...
}
IPPROTO_L2TP sockets are SOCK_DGRAM, so CAP_NET_RAW is not needed. Could
an unprivileged user run this sequence?
1) Attacker A binds L2TP/IPv6 conn_id C with no device.
2) A connects to fe80::x with scope_id=eth0. The call chain
l2tp_ip6_connect()->__ip6_datagram_connect()->ip6_datagram_connect_dev()
sets sk_bound_dev_if=eth0 and SOCK_CONNECT_DEV.
3) While A is connected, victim V calls SO_BINDTODEVICE(eth1) and binds
conn_id C. l2tp_ip6_bind() calls __l2tp_ip6_bind_lookup() with
dif=eth1. A is skipped because its live device is eth0, so V's bind
succeeds.
4) A calls connect(AF_UNSPEC). The call chain
l2tp_ip6_disconnect()->ip6_datagram_disconnect()->__udp_disconnect()
sees SOCK_CONNECT_DEV and sets sk_bound_dev_if=0.
l2tp_ip6_unhash() only touches sk_node, so A stays in
l2tp_ip6_bind_table. Without SOCK_BINDADDR_LOCK, inet_reset_saddr()
also turns A's local address into a wildcard.
5) A connects to a non-scoped peer P. No device is set, and A moves to the
head of the bind list. On receive, __l2tp_ip6_bind_lookup() then returns
A ahead of V for conn_id C traffic from P, on any device.
A later commit in this series, "udp: Ignore a connect()-set device in the
bind conflict check", fixes the UDP side. It changes udp_lib_lport_inuse()
and udp_lib_lport_inuse2() to use udp_bound_dev_if(), which returns 0 for
a SOCK_CONNECT_DEV socket.
I couldn't find a matching change to __l2tp_ip6_bind_lookup() anywhere in
the series. Should L2TP/IPv6 get the same treatment, given that this patch
moves it to the new disconnect behaviour?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130050729.893-1-juanagusnicco%40gmail.com
Technical Details
Message-ID:
<179610295120.3146.5772948202560480809@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374708-linux-kernel-netdev=dewy.ruReferences:
<20261130050729.893-2-juanagusnicco@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374708-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2 1/3] udp: Keep the bound device on disconnect unless connect() set it Date: Tue, 01 Dec 2026 05:29:11 +0000 Organization: Usenet Network Message-ID: <179610295120.3146.5772948202560480809@kernel.org> References: <20261130050729.893-2-juanagusnicco@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1624740"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:kYPxUeZmPK745sxVURLWBjCniUU= sha256:ZCy4LwSeYQsnVYhXKpN97+NatpNuPo3OIpeEmjbbtRA= sha1:KjjrJTvV6FIVbRAQ9m2yfTVZsX8= sha256:PBA7nwNfIU+mIwhVpgnMfgLx3z55gULJYSxK7pSQyM0= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 4D5B6117247; Tue, 1 Dec 2026 08:29:29 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.5 X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26I3f0snZuzh; Tue, 1 Dec 2026 08:29:25 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-374708-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 4294E11723C; Tue, 1 Dec 2026 08:29:16 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 66CA9601815; Tue, 1 Dec 2026 05:29:15 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796102954; b=sHbqly8QJURMr7/t9JAcQZI3pqeClFFCuh/kseTJShxOoOkAqMaB5gzZI7Dj+xZda215 gPlLBkhwBMuCRKod3Cda8Vxta7ryvc3cuKp32ZRQkrdheOQcy0GX6E1ffzmOzv6jT+OWi CY/1v7E4m0DVBuCIO5D/G6PmXoW9Wk9M+L46IkrEMDM5oLBS8x7ys/0RWCDHHqryp70V/ sZTDtAjp4xd1pHVSzNqYGnApWYppDfqItrujP+/L/F7WpYJDPt9u7hT+bMG1+CTqMxaz8 xEVHV62ljFsRzLJPak3DwSE15VuQZWvtNfMGKfTQJgWdPM1e6R8VlaPridK9nWDC9RA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796102954; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=UGPWjX0eahGWZLeMm4obHfq1np54U7NT+ssva8nGEO4=; b=zu4UP7aCQj8LYitZiOTt69M4QSXh0K/GUgokYfoUdnW192hB0eyLlcbgBtM3zk3czI4O 6GvO2Iu9Iy8ZaY0+B4LFHNWiFRQJxDqMpOQUSv8IYjV58e5j7Gbpqc8MeXefuv3yF39V9 TiMNG5xNXr5qntunrg7FJcYqvLVQhBkOOz22j+7DvrjsDOWEhMXkxpAVuioIoUHqHQmey JoY+sy/HE+QKbzMS2gmJPskBZVEmltVWFw6Uc645tbRLQdvN4i7IgfQfw7WSOx0DuQm/K Npu6kxCRntq0uKmb20Z4h1PdMc28EY9c+/aDeWGeN2C+IFj5nlOzt+F0qAXzhtG+zpQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bYUr0sV0; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FBD4606A32F; Tue, 1 Dec 2026 05:29:14 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bYUr0sV0 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796102953; b=pQl8FWUZoMjvNIVeIm9pWWS44ZJZ4p89KJtnb2awXKB8+J6Lx+/eu1P7asd04LOZr7y+ BHx5JuW+fQAt9NvbKS5PpnTQWtBWrGapsSXFYug3/ciR/3eZ69YOzMkX+M4+lFqcr0ZZB Ph/kaOkLnPGhaddpWkfjrNiInJ8hmfSvt6E7ai17BF4a0ZAaNA+K90EK7srXWiOdjTM8v oNSjk7GH/q86lh2eKCx5ZLc9FEMUhWQ+X5Qvr5mxNB6+EMRqy0V6gJ6q65REGokVf7T2b 4oiHuk67H1Tkj43uFVxMO+CWo6txKZASA1dfocv92ZMdDHU7EUIIbqrJ8zAWi0xnEGg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796102953; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=UGPWjX0eahGWZLeMm4obHfq1np54U7NT+ssva8nGEO4=; b=5AFH3oKnHQLkoZjZCkfDR3r9CowNNRo2YGE04ASUlgxS4JvwthY4+Kkmg76xwAZDlQ6z CKQH9b1u2FQXd1k2bAH4k9NR7PlEbbadtmitlAzv3lAj30mAM7LLaymVDjun7Aqx0Vzg2 RRfEj4IKqCM4ksHwUxWza3Q7+ha5fr7/htTk/2bi33p2Tcp0xh9b1hiIFcryUykKxOT/+ sffjf/q3rCrMYNFMmrO1JHjZfSieYzNaf7zlvzApCe6cgC49zud+KSPf0wpBKZXzRg5Xm Ch8XDp3uHxNFjMwbh+DzhiiWHj36diXCgP5z9i1EQV3HwMnU8DqSwGMgnZLxeCTSIRA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bYUr0sV0; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B504606A31A; Tue, 1 Dec 2026 05:29:13 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEFF21F00893; Tue, 1 Dec 2026 05:29:11 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796102953; bh=UGPWjX0eahGWZLeMm4obHfq1np54U7NT+ssva8nGEO4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=bYUr0sV0yo+Ny3z16jU+viNXDRpjsbHytSSylBykBSCaILMYffGz5FkkEXoXA4BaK ePrwC0580JEQCyP7cHwtg43Zg+PaHRwoV5t6W686juoJk7WyiZEHKmqmPD4/fayOdl 8jJJC6vNPpo+oyBsGramuAHn+UQuluAxcxpXL/Q5Fx4Kc4RQEMRmPhxasUXF223iIj MKVADA/no6TMOwvDKBiTfp9MY+W2WrlqP2BIpG6Fc3IuCILuahqQ5Dw6C5ObXBAjot O31vHDUlA+FLRvQbTRyz0IpTwqNLuoedGaBCkclY/pLmcOZ0mkcOALmGKpV1bEysdw 18oeWjzH2GRvw== X-Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, kuniyu@google.com, willemb@google.com, willemdebruijn.kernel@gmail.com, dsahern@kernel.org, idosch@nvidia.com, shuah@kernel.org, tpluszz77@gmail.com, brauner@kernel.org, alice.kernel@fastmail.im, kylebot@openai.com, joe@dama.to, leitao@debian.org, xudu@redhat.com, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261130050729.893-2-juanagusnicco@gmail.com> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list