scsi: Correct sysfs attributes access rights
PATCH 1/1 scsi: Correct sysfs attributes access rights
The scsi sysfs attributes "supported_mode" and "active_mode" do not define a store method and thus cannot be modified. Correct the DEVICE_ATTR() call for these two attributes to not include S_IWUSR to allow write access as they are read-only.
--- drivers/scsi/scsi_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/scsi_sysfs.c +2 -2
@@ -265,7 +265,7 @@ show_shost_supported_mode(struct device *dev, struct device_attribute *attr,return show_shost_mode (supported_mode, buf); } -static DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL); +static DEVICE_ATTR(supported_mode, S_IRUGO, show_shost_supported_mode, NULL); static ssize_t show_shost_active_mode(struct device *dev,
@@ -279,7 +279,7 @@ show_shost_active_mode(struct device *dev,return show_shost_mode (shost->active_mode, buf); } -static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL); +static DEVICE_ATTR(active_mode, S_IRUGO, show_shost_active_mode, NULL);static int check_reset_type (const char *str) {
Signature · 1 line
2.50.1
Quoted 6 lines · Damien Le Moal
The scsi sysfs attributes "
supported_mode" and "active_mode" do not define a store method and thus cannot be modified. Correct theDEVICE_ATTR()call for these two attributes to not includeS_IWUSRto allow write access as they are read-only.Signed-off-by Damien Le Moal <[email protected]>
Note that class_attr_store() returns -EIO for no store method. Does the same happen after this change?
Quoted 26 lines
--- drivers/scsi/scsi_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/scsi/scsi_sysfs.c +2
-2@@ -265,7 +265,7 @@ show_shost_supported_mode(struct device *dev, struct device_attribute *attr,return show_shost_mode (supported_mode, buf); } -static DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL); +static DEVICE_ATTR(supported_mode, S_IRUGO, show_shost_supported_mode, NULL); static ssize_t show_shost_active_mode(struct device *dev,@@ -279,7 +279,7 @@ show_shost_active_mode(struct device *dev,return show_shost_mode (shost->active_mode, buf); } -static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL); +static DEVICE_ATTR(active_mode, S_IRUGO, show_shost_active_mode, NULL);static int check_reset_type (const char *str) {
Quoted 6 lines · John Garry
Quoted 5 lines · Damien Le Moal
The scsi sysfs attributes "
supported_mode" and "active_mode" do not define a store method and thus cannot be modified. Correct theDEVICE_ATTR()call for these two attributes to not includeS_IWUSRto allow write access as they are read-only.
Quoted 6 lines
Quoted 1 line
Signed-off-by Damien Le Moal <[email protected]>Reviewed-by John Garry <[email protected]>Note that
class_attr_store()returns-EIOfor no store method. Does the same happen after this change?
The regular Permission Denied (-EPERM) is returned. Do you think that is a problem ?
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 4 lines · Damien Le Moal
Quoted 2 lines
Note that
class_attr_store()returns-EIOfor no store method. Does the same happen after this change?The regular Permission Denied (
-EPERM) is returned. Do you think that is a problem ?
Probably not. I can't imagine that any sane application would rely on that behavior (of returning -EIO).
Looks good,
Martin K. Petersen
AppliedDamien,
Quoted 4 lines
The scsi sysfs attributes "
supported_mode" and "active_mode" do not define a store method and thus cannot be modified. Correct theDEVICE_ATTR()call for these two attributes to not includeS_IWUSRto allow write access as they are read-only.
Applied to 6.17/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen
Martin K. Petersen
AppliedQuoted 6 lines · Damien Le Moal
The scsi sysfs attributes "
supported_mode" and "active_mode" do not define a store method and thus cannot be modified. Correct theDEVICE_ATTR()call for these two attributes to not includeS_IWUSRto allow write access as they are read-only.
Applied to 6.17/scsi-queue, thanks!
[1/1] scsi: Correct sysfs attributes access rights
https://git.kernel.org/mkp/scsi/c/a2f54ff15c3b
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering