Commit 761d328d authored by Ma Jun's avatar Ma Jun Committed by Lin Ruifeng
Browse files

drm/amdgpu: Fix out-of-bounds read of df_v1_7_channel_number

stable inclusion
from stable-v5.10.226
commit 725b728cc0c8c5fafdfb51cb0937870d33a40fa4
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IARV1E
CVE: CVE-2024-46724

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



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

[ Upstream commit d768394fa99467bcf2703bde74ddc96eeb0b71fa ]

Check the fb_channel_number range to avoid the array out-of-bounds
read error

Signed-off-by: default avatarMa Jun <Jun.Ma2@amd.com>
Reviewed-by: default avatarTim Huang <Tim.Huang@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 avatarLin Ruifeng <linruifeng4@huawei.com>
parent 52e62ae6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -70,6 +70,8 @@ static u32 df_v1_7_get_hbm_channel_number(struct amdgpu_device *adev)
	int fb_channel_number;

	fb_channel_number = adev->df.funcs->get_fb_channel_number(adev);
	if (fb_channel_number >= ARRAY_SIZE(df_v1_7_channel_number))
		fb_channel_number = 0;

	return df_v1_7_channel_number[fb_channel_number];
}