Article View: linux.kernel.netdev
Article #26809Re: [PATCH net 1/2] macvlan: drop the conntrack entry of source-mode clones to fix a double free
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 07:21
Date: Fri, 04 Dec 2026 07:21
163 lines
13653 bytes
13653 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 1
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.
- [Low] macvlan: Fixes tag cites act_ct instead of macvlan source-mode
commit
--
macvlan: drop the conntrack entry of source-mode clones to fix a double free
This patch calls nf_reset_ct() on the clone that
macvlan_forward_source_one() creates. The clone handed to a source-mode
macvlan device then no longer shares the original skb's unconfirmed
conntrack entry. Without this, the original and the clone can both run
nf_ct_ext_add() on the same entry from different CPUs and double free
ct->ext.
> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
> index 4f8416bb5169b..7fb584621fa06 100644
> --- a/drivers/net/macvlan.c
> +++ b/drivers/net/macvlan.c
> @@ -422,6 +422,7 @@ static void macvlan_forward_source_one(struct sk_buff *skb,
> return;
>
> len = nskb->len + ETH_HLEN;
> + nf_reset_ct(nskb);
> nskb->dev = dev;
>
> if (ether_addr_equal_64bits(eth_hdr(skb)->h_dest, dev->dev_addr))
[Severity: Low]
Is b57dc7c13ea9 the right commit for the Fixes tag?
That commit introduced net/sched/act_ct.c and did not touch
drivers/net/macvlan.c. The clone that this patch resets is created in
macvlan_forward_source_one(). That function came in with 79cf79abce71
("macvlan: add source mode"), and it has never dropped the clone's
_nfct.
The bridge path below does not depend on act_ct at all. Take a
source-mode macvlan stacked on a bridge with br_netfilter enabled.
Conntrack is attached at the bridge's prerouting hook. For a unicast
PACKET_HOST frame, br_nf_local_in() then returns early:
net/bridge/br_netfilter_hooks.c:br_nf_local_in() {
...
if (!nfct || skb->pkt_type == PACKET_HOST)
return NF_ACCEPT;
...
}
br_netif_receive_skb() then hands the skb to netif_receive_skb() on
the bridge device. The unconfirmed _nfct is still attached, and the
bridge device's rx_handler is macvlan_handle_frame(). From there,
macvlan_forward_source_one() clones it just as in the act_ct case.
The original and the clone then share the same unconfirmed nf_conn,
with no tc involved.
Stable tooling uses the Fixes tag to decide which trees get the
backport. Pointing it at act_ct suggests the problem only exists
once act_ct is present, and that does not seem to be the case.
Should this be Fixes: 79cf79abce71 ("macvlan: add source mode")
instead?
[Severity: High]
Can the broadcast/multicast RX path in this driver still hit the same
double free?
In macvlan_handle_frame(), a broadcast or multicast frame is cloned, and
then the original keeps going up the lower device:
drivers/net/macvlan.c:macvlan_handle_frame() {
...
hash = mc_hash(NULL, eth->h_dest);
if (test_bit(hash, port->bc_filter))
macvlan_broadcast_enqueue(port, src, skb);
else if (test_bit(hash, port->mc_filter))
macvlan_multicast_rx(port, src, skb);
return RX_HANDLER_PASS;
...
}
The broadcast address is always set in port->bc_filter (see
macvlan_compute_filter()). macvlan_broadcast_enqueue() uses skb_clone(),
and skb_clone() keeps _nfct.
macvlan_process_broadcast() then handles the clone on the unbound
system_dfl_wq. That worker can run on another CPU even without RPS.
macvlan_process_broadcast()->macvlan_multicast_rx()->macvlan_broadcast()
then clones once for each matching vlan:
drivers/net/macvlan.c:macvlan_broadcast() {
...
nskb = skb_clone(skb, GFP_ATOMIC);
if (likely(nskb))
err = macvlan_broadcast_one(nskb, vlan, eth,
mode == MACVLAN_MODE_BRIDGE) ?:
netif_rx(nskb);
...
}
On RX, mode is a mask such as MACVLAN_MODE_VEPA | MACVLAN_MODE_BRIDGE.
That makes local false, so macvlan_broadcast_one() never calls
__dev_forward_skb():
drivers/net/macvlan.c:macvlan_broadcast_one() {
...
if (local)
return __dev_forward_skb(dev, skb);
skb->dev = dev;
...
}
Each clone therefore reaches netif_rx() still pointing at the shared
unconfirmed nf_conn.
In prerouting, the original on the lower device and the clones on the
macvlan devices can then call nf_ct_ext_add() on the same ct at the same
time. One way in is nft "ct expectation" -> nf_ct_helper_ext_add(), which
only requires !nf_ct_is_confirmed(ct). Both paths end up here:
net/netfilter/nf_conntrack_extend.c:nf_ct_ext_add() {
...
new = krealloc(ct->ext, alloc, gfp);
...
}
No lock is held there. This is the double free the commit message
describes, reached with broadcast traffic instead of source mode.
The commit message names __dev_forward_skb() as the model for this fix.
However, only the local (TX bridge) branch of macvlan_broadcast_one() uses
it.
The later patch in this series, "macsec: drop the conntrack entry of
delivered clones to fix a double free", only touches drivers/net/macsec.c.
The macvlan broadcast path is therefore still unfixed at the end of the
series.
Could nf_reset_ct() also be called at one of these points?
- on the clone in macvlan_broadcast_enqueue()
- on each clone in macvlan_broadcast()
- in macvlan_broadcast_one() when !local
These clones also carry a conntrack entry owned by the lower device's
netns into macvlan devices that may be in another netns.
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203063745.75353-1-juanagusnicco%40gmail.com
Technical Details
Message-ID:
<179636888470.3146.9085451232838721319@kernel.org>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377151-linux-kernel-netdev=dewy.ruReferences:
<20261203063745.75353-2-juanagusnicco@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377151-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 1/2] macvlan: drop the conntrack entry of source-mode clones to fix a double free Date: Fri, 04 Dec 2026 07:21:24 +0000 Organization: Usenet Network Message-ID: <179636888470.3146.9085451232838721319@kernel.org> References: <20261203063745.75353-2-juanagusnicco@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2702010"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:c3R46KzBZdNrh5Shihk1B0eQD94= sha256:5rYM8npfZqrDasNWBERSfkdukehZjR2UQ5XOziTCMuw= sha1:QDE1PAJAnqID1dKrl4UdYMPaO2A= sha256:/zmvgRwnPc66YiLrTFz7j3XW+5SKnCLoyVD4m7URoas= 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 62BFA117B56; Fri, 4 Dec 2026 10:21:52 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.739 X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.24, 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 6xjJQ-kpBq2y; Fri, 4 Dec 2026 10:21:44 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-377151-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id C25B9117B53; Fri, 4 Dec 2026 10:21:29 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id E5028601369; Fri, 4 Dec 2026 07:21:28 +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=1796368887; b=i+3dev/OJniDWfTKfyylulRMuxm/c72ZktaoVa5708kAG+IOJ3iR/hVBJRBYi2VypduA BtSVhA+iHHhk0H8sd0ik2nBrqfAF2JI4oQo6HSjzF2+amrYXcXH8ShugGhczYM2tmtp8q k3e5IQ6HZN2Gt0bz9iPRi+xO74pNrCaUBlb9O+2+fr8r1SJ7ge/G+1ouh9H4WijnNxwx6 cIvRsKVQBU8BBhKLzNESJQVhgFb1JFN4aIonzE6SFmrEkQf+XIvi0zsG+3WsK/xoudIg/ O8rGnULs/pKGtb9ziRQQ06r3bBIkhaClibzq3AYV3IRdbtf9zM5Qzv/1hXf9B3525kw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796368887; 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=fvfpvKSpdwZmCBzqBZgQ/ebHieB831+Hzb076GbANWE=; b=xivFyGwMr0d8UspFtoH6C8I2iG/uDf+5TtOWh4ymavydBRvCSfD1VQNzEJAe+8kAQx6j YdaGJCGAce7Z9f+2kxF84wq2oOmhKtmISY8u2BxOugfieFqhDOdlyW1vGap+6dMdpYypy wUO3xny68eVfMlYVcU4nYt7DCgBOw0btcFjDxy2XRAX5OAG8cHC7cN9atox1SEEE5DZfU 1i7+C+1UBdgMRE+kHgvBKhDhFkQsHGH6N41jSuqjEY0d2Mjc/j6dnqZUEt2ocWo22JlzT BQzdNMPr7ApPlg242nar+gs9f16B8g8Q5USTxMDP9HSkS1M9AR2xlaCRF9cX1EihTLQ== 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=TJu4XuYd; 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 4DBFB606A336; Fri, 4 Dec 2026 07:21:27 +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=TJu4XuYd 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=1796368886; b=Orp4qUe9qcrJofrHcqZO1iFX5W/OfvujgOzLi5efMCprTxV3hRqSb/KOLgEMMemRUd87 6xweZ8TNNcTLrdEofT+vucUOJy0SE6pX9nKC6mj8jwgxmoqW70dDRMZgggxI9JLDn2qw/ WcSL/GUx6ENiKJuU70cv/3J5PHWpCNVRjUBbIjQQBhKu45aMRDpdp6Wv86kSR+ap1/hnU Al2XcSSP2MuZsLP3WNddZ6HONLzDjfqV6dYRs0NUM9lao/9wF/opB8XAG9ZBjgtMLbaQc b82UAdnf9rKB7XgXq1mUastB0NtoqwYxVndG69N/1fy/GkI106Frf/mWXsaqoFbo3Gg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796368886; 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=fvfpvKSpdwZmCBzqBZgQ/ebHieB831+Hzb076GbANWE=; b=W3Xb2960eeyOG8Z3cHlHQraowDnP7mP/t2IIZpgquEH/mLlx3FdBY8rYexz9LzVNoiNE 93Kw54WrFYMwKYnksYf8xRjnw5ABFbqUH3DqZWUZbHQAChW374lnnHH5sQxd3xbiyWquS 95vQrynoDl7T5j8Er50nCVq+jRZljKKw5pTvN/LCha+Um0JHWEAJSNn3jv2/CHdxd7QLz YoVo+oQ5IS7nCirqC+u9gwfAsyiNzlkbMyTOtjq/ceoc54bg32cdxS9W939kn+xzI4PQY cFINMYzQqVsLEJfG3f/HzQEuFiky93vE4vn80NZecWPj/rMCc3GfyCFu4iB85dE9+Ag== 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=TJu4XuYd; 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 687C1606A322 for <netdev@vger.kernel.org>; Fri, 4 Dec 2026 07:21:26 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3809C1F000CE; Fri, 4 Dec 2026 07:21:25 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796368886; bh=fvfpvKSpdwZmCBzqBZgQ/ebHieB831+Hzb076GbANWE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=TJu4XuYdUlsKJJwcR6UYoS4Ry22JRjnsfVZGMUaPI0Luz8/nz1qDYPNdCwMvIq9ac bDPdw7IbSuoFe7itWTN0eNuxGdawrTMP8I/AQWAM0P9ezzQBwGAFrgbdIkFoGfJGxv dQkH6zuLpgjnv+97pvW8YMdUPweA5fuVR23sgKhcR/NdLcc8fbiQC88XKramV45pTq eUfIvddz2kOQZT6TesZb0wmPoEeYsPzDgR5rHrJk3yFfDZMTEqagcZUZByXICftX6h u3a9bOToh1l+SKfSaW0d8QSMDAEDEVItr1nRgyY6wLoIuK9Sn9crVvrt0POPcnIIiB 6dPZhIWcImdbA== X-Cc: sd@queasysnail.net, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, kyuwon.cho@skku.edu, cratiu@nvidia.com, haseebulhaq55@gmail.com, paulb@mellanox.com, marcelo.leitner@gmail.com, yossiku@mellanox.com, jiri@resnulli.us X-In-Reply-To: <20261203063745.75353-2-juanagusnicco@gmail.com> 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