]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
netfilter: nf_tables: bail out on mismatching dynset and set expressions
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 4 Dec 2023 13:25:33 +0000 (14:25 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 6 Dec 2023 16:15:43 +0000 (17:15 +0100)
If dynset expressions provided by userspace is larger than the declared
set expressions, then bail out.

Fixes: 48b0ae046ee9 ("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>
net/netfilter/nft_dynset.c

index b18a7903912597115c27e2857298c0211cca0fd0..c09dba57354c17e0776e4d5c3b52486719d20163 100644 (file)
@@ -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++;
                }