BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Björn Töpel" <bjorn@kernel.org>, bpf@vger.kernel.org
Subject: Re: [PATCH net-next 3/7] net: Admit native XDP on provider queues
Date: Wed, 18 Nov 2026 16:48:27 +0000	[thread overview]
Message-ID: <sashiko-outbox-221553@kernel.org> (raw)
In-Reply-To: <20261117164700.2157816-4-bjorn@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net: missing propagated XDP check in netif_xdp_mp_ok()
--

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

net: Admit native XDP on provider queues

This commit allows native XDP programs to run alongside unreadable memory
providers on drivers that set netdev_queue_mgmt_ops.xdp_unreadable.

> diff --git a/net/core/dev.c b/net/core/dev.c
> index a230ecce9327d..f0c3d56d5b832 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -10575,6 +10575,27 @@ u8 dev_xdp_sb_prog_count(struct net_device *dev)
>  	return count;
>  }
>  
> +/* Only native programs run next to unreadable memory providers. Drivers must
> + * mark unreadable fragments and reject XDP_TX while they remain attached.
> + * Tcp-data-split, which these providers need, also needs frags support.
> + */
> +static bool netif_xdp_mp_mode_ok(const struct net_device *dev,
> +				 enum bpf_xdp_mode mode)
> +{
> +	return mode == XDP_MODE_DRV && dev->queue_mgmt_ops->xdp_unreadable;
> +}
> +
> +/* Can the XDP programs of @dev run next to a new memory provider? */
> +bool netif_xdp_mp_ok(struct net_device *dev)
> +{
> +	int i;
> +
> +	for (i = 0; i < __MAX_XDP_MODE; i++)
> +		if (dev_xdp_prog(dev, i) && !netif_xdp_mp_mode_ok(dev, i))
> +			return false;
> +	return true;
> +}
> +
>  int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
>  {
>  	if (!dev->netdev_ops->ndo_bpf)
> @@ -10588,7 +10609,9 @@ int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
>  		return -EBUSY;
>  	}
>  
> -	if (dev_get_min_mp_channel_count(dev)) {
> +	if (dev_get_min_mp_channel_count(dev) &&
> +	    (bpf->command != XDP_SETUP_PROG ||
> +	     !netif_xdp_mp_mode_ok(dev, XDP_MODE_DRV))) {
>  		NL_SET_ERR_MSG(bpf->extack, "unable to propagate XDP to device using memory provider");
>  		return -EBUSY;
>  	}

[Severity: Medium]
Does netif_xdp_mp_ok() miss native XDP programs propagated from an upper
device such as bonding or hv_netvsc?

When an upper device propagates XDP via netif_xdp_propagate(), the
program is stored in the upper device's xdp_state[] while the lower
device's dev->xdp_state[] remains empty.  If native XDP is attached to
the upper device first and a memory provider is then opened on the lower
device via __netif_mp_open_rxq(), netif_xdp_mp_ok() sees no program on
the lower device and returns true without checking
dev->queue_mgmt_ops->xdp_unreadable.

On a lower driver with xdp_unreadable set to false, this lets native XDP
run on queues with unreadable net_iov fragments (which can cause a NULL
pointer dereference when XDP_TX or XDP_DROP paths call skb_frag_page()).
In addition, while the memory provider remains bound,
netif_xdp_propagate() rejects even bpf->prog == NULL with -EBUSY,
preventing the upper device from detaching the propagated XDP program and
leaking the bpf_prog reference.

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

  reply	other threads:[~2026-11-18 16:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 16:46 [PATCH net-next 0/7] XDP with io_uring zero-copy RX and devmem Björn Töpel
2026-11-17 16:46 ` [PATCH net-next 1/7] bpf: Keep XDP helpers within readable data Björn Töpel
2026-11-17 16:46 ` [PATCH net-next 2/7] xdp: Reject frames with unreadable fragments Björn Töpel
2026-11-17 16:46 ` [PATCH net-next 3/7] net: Admit native XDP on provider queues Björn Töpel
2026-11-18 16:48   ` sashiko-bot [this message]
2026-11-17 16:46 ` [PATCH net-next 4/7] eth: fbnic: Run " Björn Töpel
2026-11-17 16:46 ` [PATCH net-next 5/7] netdevsim: Run native XDP next to devmem Björn Töpel
2026-11-17 16:46 ` [PATCH net-next 6/7] selftests: net: Test XDP with devmem bindings Björn Töpel
2026-11-18 16:48   ` sashiko-bot
2026-11-17 16:46 ` [PATCH net-next 7/7] selftests: net: Test XDP on io_uring RX Björn Töpel
2026-11-18 16:48   ` 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-221553@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