patch 'acl: reject rules with inverted range' has been queued to stable release 24.11.9

luca.boccassi at gmail.com luca.boccassi at gmail.com
Mon Nov 16 23:52:15 CET 2026


Hi,

FYI, your patch has been queued to stable release 24.11.9

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/18/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/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/aae18714caa20cb96a299f36009940e3b0e332f5

Thanks.

Luca Boccassi

---
>From aae18714caa20cb96a299f36009940e3b0e332f5 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 503ff08894..7ab1749eb3 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -1274,6 +1274,7 @@ test_invalid_rules(void)
 	int ret;
 
 	struct rte_acl_ipv4vlan_rule rule;
+	struct acl_ipv4vlan_rule rv;
 
 	acx = rte_acl_create(&acl_param);
 	if (acx == NULL) {
@@ -1338,6 +1339,31 @@ test_invalid_rules(void)
 		goto err;
 	}
 
+	/* 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);
 
 	return 0;
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 56e3b31ed6..95a33130ea 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -1547,6 +1547,71 @@ acl_bld(struct acl_build_context *bcx, struct rte_acl_ctx *ctx,
 	return rc;
 }
 
+/*
+ * 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.
  */
@@ -1587,7 +1652,7 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
 		}
 	}
 
-	return 0;
+	return acl_check_rules(ctx, cfg);
 }
 
 /*
-- 
2.47.3

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2026-11-16 22:52:18.931962708 +0000
+++ 0061-acl-reject-rules-with-inverted-range.patch	2026-11-16 22:52:16.528234545 +0000
@@ -1 +1 @@
-From c3bbe142bd91c4ce17676ab47965016e22ef9667 Mon Sep 17 00:00:00 2001
+From aae18714caa20cb96a299f36009940e3b0e332f5 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 5d207c80cad..47786bc393e 100644
+index 503ff08894..7ab1749eb3 100644
@@ -77 +78 @@
-index 99d1dbc467f..534a0e14f65 100644
+index 56e3b31ed6..95a33130ea 100644
@@ -80 +81 @@
-@@ -1548,6 +1548,71 @@ acl_bld(struct acl_build_context *bcx, struct rte_acl_ctx *ctx,
+@@ -1547,6 +1547,71 @@ acl_bld(struct acl_build_context *bcx, struct rte_acl_ctx *ctx,
@@ -152 +153 @@
-@@ -1588,7 +1653,7 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
+@@ -1587,7 +1652,7 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)


More information about the stable mailing list