mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] locking/lockdep: Prevent abuse of lockdep subclass
@ 2025-04-09 14:37 Waiman Long
  2025-05-04 18:03 ` Boqun Feng
  0 siblings, 1 reply; 2+ messages in thread
From: Waiman Long @ 2025-04-09 14:37 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng
  Cc: linux-kernel, Waiman Long

As I have seen 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.

Signed-off-by: Waiman Long <longman@redhat.com>
---
 kernel/locking/lockdep.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 58d78a33ac65..3fb79d8fecdf 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -5101,6 +5101,9 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
 		lockevent_inc(lockdep_nocheck);
 	}
 
+	if (DEBUG_LOCKS_WARN_ON(subclass >= MAX_LOCKDEP_SUBCLASSES))
+		return 0;
+
 	if (subclass < NR_LOCKDEP_CACHING_CLASSES)
 		class = lock->class_cache[subclass];
 	/*
-- 
2.48.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] locking/lockdep: Prevent abuse of lockdep subclass
  2025-04-09 14:37 [PATCH] locking/lockdep: Prevent abuse of lockdep subclass Waiman Long
@ 2025-05-04 18:03 ` Boqun Feng
  0 siblings, 0 replies; 2+ messages in thread
From: Boqun Feng @ 2025-05-04 18:03 UTC (permalink / raw)
  To: Waiman Long; +Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, linux-kernel

On Wed, Apr 09, 2025 at 10:37:51AM -0400, Waiman Long wrote:
> As I have seen 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.
> 
> Signed-off-by: Waiman Long <longman@redhat.com>

Queued for 6.16, thanks!

Regards,
Boqun

> ---
>  kernel/locking/lockdep.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 58d78a33ac65..3fb79d8fecdf 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -5101,6 +5101,9 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
>  		lockevent_inc(lockdep_nocheck);
>  	}
>  
> +	if (DEBUG_LOCKS_WARN_ON(subclass >= MAX_LOCKDEP_SUBCLASSES))
> +		return 0;
> +
>  	if (subclass < NR_LOCKDEP_CACHING_CLASSES)
>  		class = lock->class_cache[subclass];
>  	/*
> -- 
> 2.48.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-04 18:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-09 14:37 [PATCH] locking/lockdep: Prevent abuse of lockdep subclass Waiman Long
2025-05-04 18:03 ` Boqun Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®