🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27298

Re: [PATCH net] macvlan: drop the conntrack entry of broadcast clones

#27298
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 08:46
142 lines
13498 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 2

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).

- [High] The fix is incomplete: the same macvlan clone path that shares
  an unconfirmed conntrack entry is still reachable through source-mode…
- [Low] The commit message says "In bridge mode the clone goes through
  __dev_forward_skb(), which drops its conntrack entry, but in the other…
- [Low] The commit message (title "drop the conntrack entry of broadcast
  clones", body "Drop the conntrack entry of the clone") presents the…

--

macvlan: drop the conntrack entry of broadcast clones

This patch adds nf_reset_ct() to macvlan_broadcast_one() for the non-local
case. Broadcast and multicast clones handed to macvlan devices then stop
sharing an unconfirmed conntrack entry that tc act_ct attached on the lower
device. Before the patch, one skb could krealloc() the ct extension area
while another skb was still reading it.

> macvlan_broadcast_one() hands a clone of a broadcast or multicast frame
> to each macvlan device. In bridge mode the clone goes through
> __dev_forward_skb(), which drops its conntrack entry, but in the other
> modes it keeps the entry of the original skb.

[Severity: Low]
Does this description match received frames? In macvlan_broadcast(), local
comes from the flood mask the caller passes in, not from the target vlan's
mode:

drivers/net/macvlan.c:macvlan_broadcast() {
    ...
		err = macvlan_broadcast_one(nskb, vlan, eth,
				mode == MACVLAN_MODE_BRIDGE) ?:
		      netif_rx(nskb);
    ...
}

Every RX caller in macvlan_multicast_rx() passes a multi-bit mask, either
MACVLAN_MODE_VEPA | MACVLAN_MODE_BRIDGE or that pair plus
MACVLAN_MODE_PRIVATE and MACVLAN_MODE_PASSTHRU. So local is false for
every target, bridge-mode macvlans included. Only the TX flood in
macvlan_queue_xmit() passes exactly MACVLAN_MODE_BRIDGE.

That means bridge-mode macvlans receiving broadcast or multicast from the
lower device were affected just like private or VEPA ones before this
patch. Could the commit message be reworded so it doesn't suggest
bridge-mode setups were safe?

> Drop the conntrack entry of the clone, as __dev_forward_skb() does and
> as act_mirred does since commit d09c548dbf3b ("net: sched: act_mirred:
> Reset ct info when mirror/redirect skb").

[Severity: Low]
The subject and this paragraph say only clones are affected. However,
macvlan_handle_frame() also calls macvlan_broadcast_one() on the original,
non-cloned skb:

drivers/net/macvlan.c:macvlan_handle_frame() {
    ...
			if (mode != MACVLAN_MODE_VEPA &&
			    mode != MACVLAN_MODE_BRIDGE) {
				/* forward to original port. */
				vlan = src;
				ret = macvlan_broadcast_one(skb, vlan, eth, 0) ?:
				      __netif_rx(skb);
    ...
}

Since local is 0 here, the new nf_reset_ct() also drops the ct of the
original skb. This happens when a multicast frame's source MAC belongs to
a private, passthru or source-mode macvlan. Netfilter on the upper device
used to see that entry, for example one set by tc act_ct with a zone on
the lower device, and now it won't.

This is probably intended and matches __dev_forward_skb(). Could the
commit message mention it?

> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
> index 4f8416bb5169b..237744d6bfc2d 100644
> --- a/drivers/net/macvlan.c
> +++ b/drivers/net/macvlan.c
> @@ -237,6 +237,7 @@ static int macvlan_broadcast_one(struct sk_buff *skb,
>  	if (local)
>  		return __dev_forward_skb(dev, skb);
>  
> +	nf_reset_ct(skb);

[Severity: High]
Does the source-mode clone path in the same receive handler need the same
reset? macvlan_forward_source_one() clones the skb and passes the clone to
__netif_rx() without dropping its conntrack entry:

drivers/net/macvlan.c:macvlan_forward_source_one() {
    ...
	nskb = skb_clone(skb, GFP_ATOMIC);
	if (!nskb)
		return;

	len = nskb->len + ETH_HLEN;
	nskb->dev = dev;
    ...
	ret = __netif_rx(nskb);
    ...
}

skb_clone()->__copy_skb_header()->__nf_copy() copies _nfct and takes a
reference. The clone therefore shares the original skb's unconfirmed
nf_conn.

macvlan_handle_frame() calls macvlan_forward_source() on both the
multicast branch and the unicast branch. Unless a matching vlan has
MACVLAN_FLAG_NODST, the original skb keeps going with the same ct. It can
return RX_HANDLER_PASS, be retargeted with RX_HANDLER_ANOTHER, or go
through the broadcast/multicast or forward-to-original-port paths. Several
source-mode macvlans can also register the same source MAC, which gives
more than one clone.

With tc act_ct on the lower device's ingress, wouldn't this trigger the
same use-after-free and double-free from the commit message? The path is
nft_ct_expect_obj_eval()->nf_ct_helper_ext_add()->nf_ct_ext_add() and its
krealloc(). The only difference is a source-mode macvlan (ip link add ...
type macvlan mode source) in place of a private-mode one.

Would adding nf_reset_ct(nskb) after skb_clone() in
macvlan_forward_source_one() fix this too?

>  	skb->dev = dev;
>  	if (ether_addr_equal_64bits(eth->h_dest, dev->broadcast))
>  		skb->pkt_type = PACKET_BROADCAST;

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179607207068.562302.5326868635249894085%40skku.edu
Technical Details
Message-ID: <179646040307.3146.69323079833219430@kernel.org>
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377899-linux-kernel-netdev=dewy.ru
References: <179607207068.562302.5326868635249894085@skku.edu>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377899-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] macvlan: drop the conntrack entry of broadcast clones
Date: Sat, 05 Dec 2026 08:46:43 +0000
Organization: Usenet Network
Message-ID: <179646040307.3146.69323079833219430@kernel.org>
References: <179607207068.562302.5326868635249894085@skku.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2990079"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:KEPiwsput+g0XPt+J/ocbyLIKcQ= sha256:3ocaE66HfovS8VfWk75EyfNI3g/u8ObFBDRGpCQu97A=
	sha1:APdmt2PILtpECOVt46wp2vo55P4= sha256:29tASSaM0mto8fA1SRe81YHOzyy4hg9YMcftwPMKHiY=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 6EAD1117DB4; Sat,  5 Dec 2026 11:47:01 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.541
X-Spam-Status: No, score=-3.541 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id ioVlOhVMZp9c;
	Sat,  5 Dec 2026 11:46:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377899-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 3E17D117DA6; Sat,  5 Dec 2026 11:46:47 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 76F512CDD7; Sat,  5 Dec 2026 08:46:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796460405;
	b=QKOP+E8Jcqb0AFEQc2TMNnxE74pfu5Y7R1ySrqiOlOCsImvzIqhYTTjxibaQ9Lkl1H4D
	 gj1cYKdH+9EIaP2RvVzbN8VHU1xp1s+ZLEQvvKvMH7zDVkuOtYuVKYa4NVuANm8mFFHtG
	 m1hPJiuOw3NyQLzOaLlsJyVal08MeaPEc94bio93of1b5tOk+BIMsHqOBeo2ibZf+819l
	 OitZVSp54bLWliQ2Vc7vs29VaKivC04lcvxsuPCXWSNASYwafmX5IBJE6pL1aazLzfFg/
	 UQCfbWhNfJAr25f/qf+/lRecK+Jt8KWnmVpwEL+3tTvOwGKH/TyloeA+UvSvIbi7tVQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796460405;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=SlmO9mPKehMke/ph6tWfgBXTcC7ZQWSEenMEv1bsb0M=;
	b=zvyLuvOyU00H29mzsgX9cvBHZwIJwDnE0DmceAEWNLNuewueWwLQkwLExofJamcDLUh6
	 VFt2K76DyEpqjNII5F8sM95nDwBGHSuhiLIVvFeJ81eEqMbdYFkZoehF8K8uHZeuVdulf
	 NW/nagRb0e9xIn5UY86N5pSq9WW6lCxbX647DM+ttnN0PciTuUaxGkdmXysm4pM1Pkssy
	 QRclBu8bJGqFXLiV19Lb0eqZ3IH1ogurvBieLnpFvlO/fIBK1OSnubBR1M0SHqNYr11JM
	 fEhK4zSe/olx3spoushoeCpAffi3SRkOpQiasuu9xnqlHt29BxXkSM4anD8XEF6kSrA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=grG7XQah;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C9EF606A335;
	Sat,  5 Dec 2026 08:46:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=grG7XQah
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796460404;
	b=S5lIKQHqFB9qFNscW5Ev3ibmU3iHiCJ/cWWtwZaWV2UorXMi3aF3ZsDVgNOsqIYzHv9T
	 +yPne0nbMt6sk5s5lSC2qM774A/B4+SiKvGPJDZivupIoDh6AbpTd/4l9Mg8zAv5VlXZS
	 +GO0dxxx8X9l7sbgJFHSlFRs78qhXNgXaevxkcTfknQD8dGAmC+L1wOlVfpDrEQ9z2mMo
	 Mk2jSeS3WcK3BxwYnhFL5t4iZMiE9GyfxyLNh16TL2z5pz9P98FZP1EtpToaFwTZEON1m
	 S0WeHlNlwLfVplmgfJ8tQIBcWROPr2rk6nK+TMwmOmN10cQ0OmEl6RVx+1qaidKE0Ig==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796460404;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=SlmO9mPKehMke/ph6tWfgBXTcC7ZQWSEenMEv1bsb0M=;
	b=byteGoJy7D3flhfEGJjmB/8wVzrA3ZRQ0iXeFH7QcA1XBAXc0s/cSrWcld/vxty62NWJ
	 DijaqYgf1AUQF7jb5q+VGxK8PpjHRw2AqmBdf2PWhb4wd8LagI8KZOQD//b3G9QVb/viv
	 lltQ4E8s2OdUobS5rT7xvM2t6DKGrR3EkKw1sx4BaMBDN00HjIGtrjVr6cg+DRxwc3LOv
	 NUa2Lw/lWz/I06aiINbAfq2qj5zKYq6LanwzTH/VF+MRYMX1UTBPZi5yshzc7MWsrK3gA
	 FbMtEbTtjr/VMyzm0Cb0ylIjHENyyk10Saiv3TxcdnzbCKSXMQI6cycvFN0S5+FZ+hA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=grG7XQah;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BD59606A322
	for <netdev@vger.kernel.org>; Sat,  5 Dec 2026 08:46:44 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8576C1F00936;
	Sat,  5 Dec 2026 08:46:43 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796460404;
	bh=SlmO9mPKehMke/ph6tWfgBXTcC7ZQWSEenMEv1bsb0M=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=grG7XQahMWsSANgITkBOyuMoAXx10hzri6eBmoogqn8tKC7UPE+Udfqp7/EQNzNLx
	 ecJ8b78WSwfDqcwXTt44/ENrjoiWZTSDR7Il73avpvU2u+7c4jmXmz3oCPjW1JYyNj
	 a6+l2vO/a21am7/lTs2GHhU4b1ISWQkrTlVlI8dX28UhxxJ0olk8+aa1vNd8j3X8Aa
	 Z9yPdnhpSoBLHMyyKw8jQV9mVWpnHSulz79NGZHJKgOFP1ei3YghzqbE1UQIKKjNS8
	 GnBSZ5ISbXBIZXH3Qdc8elXWTdmvb80v/QEDRPyMbxmFiOaSY5Zkp63raNzC1zwD7T
	 vdz4xftovaltA==
X-Cc: kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org,
 davem@davemloft.net, andrew+netdev@lunn.ch, pablo@netfilter.org, fw@strlen.de,
 netdev@vger.kernel.org
X-In-Reply-To: <179607207068.562302.5326868635249894085@skku.edu>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list