lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250206175114.1974171-9-bvanassche@acm.org>
Date: Thu,  6 Feb 2025 09:50:49 -0800
From: Bart Van Assche <bvanassche@....org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Will Deacon <will@...nel.org>,
	Christoph Hellwig <hch@....de>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Marco Elver <elver@...gle.com>,
	Nick Desaulniers <ndesaulniers@...gle.com>,
	Nathan Chancellor <nathan@...nel.org>,
	Kees Cook <kees@...nel.org>,
	Jann Horn <jannh@...gle.com>,
	linux-kernel@...r.kernel.org,
	Bart Van Assche <bvanassche@....org>
Subject: [PATCH RFC 08/33] kref: Add thread-safety annotations in <linux/kref.h>

Inform the Clang thread-safety analyzer that kref_put_mutex() callers
must not hold *mutex.

Note: annotating that the 'release' function pointer releases 'mutex' is
not possible because the mutex pointer is not an argument of the 'release'
function.

Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Signed-off-by: Bart Van Assche <bvanassche@....org>
---
 include/linux/kref.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/kref.h b/include/linux/kref.h
index 88e82ab1367c..29c31b103557 100644
--- a/include/linux/kref.h
+++ b/include/linux/kref.h
@@ -15,6 +15,7 @@
 
 #include <linux/spinlock.h>
 #include <linux/refcount.h>
+#include <linux/thread_safety.h>
 
 struct kref {
 	refcount_t refcount;
@@ -81,6 +82,8 @@ static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref)
 static inline int kref_put_mutex(struct kref *kref,
 				 void (*release)(struct kref *kref),
 				 struct mutex *mutex)
+	EXCLUDES(*mutex)
+	NO_THREAD_SAFETY_ANALYSIS
 {
 	if (refcount_dec_and_mutex_lock(&kref->refcount, mutex)) {
 		release(kref);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ