From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Xiang Mei <xmei5@asu.edu>
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
Subject: Re: [PATCH nf] netfilter: nft_exthdr: pull the IPv6 header before ipv6_find_hdr()
Date: Thu, 26 Nov 2026 01:29:51 +0100 [thread overview]
Message-ID: <awd9f47inahmDWRP@chamomile> (raw)
In-Reply-To: <20261126001151.13793-1-xmei5@asu.edu>
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
>
next prev parent reply other threads:[~2026-11-26 0:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 0:11 [PATCH nf] netfilter: nft_exthdr: pull the IPv6 header before ipv6_find_hdr() Xiang Mei
2026-11-26 0:29 ` Pablo Neira Ayuso [this message]
2026-11-26 0:39 ` Pablo Neira Ayuso
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=awd9f47inahmDWRP@chamomile \
--to=pablo@netfilter.org \
--cc=co+85229ab197510ca7@bugs.sh \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=fw@strlen.de \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=phil@nwl.cc \
--cc=stable@vger.kernel.org \
--cc=willemb@google.com \
--cc=xmei5@asu.edu \
/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