drm/amd: Fix UBSAN array-index-out-of-bounds for Powerplay headers
Subsystems (3)
Alex Deucher
maintainerPATCH 1/1 drm/amd: Fix UBSAN array-index-out-of-bounds for Powerplay headers
For pptable structs that use flexible array sizes, use flexible arrays.
Signed-off-by Alex Deucher <[email protected]>
--- .../drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h | 4 ++-- .../amd/pm/powerplay/hwmgr/vega10_pptable.h | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h +2 -2
@@ -367,7 +367,7 @@ typedef struct _ATOM_Tonga_VCE_State_Record {typedef struct _ATOM_Tonga_VCE_State_Table {UCHAR ucRevId;UCHAR ucNumEntries; -ATOM_Tonga_VCE_State_Record entries[1 ]; +ATOM_Tonga_VCE_State_Record entries[]; }ATOM_Tonga_VCE_State_Table ; typedef struct _ATOM_Tonga_PowerTune_Table {
@@ -481,7 +481,7 @@ typedef struct _ATOM_Tonga_Hard_Limit_Record {typedef struct _ATOM_Tonga_Hard_Limit_Table {UCHAR ucRevId;UCHAR ucNumEntries; -ATOM_Tonga_Hard_Limit_Record entries[1 ]; +ATOM_Tonga_Hard_Limit_Record entries[]; }ATOM_Tonga_Hard_Limit_Table ; typedef struct _ATOM_Tonga_GPIO_Table {
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_pptable.h +12 -12
@@ -129,7 +129,7 @@ typedef struct _ATOM_Vega10_State {typedef struct _ATOM_Vega10_State_Array {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_State states[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_State states[];/* Dynamically allocate entries. */ }ATOM_Vega10_State_Array ; typedef struct _ATOM_Vega10_CLK_Dependency_Record {
@@ -169,37 +169,37 @@ typedef struct _ATOM_Vega10_GFXCLK_Dependency_Table {typedef struct _ATOM_Vega10_MCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_MCLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_MCLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_MCLK_Dependency_Table ;typedef struct _ATOM_Vega10_SOCCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_SOCCLK_Dependency_Table ;typedef struct _ATOM_Vega10_DCEFCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_DCEFCLK_Dependency_Table ;typedef struct _ATOM_Vega10_PIXCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_PIXCLK_Dependency_Table ;typedef struct _ATOM_Vega10_DISPCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries.*/ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_DISPCLK_Dependency_Table ;typedef struct _ATOM_Vega10_PHYCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_PHYCLK_Dependency_Table ; typedef struct _ATOM_Vega10_MM_Dependency_Record {
@@ -213,7 +213,7 @@ typedef struct _ATOM_Vega10_MM_Dependency_Record {typedef struct _ATOM_Vega10_MM_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries */ -ATOM_Vega10_MM_Dependency_Record entries[1 ];/* Dynamically allocate entries */ +ATOM_Vega10_MM_Dependency_Record entries[];/* Dynamically allocate entries */ }ATOM_Vega10_MM_Dependency_Table ; typedef struct _ATOM_Vega10_PCIE_Record {
@@ -225,7 +225,7 @@ typedef struct _ATOM_Vega10_PCIE_Record {typedef struct _ATOM_Vega10_PCIE_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries */ -ATOM_Vega10_PCIE_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_PCIE_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_PCIE_Table ; typedef struct _ATOM_Vega10_Voltage_Lookup_Record {
@@ -235,7 +235,7 @@ typedef struct _ATOM_Vega10_Voltage_Lookup_Record {typedef struct _ATOM_Vega10_Voltage_Lookup_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries */ -ATOM_Vega10_Voltage_Lookup_Record entries[1 ];/* Dynamically allocate entries */ +ATOM_Vega10_Voltage_Lookup_Record entries[];/* Dynamically allocate entries */ }ATOM_Vega10_Voltage_Lookup_Table ; typedef struct _ATOM_Vega10_Fan_Table {
@@ -327,7 +327,7 @@ typedef struct _ATOM_Vega10_VCE_State_Record {typedef struct _ATOM_Vega10_VCE_State_Table {UCHAR ucRevId;UCHAR ucNumEntries; -ATOM_Vega10_VCE_State_Record entries[1 ]; +ATOM_Vega10_VCE_State_Record entries[]; }ATOM_Vega10_VCE_State_Table ; typedef struct _ATOM_Vega10_PowerTune_Table {
@@ -427,7 +427,7 @@ typedef struct _ATOM_Vega10_Hard_Limit_Record {typedef struct _ATOM_Vega10_Hard_Limit_Table {UCHAR ucRevId;UCHAR ucNumEntries; -ATOM_Vega10_Hard_Limit_Record entries[1 ]; +ATOM_Vega10_Hard_Limit_Record entries[]; }ATOM_Vega10_Hard_Limit_Table ; typedef struct _Vega10_PPTable_Generic_SubTable_Header {
Signature · 1 line
2.41.0
Quoted 4 lines · Alex Deucher
For pptable structs that use flexible array sizes, use flexible arrays.
Reviewed-by Mario Limonciello <[email protected]>
Quoted 129 lines
--- .../drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h | 4 ++-- .../amd/pm/powerplay/hwmgr/vega10_pptable.h | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-)drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h +2
-2@@ -367,7 +367,7 @@ typedef struct _ATOM_Tonga_VCE_State_Record {typedef struct _ATOM_Tonga_VCE_State_Table {UCHAR ucRevId;UCHAR ucNumEntries; -ATOM_Tonga_VCE_State_Record entries[1 ]; +ATOM_Tonga_VCE_State_Record entries[]; }ATOM_Tonga_VCE_State_Table ; typedef struct _ATOM_Tonga_PowerTune_Table {@@ -481,7 +481,7 @@ typedef struct _ATOM_Tonga_Hard_Limit_Record {typedef struct _ATOM_Tonga_Hard_Limit_Table {UCHAR ucRevId;UCHAR ucNumEntries; -ATOM_Tonga_Hard_Limit_Record entries[1 ]; +ATOM_Tonga_Hard_Limit_Record entries[]; }ATOM_Tonga_Hard_Limit_Table ; typedef struct _ATOM_Tonga_GPIO_Table {drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_pptable.h +12
-12@@ -129,7 +129,7 @@ typedef struct _ATOM_Vega10_State {typedef struct _ATOM_Vega10_State_Array {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_State states[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_State states[];/* Dynamically allocate entries. */ }ATOM_Vega10_State_Array ; typedef struct _ATOM_Vega10_CLK_Dependency_Record {@@ -169,37 +169,37 @@ typedef struct _ATOM_Vega10_GFXCLK_Dependency_Table {typedef struct _ATOM_Vega10_MCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_MCLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_MCLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_MCLK_Dependency_Table ;typedef struct _ATOM_Vega10_SOCCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_SOCCLK_Dependency_Table ;typedef struct _ATOM_Vega10_DCEFCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_DCEFCLK_Dependency_Table ;typedef struct _ATOM_Vega10_PIXCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_PIXCLK_Dependency_Table ;typedef struct _ATOM_Vega10_DISPCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries.*/ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_DISPCLK_Dependency_Table ;typedef struct _ATOM_Vega10_PHYCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_PHYCLK_Dependency_Table ; typedef struct _ATOM_Vega10_MM_Dependency_Record {@@ -213,7 +213,7 @@ typedef struct _ATOM_Vega10_MM_Dependency_Record {typedef struct _ATOM_Vega10_MM_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries */ -ATOM_Vega10_MM_Dependency_Record entries[1 ];/* Dynamically allocate entries */ +ATOM_Vega10_MM_Dependency_Record entries[];/* Dynamically allocate entries */ }ATOM_Vega10_MM_Dependency_Table ; typedef struct _ATOM_Vega10_PCIE_Record {@@ -225,7 +225,7 @@ typedef struct _ATOM_Vega10_PCIE_Record {typedef struct _ATOM_Vega10_PCIE_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries */ -ATOM_Vega10_PCIE_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_PCIE_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_PCIE_Table ; typedef struct _ATOM_Vega10_Voltage_Lookup_Record {@@ -235,7 +235,7 @@ typedef struct _ATOM_Vega10_Voltage_Lookup_Record {typedef struct _ATOM_Vega10_Voltage_Lookup_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries */ -ATOM_Vega10_Voltage_Lookup_Record entries[1 ];/* Dynamically allocate entries */ +ATOM_Vega10_Voltage_Lookup_Record entries[];/* Dynamically allocate entries */ }ATOM_Vega10_Voltage_Lookup_Table ; typedef struct _ATOM_Vega10_Fan_Table {@@ -327,7 +327,7 @@ typedef struct _ATOM_Vega10_VCE_State_Record {typedef struct _ATOM_Vega10_VCE_State_Table {UCHAR ucRevId;UCHAR ucNumEntries; -ATOM_Vega10_VCE_State_Record entries[1 ]; +ATOM_Vega10_VCE_State_Record entries[]; }ATOM_Vega10_VCE_State_Table ; typedef struct _ATOM_Vega10_PowerTune_Table {@@ -427,7 +427,7 @@ typedef struct _ATOM_Vega10_Hard_Limit_Record {typedef struct _ATOM_Vega10_Hard_Limit_Table {UCHAR ucRevId;UCHAR ucNumEntries; -ATOM_Vega10_Hard_Limit_Record entries[1 ]; +ATOM_Vega10_Hard_Limit_Record entries[]; }ATOM_Vega10_Hard_Limit_Table ; typedef struct _Vega10_PPTable_Generic_SubTable_Header {
Am 27.10.23 um 22:41 schrieb Alex Deucher:
Quoted 4 lines
For pptable structs that use flexible array sizes, use flexible arrays.
Acked-by Christian König <[email protected]>
Quoted 129 lines
--- .../drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h | 4 ++-- .../amd/pm/powerplay/hwmgr/vega10_pptable.h | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-)drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h +2
-2@@ -367,7 +367,7 @@ typedef struct _ATOM_Tonga_VCE_State_Record {typedef struct _ATOM_Tonga_VCE_State_Table {UCHAR ucRevId;UCHAR ucNumEntries; -ATOM_Tonga_VCE_State_Record entries[1 ]; +ATOM_Tonga_VCE_State_Record entries[]; }ATOM_Tonga_VCE_State_Table ; typedef struct _ATOM_Tonga_PowerTune_Table {@@ -481,7 +481,7 @@ typedef struct _ATOM_Tonga_Hard_Limit_Record {typedef struct _ATOM_Tonga_Hard_Limit_Table {UCHAR ucRevId;UCHAR ucNumEntries; -ATOM_Tonga_Hard_Limit_Record entries[1 ]; +ATOM_Tonga_Hard_Limit_Record entries[]; }ATOM_Tonga_Hard_Limit_Table ; typedef struct _ATOM_Tonga_GPIO_Table {drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_pptable.h +12
-12@@ -129,7 +129,7 @@ typedef struct _ATOM_Vega10_State {typedef struct _ATOM_Vega10_State_Array {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_State states[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_State states[];/* Dynamically allocate entries. */ }ATOM_Vega10_State_Array ; typedef struct _ATOM_Vega10_CLK_Dependency_Record {@@ -169,37 +169,37 @@ typedef struct _ATOM_Vega10_GFXCLK_Dependency_Table {typedef struct _ATOM_Vega10_MCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_MCLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_MCLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_MCLK_Dependency_Table ;typedef struct _ATOM_Vega10_SOCCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_SOCCLK_Dependency_Table ;typedef struct _ATOM_Vega10_DCEFCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_DCEFCLK_Dependency_Table ;typedef struct _ATOM_Vega10_PIXCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_PIXCLK_Dependency_Table ;typedef struct _ATOM_Vega10_DISPCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries.*/ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_DISPCLK_Dependency_Table ;typedef struct _ATOM_Vega10_PHYCLK_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries. */ -ATOM_Vega10_CLK_Dependency_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_CLK_Dependency_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_PHYCLK_Dependency_Table ; typedef struct _ATOM_Vega10_MM_Dependency_Record {@@ -213,7 +213,7 @@ typedef struct _ATOM_Vega10_MM_Dependency_Record {typedef struct _ATOM_Vega10_MM_Dependency_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries */ -ATOM_Vega10_MM_Dependency_Record entries[1 ];/* Dynamically allocate entries */ +ATOM_Vega10_MM_Dependency_Record entries[];/* Dynamically allocate entries */ }ATOM_Vega10_MM_Dependency_Table ; typedef struct _ATOM_Vega10_PCIE_Record {@@ -225,7 +225,7 @@ typedef struct _ATOM_Vega10_PCIE_Record {typedef struct _ATOM_Vega10_PCIE_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries */ -ATOM_Vega10_PCIE_Record entries[1 ];/* Dynamically allocate entries. */ +ATOM_Vega10_PCIE_Record entries[];/* Dynamically allocate entries. */ }ATOM_Vega10_PCIE_Table ; typedef struct _ATOM_Vega10_Voltage_Lookup_Record {@@ -235,7 +235,7 @@ typedef struct _ATOM_Vega10_Voltage_Lookup_Record {typedef struct _ATOM_Vega10_Voltage_Lookup_Table {UCHAR ucRevId;UCHAR ucNumEntries;/* Number of entries */ -ATOM_Vega10_Voltage_Lookup_Record entries[1 ];/* Dynamically allocate entries */ +ATOM_Vega10_Voltage_Lookup_Record entries[];/* Dynamically allocate entries */ }ATOM_Vega10_Voltage_Lookup_Table ; typedef struct _ATOM_Vega10_Fan_Table {@@ -327,7 +327,7 @@ typedef struct _ATOM_Vega10_VCE_State_Record {typedef struct _ATOM_Vega10_VCE_State_Table {UCHAR ucRevId;UCHAR ucNumEntries; -ATOM_Vega10_VCE_State_Record entries[1 ]; +ATOM_Vega10_VCE_State_Record entries[]; }ATOM_Vega10_VCE_State_Table ; typedef struct _ATOM_Vega10_PowerTune_Table {@@ -427,7 +427,7 @@ typedef struct _ATOM_Vega10_Hard_Limit_Record {typedef struct _ATOM_Vega10_Hard_Limit_Table {UCHAR ucRevId;UCHAR ucNumEntries; -ATOM_Vega10_Hard_Limit_Record entries[1 ]; +ATOM_Vega10_Hard_Limit_Record entries[]; }ATOM_Vega10_Hard_Limit_Table ; typedef struct _Vega10_PPTable_Generic_SubTable_Header {