* Re: [PATCH net] macvlan: drop the conntrack entry of broadcast clones
2026-12-01 8:04 [PATCH net] macvlan: drop the conntrack entry of broadcast clones Kyuwon Cho
@ 2026-12-03 6:44 ` Juan Agustin Niccolini
2026-12-05 8:46 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: Juan Agustin Niccolini @ 2026-12-03 6:44 UTC (permalink / raw)
To: Kyuwon Cho
Cc: Jakub Kicinski, Paolo Abeni, Eric Dumazet, David S . Miller,
Andrew Lunn, Pablo Neira Ayuso, Florian Westphal, netdev
On Tue, 1 Dec 2026 17:04:20 +0900, Kyuwon Cho wrote:
> --- 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);
> skb->dev = dev;
> if (ether_addr_equal_64bits(eth->h_dest, dev->broadcast))
> skb->pkt_type = PACKET_BROADCAST;
I reviewed and tested this patch, and it is correct for the case it
aims to fix.
While reviewing it I found two other places that deliver clones which
keep the original's unconfirmed entry, macvlan source mode and macsec,
and sent patches for both:
https://lore.kernel.org/netdev/20261203063745.75353-1-juanagusnicco@gmail.com/
Reviewed-by: Juan Agustin Niccolini <juanagusnicco@gmail.com>
Tested-by: Juan Agustin Niccolini <juanagusnicco@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] macvlan: drop the conntrack entry of broadcast clones
2026-12-01 8:04 [PATCH net] macvlan: drop the conntrack entry of broadcast clones Kyuwon Cho
2026-12-03 6:44 ` Juan Agustin Niccolini
@ 2026-12-05 8:46 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 8:46 UTC (permalink / raw)
To: kyuwon.cho
Cc: kuba, pabeni, edumazet, davem, andrew+netdev, pablo, fw, netdev
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
^ permalink raw reply [flat|nested] 3+ messages in thread