Skip to content

Commit 65b3bd6

Browse files
committed
netfilter: nf_tables: validate .maxattr at expression registration
struct nft_expr_info allows to store up to NFT_EXPR_MAXATTR (16) attributes when parsing netlink attributes. Rise a warning in case there is ever a nft expression whose .maxattr goes beyond this number of expressions, in such case, struct nft_expr_info needs to be updated. Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 0617c3d commit 65b3bd6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2977,6 +2977,9 @@ static int nf_tables_delchain(struct sk_buff *skb, const struct nfnl_info *info,
29772977
*/
29782978
int nft_register_expr(struct nft_expr_type *type)
29792979
{
2980+
if (WARN_ON_ONCE(type->maxattr > NFT_EXPR_MAXATTR))
2981+
return -ENOMEM;
2982+
29802983
nfnl_lock(NFNL_SUBSYS_NFTABLES);
29812984
if (type->family == NFPROTO_UNSPEC)
29822985
list_add_tail_rcu(&type->list, &nf_tables_expressions);

0 commit comments

Comments
 (0)