* [PATCH] scsi: Correct sysfs attributes access rights
@ 2025-07-28 4:17 Damien Le Moal
2025-07-28 9:40 ` John Garry
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Damien Le Moal @ 2025-07-28 4:17 UTC (permalink / raw)
To: Martin K . Petersen, linux-scsi
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.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
drivers/scsi/scsi_sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index d772258e29ad..e6464b998960 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -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)
{
--
2.50.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] scsi: Correct sysfs attributes access rights
2025-07-28 4:17 [PATCH] scsi: Correct sysfs attributes access rights Damien Le Moal
@ 2025-07-28 9:40 ` John Garry
2025-07-28 9:52 ` Damien Le Moal
2025-07-28 10:46 ` Johannes Thumshirn
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: John Garry @ 2025-07-28 9:40 UTC (permalink / raw)
To: Damien Le Moal, Martin K . Petersen, linux-scsi
On 28/07/2025 05:17, Damien Le Moal wrote:
> 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.
>
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Note that class_attr_store() returns -EIO for no store method. Does the
same happen after this change?
> ---
> drivers/scsi/scsi_sysfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index d772258e29ad..e6464b998960 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -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)
> {
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] scsi: Correct sysfs attributes access rights
2025-07-28 9:40 ` John Garry
@ 2025-07-28 9:52 ` Damien Le Moal
2025-07-28 9:57 ` John Garry
0 siblings, 1 reply; 7+ messages in thread
From: Damien Le Moal @ 2025-07-28 9:52 UTC (permalink / raw)
To: John Garry, Martin K . Petersen, linux-scsi
On 7/28/25 6:40 PM, John Garry wrote:
> On 28/07/2025 05:17, Damien Le Moal wrote:
>> 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.
>>
>> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
>
> Reviewed-by: John Garry <john.g.garry@oracle.com>
>
> Note that class_attr_store() returns -EIO for no store method. Does the same
> happen after this change?
The regular Permission Denied (-EPERM) is returned.
Do you think that is a problem ?
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] scsi: Correct sysfs attributes access rights
2025-07-28 9:52 ` Damien Le Moal
@ 2025-07-28 9:57 ` John Garry
0 siblings, 0 replies; 7+ messages in thread
From: John Garry @ 2025-07-28 9:57 UTC (permalink / raw)
To: Damien Le Moal, Martin K . Petersen, linux-scsi
On 28/07/2025 10:52, Damien Le Moal wrote:
>> Note that class_attr_store() returns -EIO for 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).
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] scsi: Correct sysfs attributes access rights
2025-07-28 4:17 [PATCH] scsi: Correct sysfs attributes access rights Damien Le Moal
2025-07-28 9:40 ` John Garry
@ 2025-07-28 10:46 ` Johannes Thumshirn
2025-07-29 2:33 ` Martin K. Petersen
2025-08-06 2:39 ` Martin K. Petersen
3 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2025-07-28 10:46 UTC (permalink / raw)
To: Damien Le Moal, Martin K . Petersen, linux-scsi@vger.kernel.org
Looks good,
Reviewed-by: Johannes Thumshin <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] scsi: Correct sysfs attributes access rights
2025-07-28 4:17 [PATCH] scsi: Correct sysfs attributes access rights Damien Le Moal
2025-07-28 9:40 ` John Garry
2025-07-28 10:46 ` Johannes Thumshirn
@ 2025-07-29 2:33 ` Martin K. Petersen
2025-08-06 2:39 ` Martin K. Petersen
3 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2025-07-29 2:33 UTC (permalink / raw)
To: Damien Le Moal; +Cc: Martin K . Petersen, linux-scsi
Damien,
> 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.
Applied to 6.17/scsi-staging, thanks!
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] scsi: Correct sysfs attributes access rights
2025-07-28 4:17 [PATCH] scsi: Correct sysfs attributes access rights Damien Le Moal
` (2 preceding siblings ...)
2025-07-29 2:33 ` Martin K. Petersen
@ 2025-08-06 2:39 ` Martin K. Petersen
3 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2025-08-06 2:39 UTC (permalink / raw)
To: linux-scsi, Damien Le Moal; +Cc: Martin K . Petersen
On Mon, 28 Jul 2025 13:17:00 +0900, Damien Le Moal wrote:
> 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.
>
>
Applied to 6.17/scsi-queue, thanks!
[1/1] scsi: Correct sysfs attributes access rights
https://git.kernel.org/mkp/scsi/c/a2f54ff15c3b
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-08-06 2:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-28 4:17 [PATCH] scsi: Correct sysfs attributes access rights Damien Le Moal
2025-07-28 9:40 ` John Garry
2025-07-28 9:52 ` Damien Le Moal
2025-07-28 9:57 ` John Garry
2025-07-28 10:46 ` Johannes Thumshirn
2025-07-29 2:33 ` Martin K. Petersen
2025-08-06 2:39 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox