patch 'acl: reject rules with inverted range' has been queued to stable release 25.11.5
Kevin Traynor
ktraynor at redhat.com
Thu Dec 3 14:05:52 CET 2026
Hi,
FYI, your patch has been queued to stable release 25.11.5
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/08/26. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable
This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/67b9b94fb4fecdbfee0608b3c9cc65675ab5df4b
Thanks.
Kevin
---
>From 67b9b94fb4fecdbfee0608b3c9cc65675ab5df4b Mon Sep 17 00:00:00 2001
From: Andrey Mokrushin <a.mokrushin at ideco.ru>
Date: Wed, 11 Nov 2026 12:30:41 +0500
Subject: [PATCH] acl: reject rules with inverted range
[ upstream commit c3bbe142bd91c4ce17676ab47965016e22ef9667 ]
rte_acl_build() doesn't check that for a RANGE field the low bound
(value) doesn't exceed the high bound (mask_range). Field types are
known only from the rte_acl_config passed to rte_acl_build(), so
rte_acl_add_rules() doesn't validate ranges. Such a rule is accepted,
and then:
- for a 1-byte field the build crashes with a NULL pointer
dereference in acl_gen_node();
- for a 2-byte field (e.g. port range 80..22) the build succeeds,
but the rule matches every value of the field instead of none.
The check was done only for the legacy ipv4vlan rules
(acl_ipv4vlan_check_rule(), now in app/test). Validate RANGE fields
of all rules in acl_check_bld_param(), together with the rest of the
build parameters, and fail rte_acl_build() with -EINVAL.
Add a test case with the generic API.
Fixes: dc276b5780c2 ("acl: new library")
Signed-off-by: Andrey Mokrushin <a.mokrushin at ideco.ru>
Acked-by: Konstantin Ananyev <konstantin.v.ananyev at yandex.ru>
---
app/test/test_acl.c | 26 ++++++++++++++++++
lib/acl/acl_bld.c | 67 ++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 92 insertions(+), 1 deletion(-)
diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 43d13b5b0f..e18a0cf278 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -1274,4 +1274,5 @@ test_invalid_rules(void)
struct rte_acl_ipv4vlan_rule rule;
+ struct acl_ipv4vlan_rule rv;
acx = rte_acl_create(&acl_param);
@@ -1338,4 +1339,29 @@ test_invalid_rules(void)
}
+ /* test inverted high/low destination ports added through the
+ * generic API: rte_acl_add_rules() doesn't know the field types,
+ * so the rule has to be rejected by rte_acl_build().
+ */
+ rule = acl_rule;
+ rule.data.userdata = 1;
+ rule.dst_port_low = 0xfff0;
+ rule.dst_port_high = 0x0010;
+
+ acl_ipv4vlan_convert_rule(&rule, &rv);
+ ret = rte_acl_add_rules(acx, (struct rte_acl_rule *)&rv, 1);
+ if (ret != 0) {
+ printf("Line %i: Adding rules to ACL context failed!\n",
+ __LINE__);
+ goto err;
+ }
+
+ ret = rte_acl_ipv4vlan_build(acx, ipv4_7tuple_layout,
+ RTE_ACL_MAX_CATEGORIES);
+ if (ret != -EINVAL) {
+ printf("Line %i: Building ACL context "
+ "should have failed!\n", __LINE__);
+ goto err;
+ }
+
rte_acl_free(acx);
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 7056b1c117..0f0c00a27e 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -1549,4 +1549,69 @@ acl_bld(struct acl_build_context *bcx, struct rte_acl_ctx *ctx,
}
+/*
+ * Check that for all RANGE fields lower bound doesn't exceed upper bound.
+ */
+static int
+acl_check_rule_range(const struct rte_acl_config *cfg,
+ const struct rte_acl_rule *rule)
+{
+ uint32_t n;
+ uint64_t lo, hi;
+ const struct rte_acl_field *fld;
+
+ for (n = 0; n != cfg->num_fields; n++) {
+ if (cfg->defs[n].type != RTE_ACL_FIELD_TYPE_RANGE)
+ continue;
+
+ fld = rule->field + cfg->defs[n].field_index;
+ switch (cfg->defs[n].size) {
+ case sizeof(uint8_t):
+ lo = fld->value.u8;
+ hi = fld->mask_range.u8;
+ break;
+ case sizeof(uint16_t):
+ lo = fld->value.u16;
+ hi = fld->mask_range.u16;
+ break;
+ case sizeof(uint32_t):
+ lo = fld->value.u32;
+ hi = fld->mask_range.u32;
+ break;
+ default:
+ lo = fld->value.u64;
+ hi = fld->mask_range.u64;
+ break;
+ }
+
+ if (lo > hi)
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+/*
+ * Check that rules added to the context are valid for the given config.
+ */
+static int
+acl_check_rules(const struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
+{
+ uint32_t i;
+ const struct rte_acl_rule *rule;
+
+ for (i = 0; i != ctx->num_rules; i++) {
+ rule = (const struct rte_acl_rule *)
+ ((uintptr_t)ctx->rules + ctx->rule_sz * i);
+ if (acl_check_rule_range(cfg, rule) != 0) {
+ ACL_LOG(ERR,
+ "ACL context: %s, rule[%u] (userdata: %u): low bound exceeds high bound of a range field",
+ ctx->name, i, rule->data.userdata);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
/*
* Check that parameters for acl_build() are valid.
@@ -1589,5 +1654,5 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
}
- return 0;
+ return acl_check_rules(ctx, cfg);
}
--
2.56.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-12-03 12:52:51.249535001 +0000
+++ 0426-acl-reject-rules-with-inverted-range.patch 2026-12-03 12:52:39.331938815 +0000
@@ -1 +1 @@
-From c3bbe142bd91c4ce17676ab47965016e22ef9667 Mon Sep 17 00:00:00 2001
+From 67b9b94fb4fecdbfee0608b3c9cc65675ab5df4b Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit c3bbe142bd91c4ce17676ab47965016e22ef9667 ]
+
@@ -23 +24,0 @@
-Cc: stable at dpdk.org
@@ -33 +34 @@
-index 5d207c80ca..47786bc393 100644
+index 43d13b5b0f..e18a0cf278 100644
@@ -36 +37 @@
-@@ -1275,4 +1275,5 @@ test_invalid_rules(void)
+@@ -1274,4 +1274,5 @@ test_invalid_rules(void)
@@ -42 +43 @@
-@@ -1339,4 +1340,29 @@ test_invalid_rules(void)
+@@ -1338,4 +1339,29 @@ test_invalid_rules(void)
@@ -73 +74 @@
-index 99d1dbc467..534a0e14f6 100644
+index 7056b1c117..0f0c00a27e 100644
More information about the stable
mailing list