From: netdev-bot+sashiko@kernel.org
To: anilkaushikwireless@gmail.com
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
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 [thread overview]
Message-ID: <179553579621.3135.2576494122860587206@kernel.org> (raw)
In-Reply-To: <20261123155503.2497063-3-anilkaushikwireless@gmail.com>
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
prev parent reply other threads:[~2026-11-24 15:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 15:55 [PATCH net v8 0/2] genetlink: Reject joining multicast " Anil Kaushik
2026-11-23 15:55 ` [PATCH net v8 1/2] " Anil Kaushik
2026-11-24 15:56 ` netdev-bot+sashiko
2026-11-23 15:55 ` [PATCH net v8 2/2] selftests: net: test joining genetlink " Anil Kaushik
2026-11-24 15:56 ` netdev-bot+sashiko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179553579621.3135.2576494122860587206@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=aliceryhl@google.com \
--cc=anilkaushikwireless@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=fw@strlen.de \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=jacob.e.keller@intel.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martineau@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=nicolas.dichtel@6wind.com \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=v3rdant.xiang@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®