1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Mario Limonciello <mario.limonciello@amd.com>
3 Date: Wed, 4 Oct 2023 15:46:44 -0500
4 Subject: [PATCH] drm/amd: Fix UBSAN array-index-out-of-bounds for Polaris and
7 For pptable structs that use flexible array sizes, use flexible arrays.
9 Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2036742
10 Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
11 Acked-by: Alex Deucher <alexander.deucher@amd.com>
12 Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
13 (cherry-picked from commit 0f0e59075b5c22f1e871fbd508d6e4f495048356)
14 Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
16 .../gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h | 12 ++++++------
17 1 file changed, 6 insertions(+), 6 deletions(-)
19 diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h
20 index 41444e27bfc0..e0e40b054c08 100644
21 --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h
22 +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h
23 @@ -164,7 +164,7 @@ typedef struct _ATOM_Tonga_State {
24 typedef struct _ATOM_Tonga_State_Array {
26 UCHAR ucNumEntries; /* Number of entries. */
27 - ATOM_Tonga_State entries[1]; /* Dynamically allocate entries. */
28 + ATOM_Tonga_State entries[]; /* Dynamically allocate entries. */
29 } ATOM_Tonga_State_Array;
31 typedef struct _ATOM_Tonga_MCLK_Dependency_Record {
32 @@ -210,7 +210,7 @@ typedef struct _ATOM_Polaris_SCLK_Dependency_Record {
33 typedef struct _ATOM_Polaris_SCLK_Dependency_Table {
35 UCHAR ucNumEntries; /* Number of entries. */
36 - ATOM_Polaris_SCLK_Dependency_Record entries[1]; /* Dynamically allocate entries. */
37 + ATOM_Polaris_SCLK_Dependency_Record entries[]; /* Dynamically allocate entries. */
38 } ATOM_Polaris_SCLK_Dependency_Table;
40 typedef struct _ATOM_Tonga_PCIE_Record {
41 @@ -222,7 +222,7 @@ typedef struct _ATOM_Tonga_PCIE_Record {
42 typedef struct _ATOM_Tonga_PCIE_Table {
44 UCHAR ucNumEntries; /* Number of entries. */
45 - ATOM_Tonga_PCIE_Record entries[1]; /* Dynamically allocate entries. */
46 + ATOM_Tonga_PCIE_Record entries[]; /* Dynamically allocate entries. */
47 } ATOM_Tonga_PCIE_Table;
49 typedef struct _ATOM_Polaris10_PCIE_Record {
50 @@ -235,7 +235,7 @@ typedef struct _ATOM_Polaris10_PCIE_Record {
51 typedef struct _ATOM_Polaris10_PCIE_Table {
53 UCHAR ucNumEntries; /* Number of entries. */
54 - ATOM_Polaris10_PCIE_Record entries[1]; /* Dynamically allocate entries. */
55 + ATOM_Polaris10_PCIE_Record entries[]; /* Dynamically allocate entries. */
56 } ATOM_Polaris10_PCIE_Table;
59 @@ -252,7 +252,7 @@ typedef struct _ATOM_Tonga_MM_Dependency_Record {
60 typedef struct _ATOM_Tonga_MM_Dependency_Table {
62 UCHAR ucNumEntries; /* Number of entries. */
63 - ATOM_Tonga_MM_Dependency_Record entries[1]; /* Dynamically allocate entries. */
64 + ATOM_Tonga_MM_Dependency_Record entries[]; /* Dynamically allocate entries. */
65 } ATOM_Tonga_MM_Dependency_Table;
67 typedef struct _ATOM_Tonga_Voltage_Lookup_Record {
68 @@ -265,7 +265,7 @@ typedef struct _ATOM_Tonga_Voltage_Lookup_Record {
69 typedef struct _ATOM_Tonga_Voltage_Lookup_Table {
71 UCHAR ucNumEntries; /* Number of entries. */
72 - ATOM_Tonga_Voltage_Lookup_Record entries[1]; /* Dynamically allocate entries. */
73 + ATOM_Tonga_Voltage_Lookup_Record entries[]; /* Dynamically allocate entries. */
74 } ATOM_Tonga_Voltage_Lookup_Table;
76 typedef struct _ATOM_Tonga_Fan_Table {