patch 'rib: fix undefined behavior in left shifts' has been queued to stable release 25.11.5
Kevin Traynor
ktraynor at redhat.com
Thu Dec 3 14:06:07 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/fcd76b425b31118051b5ac641f4b363549d76ff1
Thanks.
Kevin
---
>From fcd76b425b31118051b5ac641f4b363549d76ff1 Mon Sep 17 00:00:00 2001
From: Robert Sanford <rsanford at akamai.com>
Date: Tue, 27 Oct 2026 10:54:01 -0400
Subject: [PATCH] rib: fix undefined behavior in left shifts
[ upstream commit 141dd69a5bcf327ad07ce22d1441ffb24754c076 ]
The tree walk in rte_rib.c tests the bit below a node's depth with
1 << (31 - depth). For a node at depth 0, which exists for a default
route or for a common parent of routes in both halves of the address
space, that is 1 << 31 on a signed int, which is undefined behavior.
UBSan reports:
rte_rib.c:82:18: runtime error: left shift of 1 by 31 places
cannot be represented in type 'int'
and the same at lines 311 and 343. No existing unit test adds a
depth-0 route, so this was not caught before. The new test/fib
wraparound test in this series does.
Use an unsigned constant in all four bit tests. The shift count is
between 0 and 31 at each of them.
Fixes: 5a5793a5ffa2 ("rib: add RIB library")
Signed-off-by: Robert Sanford <rsanford at akamai.com>
Acked-by: Vladimir Medvedkin <vladimir.medvedkin at intel.com>
---
lib/rib/rte_rib.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index 046db131ca..43d5ab1498 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -80,5 +80,5 @@ get_nxt_node(struct rte_rib_node *node, uint32_t ip)
if (node->depth == RIB_MAXDEPTH)
return NULL;
- return (ip & (1 << (31 - node->depth))) ? node->right : node->left;
+ return (ip & (1U << (31 - node->depth))) ? node->right : node->left;
}
@@ -309,5 +309,5 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
break;
prev = *tmp;
- tmp = (ip & (1 << (31 - d))) ? &(*tmp)->right : &(*tmp)->left;
+ tmp = (ip & (1U << (31 - d))) ? &(*tmp)->right : &(*tmp)->left;
}
/* closest node found, new_node should be inserted in the middle */
@@ -320,5 +320,5 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
if ((common_prefix == ip) && (common_depth == depth)) {
/* insert as a parent */
- if ((*tmp)->ip & (1 << (31 - depth)))
+ if ((*tmp)->ip & (1U << (31 - depth)))
new_node->right = *tmp;
else
@@ -341,5 +341,5 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
new_node->parent = common_node;
(*tmp)->parent = common_node;
- if ((new_node->ip & (1 << (31 - common_depth))) == 0) {
+ if ((new_node->ip & (1U << (31 - common_depth))) == 0) {
common_node->left = new_node;
common_node->right = *tmp;
--
2.56.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-12-03 12:52:51.659913538 +0000
+++ 0441-rib-fix-undefined-behavior-in-left-shifts.patch 2026-12-03 12:52:39.336867428 +0000
@@ -1 +1 @@
-From 141dd69a5bcf327ad07ce22d1441ffb24754c076 Mon Sep 17 00:00:00 2001
+From fcd76b425b31118051b5ac641f4b363549d76ff1 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 141dd69a5bcf327ad07ce22d1441ffb24754c076 ]
+
@@ -23 +24,0 @@
-Cc: stable at dpdk.org
@@ -32 +33 @@
-index 2ba46393ed..34cfbd1ed4 100644
+index 046db131ca..43d5ab1498 100644
More information about the stable
mailing list