]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: don't update cache for anonymous chains
authorFlorian Westphal <fw@strlen.de>
Wed, 19 Mar 2025 20:05:53 +0000 (21:05 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sun, 27 Jul 2025 21:26:19 +0000 (23:26 +0200)
commit bd1fc6c740535d1ad3f38f8ba9c539c14f1732f3 upstream.

Chain lookup needs a name, not a numerical id.
After patch, loading bogon gives following errors:

Error: No symbol type information a b index 1 10.1.26.a

v2: Don't return an error, just make it a no-op (Pablo Neira Ayuso)

Fixes: c330152b7f77 ("src: support for implicit chain bindings")
Signed-off-by: Florian Westphal <fw@strlen.de>
src/evaluate.c
tests/shell/testcases/bogons/nft-f/null_deref_on_anon_chain_update_crash [new file with mode: 0644]

index 47145f4cb0f8127cfbb400c6701ea1e5822ec142..4fca39bef68f0ddb49d0ee4d425e7cb91de9c7f0 100644 (file)
@@ -5086,6 +5086,10 @@ static int rule_cache_update(struct eval_ctx *ctx, enum cmd_ops op)
        if (!table)
                return table_not_found(ctx);
 
+       /* chain is anonymous, adding new rules via index is not supported. */
+       if (!rule->handle.chain.name)
+               return 0;
+
        chain = chain_cache_find(table, rule->handle.chain.name);
        if (!chain)
                return chain_not_found(ctx);
diff --git a/tests/shell/testcases/bogons/nft-f/null_deref_on_anon_chain_update_crash b/tests/shell/testcases/bogons/nft-f/null_deref_on_anon_chain_update_crash
new file mode 100644 (file)
index 0000000..310486c
--- /dev/null
@@ -0,0 +1,8 @@
+table ip f {
+        chain c {
+                jump {
+                        accept
+                }
+        }
+}
+a b index 1 10.1.26.a