Article View: linux.kernel.netdev
Article #9922[PATCH net v4 0/2] genetlink: fix joining multicast groups no family owns
From: Anil Kaushik
Date: Mon, 02 Nov 2026 15:58
Date: Mon, 02 Nov 2026 15:58
90 lines
15241 bytes
15241 bytes
genl_bind() checks the GENL_MCAST_CAP_* flags of a group, but the
membership bit is set later, after the lock is dropped. A socket can end
up a member of a group whose flags were never checked for it: when it
joins a group ID that no family owns, or when the family of the group is
unregistered between the check and the point where the bit is set.
Patch 1 rejects joins to group IDs that no family owns. Patch 2 counts,
per group, how many times its members were cleared, which genetlink does
when a family is unregistered. If the count changed after the check, the
group is checked again against its current owner, after the bind
callback is undone if that owner is the one it reached. The core cannot
always tell, see patch 2.
Tested as an unprivileged user, with an msleep() added after the bind
callback in netlink_setsockopt() and netlink_bind(), and a test family
that registers again with GENL_MCAST_CAP_NET_ADMIN:
patch 1 only v4
setsockopt:
unregister in the window,
register later member not member
unregister and register in the window member not member
another family unregistered
(must still join) member member
bind():
unregister and register in the window member not member
With the msleep() before the bind callback instead, and a test family
that registers again without the flag, the family is bound once, and not
twice as with v3:
v3 v4
binds while a member, setsockopt/bind 2 1
binds once the socket is closed 1 0
The test family counts its bind and unbind callbacks: they stay
balanced in all these cases. If the family is replaced just after the
bind callback returned, and before the second read, with an msleep()
there, it gets one unbind too many. The socket is still rejected or
checked against the new family. Normal joins and rtnetlink bind() show
no change.
The test from v1 (join all free IDs, then load gtp and drop_monitor)
gives the same result as before.
I used an LLM to help write and review the code, the tests and the
commit messages of this series. I checked and tested every change
myself.
Changes in v4:
- Patch 2: read the count after ->netlink_bind() too, and call
->netlink_unbind() before checking again if the count had already
changed: ->netlink_bind() can have reached the new owner, which was
then bound twice (netdev Sashiko). The commit message says what the
core still cannot tell.
- Patch 1: no change. It does not close the window on its own, patch 2
does, and it keeps its tags (netdev Sashiko asked about the order).
- The deadlock netdev Sashiko found on the insert failure path of
netlink_bind() exists without this series, it has its own patch:
https://lore.kernel.org/netdev/20261102120929.4077030-1-anilkaushikwireless@gmail.com/
Changes in v3:
- Patch 2: check the group again in af_netlink.c instead of clearing
the members when a family registers. This also covers the case where
the family is unregistered and another one registers, both in the
window, does not walk the sockets on every registration, and does not
touch the members of a group another family still owns (Sashiko).
- Fixes: tag of both patches: the race exists since genl_bind() first
checked a capability, in 4d54cc32112d (Sashiko).
Changes in v2:
- New patch 2 (Sashiko).
- Patch 1: no change, added Reviewed-by tags.
v3: https://lore.kernel.org/netdev/20261101101347.3910654-1-anilkaushikwireless@gmail.com/
v2: https://lore.kernel.org/netdev/20261031054632.3697295-1-anilkaushikwireless@gmail.com/
v1: https://lore.kernel.org/netdev/20261029062214.3407223-1-anilkaushikwireless@gmail.com/
Anil Kaushik (2):
genetlink: Reject joining multicast groups no family owns
netlink: Check a group again if it was released while joining it
net/netlink/af_netlink.c | 79 +++++++++++++++++++++++++++++++++++++++-
net/netlink/af_netlink.h | 1 +
net/netlink/genetlink.c | 3 +-
3 files changed, 81 insertions(+), 2 deletions(-)
--
2.25.1
Technical Details
Message-ID:
<20261102155819.4100930-1-anilkaushikwireless@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354921-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354921-linux-kernel-netdev=dewy.ru
From: anilkaushikwireless@gmail.com (Anil Kaushik)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v4 0/2] genetlink: fix joining multicast groups no family owns
Date: Mon, 2 Nov 2026 15:58:17 +0000
Organization: Usenet Network
Message-ID: <20261102155819.4100930-1-anilkaushikwireless@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="3023028"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:CGt1AtAZSyoKnd1JRQsky4VmQ+4= sha256:cRCuoQnXs/0PvAoIZ5UW2uy0GZUspQxQAckiiNTqJC4=
sha1:EkVUqzqjZHmCJBCtSyzz2G0TuWI= sha256:DtNI9lAx2Lrvu2RW2ZLODRkOnyUlPKDmQToCjH+mPbw=
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 6B8A1112665; Mon, 2 Nov 2026 23:28:33 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
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 y9FWjuhuC1ad;
Mon, 2 Nov 2026 23:28:26 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-354921-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id EB709112638; Mon, 2 Nov 2026 23:28:16 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id 10A2D108D85; Mon, 2 Nov 2026 16:59:20 +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=1793635113;
b=umul9iXdIxcxmEKQWSrds36tkMfurK3/XXn7OCGA/2CDfMY2ZlCGYqdPb8FcuBJx2a/B
am6cQrKDP4Nm4SJ/Xo2gLXPWmcYBl6DRf8uNw5cXEps4BbmOw+AYKJHBZT9SJQryu1S/M
I9f5eyk04NW+G7f3uo9ih+wwzFS+R+tamsqxbrcWyGdQddPOWofXNYfp2pLMo1gyMA/rb
KWK41xXKkC8HbstCg6GDAgNnuGJJlqjXZB1ISD05rrbNyoODB7WyyJIuDwiVnOL5/njyP
djlNCwzQxmky3145lT03D4NCBgLVpnLOGdjLkmypzpwAPR5KjUvFV2xHS/ZBdhvx8KQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793635113;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:X-Mailing-List:
List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
bh=ZLAdr+wJraqBBQJZMLxL2JwKTZnl1MAf4rmeB7WLuOw=;
b=sK3/n/a5nqqgBGEdfWVe05UXIA8LjWHG2hFuj4kzbRWZF4VtmNpgD3lH97Xy/4+WIunh
BybPbTKdO1LqXoCGBUXPQ5hNJ+BIaGuLbeNWg5x2IMylNvbG7jS1+ru1qSEQAtcV77tSg
BX8mm5m7613lI5tsgxGKhQhAC3YR/SjCtRfkI0Hrz2W1hPvK2i53UWsi4bx5N/+nfntb1
yT9MCMdE4vS34TFlJ8c1fJKe/hJ3qFCdsV3WMa69Jz2axVCTyW4hrJqj/9pRzYs+8zOKU
D62owtwWgtvbVz489hGtdu+HcrNv3qh7Aarb+eAYndi76zMtG7Ai73Yg7b4QFVP+eCw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=plb0ZRPL;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
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 BFC7A60752A1;
Mon, 2 Nov 2026 15:58:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=plb0ZRPL
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.50
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793635107;
b=k3CzawyYcHSudrrWa+mdtGfvEPqY2YNXnnj3uFm6sOl82YdmRnCJcDFSZAh2ZVO3RV6n
Ezgmflh19FkEXcoLlZcnvka8fY4N7+ImU1QjXc7CaBfJMf5RlmxXOlkBfdnxiR8m5Phze
0Z956OTMmcSRtCGgcDTG0b/r9PnpxRHmPW8EwxX7J5Vt3bTpZ7zYOex4CmYEG1f+ER/iU
zIIPfyOWG8/WBRerQVuAVOadyF7vHTQKvs2D/4Nm8bkEb4q08QtL2/V7r8xFM4tyq9GEY
WbR4p0eL3/U5Sq9gO9RuknQBhP3nVxLRe5e6U9MSMuaOOZo6R/LFxmbdoMvYZJ8WO1g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793635107;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
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=ZLAdr+wJraqBBQJZMLxL2JwKTZnl1MAf4rmeB7WLuOw=;
b=PT8OMqwGh0poR6jucr427eugmI9BUD1vVjeBKPn5uxRhq2CCvSbGbQ5GwouG5EgXIP3V
FwlUjAzHcI13HMR2wYxFA6wwbWIQ5SLLC1BL1Gb3f/hPdqE82U4kh9lDrFsY4krFxk5xz
pUsnjsiyi3JIKpwQ+twyGNRP1wGefL14R9bEUW2IowH8xfebg9vhqA+yy6wopC3bm69cZ
blf5rTj7iJelFMsokMlZYOXLkn+RMStBp1zpdfntwn/ystb8WlYdKZwBtfIbZicV1+lRz
c2Ddc8Trz4HYHKOdQd5Sw/OZvaU+tCokhl/atabg3BG1Bb/0pnbDvz/EGnyayAyl8Tw==
X-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=plb0ZRPL;
arc=none smtp.remote-ip=74.125.82.50
X-Received: from mail-dl1-f50.google.com (mail-dl1-f50.google.com [74.125.82.50])
(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 8BDC6606EEBB
for <netdev@vger.kernel.org>; Mon, 2 Nov 2026 15:58:27 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8BDC6606EEBB
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dl1-f50.google.com with SMTP id a92af1059eb24-1b1ce85287aso1100796c88.0
for <netdev@vger.kernel.org>; Mon, 02 Nov 2026 07:58:27 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1793635107; x=1794239907; 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=ZLAdr+wJraqBBQJZMLxL2JwKTZnl1MAf4rmeB7WLuOw=;
b=plb0ZRPLqV81cehr7hYrsYdNFFdgIQVNIOqv5zHeb8a8/h7pC0RbmcVgQhQ6fbeeUC
AiPWqyk0hlWsBwhg/vheb9hRcgvln+MCwnzrFiPMTXhGoceORTBGjAtMDdE7Pl1tSM/f
c0eV0zT6tq5ajsmY/5cEpqf2m6gNmQVsI/I3bgUS3SCOPkZ3o2NPm3LQpgMEqiAvRPLt
SJgmX9Zw08kjNoIiM3cncQ01tEmpA9iKrJ7qymvvZlYgsH/x65kB9xlMrQQ+LRWXFv+H
7QHya6c35uvD4ufukQKjNHGi6hCJo0va8FVrMd28hsWh1ZSXq9QLU/tCe77JW4GbV0Rx
RFxg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793635107; x=1794239907;
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=ZLAdr+wJraqBBQJZMLxL2JwKTZnl1MAf4rmeB7WLuOw=;
b=J017V5RDWFTiZyUCiwhNhxU9pIpqcGlKUdnOqz+bEH+gROuHbCOyYDKiobIUOcS8Xo
UJr/gEDa0NsJ/8HiJfN4fIo93y1uwb6hYSrMSVLbc1NJP+nlbybwGc5pcn8sGd/5WZRu
j/IHl1PA1da/OE8uOwZ/tzP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M2MQhj5w
==
X-Received: by 2002:a05:7022:4392:b0:1a4:c892:b14f with SMTP id a92af1059eb24-1ac5de53bc8mr25736739c88.29.1793635106285;
Mon, 02 Nov 2026 07:58:26 -0800 (PST)
X-Received: from ramen-dev-security-2.asia-south1-c.c.ramen-dev-345017.internal (90.156.200.35.bc.googleusercontent.com. [35.200.156.90])
by smtp.gmail.com with ESMTPSA id a92af1059eb24-1aed79b3dfcsm35115869c88.12.2026.11.02.07.58.21
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Mon, 02 Nov 2026 07:58:25 -0800 (PST)
X-Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Ido Schimmel <idosch@nvidia.com>,
Nicolas Dichtel <nicolas.dichtel@6wind.com>,
Jacob Keller <jacob.e.keller@intel.com>,
Jiri Pirko <jiri@resnulli.us>,
Florian Westphal <fw@strlen.de>,
Mat Martineau <martineau@kernel.org>,
XingWang Xiang <v3rdant.xiang@gmail.com>,
Alice Ryhl <aliceryhl@google.com>,
linux-kernel@vger.kernel.org,
Anil Kaushik <anilkaushikwireless@gmail.com>
X-Mailer: git-send-email 2.25.1
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