From: Kurt Kanzenbach <kurt@linutronix.de>
To: "Linus Walleij" <linusw@kernel.org>,
"Andrew Lunn" <andrew@lunn.ch>,
"Vladimir Oltean" <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Simon Horman" <horms@kernel.org>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Jonas Gorski" <jonas.gorski@gmail.com>,
"Hauke Mehrtens" <hauke@hauke-m.de>,
"Woojung Huh" <woojung.huh@microchip.com>,
UNGLinuxDriver@microchip.com,
"Chester A. Unal" <chester.a.unal@arinc9.com>,
"Daniel Golle" <daniel@makrotopia.org>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Wei Fang" <wei.fang@nxp.com>,
"Clark Wang" <xiaoning.wang@nxp.com>,
"Clément Léger" <clement.leger@bootlin.com>,
"George McCollister" <george.mccollister@gmail.com>,
"David Yang" <mmyangfl@gmail.com>
Cc: netdev@vger.kernel.org,
Sashiko AI Review <sashiko-bot@kernel.org>,
Linus Walleij <linusw@kernel.org>
Subject: Re: [PATCH net] net: dsa: Fix skb ownership in taggers
Date: Tue, 16 Jun 2026 08:38:23 +0200 [thread overview]
Message-ID: <87y0gfdm74.fsf@jax.kurt.home> (raw)
In-Reply-To: <20260616-dsa-fix-free-skb-v1-1-fd30b35dcf66@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 1676 bytes --]
On Tue Jun 16 2026, Linus Walleij wrote:
> The tag_8021q.c tagger calls vlan_insert_tag() in dsa_8021q_xmit().
> vlan_insert_tag() will consume the skb with kfree_skb() on failure
> and return NULL.
>
> When NULL is returned as error code to ->xmit() in dsa_user_xmit()
> it will free the same skb again leading to a double-free.
>
> The idea of dsa_user_xmit() and dsa_switch_rcv() dropping the skb
> they held before the call to ->xmit() and ->rcv() is conceptually
> wrong: the pattern elsewhere in the networking code is that consumers
> drop their skb:s on failure.
>
> Modify the ->xmit() and ->rcv() call sites to not drop the SKB if
> the taggers return NULL from any of these calls. Move those drops into
> the taggers so every callback error path that retains ownership consumes
> the skb before returning NULL.
>
> Keep the existing helper ownership rules: VLAN insertion helpers already
> free on failure (this is the case in tag_8021q.c), while deferred
> transmit paths either transfer the skb reference to worker context or
> hold a worker reference with skb_get() and drop the caller's reference.
>
> For SJA1105 meta RX, transfer the buffered stampable skb under the meta
> lock and return NULL while the skb is waiting for its meta frame: the
> skb is not dropped in this case.
>
> Reported-by: Sashiko AI Review <sashiko-bot@kernel.org>
> Closes: https://lore.kernel.org/r/20260610153952.1685895-1-kuba@kernel.org/
> Suggested-by: Jakub Kicinski <kuba@kernel.org>
> Assisted-by: Codex:gpt-5-5
> Signed-off-by: Linus Walleij <linusw@kernel.org>
Acked-by: Kurt Kanzenbach <kurt@linutronix.de> # hellcreek
> ---
> net/dsa/tag_hellcreek.c | 9 +++++++--
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
next prev parent reply other threads:[~2026-06-16 6:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 22:33 [PATCH net] net: dsa: Fix skb ownership in taggers Linus Walleij
2026-06-16 1:01 ` Jakub Kicinski
2026-06-16 9:01 ` Linus Walleij
2026-06-16 1:52 ` Wei Fang
2026-06-16 2:20 ` Qingfang Deng
2026-06-16 6:38 ` Kurt Kanzenbach [this message]
2026-06-16 6:54 ` David Yang
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=87y0gfdm74.fsf@jax.kurt.home \
--to=kurt@linutronix.de \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chester.a.unal@arinc9.com \
--cc=clement.leger@bootlin.com \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=george.mccollister@gmail.com \
--cc=hauke@hauke-m.de \
--cc=horms@kernel.org \
--cc=jonas.gorski@gmail.com \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=mmyangfl@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=sashiko-bot@kernel.org \
--cc=wei.fang@nxp.com \
--cc=woojung.huh@microchip.com \
--cc=xiaoning.wang@nxp.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