amdgpu/pm: Modify sysfs pp_dpm_sclk to have only read premission in ONEVF mode
Subsystems (3)
PATCH 1/1 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.
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 2 +- drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -1
@@ -2021,7 +2021,7 @@ static struct amdgpu_device_attr amdgpu_device_attrs[] = {AMDGPU_DEVICE_ATTR_RO (pp_cur_state,ATTR_FLAG_BASIC |ATTR_FLAG_ONEVF ),AMDGPU_DEVICE_ATTR_RW (pp_force_state,ATTR_FLAG_BASIC |ATTR_FLAG_ONEVF ),AMDGPU_DEVICE_ATTR_RW (pp_table,ATTR_FLAG_BASIC |ATTR_FLAG_ONEVF ), -AMDGPU_DEVICE_ATTR_RW (pp_dpm_sclk,ATTR_FLAG_BASIC |ATTR_FLAG_ONEVF ), +AMDGPU_DEVICE_ATTR_RRW (pp_dpm_sclk,ATTR_FLAG_BASIC ,ATTR_FLAG_ONEVF ),AMDGPU_DEVICE_ATTR_RW (pp_dpm_mclk,ATTR_FLAG_BASIC |ATTR_FLAG_ONEVF ),AMDGPU_DEVICE_ATTR_RW (pp_dpm_socclk,ATTR_FLAG_BASIC |ATTR_FLAG_ONEVF ), AMDGPU_DEVICE_ATTR_RW(pp_dpm_fclk, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF),
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h +4 -0
@@ -79,6 +79,10 @@ struct amdgpu_device_attr_entry { amdgpu_get_##_name, NULL, \ _flags, ##__VA_ARGS__) +#define AMDGPU_DEVICE_ATTR_RRW(_name, _flags_full, _flags_restricted, ...) \ + AMDGPU_DEVICE_ATTR_RW(_name, _flags_full, ##__VA_ARGS__), \ + AMDGPU_DEVICE_ATTR_RO(_name, _flags_restricted, ##__VA_ARGS__) + int amdgpu_pm_sysfs_init(struct amdgpu_device *adev); int amdgpu_pm_virt_sysfs_init(struct amdgpu_device *adev);void amdgpu_pm_sysfs_fini (struct amdgpu_device *adev);
Signature · 1 line
2.20.1
[AMD Official Use Only]
Please ignore this one.
There was some issue, and all changes are not included in the patch. I have sent an update in a new mail (same subject).
Sorry for inconvenience.
BR,
Marina
________________________________
From: Marina Nikolic <[email protected]>
Sent: Friday, December 10, 2021 1:00 PM
To: [email protected] <[email protected]>
Cc: Nikolic, Marina <[email protected]>; Nikolic, Marina <[email protected]>
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.
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 2 +- drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -1
@@ -2021,7 +2021,7 @@ static struct amdgpu_device_attr amdgpu_device_attrs[] = {AMDGPU_DEVICE_ATTR_RO (pp_cur_state,ATTR_FLAG_BASIC |ATTR_FLAG_ONEVF ),AMDGPU_DEVICE_ATTR_RW (pp_force_state,ATTR_FLAG_BASIC |ATTR_FLAG_ONEVF ),AMDGPU_DEVICE_ATTR_RW (pp_table,ATTR_FLAG_BASIC |ATTR_FLAG_ONEVF ), -AMDGPU_DEVICE_ATTR_RW (pp_dpm_sclk,ATTR_FLAG_BASIC |ATTR_FLAG_ONEVF ), +AMDGPU_DEVICE_ATTR_RRW (pp_dpm_sclk,ATTR_FLAG_BASIC ,ATTR_FLAG_ONEVF ),AMDGPU_DEVICE_ATTR_RW (pp_dpm_mclk,ATTR_FLAG_BASIC |ATTR_FLAG_ONEVF ),AMDGPU_DEVICE_ATTR_RW (pp_dpm_socclk,ATTR_FLAG_BASIC |ATTR_FLAG_ONEVF ), AMDGPU_DEVICE_ATTR_RW(pp_dpm_fclk, ATTR_FLAG_BASIC|ATTR_FLAG_ONEVF),
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h +4 -0
@@ -79,6 +79,10 @@ struct amdgpu_device_attr_entry { amdgpu_get_##_name, NULL, \ _flags, ##__VA_ARGS__) +#define AMDGPU_DEVICE_ATTR_RRW(_name, _flags_full, _flags_restricted, ...) \ + AMDGPU_DEVICE_ATTR_RW(_name, _flags_full, ##__VA_ARGS__), \ + AMDGPU_DEVICE_ATTR_RO(_name, _flags_restricted, ##__VA_ARGS__) + int amdgpu_pm_sysfs_init(struct amdgpu_device *adev); int amdgpu_pm_virt_sysfs_init(struct amdgpu_device *adev);void amdgpu_pm_sysfs_fini (struct amdgpu_device *adev);
--
2.20.1