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]
Date:	Mon, 30 May 2016 23:31:36 -0700
From:	Eduardo Valentin <edubezval@...il.com>
To:	Rui Zhang <rui.zhang@...el.com>
Cc:	Linux PM <linux-pm@...r.kernel.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Eduardo Valentin <edubezval@...il.com>
Subject: [PATCH 15/15] thermal: sysfs: add comments describing locking strategy

The locking strategy of sysfs entries in thermal subsystem
is to hold a lock to serialize access to struct thermal_zone_device
and struct thermal_cooling_device data. Besides, the respective
locks will also be held if calls to ops need to be done to fetch
data or to trigger driver actions.

The exception of the locking strategy are functions called
during initialization of cdev and tz.

Cc: Zhang Rui <rui.zhang@...el.com>
Cc: linux-pm@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@...il.com>
---
 drivers/thermal/thermal_sysfs.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index 31314be..743df50 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -23,7 +23,14 @@
 
 #include "thermal_core.h"
 
-/* sys I/F for thermal zone */
+/*
+ * sys I/F for thermal zone
+ *
+ * Note on locking. The sysfs interface will always first
+ * lock the zone to serialize data access and ops calls.
+ * All calls to thermal_core and thermal_helpers are assumed
+ * to handle locking properly.
+ */
 
 static ssize_t
 type_show(struct device *dev, struct device_attribute *attr, char *buf)
@@ -555,6 +562,9 @@ static const struct attribute_group *thermal_zone_attribute_groups[] = {
  * helper function to instantiate sysfs entries for every trip
  * point and its properties of a struct thermal_zone_device.
  *
+ * This function is assumed to be called only during probe,
+ * and therefore no locking in the thermal zone device is done.
+ *
  * Return: 0 on success, the proper error value otherwise.
  */
 static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
@@ -770,6 +780,10 @@ static const struct attribute_group *cooling_device_attr_groups[] = {
 	NULL,
 };
 
+/*
+ * Assumed to be called at the creation of the cooling device
+ * and for this reason, no locking is done
+ */
 void thermal_cooling_device_setup_sysfs(struct thermal_cooling_device *cdev)
 {
 	cdev->device.groups = cooling_device_attr_groups;
-- 
2.1.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ