From: Peter Zijlstra Date: Mon, 11 Aug 2008 10:34:42 +0000 (+0200) Subject: lockdep: fix overflow in the hlock shrinkage code X-Git-Tag: v2.6.27-rc3~50^2^2~2 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b42e737e576339c795d9ac77a1fce6057f6bc0cf;p=linux-2.6 lockdep: fix overflow in the hlock shrinkage code There is a overflow by 1 case in the new shrunken hlock code. Signed-off-by: Peter Zijlstra Signed-off-by: Ingo Molnar --- diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 67f42b300c..c88aa3d8e8 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -191,7 +191,12 @@ struct lock_chain { }; #define MAX_LOCKDEP_KEYS_BITS 11 -#define MAX_LOCKDEP_KEYS (1UL << MAX_LOCKDEP_KEYS_BITS) +/* + * Subtract one because we offset hlock->class_idx by 1 in order + * to make 0 mean no class. This avoids overflowing the class_idx + * bitfield and hitting the BUG in hlock_class(). + */ +#define MAX_LOCKDEP_KEYS ((1UL << MAX_LOCKDEP_KEYS_BITS) - 1) struct held_lock { /*