From aef752f9b93acb107cae0dbc941734e47958b4ec Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 25 Apr 2024 20:32:35 +0800 Subject: [PATCH] amdkfd: use calloc instead of kzalloc to avoid integer overflow stable inclusion from stable-v6.6.27 commit 315eb3c2df7e4cb18e3eacfa18a53a46f2bf0ef7 category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9GE8D CVE: CVE-2024-26817 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=315eb3c2df7e4cb18e3eacfa18a53a46f2bf0ef7 -------------------------------- commit 3b0daecfeac0103aba8b293df07a0cbaf8b43f29 upstream. This uses calloc instead of doing the multiplication which might overflow. Cc: stable@vger.kernel.org Signed-off-by: Dave Airlie Signed-off-by: Greg Kroah-Hartman Signed-off-by: Xiang Yang --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index c37f1fcd2165..c157721214e8 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -778,8 +778,8 @@ static int kfd_ioctl_get_process_apertures_new(struct file *filp, * nodes, but not more than args->num_of_nodes as that is * the amount of memory allocated by user */ - pa = kzalloc((sizeof(struct kfd_process_device_apertures) * - args->num_of_nodes), GFP_KERNEL); + pa = kcalloc(args->num_of_nodes, sizeof(struct kfd_process_device_apertures), + GFP_KERNEL); if (!pa) return -ENOMEM; -- Gitee