mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] hwmon: (ina3221): tighten attribute sysfs permissions
@ 2022-11-17  8:39 Ninad Malwade
  2022-11-17 14:27 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Ninad Malwade @ 2022-11-17  8:39 UTC (permalink / raw)
  To: nmalwade, treding, jonathanh, linux, jdelvare, nicolinc, rkasirajan
  Cc: linux-hwmon, linux-kernel, linux-pm

The INA3221 device provides voltage and current measurements for
various power rails, including the CPU rail, on at least some Jetson
boards. This raises the possibility of the Platypus attack being relevant
to Jetson. To prevent this possibility, modify all attribute
channel permissions so that only root can access the values.

This is logically equivalent to 949dd0104c49 ("powercap: restrict energy
meter to root access") upstream.

Signed-off-by: Ninad Malwade <nmalwade@nvidia.com>
---
 drivers/hwmon/ina3221.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c
index e06186986444..ceddcbaa26dc 100644
--- a/drivers/hwmon/ina3221.c
+++ b/drivers/hwmon/ina3221.c
@@ -605,7 +605,7 @@ static umode_t ina3221_is_visible(const void *drvdata,
 		switch (attr) {
 		case hwmon_chip_samples:
 		case hwmon_chip_update_interval:
-			return 0644;
+			return 0600;
 		default:
 			return 0;
 		}
@@ -619,13 +619,13 @@ static umode_t ina3221_is_visible(const void *drvdata,
 			if (channel - 1 <= INA3221_CHANNEL3)
 				input = &ina->inputs[channel - 1];
 			else if (channel == 7)
-				return 0444;
+				return 0400;
 			/* Hide label node if label is not provided */
-			return (input && input->label) ? 0444 : 0;
+			return (input && input->label) ? 0400 : 0;
 		case hwmon_in_input:
-			return 0444;
+			return 0400;
 		case hwmon_in_enable:
-			return 0644;
+			return 0600;
 		default:
 			return 0;
 		}
@@ -634,10 +634,10 @@ static umode_t ina3221_is_visible(const void *drvdata,
 		case hwmon_curr_input:
 		case hwmon_curr_crit_alarm:
 		case hwmon_curr_max_alarm:
-			return 0444;
+			return 0400;
 		case hwmon_curr_crit:
 		case hwmon_curr_max:
-			return 0644;
+			return 0600;
 		default:
 			return 0;
 		}
-- 
2.17.1


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

end of thread, other threads:[~2022-11-17 14:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17  8:39 [PATCH] hwmon: (ina3221): tighten attribute sysfs permissions Ninad Malwade
2022-11-17 14:27 ` Guenter Roeck

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®