diff mbox series

hwmon: (ina3221): tighten attribute sysfs permissions

Message ID 20221117083920.20493-1-nmalwade@nvidia.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series hwmon: (ina3221): tighten attribute sysfs permissions | expand

Commit Message

Ninad Malwade Nov. 17, 2022, 8:39 a.m. UTC
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(-)

Comments

Guenter Roeck Nov. 17, 2022, 2:27 p.m. UTC | #1
On Thu, Nov 17, 2022 at 04:39:20PM +0800, Ninad Malwade wrote:
> 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.

NACK. The hwmon ABI expects all attributes to be readable for everyone.
Forcing userspace to have root privilege to read sensor values just moves
the attack vector into the affected applications.

You have a number of options:

1) Make the values reported vague enough to be useless for attacks
2) Remove the attributes
3) Remove the driver

2) and 3) are obviously unacceptable here. Your option would be to
disable the driver on the affected system.

Having said that, for me to accept any driver change, you would have to
prove that the values reported by the chip are really accurate enough to
be useful in any attack (most chips do not deliver that level of accuracy).
A generic statement along the line of "raises the possibility" is
insufficient.

> This is logically equivalent to 949dd0104c49 ("powercap: restrict energy
> meter to root access") upstream.
 
The change in the powercap driver is not hwmon ABI related and
irrelevant. If you look for an example, use commit 9049572fb145
("hwmon: Remove amd_energy driver").

Guenter
diff mbox series

Patch

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;
 		}