[PATCH] 64 bit bug in radix-tree lookup.

From: Martin Schwidefsky
Date: Wed Jun 30 2004 - 12:10:14 EST


[PATCH] 64 bit bug in radix-tree lookup.

The radix tree functions __lookup and __lookup_tag uses (1 << shift)
in their index calculations. On 64 bit systems the shift can be
bigger than 32. The shift of an integer by more than 32 bits evaluates
to zero which causes the lookup to fail.

Signed-off-by: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>

diffstat:
lib/radix-tree.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diff -urN linux-2.6/lib/radix-tree.c linux-2.6-s390/lib/radix-tree.c
--- linux-2.6/lib/radix-tree.c Wed Jun 30 17:06:23 2004
+++ linux-2.6-s390/lib/radix-tree.c Wed Jun 30 17:06:32 2004
@@ -494,8 +494,8 @@
for ( ; i < RADIX_TREE_MAP_SIZE; i++) {
if (slot->slots[i] != NULL)
break;
- index &= ~((1 << shift) - 1);
- index += 1 << shift;
+ index &= ~((1UL << shift) - 1);
+ index += 1UL << shift;
if (index == 0)
goto out; /* 32-bit wraparound */
}
@@ -584,8 +584,8 @@
BUG_ON(slot->slots[i] == NULL);
break;
}
- index &= ~((1 << shift) - 1);
- index += 1 << shift;
+ index &= ~((1UL << shift) - 1);
+ index += 1UL << shift;
if (index == 0)
goto out; /* 32-bit wraparound */
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/