Skip to content

Commit

Permalink
netfilter: nf_tables: bail out on mismatching dynset and set expressions
Browse files Browse the repository at this point in the history
If dynset expressions provided by userspace is larger than the declared
set expressions, then bail out.

Fixes: 48b0ae0 ("netfilter: nftables: netlink support for several set element expressions")
Reported-by: Xingyuan Mo <hdthky0@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
ummakynes committed Dec 6, 2023
1 parent 63331e3 commit 3701cd3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions net/netfilter/nft_dynset.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,15 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
priv->expr_array[i] = dynset_expr;
priv->num_exprs++;

if (set->num_exprs &&
dynset_expr->ops != set->exprs[i]->ops) {
err = -EOPNOTSUPP;
goto err_expr_free;
if (set->num_exprs) {
if (i >= set->num_exprs) {
err = -EINVAL;
goto err_expr_free;
}
if (dynset_expr->ops != set->exprs[i]->ops) {
err = -EOPNOTSUPP;
goto err_expr_free;
}
}
i++;
}
Expand Down

0 comments on commit 3701cd3

Please sign in to comment.