Re: [PATCH net v2] l2tp: require CAP_NET_ADMIN to join the l2tp multicast group
From: Wong Steve
Date: Fri Nov 27 2026 - 06:06:41 EST
> Can an unprivileged user also control when that registration happens? If
> so, the leak is still reachable as long as this patch is applied
> without [1].
Yes. Where l2tp_netlink is a module that is not loaded yet, an
unprivileged user can join the free genl group IDs and then trigger the
load with CTRL_CMD_GETFAMILY, which calls request_module() for the
"l2tp" family alias. So the pre-registration case can be reached on
demand, not only by joining early by chance. The commit message
understates that.
> Should [1] also be merged with or before this patch, and be listed as a
> hard dependency for the stable backports?
The two patches are independent. This one stops unprivileged sockets
from joining the l2tp group once the family is registered, and does
that on its own. [1] (now "genetlink: Reject joining multicast groups
no family owns", v8) closes the pre-registration case for every family
that uses GENL_MCAST_CAP_*, including gtp. Neither patch depends on the
other to build or work, and the order does not matter, but a backport
needs both to close both cases.
If the maintainers want it, I can send a v3 that only changes the
commit message: say that an unprivileged user can trigger the module
load, and that stable backports should take [1] as well. Otherwise I'll
leave v2 as it is.
Thanks,
Suyuan
<netdev-bot+sashiko@xxxxxxxxxx> 于2026年11月25日周三 17:58写道:
>
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> 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] On its own, this patch does not stop an unprivileged local
> user from receiving l2tp tunnel and session notifications, including…
>
> --
>
> l2tp: require CAP_NET_ADMIN to join the l2tp multicast group
>
> This patch marks the l2tp generic netlink multicast group with
> GENL_MCAST_CAP_NET_ADMIN. After this, genl_bind() requires CAP_NET_ADMIN
> in the user namespace that owns the network namespace before a socket can
> join the group. Tunnel and session notifications, including L2TPv3
> cookies, then no longer reach unprivileged listeners that join after the
> family is registered.
>
> Link: https://lore.kernel.org/all/20261123155503.2497063-1-anilkaushikwireless@xxxxxxxxx/ [1]
>
> > diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
> > index a07009d4cb009..c442e953df66a 100644
> > --- a/net/l2tp/l2tp_netlink.c
> > +++ b/net/l2tp/l2tp_netlink.c
> > @@ -31,6 +31,7 @@ static struct genl_family l2tp_nl_family;
> > static const struct genl_multicast_group l2tp_multicast_group[] = {
> > {
> > .name = L2TP_GENL_MCGROUP,
> > + .flags = GENL_MCAST_CAP_NET_ADMIN,
>
> [Severity: Medium]
> The commit message says the pre-registration case remains open, and gives
> this example:
>
> "A socket that joins the ID before the l2tp family is registered, for
> example before l2tp_netlink is loaded, keeps getting the notifications."
>
> Can an unprivileged user also control when that registration happens? If
> so, the leak is still reachable as long as this patch is applied
> without [1].
>
> The new flag is only checked in genl_bind(), and only when a registered
> family owns the requested group ID:
>
> net/netlink/genetlink.c:genl_bind() {
> ...
> i = group - family->mcgrp_offset;
> if (i < 0 || i >= family->n_mcgrps)
> continue;
> ...
> }
>
> For an ID that no family owns, ret stays 0 and the join succeeds.
>
> netlink_setsockopt(NETLINK_ADD_MEMBERSHIP) checks only
> NL_CFG_F_NONROOT_RECV, which genetlink sets, and that val - 1 is below
> nlk->ngroups. So any free bit in the genl group bitmap can be joined
> without a capability.
>
> When l2tp_netlink registers, genl_allocate_reserve_groups() picks a free
> bit with find_first_zero_bit(), and genl_validate_assign_mc_groups()
> assigns it:
>
> family->mcgrp_offset = first_id;
>
> On this path __netlink_clear_multicast_users() is never called. It is
> only called from genl_unregister_mc_groups(), so existing subscribers
> keep their membership.
>
> CTRL_CMD_GETFAMILY has no admin permission flag. For an unknown name,
> ctrl_getfamily() loads the module:
>
> net/netlink/genetlink.c:ctrl_getfamily() {
> ...
> if (res == NULL) {
> genl_unlock();
> up_read(&cb_lock);
> request_module("net-pf-%d-proto-%d-family-%s",
> PF_NETLINK, NETLINK_GENERIC, name);
> ...
> }
>
> l2tp_netlink declares MODULE_ALIAS_GENL_FAMILY("l2tp"), so this sequence
> looks possible:
>
> unprivileged user:
> NETLINK_ADD_MEMBERSHIP on every free genl group ID
> genl_bind() returns 0 (no owner)
> CTRL_CMD_GETFAMILY name="l2tp"
> ctrl_getfamily()->request_module()
> l2tp_nl_init() registers the family on a bit already joined
>
> root:
> creates an L2TPv3 tunnel and session with cookies
> l2tp_session_notify()->genlmsg_multicast_netns()
>
> The message is built by l2tp_nl_session_send(), which includes
> L2TP_ATTR_COOKIE and L2TP_ATTR_PEER_COOKIE. It reaches the unprivileged
> socket, and membership is never checked again.
>
> Since the case here can be triggered on demand on any system with module
> autoloading where l2tp_netlink is not loaded yet, should the commit
> message say that an unprivileged user can trigger the load? Should [1]
> also be merged with or before this patch, and be listed as a hard
> dependency for the stable backports?
>
> > },
> > };
> >
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124-l2tp-mcast-perm-v2-1-416741ccb334%40gmail.com