Skip to content

Commit 789fbe0

Browse files
committed
netfilter: nf_tables: bail out on mismatching dynset and set expressions
jira VULN-683 cve CVE-2023-6622 commit-author Pablo Neira Ayuso <[email protected]> commit 3701cd3 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]> (cherry picked from commit 3701cd3) Signed-off-by: Greg Rose <[email protected]>
1 parent 4b1bb03 commit 789fbe0

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
@@ -274,10 +274,15 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
274274
priv->expr_array[i] = dynset_expr;
275275
priv->num_exprs++;
276276

277-
if (set->num_exprs &&
278-
dynset_expr->ops != set->exprs[i]->ops) {
279-
err = -EOPNOTSUPP;
280-
goto err_expr_free;
277+
if (set->num_exprs) {
278+
if (i >= set->num_exprs) {
279+
err = -EINVAL;
280+
goto err_expr_free;
281+
}
282+
if (dynset_expr->ops != set->exprs[i]->ops) {
283+
err = -EOPNOTSUPP;
284+
goto err_expr_free;
285+
}
281286
}
282287
i++;
283288
}

0 commit comments

Comments
 (0)