patch 'rib: fix undefined behavior in left shifts' has been queued to stable release 24.11.9
luca.boccassi at gmail.com
luca.boccassi at gmail.com
Mon Nov 16 23:52:30 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/4d3c50f089ad1b3f45722e846aba6b9ffb1958ff
Thanks.
Luca Boccassi
---
>From 4d3c50f089ad1b3f45722e846aba6b9ffb1958ff 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 b95d329c8b..a46208b489 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -78,7 +78,7 @@ 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;
}
static struct rte_rib_node *
@@ -301,7 +301,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
if ((d >= depth) || !is_covered(ip, (*tmp)->ip, d))
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 */
common_depth = RTE_MIN(depth, (*tmp)->depth);
@@ -312,7 +312,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
common_prefix = ip & rte_rib_depth_to_mask(common_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
new_node->left = *tmp;
@@ -333,7 +333,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
common_node->parent = (*tmp)->parent;
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;
} else {
--
2.47.3
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-11-16 22:52:19.493116769 +0000
+++ 0076-rib-fix-undefined-behavior-in-left-shifts.patch 2026-11-16 22:52:16.540234862 +0000
@@ -1 +1 @@
-From 141dd69a5bcf327ad07ce22d1441ffb24754c076 Mon Sep 17 00:00:00 2001
+From 4d3c50f089ad1b3f45722e846aba6b9ffb1958ff 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 b95d329c8b..a46208b489 100644
@@ -35 +36 @@
-@@ -79,7 +79,7 @@ get_nxt_node(struct rte_rib_node *node, uint32_t ip)
+@@ -78,7 +78,7 @@ get_nxt_node(struct rte_rib_node *node, uint32_t ip)
@@ -44 +45 @@
-@@ -308,7 +308,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
+@@ -301,7 +301,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
@@ -53 +54 @@
-@@ -319,7 +319,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
+@@ -312,7 +312,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
@@ -62 +63 @@
-@@ -340,7 +340,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
+@@ -333,7 +333,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
More information about the stable
mailing list