diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index b32d972328d52cbddb53e65e50f14b68c698ae59..5be4cdb6590b488cea4daa225c03b297cdf43afd 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -1496,7 +1496,7 @@ static int nft_chain_parse_hook(struct net *net, if (IS_ERR(type)) return PTR_ERR(type); } - if (!(type->hook_mask & (1 << hook->num))) + if (hook->num > NF_MAX_HOOKS || !(type->hook_mask & (1 << hook->num))) return -EOPNOTSUPP; if (type->type == NFT_CHAIN_T_NAT &&