Skip to contentSkip to conversation

amdgpu/pm: prevent array underflow in vega20_odn_edit_dpm_table()

PATCH Applied Dan Carpenter 2 participants 2 messages Nov 15, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amdgpu/pm: prevent array underflow in vega20_odn_edit_dpm_table()

In the PP_OD_EDIT_VDDC_CURVE case the "input_index" variable is capped at 2 but not checked for negative values so it results in an out of bounds read. This value comes from the user via sysfs.

Fixes d5bf26539494 ("drm/amd/powerplay: added vega20 overdrive support V3")
---
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c +2 -1
index 97b3ad369046..b30684c84e20 100644
@@ -2961,7 +2961,8 @@ static int vega20_odn_edit_dpm_table(struct pp_hwmgr *hwmgr,
 			data->od8_settings.od8_settings_array;
 	OverDriveTable_t *od_table =
 			&(data->smc_state_table.overdrive_table);
-	int32_t input_index, input_clk, input_vol, i;
+	int32_t input_clk, input_vol, i;
+	uint32_t input_index;
 	int od8_id;
 	int ret;
 
Signature · 1 line
2.35.1
Applied
#1 lore raw

Applied. Thanks!

Alex

Quoted 28 lines · Dan Carpenter

In the PP_OD_EDIT_VDDC_CURVE case the "input_index" variable is capped at 2 but not checked for negative values so it results in an out of bounds read. This value comes from the user via sysfs.

Fixes d5bf26539494 ("drm/amd/powerplay: added vega20 overdrive support V3")
---
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c +2 -2
index 97b3ad369046..b30684c84e20 100644
@@ -2961,7 +2961,8 @@ static int vega20_odn_edit_dpm_table(struct pp_hwmgr *hwmgr,
                        data->od8_settings.od8_settings_array;
        OverDriveTable_t *od_table =
                        &(data->smc_state_table.overdrive_table);
-       int32_t input_index, input_clk, input_vol, i;
+       int32_t input_clk, input_vol, i;
+       uint32_t input_index;
        int od8_id;
        int ret;
 
--

2.35.1