evaluate: disable ct set with ranges
Florian Westphal
maintainerPATCH 1/1 evaluate: disable ct set with ranges
... this will cause an assertion in netlink linearization, catch this at eval stage instead.
before:
BUG: unknown expression type range
nft: netlink_linearize.c:908: netlink_gen_expr: Assertion `0' failed.
after:
/unknown_expr_type_range_assert:3:31-40: Error: ct expression cannot be a range ct mark set 0x001-3434
^^^^^^^^^^
--- src/evaluate.c | 12 +++++++++++- .../bogons/nft-f/unknown_expr_type_range_assert | 1 + 2 files changed, 12 insertions(+), 1 deletion(-)
src/evaluate.c +11 -1
@@ -3331,7 +3331,17 @@ static int stmt_evaluate_ct(struct eval_ctx *ctx, struct stmt *stmt)return stmt_error (ctx, stmt,"ct secmark must not be set to constant value" ); -return 0 ; +switch (stmt->meta.expr->etype) { +case EXPR_RANGE : + ret =expr_error (ctx->msgs, stmt->ct.expr, +"ct expression cannot be a range" ); +break ; +default : +break ; + + } + +return ret; } static int reject_payload_gen_dependency_tcp(struct eval_ctx *ctx,
tests/shell/testcases/bogons/nft-f/unknown_expr_type_range_assert +1 -0
@@ -1,5 +1,6 @@ table ip x { chain k { meta mark set 0x001-3434 + ct mark set 0x001-3434 } }
Signature · 1 line
2.41.0
Florian Westphal
maintainerQuoted 11 lines · Florian Westphal
... this will cause an assertion in netlink linearization, catch this at eval stage instead.
before:
BUG: unknown expression type rangenft: netlink_linearize.c:908:
netlink_gen_expr: Assertion `0' failed.after:
/unknown_expr_type_range_assert:3:31-40: Error: ct expression cannot be a range ct mark set 0x001-3434^^^^^^^^^^
This isn't enough, we have a truckload of bugs like this.
e.g. 'tproxy to 1.1.1.10/0'. This passes EXPR_RANGE check, but we still hit the assertion because prefix is translated to a range later on.
dup and fwd also have this issue, probably a lot more.
Pablo Neira Ayuso
maintainerHi Florian,
Quoted 13 lines · Florian Westphal
Quoted 11 lines · Florian Westphal
... this will cause an assertion in netlink linearization, catch this at eval stage instead.
before:
BUG: unknown expression type rangenft: netlink_linearize.c:908:
netlink_gen_expr: Assertion `0' failed.after:
/unknown_expr_type_range_assert:3:31-40: Error: ct expression cannot be a range ct mark set 0x001-3434^^^^^^^^^^
Quoted 5 lines
This isn't enough, we have a truckload of bugs like this.
e.g. 'tproxy to 1.1.1.10/0'. This passes
EXPR_RANGEcheck, but we still hit the assertion because prefix is translated to a range later on.
I am going to take a look at this one.
Quoted 1 line
dup and fwd also have this issue, probably a lot more.
I believe we have to go the extra mile and sanitize this, to avoid non-sensical transformations which leads to hit BUG.