Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796015256; b=r97Oncu5IPAKuUJQaww5B1uK0inTlyb3sS9Ook5wK51lyMCuzH58X++dZNdhUfScSWrq XA8Q9AaW8CJgWHUb6np0sFivRBGPOLh5cNyKOwDTnWL2KrCPHAIj5xj4i+0TwoZoa+qdJ 6PAvxVHTBVOOV2C49O7kzBQADrz9idAMzmlLgaz+bDwOwrPMt9Wp7NrslYJC4KuO9zJv/ 9Aidj9gQWTNiqGitlcr3yg8BlFu/2b/WFOmvDEstJNEGbqw0O9wh72JSbbyYZ+Ya/Cr8T qYEuSvDCOLpepOOEHQMMdph0eQPP/InzmvKVu66fnOHcRTWUN0Jzho8NELoUHpImWWA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796015256; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=+ipvQ1ru0Ak/gW59wqE+lg5pLKq/R9GPYSwS0rk8o1Y=; b=fsz8syJqByxPGltAiyp/99obVkAg/mPD2aJ/TGefMp6gOiSK13nrBzkPzXl0YkqFdGiI +Lv0j7xIaZgdZPBItCc028pvk7ChK18eH1ZmoofDCvKBOEZtZLYJZ6ARRJE0N0HNWbI0N 6FhO+Qlv/+UA3CPFW9SN+AtcjzFAfgJ8mk+6zFkrKBdiB+1G8aNyd6LTrTo0xS886iQsJ e3c5BcJbR5UdLUScjKI/ibIkUhA3E0HJUIOQXrmVa8LbWa24xLQ5W8Ual1Jy/5Jgb7hRj l1aZkdkj10Whwrl2rObFZ4KvGeSa9s5CeVyEGXAE3u4dw7eUxDwvHrg/rsjn/C43MMQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=eVWbmOV0; arc=none smtp.remote-ip=209.85.128.170 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FA75606A31C for ; Mon, 30 Nov 2026 05:07:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1FA75606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=eVWbmOV0 Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-8b4e2ec4b42so51105767b3.0 for ; Sun, 29 Nov 2026 21:07:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796015255; x=1796620055; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=+ipvQ1ru0Ak/gW59wqE+lg5pLKq/R9GPYSwS0rk8o1Y=; b=eVWbmOV0oJmuFmTLwYmr6AQfD3b6YBudDgI2IEiOdangkZcvRoYk2I3BhVID0HcqI6 YCzh/s+LqKPj8QFlyclulOrrno6Xdz4mP+s7nZpgzaxX520zyDsr1bf05Gk9sHgeVjH+ g6IEN8JcwbtBZcdBakhXduA2K7Vub2xgj8rqlim5Egyies3nZdx+HbckzbuOUeP0gjF2 tWWq7cjHm2BAzktMpvYzsoOqebScioOumyTKj505dSLZqp5zY1KgOXIxl+fBgTKP5P+g rL7c/ffFPlKenjwLx4CGwe+BNchtUxa8xq2BftWqzR/7ugkS1zGY6h51nKqFtaRejqRv 985w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796015255; x=1796620055; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+ipvQ1ru0Ak/gW59wqE+lg5pLKq/R9GPYSwS0rk8o1Y=; b=r4GNy+dWf6OIyuWFoKYM+jaho9rzQE6ofYB5o8diU5MsvE/QJ6okgnlXvdHCy/kbec WdNUMu8OF69ed9BX3+G/Yy9kF6fHXL3IeQQ8mtPAXOTb1Zw/ifoM5Vj/mgAyfkjhm+Dt HvLVBUmc//TC+2R7jTNs5v6fSQEg3VQkCTQF+6pu7xxd1unchIE9SDmaZBqjFo0U9rtX So496AZJgSczHpjz3L4RLbmXMcj3mnkHqvexPbmja81xLa3YOo5SVUOoqxnZS3YXsJis 1BBqVVdQjC2MRzqtip+m0VHdUiVXOL27AiNEFvN08rph8x2Nl8XK5VxXTv7hINtIG/zR pPYA== X-Forwarded-Encrypted: i=1; AL+hErGwygM7+y2VIOfgySDe6YegnteU8IlugPTGkxmstOgo2N6cB2DMpSzTiqLqx46IIB3vuVaHYfo8VYr8UJYPdXs=@vger.kernel.org X-Gm-Message-State: APuU4Z+6Yv1iBc08kGj5Yr+tl2MFuBBNpk0hzZSoIUJ6U2rgX9+Qd5UY GEzRQqfIoioTpcRWilv+j4KyzWTMlsiExEFRqyFOCkpOIENQheh5KckW X-Gm-Gg: AZFdTZcVwADVjtzUUgCatl8GcM1559XJn/CqmUcR/5AvEjZaNqmvbROB5z8YuRo4Sxd mC9kyuIU2NqBIR/LuAYyFdkPLm27NMuOAGtLg6JNSxmsV3v5BPGjVd5S0CVXK+hEhgdpmIcu67H HY5ClGRPwIkJ0MOHL/9BnP6Wv2mz8GgpkMyeZzlzN/6sCjczvfRlS/TwatBxHq7IZcXkn619Its ZueYDdmy8GZZXusbl6pFD9eo09lTnNi3UfyMDBgF6fzITD7g89i2cJxKzsROOx+jpA9PhD1NMPo MAxTatBq/Q6+vP24tgZqMetgURaLkPuMyQ/ML0+ceaR0nl/nkvrLsipSur/fkkSjFms3OtDL1Yt 0r/N13ORGJ8/Q8ZalxaXn6Kzp70bcaTLLcXMnXcWVyWvgvNu6Veu2GNiEnssxIKoR7cq9yDx/lz StpVDHRZRv8x3C0KyV0L7go++SMZ42P3ylqdU2TlLK3v6SMogV259ILyhF3aJ5KWdQZa/dsUvIf lmCqteeok/nhuYB9TjS82XY8J2IFhD+kVAF6ReV5GXhrkyY6caPzUl6xI6lLfvXCKQ67/1eL8hy XICDW0u1XT+CnoyN1rTQ0I/X+Pg17sC/Y31FCJimem9I7ujd0IQpPiZJhTyUv8Amu9i8CF7fPA= = X-Received: by 2002:a05:690c:4a05:b0:8b4:f721:fd62 with SMTP id 00721157ae682-8b5204e1c88mr123810927b3.48.1796015254998; Sun, 29 Nov 2026 21:07:34 -0800 (PST) Received: from VPN-156-19.vpn.usf.edu ([2607:fe50:0:f802::4046]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b52028c7f5sm126540357b3.12.2026.11.29.21.07.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 29 Nov 2026 21:07:34 -0800 (PST) From: Juan Agustin Niccolini To: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com Cc: 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 Subject: [PATCH net v2 0/3] udp: Fix bind conflict check bypasses Date: Mon, 30 Nov 2026 00:07:26 -0500 Message-ID: <20261130050729.893-1-juanagusnicco@gmail.com> X-Mailer: git-send-email 2.53.0 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 Content-Transfer-Encoding: 8bit An unprivileged user can get a UDP socket bound to an address and port that another user's socket holds, in a state bind() would have refused, and receive that socket's datagrams. This series fixes two bugs that allow that, both through the bound device, and adds a selftest. These are sibling vulnerabilities of the TCP one fixed by my commit f675070191f2 ("tcp: Fix the SO_REUSEPORT bind cache admitting a conflicting socket"). Both predate git. They were discovered during an LLM-based audit. v2: - Drop v1 patch 1, which commit d77700039d09 ("udp: only quit inuse scan early on identical SO_REUSEPORT sockets") fixed, and rebase on it (Willem). - Patch 1: take the socket lock on IPv6 ping, raw and L2TP disconnect, which now writes sk_userlocks (Willem). - Patch 1: move the VRF behaviour change from the notes into the commit message (Willem). - Patch 2: read the device of the socket being bound directly and load the other socket's device once (Willem). - Patch 3: keep the SO_REUSEPORT tests and update the commit message (Willem). - v1: https://lore.kernel.org/netdev/20261120174341.35873-1-juanagusnicco@gmail.com/ Juan Agustin Niccolini (3): udp: Keep the bound device on disconnect unless connect() set it udp: Ignore a connect()-set device in the bind conflict check selftests: net: Add UDP bind conflict tests include/net/ipv6.h | 1 + include/net/sock.h | 4 + net/core/sock.c | 3 + net/ipv4/udp.c | 55 ++++- net/ipv6/datagram.c | 35 ++- net/ipv6/ping.c | 2 +- net/ipv6/raw.c | 2 +- net/l2tp/l2tp_ip6.c | 2 +- tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 1 + .../testing/selftests/net/udp_bind_conflict.c | 228 ++++++++++++++++++ 11 files changed, 317 insertions(+), 17 deletions(-) create mode 100644 tools/testing/selftests/net/udp_bind_conflict.c base-commit: fad0d57b12f6979bc0127f0a4f704c6d7177ca78 -- 2.43.0