BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Björn Töpel" <bjorn@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [RFC net-next 03/15] net: Add memory provider capabilities
Date: Sat, 03 Oct 2026 19:02:36 +0000	[thread overview]
Message-ID: <20261003190237.E1B451F0089B@smtp.kernel.org> (raw)
In-Reply-To: <20261002190018.696925-4-bjorn@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: Use-After-Free in NAPI poll due to erroneous kick after failed queue rollback
--

commit 6916b55bc2fd7fcbee42e2cf1fc4f277ee96ed12
Author: Björn Töpel <bjorn@kernel.org>

    net: Add memory provider capabilities
    
    The current memory providers, devmem and io_uring zero-copy RX, give
    memory that the CPU cannot read. The core allows them only on queues
    with header-data split on, a zero header-split threshold, and no XDP
    program. AF_XDP needs a provider that the CPU can read and that
    works with XDP.

> diff --git a/net/core/netdev_rx_queue.c b/net/core/netdev_rx_queue.c
> index 00a7011eb4d57..610e31d1a7173 100644
> --- a/net/core/netdev_rx_queue.c
> +++ b/net/core/netdev_rx_queue.c
[ ... ]
> @@ -165,6 +197,11 @@ static int netdev_rx_queue_reconfig(struct net_device *dev,
>  
>  err_free_new_queue_mem:
>  	qops->ndo_queue_mem_free(dev, new_mem);
> +	/* Freeing the replacement can hand provider memory back to the old
> +	 * queue, which still runs unless the rollback failed.
> +	 */
> +	if (err != -ENETDOWN && netif_running(dev))
> +		netdev_rx_queue_kick(rxq);
>  
>  err_free_old_mem:
>  	kvfree(old_mem);

[Severity: High]
Does this code risk a use-after-free if the queue rollback fails?

If ndo_queue_start() fails during the rollback, the old memory is freed, but
err is not updated to reflect the failure:

net/core/netdev_rx_queue.c:netdev_rx_queue_reconfig() {
err_start_queue:
	if (qops->ndo_queue_start(dev, qcfg_old, old_mem, rxq_idx)) {
		WARN(1, ...);
		qops->ndo_queue_mem_free(dev, old_mem);
	}

err_free_new_queue_mem:
	qops->ndo_queue_mem_free(dev, new_mem);
	/* err still holds its previous value (e.g., -ENOMEM) */
	if (err != -ENETDOWN && netif_running(dev))
		netdev_rx_queue_kick(rxq);

Because err isn't updated to -ENETDOWN when the rollback fails, the kick will
proceed and schedule a NAPI poll on a stopped queue whose memory was just
freed.

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

  parent reply	other threads:[~2026-10-03 19:02 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 19:00 [RFC net-next 00/15] xsk: Zero copy through page-pool memory providers Björn Töpel
2026-10-02 19:00 ` [RFC net-next 01/15] xdp: Size zero-copy skb heads by their contents Björn Töpel
2026-10-02 19:00 ` [RFC net-next 02/15] eth: fbnic: Report the logical XDP RX queue Björn Töpel
2026-10-02 19:00 ` [RFC net-next 03/15] net: Add memory provider capabilities Björn Töpel
2026-10-03  4:13   ` Mina Almasry
2026-10-03 19:02   ` sashiko-bot [this message]
2026-10-05 16:26   ` Stanislav Fomichev
2026-10-02 19:00 ` [RFC net-next 04/15] net: Let memory providers set RX buffer headroom Björn Töpel
2026-10-05 16:52   ` Stanislav Fomichev
2026-10-02 19:00 ` [RFC net-next 05/15] page_pool: Extend memory provider operations Björn Töpel
2026-10-05 16:51   ` Stanislav Fomichev
2026-10-02 19:00 ` [RFC net-next 06/15] xdp: Track non-page netmem in receive buffers Björn Töpel
2026-10-05 17:01   ` Stanislav Fomichev
2026-10-02 19:00 ` [RFC net-next 07/15] xsk: Keep the DMA mapping in the buffer pool Björn Töpel
2026-10-02 19:00 ` [RFC net-next 08/15] xsk: Handle a detached FILL ring in RX wakeup Björn Töpel
2026-10-02 19:00 ` [RFC net-next 09/15] xsk: Add a page-pool memory provider for UMEM Björn Töpel
2026-10-05 17:38   ` Stanislav Fomichev
2026-10-02 19:00 ` [RFC net-next 10/15] xsk: Add RX helpers for page-pool drivers Björn Töpel
2026-10-02 19:00 ` [RFC net-next 11/15] xdp: Copy provider buffers on pass and redirect Björn Töpel
2026-10-03 19:02   ` sashiko-bot
2026-10-02 19:00 ` [RFC net-next 12/15] xsk: Receive provider UMEM without copying Björn Töpel
2026-10-02 19:00 ` [RFC net-next 13/15] eth: fbnic: Support AF_XDP zero-copy receive Björn Töpel
2026-10-03 19:02   ` sashiko-bot
2026-10-05 17:51   ` Stanislav Fomichev
2026-10-02 19:00 ` [RFC net-next 14/15] eth: fbnic: Support AF_XDP zero-copy transmit Björn Töpel
2026-10-02 19:00 ` [RFC net-next 15/15] Documentation: xsk: Document page-pool zero copy Björn Töpel

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=20261003190237.E1B451F0089B@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox