]> git.itanic.dy.fi Git - linux-stable/commitdiff
drm/amdgpu: fix possible UAF in amdgpu_cs_pass1()
authorAlex Deucher <alexander.deucher@amd.com>
Fri, 28 Jul 2023 15:14:05 +0000 (11:14 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 9 Aug 2023 13:39:40 +0000 (09:39 -0400)
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 <guchun.chen@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

index 977e1804718d0671e820a2dd6c22226a1b0f4264..49dd9aa8da70883871c9859717f590df32fc34fa 100644 (file)
@@ -293,7 +293,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) {