From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02FD232E72C; Wed, 4 Feb 2026 22:52:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770245554; cv=none; b=GZVZyMT4WpQvt0lOo0scnXwpZdrm7fUwuihr5GtFo3JlrN1ENR/ibMuoHxP+gjCcb01fGDfEVdGzFXlTbkGC1PpSemq9V+dehcXVSMVzkRpcIPo08whtfXidp1DrpvtJIaIB9E9m5pe/WknE6LkuUy78hd1s07mK9MQbgDG0Ex4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770245554; c=relaxed/simple; bh=HE8DiP1b+MmSQURxZZ2M7HpPAYG2a/CLXNu90nk5iN4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bDuGJikT91qMQlCuijODRyn/hYgd6R4Ub2Rgb3PDFaJfDflshyuzQy5ZwBpGM3SwgVeCE/YLYLRQkxdFF8MddSMO/XFnWnytgD16UPoD3DLh76+c0I2le/++NW/IK+Z8NOuJZJr1ERkpSdC44MH7yt4tVoboFuT634yMIEQ0cFk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=HtDRI+Qz; arc=none smtp.client-ip=95.215.58.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="HtDRI+Qz" Message-ID: <3df436d9-5671-410c-ad0d-67d9fa540330@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1770245551; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EJoZknlyXtAyOLBNPLzRyCmW6dHCkdD5Zvl96QPeKQE=; b=HtDRI+Qz+/WPhHk0OHCPF1aB7QuWSOfsCq2Bf7mxIuipnkr7S2QqYvlCBTNUb0iu+hoHUt /rat+5i/6Wcn6GPCTJXfdG4OWi8GiroFMZUBIyqZVEzvhDncDL+YFzwW54xpdXPJ7W6loT VyERfVRddW5EmiuIN3/tBwu/wn6JOGk= Date: Wed, 4 Feb 2026 14:52:19 -0800 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf 1/6] xdp: produce a warning when calculated tailroom is negative To: Larysa Zaremba Cc: Claudiu Manoil , Vladimir Oltean , Wei Fang , Clark Wang , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Tony Nguyen , Przemek Kitszel , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Hao Luo , Jiri Olsa , Simon Horman , Shuah Khan , Alexander Lobakin , Maciej Fijalkowski , "Bastien Curutchet (eBPF Foundation)" , Tushar Vyavahare , Jason Xing , =?UTF-8?Q?Ricardo_B=2E_Marli=C3=A8re?= , Eelco Chaudron , Lorenzo Bianconi , Toke Hoiland-Jorgensen , 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 References: <20260203105417.2302672-1-larysa.zaremba@intel.com> <20260203105417.2302672-2-larysa.zaremba@intel.com> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: <20260203105417.2302672-2-larysa.zaremba@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT 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 > Signed-off-by: Larysa Zaremba > --- > 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