Article View: linux.kernel.netdev
Article #21927Re: [PATCH net v8 2/2] selftests: net: test joining genetlink groups no family owns
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 15:56
Date: Tue, 24 Nov 2026 15:56
140 lines
13318 bytes
13318 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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).
- [Medium] In tools/testing/selftests/net/nl_genl_mcast.py, _free_ids()
decides whether it runs in init_net by comparing the inode of…
- [Low] bind_before_family() in
tools/testing/selftests/net/nl_genl_mcast.py first checks that NET_DM…
--
selftests: net: test joining genetlink groups no family owns
This adds a Python selftest that checks Generic Netlink multicast group
IDs that no family owns cannot be joined. It covers
setsockopt(NETLINK_ADD_MEMBERSHIP), bind() with a group mask, and
loading drop_monitor after a bind(). The free IDs come from a family
dump, and the checks are meant to be skipped outside the initial
network namespace.
> diff --git a/tools/testing/selftests/net/nl_genl_mcast.py b/tools/testing/selftests/net/nl_genl_mcast.py
> new file mode 100755
> index 0000000000000..4e86a5556b627
> --- /dev/null
> +++ b/tools/testing/selftests/net/nl_genl_mcast.py
[ ... ]
> +def _free_ids(ctrl):
> + """Return the IDs in 1..32 that no family owns."""
> + # Outside init_net, the dump skips the families that are not netnsok,
> + # but their groups are still owned.
> + try:
> + netns = os.stat('/proc/self/ns/net').st_ino
> + init_netns = os.stat('/proc/1/ns/net').st_ino
> + except OSError as e:
> + raise KsftSkipEx("cannot check the network namespace") from e
> + if netns != init_netns:
> + raise KsftSkipEx("not in the initial network namespace")
[Severity: Medium]
Does comparing against /proc/1/ns/net actually detect init_net?
/proc/1 is resolved in the PID namespace of the procfs mount. Some
containers have their own PID and network namespaces, for example Docker
or Podman without --net=host, or systemd-nspawn. There, PID 1 is the
container's init and shares the test's non-init netns. The inodes match,
so this skip doesn't fire.
In that netns, ctrl_dumpfamily() hides the families that are not
netnsok:
net/netlink/genetlink.c:ctrl_dumpfamily() {
...
if (!rt->netnsok && !net_eq(net, &init_net))
continue;
...
}
genl_bind() still walks the global genl_fam_idr with no netns or netnsok
filter, so the groups of those families are still owned.
acpi_event_genl_family in drivers/acpi/event.c is one example. It has an
mcast group, no .netnsok, and is registered on any ACPI system. The
NET_DM events group is another one if drop_monitor is loaded on the
host.
Those IDs then land in the free list. In join_free(),
setsockopt(NETLINK_ADD_MEMBERSHIP) on the acpi_event group succeeds. On
the NET_DM group without CAP_SYS_ADMIN it raises PermissionError. Either
way, ksft_raises(FileNotFoundError) fails.
In bind_mask(), netlink_bind() keeps the bits that genl_bind() accepted,
so ksft_eq(_members(sk), 0) fails as well.
Because of this, the commit message statement "these checks are skipped
outside the initial one" doesn't hold in that setup.
Separately, a non-root user can't stat /proc/1/ns/net, because it needs
ptrace read access to PID 1. That gives EACCES, and the OSError branch
skips the tests. Should the commit message mention this case?
[ ... ]
> +def bind_before_family(ctrl) -> None:
> + """A free ID joined with bind() stays unjoined when a family takes it."""
> + names = [fam['family-name'] for fam in ctrl.getfamily({}, dump=True)]
> + if 'NET_DM' in names:
> + raise KsftSkipEx("NET_DM is already registered")
> +
> + free = _free_ids(ctrl)
> + with _sock() as sk:
> + sk.bind((0, sum(_bit(gid) for gid in free)))
> +
> + # Looking up the family loads drop_monitor.
> + try:
> + ids = _groups(ctrl.getfamily({'family-name': 'NET_DM'}))
> + except NlError as e:
> + raise KsftSkipEx("drop_monitor is not available") from e
[Severity: Low]
Should drop_monitor be unloaded again once this test is done?
ctrl_getfamily() autoloads it here:
net/netlink/genetlink.c:ctrl_getfamily() {
...
request_module("net-pf-%d-proto-%d-family-%s",
PF_NETLINK, NETLINK_GENERIC, name);
...
}
No exit path in bind_before_family() removes the module again. That
covers the success path, the "NET_DM got no group ID that was free"
skip, and an assertion failure.
Every later run on the same boot then hits the "NET_DM is already
registered" skip at the top of bind_before_family(). So this check runs
at most once per boot, and reruns only report SKIP.
> +
> + if not any(gid in free for gid in ids.values()):
> + raise KsftSkipEx("NET_DM got no group ID that was free")
> +
> + for name, gid in ids.items():
> + ksft_eq(_members(sk) & _bit(gid), 0,
> + comment=f"member of NET_DM {name}")
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123155503.2497063-1-anilkaushikwireless%40gmail.com
Technical Details
Message-ID:
<179553579621.3135.2576494122860587206@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370538-linux-kernel-netdev=dewy.ruReferences:
<20261123155503.2497063-3-anilkaushikwireless@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370538-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v8 2/2] selftests: net: test joining genetlink groups no family owns Date: Tue, 24 Nov 2026 15:56:36 +0000 Organization: Usenet Network Message-ID: <179553579621.3135.2576494122860587206@kernel.org> References: <20261123155503.2497063-3-anilkaushikwireless@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4174359"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:gfLZDyDUNg7zLi5UEv51/p4XEI8= sha256:FnrB7PRKhRWAYHEeCZDq8Y+Ye75ZeFn3HcoV1fxVkpg= sha1:X8val/rjdllyGf7rfiQMEIfJIRc= sha256:TGfGzEwfSAVdt5zuV3q0JjQEozfEqSqb15Un44dKhkQ= 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 8D275125E20; Tue, 24 Nov 2026 18:57:01 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, 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] 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 iDG_5Mj2jOBp; Tue, 24 Nov 2026 18:56:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-370538-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 131AC125E1F; Tue, 24 Nov 2026 18:56:46 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id B5F6038C90; Tue, 24 Nov 2026 15:56:39 +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=1795535799; b=tgBtwcIanj0Pwc1dKDtwuolq4pPCnbJlGD+XI+nUvSqAn7VxrSTiYzSGmpgNH+Ek98JG YXbvZbS478enTZ64Cg+N0UK57EsljApotTwPBX3vBoc69O/Bi9e50TNsQhu3LqXZ5HW86 latWdJ2lEg6dWJ1yF9+lyAEv6YpAUHHfC/U/FyllancwZWNOktUcQK0h0uPwbWahjm5gT Mtcr3NH16gO6BywxJcrHRXRmHjZDR6/FtYKzZZsZAv2jmxF93gyq10mN0SkEO0A2bPO21 HVzNCLSv6sXmc98IbMBxkkESNKZnBDhzFCnyq43Bxu/9FRl65TY/vq9ZVhcwsIXyJFA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795535799; 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=Qxe57lMNKukT31B5po2sqaJC36RczLL5Kjvfjsw19PE=; b=D92a99t6SjOR/x8I3WHO8sTy/V/Hxhkf3g91jGerSOvVAao82Ldn59n1iSQukgMReGNr bQjYUfb7vyjZlc/wyQJTPrlraaptGmcmreK/mbwgxyZzb127t0iqKOVsclhK14fdqWyqk nqpAMMCUfyOux0132gem9jW6FfIOuvOSfUJ/o5XFEAWh8cMdZ613yPy2IbCsKHhW/WDd6 xzYtuC6rELA05+xuuVDrhYkXr27YRcNjoIgb82fA8Wwbh12ZkVvtKHmwToj0xAuDDxAbj 78tgxVJj9pQChsxYTOtEjRfHKvNEu8JVdLCttAjERa1xSSx0lZ7jGslyH1mO8NTE3YQ== 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=THR5ispW; 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 22544606A338; Tue, 24 Nov 2026 15:56:39 +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=THR5ispW 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=1795535798; b=yD5y0aeRdga7tzT8/DfFqOqXw14INgt+Ld+jKrkE+3jX0adBSpu2oAYJAD8dU85V52vM D9i+Ox+S7JELtkG/8yu8uJTaNcH8zHyzCVkBxthdxuo76SV5KqS6Mo7aboun0e7GeHuAx UbzkSEbeUXSUf6PbyH9IO3u/NyYzzQRUl0hnC/oJ3pNx6jnJt7DERBuB8gZrzUUcj6Ws8 CpCChR48dhRjqlnoQdmlVNEZs1XMKGcP5qD8f8Q9PMijlMVLKqSnzW9qLbT3QcqgBVt5z kGkz24B9zXK5dONDCn6dKnhLb+GK6yEJ77zwe1pqXLSRjW4PSn+5EiblNg9M4wPQugA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795535798; 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=Qxe57lMNKukT31B5po2sqaJC36RczLL5Kjvfjsw19PE=; b=wACyMK/ba0lv9ovk3HFKeZIh9ztJVBMSDW5sPOLsDZCK9ArB08nzXFO/O8KmHt9DlxGQ LY842TpMPx+YrJQyrP3dfYghTrsd5uF5lq3rCRfx1RFC6CHtwNECzUSbLFbkNozSrf+Tw gRjnI86GgjkopXQC4oI0JjOLTdivt3FJjrE6ffxGTV2qeuX1Bkp+DIRA4e5vOape5t7N+ KHmoQOuUPRW9XWVHwotg8cu5WVve+AcgLkpAWJ7XtQ8CtkLOsQhTrzfjOfl5/M08D0chn 1QPbIRatc3J0JNeVVP+nPulEmxaKUQo0KxAW4uTqI6mCJRZzEgvUkFpQ2g11MDdUgyg== 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=THR5ispW; 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 42AA4606A31E; Tue, 24 Nov 2026 15:56:37 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA2321F000ED; Tue, 24 Nov 2026 15:56:36 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795535797; bh=Qxe57lMNKukT31B5po2sqaJC36RczLL5Kjvfjsw19PE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=THR5ispWIaQhB99nOBAFofxpXpIdVAm0fVy4q/IRS0YyUrMS3CEitYtmLbH6xHugX Qn10JvblAN3uvpDEThmUsLP3Y2AXQi193V9kzuglJ8mJF17SQhJLshAaGFUVKVrQb2 DUoCd8qf1clkuijJUW+6N8NidmmVcmm+06BclEOn/peTAQtIkjJjK4+wA6KvzLZ9W5 xoPktGHzfyWwv6uM6+PY2ZE645rhYAbtNsWUsMx5zBQ0mpg9AsIIhc1N8L/CDCX3xq 7cy7PCXjjiAopz7zlF57wAlPnrkqefqLW74ltkMHCMVgthE/4yEahj5KhelBsOQrwz FIEhsgU7ovhbA== X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, idosch@nvidia.com, nicolas.dichtel@6wind.com, jacob.e.keller@intel.com, jiri@resnulli.us, fw@strlen.de, martineau@kernel.org, v3rdant.xiang@gmail.com, aliceryhl@google.com, linux-kernel@vger.kernel.org, nhorman@tuxdriver.com, shuah@kernel.org, linux-kselftest@vger.kernel.org X-In-Reply-To: <20261123155503.2497063-3-anilkaushikwireless@gmail.com> X-sashiko-severity: Medium 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