public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Larysa Zaremba <larysa.zaremba@intel.com>
Cc: "Claudiu Manoil" <claudiu.manoil@nxp.com>,
	"Vladimir Oltean" <vladimir.oltean@nxp.com>,
	"Wei Fang" <wei.fang@nxp.com>,
	"Clark Wang" <xiaoning.wang@nxp.com>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Tony Nguyen" <anthony.l.nguyen@intel.com>,
	"Przemek Kitszel" <przemyslaw.kitszel@intel.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Jesper Dangaard Brouer" <hawk@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Stanislav Fomichev" <sdf@fomichev.me>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"KP Singh" <kpsingh@kernel.org>, "Hao Luo" <haoluo@google.com>,
	"Jiri Olsa" <jolsa@kernel.org>, "Simon Horman" <horms@kernel.org>,
	"Shuah Khan" <shuah@kernel.org>,
	"Alexander Lobakin" <aleksander.lobakin@intel.com>,
	"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
	"Bastien Curutchet (eBPF Foundation)"
	<bastien.curutchet@bootlin.com>,
	"Tushar Vyavahare" <tushar.vyavahare@intel.com>,
	"Jason Xing" <kernelxing@tencent.com>,
	"Ricardo B. Marlière" <rbm@suse.com>,
	"Eelco Chaudron" <echaudro@redhat.com>,
	"Lorenzo Bianconi" <lorenzo@kernel.org>,
	"Toke Hoiland-Jorgensen" <toke@redhat.com>,
	imx@lists.linux.dev, bpf@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
	linux-kselftest@vger.kernel.org,
	"Aleksandr Loktionov" <aleksandr.loktionov@intel.com>
Subject: Re: [PATCH bpf 1/6] xdp: produce a warning when calculated tailroom is negative
Date: Wed, 4 Feb 2026 14:52:19 -0800	[thread overview]
Message-ID: <3df436d9-5671-410c-ad0d-67d9fa540330@linux.dev> (raw)
In-Reply-To: <20260203105417.2302672-2-larysa.zaremba@intel.com>


On 2/3/26 2:53 AM, Larysa Zaremba wrote:
> The issue can be fixed in all in-tree drivers, but we cannot just trust OOT
> drivers to not do this. Therefore, make tailroom a signed int and produce a
> warning when it is negative to prevent such mistakes in the future.
> 
> Fixes: bf25146a5595 ("bpf: add frags support to the bpf_xdp_adjust_tail() API")
> Reviewed-by: Aleksandr Loktionov<aleksandr.loktionov@intel.com>
> Signed-off-by: Larysa Zaremba<larysa.zaremba@intel.com>
> ---
>   net/core/filter.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 616e0520a0bb..9715d957e3c5 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -4149,12 +4149,13 @@ static int bpf_xdp_frags_increase_tail(struct xdp_buff *xdp, int offset)
>   	struct skb_shared_info *sinfo = xdp_get_shared_info_from_buff(xdp);
>   	skb_frag_t *frag = &sinfo->frags[sinfo->nr_frags - 1];
>   	struct xdp_rxq_info *rxq = xdp->rxq;
> -	unsigned int tailroom;
> +	int tailroom;
>   
>   	if (!rxq->frag_size || rxq->frag_size > xdp->frame_sz)
>   		return -EOPNOTSUPP;
>   
>   	tailroom = rxq->frag_size - skb_frag_size(frag) - skb_frag_off(frag);
> +	WARN_ON_ONCE(tailroom < 0);
>   	if (unlikely(offset > tailroom))
>   		return -EINVAL;

Acked-by: Martin KaFai Lau <martin.lau@kernel.org>

  parent reply	other threads:[~2026-02-04 22:52 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-03 10:53 [PATCH bpf 0/6] Address XDP frags having negative tailroom Larysa Zaremba
2026-02-03 10:53 ` [PATCH bpf 1/6] xdp: produce a warning when calculated tailroom is negative Larysa Zaremba
2026-02-03 12:26   ` Toke Høiland-Jørgensen
2026-02-03 12:31     ` Larysa Zaremba
2026-02-03 12:38       ` Toke Høiland-Jørgensen
2026-02-03 12:54         ` Larysa Zaremba
2026-02-03 13:37           ` Toke Høiland-Jørgensen
2026-02-04 22:52   ` Martin KaFai Lau [this message]
2026-02-03 10:53 ` [PATCH bpf 2/6] ice: fix rxq info registering in mbuf packets Larysa Zaremba
2026-02-03 10:53 ` [PATCH bpf 3/6] ice: change XDP RxQ frag_size from DMA write length to truesize Larysa Zaremba
2026-02-03 10:53 ` [PATCH bpf 4/6] i40e: use truesize as XDP RxQ info frag_size Larysa Zaremba
2026-02-03 10:53 ` [PATCH bpf 5/6] idpf: " Larysa Zaremba
2026-02-03 10:53 ` [PATCH bpf 6/6] net: enetc: " Larysa Zaremba
2026-02-05  0:59   ` Vladimir Oltean
2026-02-05  1:34     ` Jakub Kicinski
2026-02-05 12:29       ` Vladimir Oltean
2026-02-05 12:41         ` Larysa Zaremba
2026-02-05 12:46           ` Vladimir Oltean
2026-02-05 13:23             ` Larysa Zaremba
2026-02-05 13:40               ` Vladimir Oltean
2026-02-06  1:54                 ` Jakub Kicinski
2026-02-06  8:36                   ` Larysa Zaremba
2026-02-07  2:57                     ` Jakub Kicinski
2026-02-09  9:46                       ` Larysa Zaremba
2026-02-08 12:59                   ` Vladimir Oltean
2026-02-10 17:27                     ` Dragos Tatulea
2026-02-04 22:57 ` [PATCH bpf 0/6] Address XDP frags having negative tailroom Martin KaFai Lau
2026-02-05  1:23   ` Jakub Kicinski
2026-02-05  1:26 ` Jakub Kicinski

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=3df436d9-5671-410c-ad0d-67d9fa540330@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=aleksander.lobakin@intel.com \
    --cc=aleksandr.loktionov@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrii@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=ast@kernel.org \
    --cc=bastien.curutchet@bootlin.com \
    --cc=bpf@vger.kernel.org \
    --cc=claudiu.manoil@nxp.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=echaudro@redhat.com \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@google.com \
    --cc=haoluo@google.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernelxing@tencent.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=larysa.zaremba@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=rbm@suse.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=toke@redhat.com \
    --cc=tushar.vyavahare@intel.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=wei.fang@nxp.com \
    --cc=xiaoning.wang@nxp.com \
    --cc=yonghong.song@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