lkml.org 
[lkml]   [2004]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] 64 bit bug in radix-tree lookup.
[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@de.ibm.com>

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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:04    [W:0.024 / U:2.880 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site