All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Til Kaiser" <mail@tk154.de>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v3 1/4] net: mvpp2: sync RX data at the hardware packet offset
Date: Sat, 06 Jun 2026 12:15:05 +0000	[thread overview]
Message-ID: <20260606121505.6B4D71F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260605121332.147397-2-mail@tk154.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] If SKB allocation fails after XDP processing, the buffer is recycled with a potentially truncated DMA sync size, leading to possible data corruption.
--

commit 2937dd51dcd41c34cf709a921bae57060051477d
Author: Til Kaiser <mail@tk154.de>

net: mvpp2: sync RX data at the hardware packet offset

mvpp2 programs the RX queue packet offset, so hardware writes received
data at dma_addr + MVPP2_SKB_HEADROOM. The current CPU sync starts at
dma_addr and only covers rx_bytes + MVPP2_MH_SIZE bytes, which syncs the
unused headroom and misses the same number of bytes at the packet tail.

> diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> index f442b874bb593..92a701f4fe3f5 100644
> --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> @@ -3946,9 +3946,10 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
>  			dma_dir = DMA_FROM_DEVICE;
>  		}
>  
> -		dma_sync_single_for_cpu(dev->dev.parent, dma_addr,
> -					rx_bytes + MVPP2_MH_SIZE,
> -					dma_dir);
> +		dma_sync_single_range_for_cpu(dev->dev.parent, dma_addr,
> +					      MVPP2_SKB_HEADROOM,
> +					      rx_bytes + MVPP2_MH_SIZE,
> +					      dma_dir);
>  
>  		/* Buffer header not supported */
>  		if (rx_status & MVPP2_RXD_BUF_HDR)

[Severity: High]
Can recycling the buffer with a truncated DMA sync size corrupt memory?

Looking further down in mvpp2_rx(), if an XDP program shrinks the packet,
rx_bytes is updated to the smaller size:

	rx_bytes  = xdp.data_end - xdp.data;

If the subsequent build_skb() or slab_build_skb() allocation fails, the error
path recycles the buffer with the modified rx_bytes:

	if (!skb) {
		netdev_warn(port->dev, "skb build failed\n");
		if (pp) {
			page_pool_put_page(pp, virt_to_head_page(data),
					   rx_bytes + MVPP2_MH_SIZE,
					   true);

Because rx_bytes is truncated, does this leave dirty CPU cache lines at the
tail of the original packet uncleaned?

If the hardware reuses this buffer to DMA a new packet, random CPU cache
evictions of these dirty lines could silently corrupt the new packet data
in RAM on non-coherent architectures.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260605121332.147397-1-mail@tk154.de?part=1

  reply	other threads:[~2026-06-06 12:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02 16:46 [PATCH net v2 0/4] net: mvpp2: fix XDP RX buffer handling Til Kaiser
2026-06-02 16:46 ` [PATCH net v2 1/4] net: mvpp2: sync RX data at the hardware packet offset Til Kaiser
2026-06-03 16:55   ` sashiko-bot
2026-06-02 16:46 ` [PATCH net v2 2/4] net: mvpp2: limit XDP frame size to the RX buffer Til Kaiser
2026-06-03 16:55   ` sashiko-bot
2026-06-02 16:46 ` [PATCH net v2 3/4] net: mvpp2: do not return retired RX buffers to BM Til Kaiser
2026-06-03 16:55   ` sashiko-bot
2026-06-04 15:45   ` Jakub Kicinski
2026-06-02 16:46 ` [PATCH net v2 4/4] net: mvpp2: build skb from XDP-adjusted data on XDP_PASS Til Kaiser
2026-06-03 16:55   ` sashiko-bot
2026-06-03 13:55 ` [PATCH net v2 0/4] net: mvpp2: fix XDP RX buffer handling Alexander Lobakin
2026-06-04 11:30   ` Marcin Wojtas
2026-06-05 12:13 ` [PATCH net v3 " Til Kaiser
2026-06-05 12:13   ` [PATCH net v3 1/4] net: mvpp2: sync RX data at the hardware packet offset Til Kaiser
2026-06-06 12:15     ` sashiko-bot [this message]
2026-06-05 12:13   ` [PATCH net v3 2/4] net: mvpp2: limit XDP frame size to the RX buffer Til Kaiser
2026-06-05 12:13   ` [PATCH net v3 3/4] net: mvpp2: refill RX buffers before XDP or skb use Til Kaiser
2026-06-06 12:15     ` sashiko-bot
2026-06-05 12:13   ` [PATCH net v3 4/4] net: mvpp2: build skb from XDP-adjusted data on XDP_PASS Til Kaiser
2026-06-06 12:15     ` sashiko-bot

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=20260606121505.6B4D71F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=mail@tk154.de \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.