Commit ae7eeb9c authored by Mario Limonciello's avatar Mario Limonciello Committed by Ye Bin
Browse files

drm/amd: Fix UBSAN array-index-out-of-bounds for SMU7

stable inclusion
from stable-v5.10.202
commit 8af28ae3acb736ada4ce3457662fa446cc913bb4
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9RFET
CVE: CVE-2023-52818

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8af28ae3acb736ada4ce3457662fa446cc913bb4



--------------------------------

[ Upstream commit 760efbca74a405dc439a013a5efaa9fadc95a8c3 ]

For pptable structs that use flexible array sizes, use flexible arrays.

Suggested-by: default avatarFelix Held <felix.held@amd.com>
Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2874


Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
parent 4fcf8eb9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ typedef struct _ATOM_PPLIB_THERMALCONTROLLER
typedef struct _ATOM_PPLIB_STATE
{
    UCHAR ucNonClockStateIndex;
    UCHAR ucClockStateIndices[1]; // variable-sized
    UCHAR ucClockStateIndices[]; // variable-sized
} ATOM_PPLIB_STATE;


@@ -473,7 +473,7 @@ typedef struct _ATOM_PPLIB_STATE_V2
      /**
      * Driver will read the first ucNumDPMLevels in this array
      */
      UCHAR clockInfoIndex[1];
      UCHAR clockInfoIndex[];
} ATOM_PPLIB_STATE_V2;

typedef struct _StateArray{
+2 −2
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ typedef struct _ATOM_Tonga_MCLK_Dependency_Record {
typedef struct _ATOM_Tonga_MCLK_Dependency_Table {
	UCHAR ucRevId;
	UCHAR ucNumEntries; 										/* Number of entries. */
	ATOM_Tonga_MCLK_Dependency_Record entries[1];				/* Dynamically allocate entries. */
	ATOM_Tonga_MCLK_Dependency_Record entries[];				/* Dynamically allocate entries. */
} ATOM_Tonga_MCLK_Dependency_Table;

typedef struct _ATOM_Tonga_SCLK_Dependency_Record {
@@ -194,7 +194,7 @@ typedef struct _ATOM_Tonga_SCLK_Dependency_Record {
typedef struct _ATOM_Tonga_SCLK_Dependency_Table {
	UCHAR ucRevId;
	UCHAR ucNumEntries; 										/* Number of entries. */
	ATOM_Tonga_SCLK_Dependency_Record entries[1];				 /* Dynamically allocate entries. */
	ATOM_Tonga_SCLK_Dependency_Record entries[];				 /* Dynamically allocate entries. */
} ATOM_Tonga_SCLK_Dependency_Table;

typedef struct _ATOM_Polaris_SCLK_Dependency_Record {