DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Sanford <rsanford2@gmail.com>
To: dev@dpdk.org
Cc: vladimir.medvedkin@intel.com,
	Robert Sanford <rsanford@akamai.com>,
	stable@dpdk.org
Subject: [PATCH v1 1/4] fib: fix full table overwrite on address wraparound
Date: Mon, 26 Oct 2026 20:14:20 -0400	[thread overview]
Message-ID: <20261027001423.3028072-2-rsanford2@gmail.com> (raw)
In-Reply-To: <20261027001423.3028072-1-rsanford2@gmail.com>

From: Robert Sanford <rsanford@akamai.com>

When a prefix whose range ends at 255.255.255.255 is added, deleted,
or has its next hop changed, modify_fib() walks the more-specific
routes under it and installs the next hop into the gaps. If the last
of those routes starts exactly at the current left edge and ends at
255.255.255.255, the equal-edges branch advances ledge past it, and
ledge wraps to 0. That branch has no wraparound check, so the loop
continues. With no more routes, the final branch computes redge,
which also wraps to 0. Its ledge != 0 exception, which exists for a
default route added as the first route, lets the call through, and
install_to_fib(dp, 0, 0, nh) overwrites the entire table. The call
returns 0, so the corruption is silent.

For example, with 0.0.0.0/0, 0.0.0.0/1 and 128.0.0.0/1 installed,
deleting 0.0.0.0/0 makes every lookup miss. With 10.0.0.0/8,
255.255.255.0/25 and 255.255.255.128/25 installed, adding
255.255.255.0/24 makes every address, including 10.1.1.1, return the
/24's next hop.

Commit ab1b927cd73e ("fib: fix adding default route overwriting
entire table") added the wraparound check to the other branch only.
Add the same check to the equal-edges branch.

Fixes: 880bc2b5f3bd ("fib: fix adding default route")
Cc: stable@dpdk.org

Signed-off-by: Robert Sanford <rsanford@akamai.com>
---
 lib/fib/dir24_8.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/fib/dir24_8.c b/lib/fib/dir24_8.c
index c135285a65..68029c6165 100644
--- a/lib/fib/dir24_8.c
+++ b/lib/fib/dir24_8.c
@@ -436,6 +436,12 @@ modify_fib(struct dir24_8_tbl *dp, struct rte_rib *rib, uint32_t ip,
 			if (ledge == redge) {
 				ledge = redge +
 					(uint32_t)(1ULL << (32 - tmp_depth));
+				/*
+				 * we got to the end of address space
+				 * and wrapped around
+				 */
+				if (ledge == 0)
+					break;
 				continue;
 			}
 			ret = install_to_fib(dp, ledge, redge,
-- 
2.34.1


  reply	other threads:[~2026-10-27  0:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27  0:14 [PATCH v1 0/4] fib: fix full table overwrite on address wraparound Robert Sanford
2026-10-27  0:14 ` Robert Sanford [this message]
2026-10-27  0:14 ` [PATCH v1 2/4] fib6: " Robert Sanford
2026-10-27  0:14 ` [PATCH v1 3/4] test/fib: reproduce " Robert Sanford
2026-10-27  0:14 ` [PATCH v1 4/4] test/fib6: " Robert Sanford
2026-10-27 14:54 ` [PATCH v2 0/5] fib: fix full " Robert Sanford
2026-10-27 14:54   ` [PATCH v2 1/5] rib: fix undefined behavior in bit test Robert Sanford
2026-10-27 14:54   ` [PATCH v2 2/5] fib: fix full table overwrite on address wraparound Robert Sanford
2026-10-27 14:54   ` [PATCH v2 3/5] fib6: " Robert Sanford
2026-10-27 14:54   ` [PATCH v2 4/5] test/fib: reproduce " Robert Sanford
2026-10-27 14:54   ` [PATCH v2 5/5] test/fib6: " Robert Sanford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261027001423.3028072-2-rsanford2@gmail.com \
    --to=rsanford2@gmail.com \
    --cc=dev@dpdk.org \
    --cc=rsanford@akamai.com \
    --cc=stable@dpdk.org \
    --cc=vladimir.medvedkin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox