All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Björn Töpel" <bjorn@kernel.org>, bpf@vger.kernel.org
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH net-next 12/15] eth: mlx5e: Receive into XDP-only memory providers
Date: Wed, 25 Nov 2026 13:00:14 +0000	[thread overview]
Message-ID: <sashiko-outbox-233422@kernel.org> (raw)
In-Reply-To: <20261124125654.183091-12-bjorn@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] net/mlx5e: NAPI busy loop and refill rollback in
  mlx5e_post_rx_wqes()
- [High] net/mlx5e: deferred close in mlx5e_switch_priv_channels()
  starves XDP-only MP
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Critical] net/mlx5e: missing bounds check in
  mlx5e_skb_from_cqe_linear() [1]
--

commit 6c6731701cc9a2c8380223f3b08de0cdf6d5c368
Author: Björn Töpel <bjorn@kernel.org>

eth: mlx5e: Receive into XDP-only memory providers

This commit enables mlx5e receive queues with an attached XDP program to
use XDP-only memory providers and allows queue restarts while an XDP
program is attached.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index 06a8a4be4be7c..a8d46508b6fc3 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -1012,6 +1012,9 @@ static int mlx5e_alloc_rq(struct mlx5e_params *params,
>  
>  		pp_params.order     = pool_order;
>  		pp_params.flags     = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV;
> +		/* Trap and PTP RQs use queue 0 too, without a program */
> +		if (params->xdp_prog)
> +			pp_params.flags |= PP_FLAG_ALLOW_XDP_ONLY_NETMEM;

[Severity: High]
Can a full channel switch via mlx5e_safe_switch_params() (such as on an
MTU or ring-size change) leave a queue backed by an XDP-only memory
provider with zero posted RX WQEs on devices with tis_tir_td_order?

When MLX5_CAP_GEN(priv->mdev, tis_tir_td_order) is set,
mlx5e_switch_priv_channels() only closes legacy XSK RQs before calling
mlx5e_activate_priv_channels(), deferring mlx5e_close_channels(old_chs)
until after the new channels have been activated:

drivers/net/ethernet/mellanox/mlx5/core/en_main.c:mlx5e_switch_priv_channels() {
    ...
	if (!MLX5_CAP_GEN(priv->mdev, tis_tir_td_order))
		mlx5e_close_channels(old_chs);
	else
		mlx5e_close_channels_xsk(old_chs);
	priv->profile->update_rx(priv);

	mlx5e_selq_apply(&priv->selq);
out:
	mlx5e_activate_priv_channels(priv);
    ...
}

Because an XDP-only memory provider backs c->rq.page_pool rather than
c->xskrq, old_chs->c[i]->rq and its page_pool are still open when
mlx5e_activate_priv_channels() schedules the initial NAPI poll on the new
channel.  During that poll, sink->released is still empty, and any chunks
in sink->fq that previously cycled through the old page_pool still have
netmem_get_pp(netmem) == old_pp, so xsk_sink_take_fill() returns them to
old_pp->ring instead of the new page_pool.  The new RQ fails to allocate
any buffers and NAPI completes with zero posted RX WQEs; when
mlx5e_close_channels(old_chs) finally destroys old_pp, nothing re-triggers
NAPI on the new channel, wedging RX on that queue.

> @@ -3050,6 +3053,14 @@ static int mlx5e_wait_channels_min_rx_wqes(struct mlx5e_channels *chs)
>  		if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state))
>  			continue;
>  
> +		/* An RQ that an XDP-only provider backs fills from the FILL
> +		 * ring of its socket, which stays empty until the socket
> +		 * gets its chunks back, so a queue that restarts under a
> +		 * slow reader would never meet the bound.
> +		 */
> +		if (netif_rxq_has_xdp_only_mp(c->netdev, c->ix))
> +			continue;

[Severity: High]
On a cyclic RQ (MLX5_WQ_TYPE_CYCLIC), what happens when the XDP-only
provider's FILL ring is empty or has fewer entries than wqe_bulk?

Unlike mlx5e_post_rx_mpwqes(), which posts partial batches and only
returns busy = true when rq->xsk_pool is set, mlx5e_post_rx_wqes() calls
mlx5e_refill_rx_wqes(rq, head, wqe_bulk) for the entire missing ring size.
If the FILL ring cannot satisfy the full wqe_bulk at once,
mlx5e_refill_rx_wqes() frees all descriptors it just allocated and returns
0, and mlx5e_post_rx_wqes() unconditionally sets busy = true:

drivers/net/ethernet/mellanox/mlx5/core/en_rx.c:mlx5e_post_rx_wqes() {
    ...
	count = mlx5e_refill_rx_wqes(rq, head, wqe_bulk);

	mlx5_wq_cyc_push_n(wq, count);
	if (unlikely(count != wqe_bulk)) {
		rq->stats->buff_alloc_err++;
		busy = true;
	}
    ...
}

When busy is true, mlx5e_napi_poll() returns full budget without calling
napi_complete_done(), spinning NAPI in softirq with zero posted RX WQEs
instead of posting available descriptors and waiting for wakeup.

[ ... ]

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> index 22fea4739a2c9..130e54f81293a 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c

[ ... ]

> @@ -1585,7 +1585,7 @@ mlx5e_skb_from_cqe_linear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wi,
>  	dma_addr_t addr;
>  	u32 frag_size;
>  
> -	va             = netmem_address(frag_page->netmem) + wi->offset;
> +	va             = xdp_netmem_address(frag_page->netmem) + wi->offset;
>  	data           = va + rx_headroom;
>  	frag_size      = MLX5_SKB_FRAG_SZ(rx_headroom + cqe_bcnt);

[Severity: Critical]
This problem wasn't introduced by this patch, but can an oversized
cqe_bcnt from a malfunctioning or compromised device [1] cause
mlx5e_skb_from_cqe_linear() to write skb_shared_info out of bounds?

Unlike mlx5e_skb_from_cqe_mpwrq_linear(), mlx5e_skb_from_cqe_linear() does
not check cqe_bcnt against rq->hw_mtu or the fragment stride before
computing frag_size = MLX5_SKB_FRAG_SZ(rx_headroom + cqe_bcnt) and passing
it to mlx5e_build_linear_skb() -> napi_build_skb(), which places
skb_shinfo() at the end of frag_size past the allocated buffer.

[1] https://sashiko.dev/#/bug/linux-f8009756-e155-49d4-89b6-f278e7d2f08e

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124112707.118678-1-bjorn@kernel.org?part=12

  reply	other threads:[~2026-11-25 13:00 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 11:26 [PATCH net-next 00/15] xsk: Receive in the device's buffer layout Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 01/15] xdp: Let memory providers offer XDP a view of their net_iovs Björn Töpel
2026-11-25 13:00   ` sashiko-bot
2026-11-25 14:07   ` netdev-bot+sashiko
2026-11-25 19:34     ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 02/15] xdp: Keep the shared info of a buffer in kernel memory Björn Töpel
2026-11-25 14:07   ` netdev-bot+sashiko
2026-11-25 19:39     ` Björn Töpel
2026-11-25 15:17   ` Maciej Fijalkowski
2026-11-25 19:36     ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 03/15] net: Add memory providers that only feed XDP Björn Töpel
2026-11-25 14:08   ` netdev-bot+sashiko
2026-11-25 19:43     ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 04/15] page_pool: Let memory providers take back net_iovs Björn Töpel
2026-11-25 14:08   ` netdev-bot+sashiko
2026-11-25 19:45     ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 05/15] xdp: Run programs on buffers that must not hold kernel structures Björn Töpel
2026-11-25 13:00   ` sashiko-bot
2026-11-25 14:08   ` netdev-bot+sashiko
2026-11-25 19:55     ` Björn Töpel
2026-11-25 15:22   ` Maciej Fijalkowski
2026-11-25 15:28     ` Maciej Fijalkowski
2026-11-25 19:50     ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 06/15] xsk: Lend UMEM chunks to the page pools of a queue Björn Töpel
2026-11-24 14:34   ` Magnus Karlsson
2026-11-24 15:12     ` Björn Töpel
2026-11-25 13:00   ` sashiko-bot
2026-11-25 14:08   ` netdev-bot+sashiko
2026-11-25 20:02     ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 07/15] xsk: Deliver to the socket in the device's buffer layout Björn Töpel
2026-11-25 13:00   ` sashiko-bot
2026-11-25 14:08   ` netdev-bot+sashiko
2026-11-25 20:11     ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 08/15] xsk: Receive " Björn Töpel
2026-11-25 13:00   ` sashiko-bot
2026-11-25 14:08   ` netdev-bot+sashiko
2026-11-25 20:16     ` Björn Töpel
2026-11-30 14:47   ` Maciej Fijalkowski
2026-11-24 12:56 ` [PATCH net-next 09/15] eth: fbnic: Support XDP redirect Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 10/15] eth: fbnic: Receive into XDP-only memory providers Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 11/15] net: Add netif_rxq_has_xdp_only_mp() Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 12/15] eth: mlx5e: Receive into XDP-only memory providers Björn Töpel
2026-11-25 13:00   ` sashiko-bot [this message]
2026-11-25 14:08   ` netdev-bot+sashiko
2026-11-25 20:26     ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 13/15] eth: bnxt: " Björn Töpel
2026-11-25 13:00   ` sashiko-bot
2026-11-25 14:08   ` netdev-bot+sashiko
2026-11-25 20:33     ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 14/15] selftests: net: xsk: Test the device's RX buffer layout Björn Töpel
2026-11-25 13:00   ` sashiko-bot
2026-11-25 14:08   ` netdev-bot+sashiko
2026-11-24 12:56 ` [PATCH net-next 15/15] Documentation: networking: Describe AF_XDP RX in the device's layout Björn Töpel
2026-11-25 14:08   ` netdev-bot+sashiko
2026-11-25 13:00 ` [PATCH net-next 00/15] xsk: Receive in the device's buffer layout 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=sashiko-outbox-233422@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --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.