mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: shyckless@gmail.com
Cc: pabeni@redhat.com, kuba@kernel.org, davem@davemloft.net,
	edumazet@kernel.org, netdev@vger.kernel.org,
	maoyixie.tju@gmail.com, anilkaushikwireless@gmail.com,
	stephen@networkplumber.org, linux-kernel@vger.kernel.org,
	horms@kernel.org
Subject: Re: [PATCH net v2] l2tp: require CAP_NET_ADMIN to join the l2tp multicast group
Date: Wed, 25 Nov 2026 09:58:31 +0000	[thread overview]
Message-ID: <179560071114.3135.2532610269837690017@kernel.org> (raw)
In-Reply-To: <20261124-l2tp-mcast-perm-v2-1-416741ccb334@gmail.com>

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@gmail.com/ [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

      reply	other threads:[~2026-11-25  9:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  9:57 Suyuan Wang via B4 Relay
2026-11-25  9:58 ` 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=179560071114.3135.2532610269837690017@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=anilkaushikwireless@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maoyixie.tju@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shyckless@gmail.com \
    --cc=stephen@networkplumber.org \
    /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®