]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: tunnel: don't assume src is set
authorFlorian Westphal <fw@strlen.de>
Thu, 16 Oct 2025 14:59:33 +0000 (16:59 +0200)
committerFlorian Westphal <fw@strlen.de>
Fri, 17 Oct 2025 07:40:55 +0000 (09:40 +0200)
Included bogon crashes, after fix:

empty_geneve_definition_crash:2:9-16: Error: Could not process rule: Invalid argument

Since this feature is undocumented (hint, hint) I don't know
if there are cases where ip daddr can be elided.

If not, a followup patch should reject empty dst upfront
so users get a more verbose error message.

Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>
src/evaluate.c
tests/shell/testcases/bogons/nft-f/empty_geneve_definition_crash [new file with mode: 0644]

index 0c7d90f8f43b0f807436c1a6a39c23b8d14f9aad..ac482c83cce2ae91ad9db41a8ae27e7f3aa19735 100644 (file)
@@ -5865,11 +5865,12 @@ static int tunnel_evaluate(struct eval_ctx *ctx, struct obj *obj)
                                 obj->tunnel.dst->dtype->size);
                if (expr_evaluate(ctx, &obj->tunnel.dst) < 0)
                        return -1;
-       }
 
-       if (obj->tunnel.src->dtype != obj->tunnel.dst->dtype)
-               return __stmt_binary_error(ctx, &obj->location, NULL,
-                                         "specify either ip or ip6 for address");
+               if (obj->tunnel.src &&
+                   obj->tunnel.src->dtype != obj->tunnel.dst->dtype)
+                       return __stmt_binary_error(ctx, &obj->location, NULL,
+                                                 "specify either ip or ip6 for address");
+       }
 
        return 0;
 }
diff --git a/tests/shell/testcases/bogons/nft-f/empty_geneve_definition_crash b/tests/shell/testcases/bogons/nft-f/empty_geneve_definition_crash
new file mode 100644 (file)
index 0000000..d1bc76c
--- /dev/null
@@ -0,0 +1,4 @@
+table netdev x {
+       tunnel geneve-t {
+       }
+}