]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: xt_length: use skb len to match in length_mt6
authorXin Long <lucien.xin@gmail.com>
Fri, 17 Feb 2023 23:22:57 +0000 (18:22 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 12:55:24 +0000 (13:55 +0100)
commitd2ad2c7affa5df202cb379139349e952f43c37a8
treece425516c248d4b67ddcc449beee73da3a63578d
parent912a000cb5dd9b00e48fbb846f19f6b3672da244
netfilter: xt_length: use skb len to match in length_mt6

[ Upstream commit 7103c48f00d180663b83ebb7a9043ca454fda9cc ]

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: f4d2f29901ff ("net: allow gso_max_size to exceed 65536")
Fixes: 12478a2acbca ("net: allow gro_max_size to exceed 65536")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/xt_length.c