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-8-bvanassche@acm.org>
Date: Thu,  6 Feb 2025 09:50:48 -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 07/33] driver core: Annotate locking functions in <linux/device.h>

Annotate the locking functions in <linux/device.h> with thread-safety
attributes.

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

diff --git a/include/linux/device.h b/include/linux/device.h
index 80a5b3268986..125b89fda3af 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -31,6 +31,7 @@
 #include <linux/device/class.h>
 #include <linux/device/driver.h>
 #include <linux/cleanup.h>
+#include <linux/thread_safety.h>
 #include <asm/device.h>
 
 struct device;
@@ -1026,21 +1027,25 @@ static inline bool dev_pm_test_driver_flags(struct device *dev, u32 flags)
 }
 
 static inline void device_lock(struct device *dev)
+	ACQUIRE(dev->mutex)
 {
 	mutex_lock(&dev->mutex);
 }
 
 static inline int device_lock_interruptible(struct device *dev)
+	TRY_ACQUIRE(0, dev->mutex)
 {
 	return mutex_lock_interruptible(&dev->mutex);
 }
 
 static inline int device_trylock(struct device *dev)
+	TRY_ACQUIRE(1, dev->mutex)
 {
 	return mutex_trylock(&dev->mutex);
 }
 
 static inline void device_unlock(struct device *dev)
+	RELEASE(dev->mutex)
 {
 	mutex_unlock(&dev->mutex);
 }
@@ -1182,9 +1187,11 @@ do { \
 				  _THIS_IP_);                          \
 } while (0)
 
-void lock_device_hotplug(void);
-void unlock_device_hotplug(void);
-int lock_device_hotplug_sysfs(void);
+DEFINE_CAPABILITY(device_hotplug_capability);
+
+void lock_device_hotplug(void) ACQUIRE(device_hotplug_capability);
+void unlock_device_hotplug(void) RELEASE(device_hotplug_capability);
+int lock_device_hotplug_sysfs(void) TRY_ACQUIRE(0, device_hotplug_capability);
 int device_offline(struct device *dev);
 int device_online(struct device *dev);
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ