Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bYUr0sV0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEFF21F00893; Tue, 1 Dec 2026 05:29:11 +0000 (UTC) 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== Subject: Re: [PATCH net v2 1/3] udp: Keep the bound device on disconnect unless connect() set it From: netdev-bot+sashiko@kernel.org To: juanagusnicco@gmail.com 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 Date: Tue, 01 Dec 2026 05:29:11 +0000 Message-ID: <179610295120.3146.5772948202560480809@kernel.org> In-Reply-To: <20261130050729.893-2-juanagusnicco@gmail.com> References: <20261130050729.893-2-juanagusnicco@gmail.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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