Linux kernel -stable discussions
 help / color / mirror / Atom feed
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:39:11 +0100	[thread overview]
Message-ID: <awd_r2mOR7xuYzh4@chamomile> (raw)
In-Reply-To: <awd9f47inahmDWRP@chamomile>

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]

On Thu, Nov 26, 2026 at 01:29:55AM +0100, Pablo Neira Ayuso wrote:
> On Wed, Nov 25, 2026 at 05:11:51PM -0700, Xiang Mei wrote:
[...]
> > Pull the header before the call, as act_ct, virtio_net_hdr_to_skb() and
> > nft_set_pktinfo_ipv6_ingress() already do.

I prefer this patch (see attachment).

Please, don't take, I will submit it myself including your
Reported-by: tag.

Thanks.

[-- Attachment #2: linearize-nh.patch --]
[-- Type: text/x-diff, Size: 1546 bytes --]

diff --git a/include/net/netfilter/nf_tables_ipv4.h b/include/net/netfilter/nf_tables_ipv4.h
index e715405a73cb..5df31948c42d 100644
--- a/include/net/netfilter/nf_tables_ipv4.h
+++ b/include/net/netfilter/nf_tables_ipv4.h
@@ -21,14 +21,13 @@ static inline void nft_set_pktinfo_ipv4(struct nft_pktinfo *pkt)
 static inline int __nft_set_pktinfo_ipv4_validate(struct nft_pktinfo *pkt,
 						  int nhoff)
 {
-	struct iphdr *iph, _iph;
 	u32 len, thoff, skb_len;
+	struct iphdr *iph;
 
-	iph = skb_header_pointer(pkt->skb, skb_network_offset(pkt->skb) + nhoff,
-				 sizeof(*iph), &_iph);
-	if (!iph)
+	if (!pskb_may_pull(pkt->skb, sizeof(*iph)))
 		return -1;
 
+	iph = ip_hdr(pkt->skb);
 	if (iph->ihl < 5 || iph->version != 4)
 		return -1;
 
diff --git a/include/net/netfilter/nf_tables_ipv6.h b/include/net/netfilter/nf_tables_ipv6.h
index d7b8c559b795..06c0a57d54f0 100644
--- a/include/net/netfilter/nf_tables_ipv6.h
+++ b/include/net/netfilter/nf_tables_ipv6.h
@@ -30,17 +30,16 @@ static inline int __nft_set_pktinfo_ipv6_validate(struct nft_pktinfo *pkt, int n
 {
 #if IS_ENABLED(CONFIG_IPV6)
 	unsigned int flags = IP6_FH_F_AUTH;
-	struct ipv6hdr *ip6h, _ip6h;
 	unsigned int thoff = nhoff;
 	unsigned short frag_off;
+	struct ipv6hdr *ip6h;
 	u32 pkt_len, skb_len;
 	int protohdr;
 
-	ip6h = skb_header_pointer(pkt->skb, skb_network_offset(pkt->skb) + nhoff,
-				  sizeof(*ip6h), &_ip6h);
-	if (!ip6h)
+	if (!pskb_may_pull(pkt->skb, sizeof(*ip6h)))
 		return -1;
 
+	ip6h = ipv6_hdr(pkt->skb);
 	if (ip6h->version != 6)
 		return -1;
 

  reply	other threads:[~2026-11-26  0:39 UTC|newest]

Thread overview: 5+ 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
2026-11-26  0:39   ` Pablo Neira Ayuso [this message]
2026-11-26  1:43     ` Xiang Mei
2026-11-26  2:23       ` 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=awd_r2mOR7xuYzh4@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