[PATCH] amdgpu/pm: Modify sysfs pp_dpm_sclk to have only read premission in ONEVF mode

Nikolic, Marina Marina.Nikolic at amd.com
Tue Dec 21 14:15:07 UTC 2021


[AMD Official Use Only]

Hi Kent,

Thank you for the review. Yes, I can confirm I am trying to set this for every single file for SRIOV mode.
@Kitchen, Greg<mailto:Greg.Kitchen at amd.com> required this for ROCM-SMI 5.0 release. In case you need it, he can provide more details.
I'm going to clarify commit message more and send a new patch.

BR,
Marina
________________________________
From: Russell, Kent <Kent.Russell at amd.com>
Sent: Monday, December 20, 2021 8:01 PM
To: Nikolic, Marina <Marina.Nikolic at amd.com>; amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>
Cc: Mitrovic, Milan <Milan.Mitrovic at amd.com>; Nikolic, Marina <Marina.Nikolic at amd.com>; Kitchen, Greg <Greg.Kitchen at amd.com>
Subject: RE: [PATCH] amdgpu/pm: Modify sysfs pp_dpm_sclk to have only read premission in ONEVF mode

[AMD Official Use Only]

> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Marina Nikolic
> Sent: Monday, December 20, 2021 11:09 AM
> To: amd-gfx at lists.freedesktop.org
> Cc: Mitrovic, Milan <Milan.Mitrovic at amd.com>; Nikolic, Marina
> <Marina.Nikolic at amd.com>; Kitchen, Greg <Greg.Kitchen at amd.com>
> Subject: [PATCH] amdgpu/pm: Modify sysfs pp_dpm_sclk to have only read premission in
> ONEVF mode
>
> == Description ==
> Due to security reasons setting through sysfs
> should only be allowed in passthrough mode.
> Options that are not mapped as SMU messages
> do not have any mechanizm to distinguish between
> passthorugh, onevf and mutivf usecase.
> A unified approach is needed.
>
> == Changes ==
> This patch introduces a new mechanizm to distinguish
> ONEVF and PASSTHROUGH use case on sysfs level
> and prohibit setting (writting to sysfs).
> It also applies the new mechanizm on pp_dpm_sclk sysfs file.
>
> == Test ==
> Writing to pp_dpm_sclk sysfs file in passthrough mode will succeed.
> Writing to pp_dpm_sclk sysfs file in ONEVF mode will yield error:
> "calling process does not have sufficient permission to execute a command".
> Sysfs pp_dpm_sclk will not be created in MULTIVF mode.
>
> Signed-off-by: Marina Nikolic <Marina.Nikolic at amd.com>
> ---
>  drivers/gpu/drm/amd/pm/amdgpu_pm.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> index 082539c70fd4..d2b168babc7d 100644
> --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> @@ -2133,6 +2133,12 @@ static int default_attr_update(struct amdgpu_device *adev,
> struct amdgpu_device_
>               }
>       }
>
> +     /* security: setting should not be allowed from VF */
> +     if (amdgpu_sriov_vf(adev)) {

You should be checking for pp_dpm_sclk here, for example:
                if (DEVICE_ATTR_IS(pp_dpm_sclk) {

Otherwise I am pretty sure you're setting this for every single file. And is it only sclk? Or does it also need to affect mclk/fclk/etc? If it's only sclk, the line above should help. If it's for more, then the commit should try to clarify that as it's not 100% clear.

 Kent

> +             dev_attr->attr.mode &= ~S_IWUGO;
> +             dev_attr->store = NULL;
> +     }
> +
>  #undef DEVICE_ATTR_IS
>
>       return 0;
> --
> 2.20.1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20211221/16041dd3/attachment.htm>


More information about the amd-gfx mailing list