All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: vladimir.oltean@nxp.com
Cc: Frank.Li@kernel.org, imx@lists.linux.dev, bpf@vger.kernel.org
Subject: Re: [PATCH v3 net 6/7] net: enetc: linearize PTP event packets with one-step TX timestamping
Date: Wed, 16 Sep 2026 22:28:06 +0000	[thread overview]
Message-ID: <20260916222807.2A2EC1F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260915222735.1016937-7-vladimir.oltean@nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net/enetc: data corruption due to skb_linearize instead of skb_linearize_cow
--

commit 4e574e48c7ebf46bd9831e2efa9f6f3ac1500c3d
Author: vladimir.oltean@nxp.com <vladimir.oltean@nxp.com>

net: enetc: linearize PTP event packets with one-step TX timestamping

This commit addresses parsing issues with fragmented PTP headers in
enetc_ptp_parse() by linearizing packets with one-step timestamping requests.
The commit message states that it uses skb_linearize_cow() to also solve a
secondary issue where enetc_update_ptp_sync_msg() modifies the packet data
in-place later in the TX path, which requires the SKB to be exclusively owned.

Link: https://sashiko.dev/#/patchset/20260401172246.1075883-1-vladimir.oltean%40nxp.com

> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
> index 8a9ba168eab1e..62cdcaab3f3fb 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> @@ -1099,6 +1099,11 @@ netdev_tx_t enetc_xmit(struct sk_buff *skb, struct net_device *ndev)
>  
>  	/* Fall back to two-step timestamp if not one-step Sync packet */
>  	if (enetc_cb->flag & ENETC_F_TX_ONESTEP_SYNC_TSTAMP) {
> +		if (unlikely(skb_linearize(skb))) {

[Severity: High]
Does this code use skb_linearize() instead of the intended
skb_linearize_cow()?

The commit message and v2->v3 changelog explicitly mention using
skb_linearize_cow() to ensure the packet is exclusively owned and writable.
However, the code uses skb_linearize(), which only unshares the buffer if
it is nonlinear. A linear cloned SKB (e.g., from AF_PACKET, tc mirred, or
bridging) will bypass the copy.

Since enetc_update_ptp_sync_msg() modifies the originTimestamp field directly
in the SKB buffer later in the TX path:

    *(__be16 *)(data + tstamp_off) = new_sec_h;
    *(__be32 *)(data + tstamp_off + 2) = new_sec_l;
    *(__be32 *)(data + tstamp_off + 6) = new_nsec;

Could this corrupt the buffer for other users if the SKB was linear and
cloned?

> +			dev_kfree_skb_any(skb);
> +			return NETDEV_TX_OK;
> +		}
> +
>  		if (enetc_ptp_parse(skb, &udp, &msgtype, &twostep,
>  				    &offset1, &offset2) ||
>  		    msgtype != PTP_MSGTYPE_SYNC || twostep != 0) {

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260915222735.1016937-1-vladimir.oltean@nxp.com?part=6

  parent reply	other threads:[~2026-09-16 22:28 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 22:27 [PATCH v3 net 0/7] Fix short frame transmission in enetc vladimir.oltean
2026-09-15 22:27 ` [PATCH v3 net 1/7] net: enetc: consistenly track dropped frames in enetc_xdp_xmit() vladimir.oltean
2026-09-16  2:16   ` Wei Fang
2026-09-18 10:27     ` Vladimir Oltean
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-15 22:27 ` [PATCH v3 net 2/7] net: enetc: ensure enetc_xdp_xmit() calls enetc_update_tx_ring_tail() vladimir.oltean
2026-09-16  2:20   ` Wei Fang
2026-09-16 22:28   ` sashiko-bot
2026-09-18 23:05     ` Vladimir Oltean
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-15 22:27 ` [PATCH v3 net 3/7] net: enetc: fix bogus TX ring consumer index after reinitialization vladimir.oltean
2026-09-15 22:27 ` [PATCH v3 net 4/7] net: enetc: pad short frames in software vladimir.oltean
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-17 10:11   ` David Laight
2026-09-21 11:29     ` Vladimir Oltean
2026-09-15 22:27 ` [PATCH v3 net 5/7] net: enetc: pad short XDP frames coming from devmap vladimir.oltean
2026-09-16 22:28   ` sashiko-bot
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-15 22:27 ` [PATCH v3 net 6/7] net: enetc: linearize PTP event packets with one-step TX timestamping vladimir.oltean
2026-09-16  1:59   ` Wei Fang
2026-09-16  9:50     ` Vladimir Oltean
2026-09-16 22:28   ` sashiko-bot [this message]
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-15 22:27 ` [PATCH v3 net 7/7] net: enetc: drain and cancel one-step TX tstamp queue when going down vladimir.oltean
2026-09-16 23:36   ` 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=20260916222807.2A2EC1F00898@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vladimir.oltean@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.