BPF List
 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 v2 2/4] net: mvpp2: limit XDP frame size to the RX buffer
Date: Wed, 03 Jun 2026 16:55:18 +0000	[thread overview]
Message-ID: <20260603165519.3BAEB1F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260602164635.62517-3-mail@tk154.de>

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

Pre-existing issues:
- [High] Changing MTU to jumbo frames switches to shared buffers without detaching XDP, leading to NULL pointer dereference.
--

commit 6697a25a0b55fb9d610bfbe672d3935e951e1d53
Author: Til Kaiser <mail@tk154.de>

net: mvpp2: limit XDP frame size to the RX buffer

mvpp2 has short and long BM pools, and short pool buffers can be smaller
than PAGE_SIZE. The XDP path nevertheless initializes every xdp_buff with
PAGE_SIZE as frame size. This initializes the XDP buffer with
bm_pool->frag_size so XDP tailroom matches the actual buffer backing the
packet.

> diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> index 92a701f4fe3f5..3372ed27cc8d6 100644
> --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
[ ... ]
> @@ -3979,7 +3979,7 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
>  			else
>  				xdp_rxq = &rxq->xdp_rxq_long;
>  
> -			xdp_init_buff(&xdp, PAGE_SIZE, xdp_rxq);
> +			xdp_init_buff(&xdp, bm_pool->frag_size, xdp_rxq);
>  			xdp_prepare_buff(&xdp, data,
>  					 MVPP2_MH_SIZE + MVPP2_SKB_HEADROOM,
>  					 rx_bytes, true);

[Severity: High]
This is a pre-existing issue, but is there a problem with XDP and jumbo
frames here?

If mvpp2_change_mtu() is called with an MTU that requires jumbo frames but is
smaller than MVPP2_MAX_RX_BUF_SIZE, it allows the MTU change and switches to
shared pools by calling mvpp2_bm_switch_buffers().

This destroys the page_pool structures and sets priv->percpu_pools to false,
but the XDP program remains attached.

Later, when packets arrive in mvpp2_rx():

	if (port->priv->percpu_pools) {
		pp = port->priv->page_pool[pool];
		dma_dir = page_pool_get_dma_dir(pp);
	} else {
		dma_dir = DMA_FROM_DEVICE;
	}

Because priv->percpu_pools is now false, pp remains NULL.

When mvpp2_run_xdp() is called with this NULL pp, and the XDP program returns
XDP_DROP, it unconditionally calls page_pool_put_page() with the NULL pp and
a non-page-pool page:

	case XDP_DROP:
		page = virt_to_head_page(xdp->data);
		page_pool_put_page(pp, page, sync, true);

Could this cause a kernel panic when XDP drops or redirects a packet after
an MTU change?

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

  reply	other threads:[~2026-06-03 16:55 UTC|newest]

Thread overview: 17+ 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 [this message]
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-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-05 12:13   ` [PATCH net v3 4/4] net: mvpp2: build skb from XDP-adjusted data on XDP_PASS Til Kaiser

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=20260603165519.3BAEB1F00898@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox