]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
netfilter: ip6tables: mark malformed IPv6 extension headers for hotdrop
authorZhixing Chen <running910@gmail.com>
Wed, 1 Jul 2026 10:09:30 +0000 (18:09 +0800)
committerFlorian Westphal <fw@strlen.de>
Fri, 3 Jul 2026 12:45:21 +0000 (14:45 +0200)
The ah, hbh and rt matches check that the fixed extension header is
present, then use the header length field to derive the advertised
extension header length for matching.

For the ah match, add the missing advertised-length check. For hbh
and rt, update the existing advertised-length checks. In all three
cases, set hotdrop to true before returning false when the advertised
extension header length exceeds the available skb data.

Returning false treats the packet as a rule mismatch. Set hotdrop to
true and drop malformed packets so they cannot bypass rules intended
to drop packets with these IPv6 extension headers.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Zhixing Chen <running910@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/ipv6/netfilter/ip6t_ah.c
net/ipv6/netfilter/ip6t_hbh.c
net/ipv6/netfilter/ip6t_rt.c

index 70da2f2ce064ca1424ea5f5381c4863b42b8bc51..1258783ed87629e248c6173a01634132595f2a40 100644 (file)
@@ -56,6 +56,11 @@ 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 */
+               par->hotdrop = true;
+               return false;
+       }
 
        pr_debug("IPv6 AH LEN %u %u ", hdrlen, ah->hdrlen);
        pr_debug("RES %04X ", ah->reserved);
index 450dd53846a2f77b81cb863fc62ad0236065f9c4..6d1a5d2026a678c69930497b8596056a73658795 100644 (file)
@@ -75,6 +75,7 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
        hdrlen = ipv6_optlen(oh);
        if (skb->len - ptr < hdrlen) {
                /* Packet smaller than it's length field */
+               par->hotdrop = true;
                return false;
        }
 
index 5561bd9cea818572f8eed84bbb018ecff7e1fc47..278b52752f36456e48a0b856889fb6021e09fda0 100644 (file)
@@ -56,7 +56,8 @@ static bool rt_mt6(const struct sk_buff *skb, struct xt_action_param *par)
 
        hdrlen = ipv6_optlen(rh);
        if (skb->len - ptr < hdrlen) {
-               /* Pcket smaller than its length field */
+               /* Packet smaller than its length field */
+               par->hotdrop = true;
                return false;
        }