Article View: linux.kernel.netdev
Article #22812Re: [PATCH nf] netfilter: nft_exthdr: pull the IPv6 header before ipv6_find_hdr()
From: Pablo Neira Ayuso
Date: Thu, 26 Nov 2026 00:29
Date: Thu, 26 Nov 2026 00:29
74 lines
11278 bytes
11278 bytes
On Wed, Nov 25, 2026 at 05:11:51PM -0700, Xiang Mei wrote:
> nft_exthdr_ipv6_eval() checks only skb->protocol before calling
> ipv6_find_hdr(), whose prologue reads ipv6_hdr(skb)->nexthdr from the
> linear area without a pull. The expression is usable from every family,
> and the netdev ingress hook does not normalise the skb: an 18-byte
> 802.1Q frame with an ETH_P_IPV6 inner type has no IPv6 header,
Are you referring to a skbuff with vlan offload or with the vlan tag
in the payload?
netdev calls pskb_may_pull() to ensure the IPv6 header is linear.
Then, this only works with the skb->protocol check on IPv6.
I find these text generated by LLM of very low quality for a human to
understand.
> so the read lands past skb_tail_pointer(), and an AF_PACKET frame
> larger than a page leaves the header in frags, so it lands past
> skb_headlen().
>
> With NFT_EXTHDR_F_PRESENT, it decides the result, and
> 256 "exthdr ipv6 type=T exists counter" rules hand it to an
> unprivileged user running in its own user and network namespace.
>
> Raising the device headroom puts the skb head in kmalloc-1k. With freed
> struct net_bridge_port objects sprayed under it, a uid 1000 run on
> current mainline read back kernel-written data, byte 2 of
> WORK_STRUCT_NO_POOL in query_queue_work.data, and bits 16..23 of the
> query_queue.prev self-pointer, i.e. of direct-map heap addresses:
>
> read offset 570 = byte 2 of the 8-byte slot at 568
> freed net_bridge_port (32 probes):
> byte 0xe0 (224): 15/32
> read offset 554 = byte 2 of the 8-byte slot at 552
> freed net_bridge_port (32 probes):
> byte 0x15 ( 21): 2/32
> byte 0x21 ( 33): 2/32
> byte 0x59 ( 89): 1/32
> byte 0xb2 (178): 2/32
> byte 0xc3 (195): 1/32
> byte 0xd8 (216): 2/32
> ...
>
> Pull the header before the call, as act_ct, virtio_net_hdr_to_skb() and
> nft_set_pktinfo_ipv6_ingress() already do. For the ipv6 and inet
> families ipv6_rcv() has already pulled it, so this is a length check.
>
> Cc: stable@vger.kernel.org
> Fixes: 96518518cc41 ("netfilter: add nftables")
> Reported-by: co+85229ab197510ca7@bugs.sh
> Signed-off-by: Xiang Mei <xmei5@asu.edu>
> ---
> net/netfilter/nft_exthdr.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c
> index 861bab93f435..a7c2f7553af8 100644
> --- a/net/netfilter/nft_exthdr.c
> +++ b/net/netfilter/nft_exthdr.c
> @@ -52,7 +52,8 @@ static void nft_exthdr_ipv6_eval(const struct nft_expr *expr,
> unsigned int offset = 0;
> int err;
>
> - if (pkt->skb->protocol != htons(ETH_P_IPV6))
> + if (pkt->skb->protocol != htons(ETH_P_IPV6) ||
> + !pskb_network_may_pull(pkt->skb, sizeof(struct ipv6hdr)))
> goto err;
>
> err = ipv6_find_hdr(pkt->skb, &offset, priv->type, NULL, NULL);
> --
> 2.43.0
>
Technical Details
Message-ID:
<awd9f47inahmDWRP@chamomile>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371762-linux-kernel-netdev=dewy.ruReferences:
<20261126001151.13793-1-xmei5@asu.edu>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371762-linux-kernel-netdev=dewy.ru From: pablo@netfilter.org (Pablo Neira Ayuso) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH nf] netfilter: nft_exthdr: pull the IPv6 header before ipv6_find_hdr() Date: Thu, 26 Nov 2026 01:29:51 +0100 Organization: Usenet Network Message-ID: <awd9f47inahmDWRP@chamomile> References: <20261126001151.13793-1-xmei5@asu.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Injection-Info: usenet.network; logging-data="341827"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:YLLjbwR03PBfAdaR/rGWh5f5JEI= sha256:RnDvIlH9V9EzjcUgLyTHxjNlhEA8F/uT1cxJITWycP8= sha1:J/OFx7fi0SVGpSNO0VbZDPu2N34= sha256:xY1z5K77F5GFOH3Fws+2i/YRe7bckqTqDsP9JivbjXk= 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 52421125EAB; Thu, 26 Nov 2026 03:30:27 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.151 X-Spam-Status: No, score=-3.151 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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 P4EL2DtzvNe8; Thu, 26 Nov 2026 03:30:19 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-371762-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 53DED125EA3; Thu, 26 Nov 2026 03:30:10 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id D0F596022EE; Thu, 26 Nov 2026 00:30:08 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1795653005; b=QSmcJOzqUF9q7II2Bzac9L74RY2saS2SP72JXjiLTxeY8JKV/oJ30sH0nvf68BGMbuKc 8r2CEMPXDjlOkHN5OA8So9lPEfn2wwYYt/tO+FzYAhdxQB+dbgEpcpTRY7oz2b9LfnX+H aWUV3RNbxqgcdNsm9cN/GbRVxjgpLvDY2ocZgYbVv2X9QwgMNRn7CIFPXKsgfGvGCWUuD zMRf3o1/20iFa5vSB7d4Joc8uO5zJ7aRWlv5UZtec8hfkW0Tdw+LBI5qBfEgVQKPwnvPX r19vVZxRypYJVaUsl2YJSftSLDkI2xLSK4YDmEtUXaCfY+GrKIkpDBybWuwxjiPP+3A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795653005; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:Date: From:To:Cc:Subject:Message-ID:References:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=EUm/LkC3y6aNyJgPXiAzr8Ej6L+SfXrNHTH4HEx0xMs=; b=MkoY/QLN9LM0Wb3K4Z7BBJaXKiEQiy0LmixLSW037pBff1Gk3P8X2/wyXlBCHw7MnIvj 6pv4IanLAzRKh2mj5oN5eU45fZSsTNiAmP6Jh3vU6VYJtOTA00c4eHU6pf6qG8Yhcuyt3 pIBK/FM1OzxILfGYuBxrE8cs0dH54coyWsZTPxDJwEv/uRvBuzAFPL6KcVQNZxVQTV/p2 1g9xh8O2qG/kNEs6qac1J4jpY+wMxU0wl2iKS+VVBTVGl206P02UAoJuPc3PAM9YM+pk1 pgg2NZRb/KH/8tj83qegvOEpCxc+ov2kaXVcz6Ayoz1n9+zh8xe2JqWNG5RUoTPt5lQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=Izd6fL2m; dmarc=none header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; arc=fail smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F468606A32E; Thu, 26 Nov 2026 00:30:05 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=Izd6fL2m X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.70.190.124 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795653004; b=O73G0k9T57kVhQaRno/FAsBRljfwch5ljPBi+iHY7ZgBH9f0T9D1SoPj+yYTPVxmbN4J VBJtK+LUUUysDvH4quY4De3TxVA/ADzOWkTIMzZH61OtfoM1FATXjdWTBCoko0b/yeNpO SFl0WOZnuVFitfbboCZ/j41SQIp3N+3Jb6sscFM380cazlYw+YnZl+/ybQA3+WijA1NC2 D1PSaDQ/BjyLV3M7SumZrAcZZqzcZxZ5g4ntkc/wPgl5MOBdF6KUlqQNTE7k38Kn97+p+ ynXF741rOK+PfsXHWU9U4pB9Gk6//hCFLTL3nmRoC9YD3vT9A4+UydhdV4ej0RZKNXA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795653004; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:X-Spam-Status:X-Spam-Checker-Version; bh=EUm/LkC3y6aNyJgPXiAzr8Ej6L+SfXrNHTH4HEx0xMs=; b=glXsb5RogvStNgbTN2qV3LGEVwuDYO4l6ZMhPP/QiMqM3thM/iGQ+XhkBsNNAQzyfHei VF2b7YgAX6OoQxEyXT7qGGj31dIRs0A/qJeQBG0K3aaCqFCmB9+RcPTvQU6vJzFbDpHDi Ihuo/OkAfoeZuk0GD5TcOpWWQaMw6CgJ0gN3P5i+9xmKwXRod0K1bFukSEUMF1VRl/kSH yXjtts+zNFPQ1mjObf1KmcVnHkKmc7RoxXv2s/67OuS2WHfuKPoQYxKUgc2fVhbkAlopW 1N9ah2/KJs2x/dErZ4BzZ2tMLd3ZpdLvONZBFf+I9Kh6M9soVLsrj9dxDGzxPeghJzA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=Izd6fL2m; arc=none smtp.remote-ip=217.70.190.124 X-Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id 9C0DD606A31E; Thu, 26 Nov 2026 00:30:03 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9C0DD606A31E 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=1795652995; bh=EUm/LkC3y6aNyJgPXiAzr8Ej6L+SfXrNHTH4HEx0xMs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Izd6fL2mBUmuctoei67NbT31zbp+xSnNkNcm/T3qw9QCdyme7/d33jOV6LXzZJLTi 1Juf4i3FRgpu9VJon9Jmun5osfe9T/O/0FAgxXmOMm//up9mgu8+yjYTUl7BYmtOLi W1WSjOj5c0Un8tkAkA/yYGlb6KpGwmTgsmb3BGQYAVNxNehKtZWS64/kg2JiBy4ry+ XCDRhLhAw1MXAUafrlkcLFQx9nMy6SWNiObqTueuV3bx6kpuhVUIbW9b93GWqUb0WS I0sdVIPv+6AtokYUvQkdMZ27gUo+T8YmcgAwK5qUA8cYbHR3uJLxZOHLud8OYlqcoj R7iR5P+hYxVig== X-Received: from netfilter.org (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with UTF8SMTPSA id D7E2660056; Thu, 26 Nov 2026 01:29:54 +0100 (CET) X-Cc: Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Willem de Bruijn <willemb@google.com>, Simon Horman <horms@kernel.org>, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, co+85229ab197510ca7@bugs.sh X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261126001151.13793-1-xmei5@asu.edu>