From: Alex Deucher Date: Fri, 28 Jul 2023 15:14:05 +0000 (-0400) Subject: drm/amdgpu: fix possible UAF in amdgpu_cs_pass1() X-Git-Tag: v6.6.7~2214^2^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90e065677e0362a777b9db97ea21d43a39211399;p=platform%2Fkernel%2Flinux-starfive.git drm/amdgpu: fix possible UAF in amdgpu_cs_pass1() Since the gang_size check is outside of chunk parsing loop, we need to reset i before we free the chunk data. Suggested by Ye Zhang (@VAR10CK) of Baidu Security. Reviewed-by: Guchun Chen Reviewed-by: Christian König Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 040f4cb..fb78a8f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -295,7 +295,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p, if (!p->gang_size) { ret = -EINVAL; - goto free_partial_kdata; + goto free_all_kdata; } for (i = 0; i < p->gang_size; ++i) {