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 4/4] net: mvpp2: build skb from XDP-adjusted data on XDP_PASS
Date: Sat, 06 Jun 2026 12:15:06 +0000	[thread overview]
Message-ID: <20260606121506.ABDE31F00899@smtp.kernel.org> (raw)
In-Reply-To: <20260605121332.147397-5-mail@tk154.de>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Overwriting `rx_bytes` with the XDP-modified packet length causes a partial DMA sync on the SKB allocation error path, potentially corrupting subsequent packets.

Pre-existing issues:
- [High] Hardware checksum offload is unconditionally applied even after XDP program modifications, potentially bypassing network stack checksum validation for corrupted packets.
--

commit 92e9744c23c0c27c625a826b0e44e159927ea85a
Author: Til Kaiser <mail@tk154.de>

net: mvpp2: build skb from XDP-adjusted data on XDP_PASS

When an XDP program modifies packet geometry and returns XDP_PASS, mvpp2
currently discards these adjustments and builds the skb using fixed
offsets. This commit updates the offset and length variables to reflect
the XDP-adjusted data, ensuring the skb correctly represents the modified
packet.

> diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> index 481daafdc1cbc..dd30674148aa4 100644
> --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

[ ... ]

> @@ -3999,6 +4000,10 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
>  				continue;
>  			}
>  
> +			/* Update offset and length to reflect any XDP adjustments. */
> +			rx_offset = xdp.data     - data;
> +			rx_bytes  = xdp.data_end - xdp.data;
> +

[Severity: High]
If rx_bytes is updated to reflect the XDP-modified packet length here, what
happens if skb allocation fails later in mvpp2_rx()?

Looking at the error path:

mvpp2_rx() {
    ...
    if (!skb) {
        if (pp) {
            page_pool_put_page(pp, virt_to_head_page(data),
                               rx_bytes + MVPP2_MH_SIZE,
                               true);
    ...
}

If the XDP program truncated the packet, rx_bytes is smaller than the
original size synced to the CPU. Does this cause an incomplete DMA sync
back to the device, leaving dirty CPU cache lines in the remainder of the
buffer? Could this corrupt subsequent packets when the hardware reuses the
buffer?

>  			metasize = xdp.data - xdp.data_meta;
>  		}
>  
> @@ -4041,7 +4046,7 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
>  		ps.rx_packets++;
>  		ps.rx_bytes += rx_bytes;
>  
> -		skb_reserve(skb, MVPP2_MH_SIZE + MVPP2_SKB_HEADROOM);
> +		skb_reserve(skb, rx_offset);
>  		skb_put(skb, rx_bytes);
>  		if (metasize)
>  			skb_metadata_set(skb, metasize);

[Severity: High]
This isn't a bug introduced by this patch, but does unconditionally
applying the hardware checksum status to the skb here bypass software
validation for packets modified by XDP?

Looking at the code immediately following this block in mvpp2_rx():

    skb->ip_summed = mvpp2_rx_csum(port, rx_status);
    
Since XDP programs can modify packet headers or payloads, the
hardware-validated checksum might no longer be correct. If the hardware
reports CHECKSUM_UNNECESSARY, could this allow corrupted or improperly
modified packets to be incorrectly accepted by the network stack? Should
the hardware checksum be invalidated (e.g., set to CHECKSUM_NONE) if an
XDP program has been executed?

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

      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
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 [this message]

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=20260606121506.ABDE31F00899@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.