drm/amd/pm/smu11: Prevent division by zero
Subsystems (3)
PATCH 1/1 drm/amd/pm/smu11: Prevent division by zero
The user can set any speed value.
If speed is greater than UINT_MAX/8, division by zero is possible.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +1 -1
@@ -1200,7 +1200,7 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu,uint32_t crystal_clock_freq =2500 ;uint32_t tach_period; -if (speed ==0 ) +if (!speed || speed >UINT_MAX /8 )return -EINVAL ;/* * To prevent from possible overheat, some ASICs may have requirement
Signature · 1 line
2.43.0
Quoted 8 lines · Denis Arefev
The user can set any speed value.
If speed is greater than UINT_MAX/8, division by zero is possible.Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes 1e866f1fe528 ("drm/amd/pm: Prevent divide by zero")Signed-off-by Denis Arefev <[email protected]>
Thanks. While you are at it, can you fix up all of the other fan speed cases? I quick grep shows:drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c: tach_period = 60 * xclk
* 10000 / (8 * speed);drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_thermal.c: tach_period
= 60 * crystal_clock_freq * 10000 / (8 * speed); drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c:tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed); drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_thermal.c:tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed);drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c: tach_period = 60
* crystal_clock_freq * 10000 / (8 * speed);drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c: tach_period = 60 *crystal_clock_freq * 10000 / (8 * speed);drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c: tach_period = 60 *crystal_clock_freq * 10000 / (8 * speed);
Thanks,
Alex
Quoted 20 lines
--- drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +1
-2@@ -1200,7 +1200,7 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu,uint32_t crystal_clock_freq =2500 ;uint32_t tach_period; -if (speed ==0 ) +if (!speed || speed >UINT_MAX /8 )return -EINVAL ;/* * To prevent from possible overheat, some ASICs may have requirement -- 2.43.0
Quoted 18 lines
--- drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +1
-2@@ -1200,7 +1200,7 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu,uint32_t crystal_clock_freq =2500 ;uint32_t tach_period; -if (speed ==0 ) +if (!speed || speed >UINT_MAX /8 )return -EINVAL ;/* * To prevent from possible overheat, some ASICs may have requirement --
Quoted 2 lines
2.43.0
Hi Alex.
The patch 'drm/amd/pm/smu11: Prevent division by zero' was sent separately, not part of the patch series, maybe that's why it wasn't accepted. Should I resend it?
Regards, Denis.
Oh, sorry, I've picked it up now. Thanks!
Alex
Quoted 30 lines · Denis Arefev
Quoted 19 lines
--- drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +1
-2@@ -1200,7 +1200,7 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu,uint32_t crystal_clock_freq =2500 ;uint32_t tach_period; -if (speed ==0 ) +if (!speed || speed >UINT_MAX /8 )return -EINVAL ;/* * To prevent from possible overheat, some ASICs may have requirement -- Quoted 2 lines
2.43.0
Hi Alex.
The patch 'drm/amd/pm/smu11: Prevent division by zero' was sent separately, not part of the patch series, maybe that's why it wasn't accepted. Should I resend it?
Regards, Denis.