lkml.org 
[lkml]   [2021]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 2/2] scsi: ufs: Protect PM ops and err_handler from user access through sysfs
On 2021-01-13 22:53, Adrian Hunter wrote:
> On 13/01/21 3:57 pm, Can Guo wrote:
>> User layer may access sysfs nodes when system PM ops or error handling
>> is running, which can cause various problems. Rename eh_sem to
>> host_sem
>> and use it to protect PM ops and error handling from user layer
>> intervene.
>>
>> Acked-by: Avri Altman <avri.altman@wdc.com>
>> Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
>> Signed-off-by: Can Guo <cang@codeaurora.org>
>> ---
>> drivers/scsi/ufs/ufs-sysfs.c | 106
>> ++++++++++++++++++++++++++++++++++++-------
>> drivers/scsi/ufs/ufshcd.c | 42 ++++++++++-------
>> drivers/scsi/ufs/ufshcd.h | 10 +++-
>> 3 files changed, 125 insertions(+), 33 deletions(-)
>>
>> diff --git a/drivers/scsi/ufs/ufs-sysfs.c
>> b/drivers/scsi/ufs/ufs-sysfs.c
>> index 0e14384..7cafffc 100644
>> --- a/drivers/scsi/ufs/ufs-sysfs.c
>> +++ b/drivers/scsi/ufs/ufs-sysfs.c
>> @@ -154,18 +154,29 @@ static ssize_t auto_hibern8_show(struct device
>> *dev,
>> struct device_attribute *attr, char *buf)
>> {
>> u32 ahit;
>> + int ret;
>> struct ufs_hba *hba = dev_get_drvdata(dev);
>>
>> if (!ufshcd_is_auto_hibern8_supported(hba))
>> return -EOPNOTSUPP;
>>
>> + down(&hba->host_sem);
>> + if (!ufshcd_is_sysfs_allowed(hba)) {
>
> I expect debugfs has the same potential problem, so maybe
> ufshcd_is_sysfs_allowed() is not quite the right name.

I noticed your debugfs change - currently it is only printing
error counts recorded in hba struct, which is fine.
Even in this patch, the check is only added for those entries
which need to talk with HW. Sysfs nodes like show/store rpm/spm_lvl
does not need this check.

Thanks,
Can Guo.

>
>> + ret = -EBUSY;
>> + goto out;
>> + }
>> +

\
 
 \ /
  Last update: 2021-01-14 02:24    [W:0.594 / U:0.340 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site