Netdev List
 help / color / mirror / Atom feed
From: Doruk Tan Ozturk <doruk@0sec.ai>
To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com
Cc: xmei5@asu.edu, thomas.karlsson@paneda.se, daniel@iogearbox.net,
	horms@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH net] macvlan: require lower-netns admin for shared port settings
Date: Sun, 26 Jul 2026 14:54:47 +0200	[thread overview]
Message-ID: <20260726125447.32244-1-doruk@0sec.ai> (raw)

A macvlan device can be moved to a network namespace whose user
namespace does not administer the lower device. The rtnetlink
changelink path checks CAP_NET_ADMIN only in the macvlan device network
namespace. However, IFLA_MACVLAN_BC_QUEUE_LEN and
IFLA_MACVLAN_BC_CUTOFF update macvlan_port fields shared by every
macvlan on the lower device.

A caller can also create a nested macvlan on the moved device.
macvlan_common_newlink() resolves that device to the real lower device
without rechecking access to its network namespace.

Xiang Mei reported that a caller can set the shared broadcast queue
length to U32_MAX from an unprivileged user namespace and grow the host
backlog until OOM under an incoming broadcast flood. A fixed numeric
limit was proposed, but legitimate deployments use queue lengths of
100000 or more.

Require CAP_NET_ADMIN in the lower device network namespace for shared
port changes and nested macvlan creation. Per-device settings remain
available to an administrator of the macvlan device network namespace.
This matches the permission model used by ipvlan.

Found by 0sec automated security-research tooling (https://0sec.ai).

Reported-by: Xiang Mei (Microsoft) <xmei5@asu.edu>
Closes: https://lore.kernel.org/r/20260706212556.3199234-1-xmei5@asu.edu
Fixes: d4bff72c8401 ("macvlan: Support for high multicast packet rate")
Cc: stable@vger.kernel.org
Assisted-by: 0sec:multi-model
Signed-off-by: Doruk Tan Ozturk <doruk@0sec.ai>
---
 drivers/net/macvlan.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 9a4bc99dbf53b..22f03b206c718 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -1483,8 +1483,11 @@ int macvlan_common_newlink(struct net_device *dev,
 	/* When creating macvlans or macvtaps on top of other macvlans - use
 	 * the real device as the lowerdev.
 	 */
-	if (netif_is_macvlan(lowerdev))
+	if (netif_is_macvlan(lowerdev)) {
 		lowerdev = macvlan_dev_real_dev(lowerdev);
+		if (!rtnl_dev_link_net_capable(dev, dev_net(lowerdev)))
+			return -EPERM;
+	}
 
 	if (!tb[IFLA_MTU])
 		dev->mtu = lowerdev->mtu;
@@ -1623,6 +1626,12 @@ static int macvlan_changelink(struct net_device *dev,
 	enum macvlan_macaddr_mode macmode;
 	int ret;
 
+	if (data &&
+	    (data[IFLA_MACVLAN_BC_QUEUE_LEN] ||
+	     data[IFLA_MACVLAN_BC_CUTOFF]) &&
+	    !rtnl_dev_link_net_capable(dev, dev_net(vlan->lowerdev)))
+		return -EPERM;
+
 	/* Validate mode, but don't set yet: setting flags may fail. */
 	if (data && data[IFLA_MACVLAN_MODE]) {
 		set_mode = true;
-- 
2.43.0


                 reply	other threads:[~2026-07-26 12:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260726125447.32244-1-doruk@0sec.ai \
    --to=doruk@0sec.ai \
    --cc=andrew+netdev@lunn.ch \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=thomas.karlsson@paneda.se \
    --cc=xmei5@asu.edu \
    /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