summaryrefslogtreecommitdiff
path: root/net/netfilter/xt_length.c
diff options
context:
space:
mode:
authorXin Long <lucien.xin@gmail.com>2023-01-28 18:58:34 +0300
committerJakub Kicinski <kuba@kernel.org>2023-02-02 07:54:27 +0300
commita13fbf5ed5b4fc9095f12e955ca3a59b5507ff01 (patch)
tree1e13229b52e6af3a0fe5639a1722f44e2f741323 /net/netfilter/xt_length.c
parent043e397e48c58b4442ea5124dc1bdc95367a0a33 (diff)
downloadlinux-a13fbf5ed5b4fc9095f12e955ca3a59b5507ff01.tar.xz
netfilter: use skb_ip_totlen and iph_totlen
There are also quite some places in netfilter that may process IPv4 TCP GSO packets, we need to replace them too. In length_mt(), we have to use u_int32_t/int to accept skb_ip_totlen() return value, otherwise it may overflow and mismatch. This change will also help us add selftest for IPv4 BIG TCP in the following patch. Note that we don't need to replace the one in tcpmss_tg4(), as it will return if there is data after tcphdr in tcpmss_mangle_packet(). The same in mangle_contents() in nf_nat_helper.c, it returns false when skb->len + extra > 65535 in enlarge_skb(). Signed-off-by: Xin Long <lucien.xin@gmail.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/netfilter/xt_length.c')
-rw-r--r--net/netfilter/xt_length.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/netfilter/xt_length.c b/net/netfilter/xt_length.c
index 1873da3a945a..b3d623a52885 100644
--- a/net/netfilter/xt_length.c
+++ b/net/netfilter/xt_length.c
@@ -21,7 +21,7 @@ static bool
length_mt(const struct sk_buff *skb, struct xt_action_param *par)
{
const struct xt_length_info *info = par->matchinfo;
- u_int16_t pktlen = ntohs(ip_hdr(skb)->tot_len);
+ u32 pktlen = skb_ip_totlen(skb);
return (pktlen >= info->min && pktlen <= info->max) ^ info->invert;
}