]> git.proxmox.com Git - pve-kernel.git/blob - patches/kernel/0014-drm-amd-Fix-UBSAN-array-index-out-of-bounds-for-SMU7.patch
backport UBSAN fixes for amdgpu
[pve-kernel.git] / patches / kernel / 0014-drm-amd-Fix-UBSAN-array-index-out-of-bounds-for-SMU7.patch
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:22:52 -0500
4 Subject: [PATCH] drm/amd: Fix UBSAN array-index-out-of-bounds for SMU7
5
6 For pptable structs that use flexible array sizes, use flexible arrays.
7
8 Suggested-by: Felix Held <felix.held@amd.com>
9 Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2874
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 760efbca74a405dc439a013a5efaa9fadc95a8c3)
14 Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
15 ---
16 drivers/gpu/drm/amd/include/pptable.h | 4 ++--
17 drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h | 4 ++--
18 2 files changed, 4 insertions(+), 4 deletions(-)
19
20 diff --git a/drivers/gpu/drm/amd/include/pptable.h b/drivers/gpu/drm/amd/include/pptable.h
21 index 0b6a057e0a4c..5aac8d545bdc 100644
22 --- a/drivers/gpu/drm/amd/include/pptable.h
23 +++ b/drivers/gpu/drm/amd/include/pptable.h
24 @@ -78,7 +78,7 @@ typedef struct _ATOM_PPLIB_THERMALCONTROLLER
25 typedef struct _ATOM_PPLIB_STATE
26 {
27 UCHAR ucNonClockStateIndex;
28 - UCHAR ucClockStateIndices[1]; // variable-sized
29 + UCHAR ucClockStateIndices[]; // variable-sized
30 } ATOM_PPLIB_STATE;
31
32
33 @@ -473,7 +473,7 @@ typedef struct _ATOM_PPLIB_STATE_V2
34 /**
35 * Driver will read the first ucNumDPMLevels in this array
36 */
37 - UCHAR clockInfoIndex[1];
38 + UCHAR clockInfoIndex[];
39 } ATOM_PPLIB_STATE_V2;
40
41 typedef struct _StateArray{
42 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
43 index b0ac4d121adc..41444e27bfc0 100644
44 --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h
45 +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h
46 @@ -179,7 +179,7 @@ typedef struct _ATOM_Tonga_MCLK_Dependency_Record {
47 typedef struct _ATOM_Tonga_MCLK_Dependency_Table {
48 UCHAR ucRevId;
49 UCHAR ucNumEntries; /* Number of entries. */
50 - ATOM_Tonga_MCLK_Dependency_Record entries[1]; /* Dynamically allocate entries. */
51 + ATOM_Tonga_MCLK_Dependency_Record entries[]; /* Dynamically allocate entries. */
52 } ATOM_Tonga_MCLK_Dependency_Table;
53
54 typedef struct _ATOM_Tonga_SCLK_Dependency_Record {
55 @@ -194,7 +194,7 @@ typedef struct _ATOM_Tonga_SCLK_Dependency_Record {
56 typedef struct _ATOM_Tonga_SCLK_Dependency_Table {
57 UCHAR ucRevId;
58 UCHAR ucNumEntries; /* Number of entries. */
59 - ATOM_Tonga_SCLK_Dependency_Record entries[1]; /* Dynamically allocate entries. */
60 + ATOM_Tonga_SCLK_Dependency_Record entries[]; /* Dynamically allocate entries. */
61 } ATOM_Tonga_SCLK_Dependency_Table;
62
63 typedef struct _ATOM_Polaris_SCLK_Dependency_Record {