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/2026…%40gmail.com