mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ninad Malwade <nmalwade@nvidia.com>
To: <nmalwade@nvidia.com>, <treding@nvidia.com>,
	<jonathanh@nvidia.com>, <linux@roeck-us.net>, <jdelvare@suse.com>,
	<nicolinc@nvidia.com>, <rkasirajan@nvidia.com>
Cc: <linux-hwmon@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-pm@vger.kernel.org>
Subject: [PATCH] hwmon: (ina3221): tighten attribute sysfs permissions
Date: Thu, 17 Nov 2022 16:39:20 +0800	[thread overview]
Message-ID: <20221117083920.20493-1-nmalwade@nvidia.com> (raw)

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


             reply	other threads:[~2022-11-17  8:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17  8:39 Ninad Malwade [this message]
2022-11-17 14:27 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221117083920.20493-1-nmalwade@nvidia.com \
    --to=nmalwade@nvidia.com \
    --cc=jdelvare@suse.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=nicolinc@nvidia.com \
    --cc=rkasirajan@nvidia.com \
    --cc=treding@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®