Skip to contentSkip to conversation

nvme: make the DH-HMAC-CHAP secret attributes readable by root only

PATCH Superseded Martin Belanger 2 participants 2 messages Oct 13 – Oct 14

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: make the DH-HMAC-CHAP secret attributes readable by root only

The dhchap_secret and dhchap_ctrl_secret sysfs attributes have mode 0644. Their show functions return the secret, so any local user can read the DH-HMAC-CHAP secrets of a connected controller.

Change the mode to 0600. Writing the attributes was already limited to root and is not changed.

Fixes f50fff73d620 ("nvme: implement In-Band authentication")
Cc Daniel Wagner <[email protected]>
Assisted-by LLM
---
 drivers/nvme/host/sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/sysfs.c +2 -2
index e1e3dcfd084b..e0cb34545b97 100644
@@ -864,7 +864,7 @@ static ssize_t nvme_ctrl_dhchap_secret_store(struct device *dev,
 	return count;
 }
 
-static DEVICE_ATTR(dhchap_secret, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(dhchap_secret, 0600,
 	nvme_ctrl_dhchap_secret_show, nvme_ctrl_dhchap_secret_store);
 
 static ssize_t nvme_ctrl_dhchap_ctrl_secret_show(struct device *dev,
@@ -922,7 +922,7 @@ static ssize_t nvme_ctrl_dhchap_ctrl_secret_store(struct device *dev,
 	return count;
 }
 
-static DEVICE_ATTR(dhchap_ctrl_secret, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(dhchap_ctrl_secret, 0600,
 	nvme_ctrl_dhchap_ctrl_secret_show, nvme_ctrl_dhchap_ctrl_secret_store);
 #endif
 
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 21 lines · Martin Belanger

The dhchap_secret and dhchap_ctrl_secret sysfs attributes have mode 0644. Their show functions return the secret, so any local user can read the DH-HMAC-CHAP secrets of a connected controller.

Change the mode to 0600. Writing the attributes was already limited to root and is not changed.

Fixes f50fff73d620 ("nvme: implement In-Band authentication")
Cc Daniel Wagner <[email protected]>
Assisted-by LLM
---
 drivers/nvme/host/sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/sysfs.c +0 -0
index e1e3dcfd084b..e0cb34545b97 100644

drivers/nvme/host/sysfs.c static ssize_t nvme_ctrl_dhchap_secret_store(struct device *dev, · line 868

Quoted 6 lines
drivers/nvme/host/sysfs.c +1 -1
@@ -864,7 +864,7 @@ static ssize_t nvme_ctrl_dhchap_secret_store(struct device *dev,
 	return count;
 }
 
-static DEVICE_ATTR(dhchap_secret, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(dhchap_secret, 0600,
 	nvme_ctrl_dhchap_secret_show, nvme_ctrl_dhchap_secret_store);

DEVICE_ATTR_ADMIN_RW() perhaps?

And no need to cc: [email protected] for public patches.

thanks,

greg k-h