From: sashiko-bot@kernel.org
To: "Oliver Hartkopp" <socketcan@hartkopp.net>
Cc: "Marc Kleine-Budde" <mkl@pengutronix.de>,
linux-can@vger.kernel.org,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
"Vincent Mailhol" <mailhol@kernel.org>,
"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH v4 3/3] can: fix unique skb identifier regression under RPS
Date: Tue, 29 Sep 2026 16:09:21 +0000 [thread overview]
Message-ID: <20260929160921.E94E51F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260929154125.3298-4-socketcan@hartkopp.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] can: data race and extension corruption due to incorrect skb_cloned() check
--
commit 1ddbc558b8096bdaecb507a831137177beb7d0ad
Author: Oliver Hartkopp <socketcan@hartkopp.net>
can: fix unique skb identifier regression under RPS
This commit moves the per-skb unique identifier used for duplicate detection
into a CAN skb extension instead of using skb->hash. It aims to fix an issue
where RPS assigned a non-zero hash to CAN frames, preventing a unique ID from
being generated and causing legitimate frames to be dropped as duplicates.
Link: https://lore.kernel.org/linux-can/2859AD3D-C805-41A0-9036-C5E8EE152419@clnt.de/
> diff --git a/net/can/af_can.c b/net/can/af_can.c
> index ef435f22ac933..4aa233d7e8a1d 100644
> --- a/net/can/af_can.c
> +++ b/net/can/af_can.c
[ ... ]
> -void can_set_skb_uid(struct sk_buff *skb)
> +void can_set_skb_uid(struct can_skb_ext *csx)
> {
> - /* create non-zero unique skb identifier together with *skb */
> - while (!(skb->hash))
> - skb->hash = atomic_inc_return(&skbcounter);
> -
> - skb->sw_hash = 1;
> + while (!(csx->can_skb_uid))
> + csx->can_skb_uid = atomic_inc_return(&skbcounter);
> }
[Severity: High]
If the extension block passed here is shared with another SKB, will this write
to csx->can_skb_uid cause a data race and corrupt the clone's UID?
[ ... ]
> +static struct can_skb_ext *can_get_unshared_skb_ext(struct sk_buff *skb,
> + struct can_skb_ext *csx)
> +{
> + /* create unshared CAN skb_extension for netem/mirred skb clones */
> + if (unlikely(skb_cloned(skb)))
> + return skb_ext_add(skb, SKB_EXT_CAN);
> + else
> + return csx;
> +}
[Severity: High]
Is skb_cloned() the correct check to determine if the extension block is shared?
If a CAN SKB is cloned (for example, via tc mirred) and its data buffer is
later unshared via skb_unshare() or pskb_expand_head(), the data buffer is
copied but the extension block remains shared because __skb_ext_copy() only
increments its refcount.
In this scenario, skb_cloned(skb) returns false because the data buffer itself
is no longer shared. Returning csx directly here would bypass the COW refcount
logic inside skb_ext_add() and pass a shared extension block to
can_set_skb_uid().
This seems like it could cause raw_rcv() to mistakenly identify legitimate
frames as duplicates and silently drop them. Should this rely directly on the
refcount handling within skb_ext_add() instead?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260929154125.3298-1-socketcan@hartkopp.net?part=3
next prev parent reply other threads:[~2026-09-29 16:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 15:41 [PATCH v4 0/3] CAN netlayer fixes for stable Oliver Hartkopp
2026-09-29 15:41 ` [PATCH v4 1/3] can: remove CAN filters independent from namespace Oliver Hartkopp
2026-10-03 6:00 ` netdev-bot+sashiko
2026-09-29 15:41 ` [PATCH v4 2/3] can: convert unreliable ARPHRD_CAN type checks to robust can_get_ml_priv() Oliver Hartkopp
2026-09-29 15:41 ` [PATCH v4 3/3] can: fix unique skb identifier regression under RPS Oliver Hartkopp
2026-09-29 16:09 ` sashiko-bot [this message]
2026-10-03 6:00 ` netdev-bot+sashiko
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=20260929160921.E94E51F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=sashiko-reviews@lists.linux.dev \
--cc=socketcan@hartkopp.net \
/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