From: netdev-bot+sashiko@kernel.org
To: juanagusnicco@gmail.com
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
Subject: Re: [PATCH net 2/2] macsec: drop the conntrack entry of delivered clones to fix a double free
Date: Fri, 04 Dec 2026 07:21:26 +0000 [thread overview]
Message-ID: <179636888625.3146.13455568232369265321@kernel.org> (raw)
In-Reply-To: <20261203063745.75353-3-juanagusnicco@gmail.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] macsec: Fixes trailer cites act_ct instead of macsec clone-path
commits
Pre-existing issues:
- [Critical] This problem wasn't introduced by this patch, but the double
free it fixes in macsec can still be triggered through macvlan's…
--
macsec: drop the conntrack entry of delivered clones to fix a double free
This patch adds nf_reset_ct() to the skb clones that macsec delivers to
its upper devices, in handle_not_macsec() and in the unknown-SCI path of
macsec_handle_frame(). Without it, the clone and the original share one
unconfirmed conntrack entry. Concurrent nf_ct_ext_add() calls on that
entry can then double free ct->ext through krealloc().
> diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
> index 240ba0ae07d1e..a50266490f4a2 100644
> --- a/drivers/net/macsec.c
> +++ b/drivers/net/macsec.c
> @@ -1090,6 +1090,7 @@ static enum rx_handler_result handle_not_macsec(struct sk_buff *skb)
> if (!nskb)
> break;
>
> + nf_reset_ct(nskb);
> nskb->dev = ndev;
> eth_skb_pkt_type(nskb, ndev);
>
[Severity: Low]
The Fixes: tag points at b57dc7c13ea9 ("net/sched: Introduce action
ct"), but that commit only added net/sched/act_ct.c and did not touch
drivers/net/macsec.c. Is it the right commit to blame here?
This hunk patches the offloaded multicast clone in handle_not_macsec(),
which did not exist at b57dc7c13ea9. It was added later by
f428011b90ec ("net: macsec: support multicast/broadcast when
offloading"). A stable tree that has act_ct but not f428011b90ec has
no such skb_clone() for this hunk to apply to. The stable tooling may
still try to pick the patch up there based on the tag.
The other two clones, the untagged delivery in handle_not_macsec() and
the unknown-SCI delivery in macsec_handle_frame(), go back to the
original driver, c09440f7dcb3 ("macsec: introduce IEEE 802.1AE
driver").
act_ct is also not the only way an unconfirmed nf_conn can reach these
clones. Consider macsec stacked on a bridge with bridge netfilter
enabled. br_nf_local_in() and nf_ct_bridge_in() leave the entry
unconfirmed on purpose for PACKET_HOST frames. Such a frame can arrive
at macsec_handle_frame() with an unconfirmed ct attached, and then be
cloned the same way. That points at the macsec clone paths themselves
as the origin of the bug, rather than act_ct.
Would it be more accurate to cite these instead?
Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Fixes: f428011b90ec ("net: macsec: support multicast/broadcast when offloading")
[Severity: Critical]
This isn't a bug introduced by this patch, but can the same double free
still be reached through the macvlan multicast and broadcast receive path?
This series fixes the macsec clones here. It also fixes the macvlan
source-mode clones in "macvlan: drop the conntrack entry of source-mode
clones to fix a double free". Neither commit changes the external branch
of macvlan_handle_frame():
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 original goes on up the lower device and keeps the unconfirmed ct
that tc act_ct attached at ingress.
macvlan_broadcast_enqueue() calls skb_clone(), so the clone shares the
same _nfct. The clone is queued to bc_work on the unbound system_dfl_wq,
so it can run on another CPU even without RPS. Broadcast is always set in
port->bc_filter, so no extra macvlan configuration is needed.
After that, macvlan_broadcast() clones once per 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);
...
}
For externally received frames, mode is a combined mask such as
PRIVATE|VEPA|PASSTHRU|BRIDGE or VEPA|BRIDGE. That never equals
MACVLAN_MODE_BRIDGE, so local is false. This skips __dev_forward_skb(),
which is the only place that would clear the ct:
drivers/net/macvlan.c:macvlan_broadcast_one() {
...
if (local)
return __dev_forward_skb(dev, skb);
skb->dev = dev;
...
}
As a result, each clone reaches netif_rx() on the macvlan device while
still holding the shared, unconfirmed ct.
Suppose an nftables "ct expectation" rule matches on both the lower
device and the macvlan device. The original and the clones would then
run this chain at the same time:
nft_ct_expect_obj_eval()
nf_ct_helper_ext_add()
nf_ct_ext_add()
new = krealloc(ct->ext, alloc, gfp);
Would that free the old ct->ext twice, as in the KASAN report in the
commit message? With several macvlan devices, the clones could also race
with each other.
The only nf_reset_ct() in drivers/net/macvlan.c is in
macvlan_forward_source_one().
Should this path also get an nf_reset_ct(nskb) before netif_rx() in
macvlan_broadcast(), or in the non-local branch of
macvlan_broadcast_one()?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203063745.75353-1-juanagusnicco%40gmail.com
prev parent reply other threads:[~2026-12-04 7:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 6:37 [PATCH net 0/2] macvlan, macsec: fix double free of conntrack extensions by clones Juan Agustin Niccolini
2026-12-03 6:37 ` [PATCH net 1/2] macvlan: drop the conntrack entry of source-mode clones to fix a double free Juan Agustin Niccolini
2026-12-04 7:21 ` netdev-bot+sashiko
2026-12-03 6:37 ` [PATCH net 2/2] macsec: drop the conntrack entry of delivered " Juan Agustin Niccolini
2026-12-04 7:21 ` 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=179636888625.3146.13455568232369265321@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=cratiu@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=haseebulhaq55@gmail.com \
--cc=jiri@resnulli.us \
--cc=juanagusnicco@gmail.com \
--cc=kuba@kernel.org \
--cc=kyuwon.cho@skku.edu \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paulb@mellanox.com \
--cc=sd@queasysnail.net \
--cc=yossiku@mellanox.com \
/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