From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: Anil Kaushik <anilkaushikwireless@gmail.com>, netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, idosch@nvidia.com,
willemb@google.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 v10 1/2] genetlink: Reject joining multicast groups no family owns
Date: Mon, 30 Nov 2026 11:27:28 +0100 [thread overview]
Message-ID: <25359215-983a-4fb1-af0e-810e6ce66a6d@6wind.com> (raw)
In-Reply-To: <20261127032246.2886407-2-anilkaushikwireless@gmail.com>
Le 27/11/2026 à 04:22, Anil Kaushik a écrit :> genl_bind() checks the
GENL_MCAST_CAP_* flags of a group only when a
> family owns it. For a group ID that no family owns, it returns 0, so any
> user can join it.
>
> A family registered later can get that ID, and the socket stays a member:
> nothing checks it again. An unprivileged user can join the free IDs, load
> a family module with CTRL_CMD_GETFAMILY, which calls request_module(),
> and then receive the notifications of a group with
> GENL_MCAST_CAP_NET_ADMIN or GENL_MCAST_CAP_SYS_ADMIN. For example the
> drop_monitor "events" group always gets ID 1, and is free until the
> drop_monitor module is loaded.
>
> Fix by returning -ENOENT from genl_bind() when no family owns the group.
> There are no group flags to check before the family registers, so this
> applies to privileged callers too: a program that joins a fixed ID such
> as NET_DM_GRP_ALERT before the family is loaded no longer gets its
> messages. I don't know of a program that does this. One that resolves
> the family first still joins. Say so in the comments on the static
> IDs.
>
> bind() takes a mask of groups, and most IDs in it can have no owner. Such
> a mask used to work, so keep it working: netlink_bind() skips an ID when
> the bind callback returns -ENOENT, and joins the others. Only genl_bind()
> returns -ENOENT. A skipped ID is not joined, so it is no longer in the
> groups that getsockname() and NETLINK_LIST_MEMBERSHIPS report.
> setsockopt() returns the error, as it asks for one group.
>
> This does not cover a family that is unregistered between the check and
> the point where the membership bit is set. Hitting it needs a
> privileged module unload at the same time, and the capability check
> already has the same window.
>
> Found by the Sashiko review of the gtp multicast group fix. Tested as an
> unprivileged user who joins all free IDs, then loads gtp and
> drop_monitor:
>
> Before:
> joins: ok=62 EPERM=2
> gtp/gtp (ID 15): member
> NET_DM/events (ID 1): member
>
> After:
> joins: ok=19 ENOENT=43 EPERM=2
> gtp/gtp (ID 15): not member
> NET_DM/events (ID 1): not member
> bind(), an owned group and free IDs: ok, member of the owned group only
>
> genl_bind() was added, with its first capability check, in the commit
> in the Fixes tag.
>
> Link: https://lore.kernel.org/netdev/179324692107.3134.14443689892607921337@kernel.org/
> Fixes: 4d54cc32112d ("mptcp: avoid lock_fast usage in accept path")
> Signed-off-by: Anil Kaushik <anilkaushikwireless@gmail.com>
Reviewed-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
next prev parent reply other threads:[~2026-11-30 10:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 3:22 [PATCH net v10 0/2] " Anil Kaushik
2026-11-27 3:22 ` [PATCH net v10 1/2] " Anil Kaushik
2026-11-30 10:27 ` Nicolas Dichtel [this message]
2026-11-27 3:22 ` [PATCH net v10 2/2] selftests: net: test joining genetlink " Anil Kaushik
2026-11-30 10:37 ` Nicolas Dichtel
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=25359215-983a-4fb1-af0e-810e6ce66a6d@6wind.com \
--to=nicolas.dichtel@6wind.com \
--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=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=v3rdant.xiang@gmail.com \
--cc=willemb@google.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®