summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2021-06-10 20:20:30 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-07-20 16:21:02 +0200
commitf5623bd84f6020a63d18f8d471e0d8a447d5dc43 (patch)
tree341e339db4324fb3725e5ca7e27257f84d95ed14 /net
parent37c723fb144c6035b733f8846af28e92588d93ab (diff)
downloadlinux-stable-f5623bd84f6020a63d18f8d471e0d8a447d5dc43.tar.gz
linux-stable-f5623bd84f6020a63d18f8d471e0d8a447d5dc43.tar.bz2
linux-stable-f5623bd84f6020a63d18f8d471e0d8a447d5dc43.zip
netfilter: nft_exthdr: check for IPv6 packet before further processing
[ Upstream commit cdd73cc545c0fb9b1a1f7b209f4f536e7990cff4 ] ipv6_find_hdr() does not validate that this is an IPv6 packet. Add a sanity check for calling ipv6_find_hdr() to make sure an IPv6 packet is passed for parsing. Fixes: 96518518cc41 ("netfilter: add nftables") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/nft_exthdr.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c
index 47beb3abcc9d..e2c815ee06d0 100644
--- a/net/netfilter/nft_exthdr.c
+++ b/net/netfilter/nft_exthdr.c
@@ -34,6 +34,9 @@ static void nft_exthdr_eval(const struct nft_expr *expr,
unsigned int offset = 0;
int err;
+ if (pkt->skb->protocol != htons(ETH_P_IPV6))
+ goto err;
+
err = ipv6_find_hdr(pkt->skb, &offset, priv->type, NULL, NULL);
if (err < 0)
goto err;