]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: reject set in concatenation
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 25 Oct 2023 14:00:50 +0000 (16:00 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 22 Jan 2025 23:05:48 +0000 (00:05 +0100)
commit 4b6a4ad9134fa71277c2ff7f92776e1faeb83000 upstream.

Consider the following ruleset.

 define ext_if = { "eth0", "eth1" }
 table ip filter {
    chain c {
        iifname . tcp dport { $ext_if . 22 } accept
    }
 }

Attempting to load this ruleset results in:

BUG: invalid expression type 'set' in setnft: netlink.c:304: __netlink_gen_concat_key: Assertion `0' failed.
Aborted (core dumped)

After this patch:

 # nft -f ruleset.nft
 ruleset.nft:1:17-40: Error: cannot use set in concatenation
 define ext_if = { "eth0", "eth1" }
                 ^^^^^^^^^^^^^^^^^^

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1715
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/evaluate.c

index f307b5975f047f24d393c97759ec5c181acdd2be..849a92d15f8a45a4d273958e8a4e59b4163d60ab 100644 (file)
@@ -1401,6 +1401,12 @@ static int expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr)
 
                if (list_member_evaluate(ctx, &i) < 0)
                        return -1;
+
+               if (i->etype == EXPR_SET)
+                       return expr_error(ctx->msgs, i,
+                                         "cannot use %s in concatenation",
+                                         expr_name(i));
+
                flags &= i->flags;
 
                if (!key && i->dtype->type == TYPE_INTEGER) {