Skip to content

Commit 05c07c0

Browse files
lxinummakynes
authored andcommitted
netfilter: xt_length: use skb len to match in length_mt6
For IPv6 Jumbo packets, the ipv6_hdr(skb)->payload_len is always 0, and its real payload_len ( > 65535) is saved in hbh exthdr. With 0 length for the jumbo packets, it may mismatch. To fix this, we can just use skb->len instead of parsing exthdrs, as the hbh exthdr parsing has been done before coming to length_mt6 in ip6_rcv_core() and br_validate_ipv6() and also the packet has been trimmed according to the correct IPv6 (ext)hdr length there, and skb len is trustable in length_mt6(). Note that this patch is especially needed after the IPv6 BIG TCP was supported in kernel, which is using IPv6 Jumbo packets. Besides, to match the packets greater than 65535 more properly, a v1 revision of xt_length may be needed to extend "min, max" to u32 in the future, and for now the IPv6 Jumbo packets can be matched by: # ip6tables -m length ! --length 0:65535 Fixes: 7c4e983 ("net: allow gso_max_size to exceed 65536") Fixes: 0fe79f2 ("net: allow gro_max_size to exceed 65536") Signed-off-by: Xin Long <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent e58a171 commit 05c07c0

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

net/netfilter/xt_length.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ static bool
3030
length_mt6(const struct sk_buff *skb, struct xt_action_param *par)
3131
{
3232
const struct xt_length_info *info = par->matchinfo;
33-
const u_int16_t pktlen = ntohs(ipv6_hdr(skb)->payload_len) +
34-
sizeof(struct ipv6hdr);
33+
u32 pktlen = skb->len;
3534

3635
return (pktlen >= info->min && pktlen <= info->max) ^ info->invert;
3736
}

0 commit comments

Comments
 (0)