evaluate: don't update cache for anonymous chains
Florian Westphal
maintainerPATCH 1/1 evaluate: don't update cache for anonymous chains
Chain lookup needs a name, not a numerical id. After patch, loading bogon gives following errors:
Error: No such file or directory chain c {
Error: No symbol type information a b index 1 10.1.26.a
--- src/evaluate.c | 3 +++ .../bogons/nft-f/null_deref_on_anon_chain_update_crash | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 tests/shell/testcases/bogons/nft-f/null_deref_on_anon_chain_update_crash
src/evaluate.c +3 -0
@@ -5371,6 +5371,9 @@ static int rule_cache_update(struct eval_ctx *ctx, enum cmd_ops op)if (!table)return table_not_found (ctx); +if (!rule->handle.chain.name) +return chain_not_found (ctx); + chain =chain_cache_find (table, rule->handle.chain.name);if (!chain)return chain_not_found (ctx);
tests/shell/testcases/bogons/nft-f/null_deref_on_anon_chain_update_crash new file +8 -0
@@ -0,0 +1,8 @@ +table ip f { + chain c { + jump { + accept + } + } +} +a b index 1 10.1.26.a
Signature · 1 line
2.48.1
Pablo Neira Ayuso
maintainerQuoted 18 lines · Florian Westphal
Chain lookup needs a name, not a numerical id. After patch, loading bogon gives following errors:
Error: No such file or directory chain c {
Error: No symbol type information a b index 1 10.1.26.aSigned-off-by Florian Westphal <[email protected]>--- src/evaluate.c | 3 +++ .../bogons/nft-f/null_deref_on_anon_chain_update_crash | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 tests/shell/testcases/bogons/nft-f/null_deref_on_anon_chain_update_crashsrc/evaluate.c +0
-0
src/evaluate.c static int rule_cache_update(struct eval_ctx *ctx, enum cmd_ops op) · line 5375
Quoted 5 lines
src/evaluate.c +2
-0@@ -5371,6 +5371,9 @@ static int rule_cache_update(struct eval_ctx *ctx, enum cmd_ops op)if (!table)return table_not_found (ctx); +if (!rule->handle.chain.name) +return chain_not_found (ctx);
rule_cache_update() is invoked because of index, which toggle NFT_CACHE_UPDATE.
Maybe rule_cache_update() should be skipped for anonymous chain instead? ie. return 0.
Quoted 22 lines
src/evaluate.c +1
-0+ chain =chain_cache_find (table, rule->handle.chain.name);if (!chain)return chain_not_found (ctx);tests/shell/testcases/bogons/nft-f/null_deref_on_anon_chain_update_crash new file +8
-0@@ -0,0 +1,8 @@ +table ip f { + chain c { + jump { + accept + } + } +} +a b index 1 10.1.26.aSignature · 1 line
2.48.1
Florian Westphal
maintainerQuoted 5 lines · Pablo Neira Ayuso
rule_cache_update()is invoked because of index, which toggleNFT_CACHE_UPDATE.Maybe
rule_cache_update()should be skipped for anonymous chain instead? ie. return 0.
Makes sense, i sent a v2 and added a comment wrt. anon chains being immutable.