> 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…
These are the same two issues the bot flagged on patch 1/2 but with a
different title and severity rating.
Agustin
On Fri, Dec 4, 2026 at 2:21 AM <netd…@kernel.org> wrote:
>
> 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/2026…%40gmail.com