Skip to content

Commit 6a1a219

Browse files
Waiman-LongIngo Molnar
authored andcommitted
locking/lockdep: Prevent abuse of lockdep subclass
To catch the code trying to use a subclass value >= MAX_LOCKDEP_SUBCLASSES (8), add a DEBUG_LOCKS_WARN_ON() statement to notify the users that such a large value is not allowed. [ boqun: Reword the commit log with a more objective tone ] Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Boqun Feng <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Bill Wendling <[email protected]> Cc: Justin Stitt <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 96ca183 commit 6a1a219

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/locking/lockdep.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5101,6 +5101,9 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
51015101
lockevent_inc(lockdep_nocheck);
51025102
}
51035103

5104+
if (DEBUG_LOCKS_WARN_ON(subclass >= MAX_LOCKDEP_SUBCLASSES))
5105+
return 0;
5106+
51045107
if (subclass < NR_LOCKDEP_CACHING_CLASSES)
51055108
class = lock->class_cache[subclass];
51065109
/*

0 commit comments

Comments
 (0)