Netdev List
 help / color / mirror / Atom feed
* [PATCH nf] netfilter: ip6t_ah: validate AH header length
@ 2026-06-18 12:58 Zhixing Chen
  2026-06-30  5:16 ` Florian Westphal
  0 siblings, 1 reply; 3+ messages in thread
From: Zhixing Chen @ 2026-06-18 12:58 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Florian Westphal
  Cc: Phil Sutter, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, netfilter-devel, coreteam, netdev,
	Zhixing Chen

ip6t_ah checks that the fixed AH header is present, then uses hdrlen to
derive the advertised AH header length for matching.

Return false if the skb does not contain the advertised AH header length.
This avoids matching AH headers whose advertised length is not present in
the skb.

Signed-off-by: Zhixing Chen <running910@gmail.com>
---

I noticed ip6t_hbh and ip6t_rt already do this advertised-length check
for their IPv6 extension headers, so this keeps ip6t_ah in line with
those matches.

---
 net/ipv6/netfilter/ip6t_ah.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c
index 70da2f2ce064..a40240125a1b 100644
--- a/net/ipv6/netfilter/ip6t_ah.c
+++ b/net/ipv6/netfilter/ip6t_ah.c
@@ -56,6 +56,10 @@ static bool ah_mt6(const struct sk_buff *skb, struct xt_action_param *par)
 	}
 
 	hdrlen = ipv6_authlen(ah);
+	if (skb->len - ptr < hdrlen) {
+		/* Packet smaller than its length field */
+		return false;
+	}
 
 	pr_debug("IPv6 AH LEN %u %u ", hdrlen, ah->hdrlen);
 	pr_debug("RES %04X ", ah->reserved);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH nf] netfilter: ip6t_ah: validate AH header length
  2026-06-18 12:58 [PATCH nf] netfilter: ip6t_ah: validate AH header length Zhixing Chen
@ 2026-06-30  5:16 ` Florian Westphal
  2026-06-30 12:46   ` Zhixing Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Westphal @ 2026-06-30  5:16 UTC (permalink / raw)
  To: Zhixing Chen
  Cc: Pablo Neira Ayuso, Phil Sutter, netfilter-devel, coreteam, netdev

Zhixing Chen <running910@gmail.com> wrote:
> ip6t_ah checks that the fixed AH header is present, then uses hdrlen to
> derive the advertised AH header length for matching.
> 
> Return false if the skb does not contain the advertised AH header length.
> This avoids matching AH headers whose advertised length is not present in
> the skb.
> 
> Signed-off-by: Zhixing Chen <running910@gmail.com>
> ---
> 
> I noticed ip6t_hbh and ip6t_rt already do this advertised-length check
> for their IPv6 extension headers, so this keeps ip6t_ah in line with
> those matches.

Could you make a v2 that addresses

https://sashiko.dev/#/patchset/20260618125848.93550-1-running910%40gmail.com
?

We should not return false in matches for malformed packets without
also setting ->hotdrop = true.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH nf] netfilter: ip6t_ah: validate AH header length
  2026-06-30  5:16 ` Florian Westphal
@ 2026-06-30 12:46   ` Zhixing Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Zhixing Chen @ 2026-06-30 12:46 UTC (permalink / raw)
  To: Florian Westphal
  Cc: Pablo Neira Ayuso, Phil Sutter, netfilter-devel, coreteam, netdev

> We should not return false in matches for malformed packets without
> also setting ->hotdrop = true.

Thanks a lot for taking a careful look, I really appreciate it.

I agree. Returning false makes the packet a rule mismatch, while this
condition means the packet is malformed. I will send a v2 that sets
->hotdrop before returning false in ah, and applies the same
malformed-header handling to hbh and rt as well.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-30 12:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-18 12:58 [PATCH nf] netfilter: ip6t_ah: validate AH header length Zhixing Chen
2026-06-30  5:16 ` Florian Westphal
2026-06-30 12:46   ` Zhixing Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox