Skip to content

Commit 3ec320d

Browse files
Alexander Duyckdavem330
authored andcommitted
fib_trie: Correctly handle case of key == 0 in leaf_walk_rcu
In the case of a trie that had no tnodes with a key of 0 the initial look-up would fail resulting in an out-of-bounds cindex on the first tnode. This resulted in an entire trie being skipped. In order resolve this I have updated the cindex logic in the initial look-up so that if the key is zero we will always traverse the child zero path. Fixes: 8be33e9 ("fib_trie: Fib walk rcu should take a tnode and key instead of a trie and a leaf") Reported-by: Sabrina Dubroca <[email protected]> Signed-off-by: Alexander Duyck <[email protected]> Tested-by: Sabrina Dubroca <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7c23aaf commit 3ec320d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/ipv4/fib_trie.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ static struct key_vector *leaf_walk_rcu(struct key_vector **tn, t_key key)
15301530
do {
15311531
/* record parent and next child index */
15321532
pn = n;
1533-
cindex = get_index(key, pn);
1533+
cindex = key ? get_index(key, pn) : 0;
15341534

15351535
if (cindex >> pn->bits)
15361536
break;

0 commit comments

Comments
 (0)