Skip to content

Commit

Permalink
netfilter: nft_exthdr: check for IPv6 packet before further processing
Browse files Browse the repository at this point in the history
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: 9651851 ("netfilter: add nftables")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
ummakynes authored and intel-lab-lkp committed Jun 16, 2021
1 parent 12f36e9 commit 3e2206f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/netfilter/nft_exthdr.c
Expand Up @@ -42,6 +42,9 @@ static void nft_exthdr_ipv6_eval(const struct nft_expr *expr,
unsigned int offset = 0;
int err;

if (skb->protocol != htons(ETH_P_IPV6))
goto err;

err = ipv6_find_hdr(pkt->skb, &offset, priv->type, NULL, NULL);
if (priv->flags & NFT_EXTHDR_F_PRESENT) {
nft_reg_store8(dest, err >= 0);
Expand Down

0 comments on commit 3e2206f

Please sign in to comment.