Skip to content

Commit 3701cd3

Browse files
committed
netfilter: nf_tables: bail out on mismatching dynset and set expressions
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 <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 63331e3 commit 3701cd3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

net/netfilter/nft_dynset.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,15 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
280280
priv->expr_array[i] = dynset_expr;
281281
priv->num_exprs++;
282282

283-
if (set->num_exprs &&
284-
dynset_expr->ops != set->exprs[i]->ops) {
285-
err = -EOPNOTSUPP;
286-
goto err_expr_free;
283+
if (set->num_exprs) {
284+
if (i >= set->num_exprs) {
285+
err = -EINVAL;
286+
goto err_expr_free;
287+
}
288+
if (dynset_expr->ops != set->exprs[i]->ops) {
289+
err = -EOPNOTSUPP;
290+
goto err_expr_free;
291+
}
287292
}
288293
i++;
289294
}

0 commit comments

Comments
 (0)