Article View: linux.kernel.netdev
Article #4800Re: [PATCH net-next 09/15] netfilter: nft_exthdr: avoid 60 bytes stack buffer in TCP option mangling
From: Pablo Neira Ayuso
Date: Mon, 19 Oct 2026 09:11
Date: Mon, 19 Oct 2026 09:11
93 lines
9322 bytes
9322 bytes
On Mon, Oct 19, 2026 at 01:21:26AM +0000, netdev-bot+sashiko@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential > issue(s) to consider. > > Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0 > > If you believe none of the issues are legitimate, please reply to each > issue of Medium severity or higher and explain why the AI is wrong. > If any of them are legitimate and you plan to respin, please let patchwork > know by including "pw-bot: cr" as a separate line at the end of your reply > (one such reply per series is enough). > > - [Medium] The commit message says "This patch also updates the logic to > drop malformed packets, before this patch NFT_BREAK was used as aโฆ > > -- > > netfilter: nft_exthdr: avoid 60 bytes stack buffer in TCP option mangling > > This commit changes nft_exthdr_tcp_set_eval() and > nft_exthdr_tcp_strip_eval() so they no longer call > nft_tcp_header_pointer(). Each function now reads only the 20 byte fixed > TCP header with skb_header_pointer(), validates doff, and leaves it to > skb_ensure_writable() to pull the options. This removes a 60 byte stack > buffer and a redundant second header copy from both functions. > > > diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c > > index 3492426dccf7f..861bab93f4352 100644 > > --- a/net/netfilter/nft_exthdr.c > > +++ b/net/netfilter/nft_exthdr.c > > @@ -233,16 +233,23 @@ static void nft_exthdr_tcp_set_eval(const struct nft_expr *expr, > > [ ... ] > > > - tcph = nft_tcp_header_pointer(pkt, sizeof(buff), buff, &tcphdr_len); > > + if (pkt->tprot != IPPROTO_TCP || pkt->fragoff) > > + goto err; > > + > > + tcph = skb_header_pointer(pkt->skb, nft_thoff(pkt), sizeof(_tcph), &_tcph); > > if (!tcph) > > goto err; > > > > + tcphdr_len = __tcp_hdrlen(tcph); > > + if (tcphdr_len < sizeof(*tcph) || > > + tcphdr_len > sizeof(*tcph) + MAX_TCP_OPTION_SPACE) > > + goto err; > > + > > if (skb_ensure_writable(pkt->skb, nft_thoff(pkt) + tcphdr_len)) > > goto err; > > > > @@ -313,16 +320,23 @@ static void nft_exthdr_tcp_strip_eval(const struct nft_expr *expr, > > [ ... ] > > > - tcph = nft_tcp_header_pointer(pkt, sizeof(buff), buff, &tcphdr_len); > > + if (pkt->tprot != IPPROTO_TCP || pkt->fragoff) > > + goto err; > > + > > + tcph = skb_header_pointer(pkt->skb, nft_thoff(pkt), sizeof(_tcph), &_tcph); > > if (!tcph) > > goto err; > > > > + tcphdr_len = __tcp_hdrlen(tcph); > > + if (tcphdr_len < sizeof(*tcph) || > > + tcphdr_len > sizeof(*tcph) + MAX_TCP_OPTION_SPACE) > > + goto err; > > + > > if (skb_ensure_writable(pkt->skb, nft_thoff(pkt) + tcphdr_len)) > > goto drop; > > [Severity: Medium] Nothing wrong in this patch. > The commit message says: > > This patch also updates the logic to drop malformed packets, before this > patch NFT_BREAK was used as a verdict instead. I added this comment to make this AI robot and it keeps complaining... > Does that match what the diff does? The diff does not touch any verdict > code. The change in behaviour only comes from removing the second, > full-length skb_header_pointer() call that nft_tcp_header_pointer() made: > > return skb_header_pointer(pkt->skb, nft_thoff(pkt), *tcphdr_len, buffer); > > Before this patch, a truncated TCP packet (thoff + doff * 4 > skb->len) > made that call return NULL. Both functions then took goto err and > returned NFT_BREAK. Yes, this is what the comment aims to say.
Technical Details
Message-ID:
<atXepTQ9VUufeOAu@chamomile>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348364-linux-kernel-netdev=dewy.ruReferences:
<20261018005638.1776148-10-pablo@netfilter.org> <179237288600.3135.15119152740392179853@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348364-linux-kernel-netdev=dewy.ru From: pablo@netfilter.org (Pablo Neira Ayuso) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 09/15] netfilter: nft_exthdr: avoid 60 bytes stack buffer in TCP option mangling Date: Mon, 19 Oct 2026 11:11:01 +0200 Organization: Usenet Network Message-ID: <atXepTQ9VUufeOAu@chamomile> References: <20261018005638.1776148-10-pablo@netfilter.org> <179237288600.3135.15119152740392179853@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3555288"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:YYJvWHOnZ2jlOKE8ZDwpoy+H5uw= sha256:ac3V2B34wnv8/uTb6ijYNtTDujaIXl1FTs2fjWRPMnA= sha1:5+zegZySeWXGcHJc3Qm8BcFu+wA= sha256:czFvmjOz9GAxcv0q6Tio97m0paJj3EMXdIc+h3MGqF0= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 02BE7110962; Mon, 19 Oct 2026 12:17:54 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=netfilter.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2QwDEGhFpX83; Mon, 19 Oct 2026 12:17:50 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-348364-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=netfilter.org X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 93A5D110937; Mon, 19 Oct 2026 12:17:38 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id DF57D240C5; Mon, 19 Oct 2026 09:11:09 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88780498E2E; Mon, 19 Oct 2026 09:11:08 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b="OdkLtUQF" X-Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124]) (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 AFF26496D40; Mon, 19 Oct 2026 09:11:06 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.190.124 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792401068; cv=none; b=e0HMf982ie0bAVHxu93KnIzorh4F7+xoWbugY9hk97umSasE/SrBnVwF3+6JjQWKx61S248U294w7YrhLIdicudPpCcTisz7DSFt/bkfW5IcB35G9siao1DXaY9IwperUET4/JHHF+gMmArIq9kEw6L1OnJnWp/Kue4BjR8x1wQ= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792401068; c=relaxed/simple; bh=p+jY3tmxwUt019LxwgmVwWOXI6oEZqEVc9D9I+PEr1M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=E3yH9fhoKbPSWejzGx3PK7UZYBBuk5N2aiWVvWUE2rcfDMR3h3+Pytvb99V8IIYvNi6o73bsdKXkHOttJ70mvUOL5uoLDiAXknfGHeLbfB84ENE0cpmOkgPIswJwtP1L6xQUo5KOGA250xIX5uq/1ftpYAbhy6G1Zvd2MlaSIhk= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b=OdkLtUQF; arc=none smtp.client-ip=217.70.190.124 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1792401064; bh=cooeJdd3ZOoKuDT3EFTXdUcEgO8JUE4TEpeg7owRSCU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OdkLtUQFuykNOsUNna630292JZB/GlsKYOHeaRxonMelcM4avycN8CGhYuazZDZQE 68grN8FMDEQbZ865DblqvaiQjJ7oIUr6Bef5xLRidnP+AjNUtsZzvfzzq7tFrLStVp 0nLcjDxDmHSvQc3rsAtGHkVokJP5EGJ2OEdXs4Lz8IRXJI4X8qs4gb/xfVoI7DP90y 4ae5UOBmZpovfF3OH6XMuLnq1UFcmw2z+f7g7hfhumLvgJetfvy1HBFr+lmiqk1sg8 XSjPjTMWKvAB+bC5SGGy47pNcLx/+7xm/wqEPwEZxxpX1C1KwRXfoOtOhqSpwOYIe7 QZLIjsiTq1gvw== X-Received: from netfilter.org (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with UTF8SMTPSA id 322D060058; Mon, 19 Oct 2026 11:11:04 +0200 (CEST) X-Cc: netfilter-devel@vger.kernel.org, davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, horms@kernel.org, fw@strlen.de, ja@ssi.bg X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-In-Reply-To: <179237288600.3135.15119152740392179853@kernel.org>