diff options
author | Florian Westphal <fw@strlen.de> | 2025-03-20 09:39:20 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2025-07-27 19:52:33 +0200 |
commit | b90ac61407c595a09e46b43d458ac697f0801b9b (patch) | |
tree | 4b0004eac50d3dbdeff999e355b0fa9c7b751c55 | |
parent | c2bf4be8d0e5301a40b285e255261a30dce7b552 (diff) |
evaluate: don't allow nat map with specified protocol
commit 43cf4a2973ee9e3ab20edce47c6a054485707592 upstream.
Included bogon asserts:
src/netlink_linearize.c:1305: netlink_gen_nat_stmt: Assertion `stmt->nat.proto == NULL' failed.
The comment right above the assertion says:
nat_stmt evaluation step doesn't allow
STMT_NAT_F_CONCAT && stmt->nat.proto.
... except it does allow it. Disable this.
Fixes: c68314dd4263 ("src: infer NAT mapping with concatenation from set")
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | src/evaluate.c | 4 | ||||
-rw-r--r-- | tests/shell/testcases/bogons/nat_map_and_protocol_assert | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/evaluate.c b/src/evaluate.c index 9585991f..da7ee883 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -3851,6 +3851,10 @@ static int stmt_evaluate_nat_map(struct eval_ctx *ctx, struct stmt *stmt) int addr_type; int err; + if (stmt->nat.proto) + return stmt_binary_error(ctx, stmt, stmt->nat.proto, + "nat map and protocol are mutually exclusive"); + if (stmt->nat.family == NFPROTO_INET) expr_family_infer(pctx, stmt->nat.addr, &stmt->nat.family); diff --git a/tests/shell/testcases/bogons/nat_map_and_protocol_assert b/tests/shell/testcases/bogons/nat_map_and_protocol_assert new file mode 100644 index 00000000..67f2ae87 --- /dev/null +++ b/tests/shell/testcases/bogons/nat_map_and_protocol_assert @@ -0,0 +1,5 @@ +table t { + chain y { + snat to ip saddr . tcp sport map { 1.1.1.1 . 1 : 1.1.1.2 . 1 } : 6 + } +} |