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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Aug 2023 16:27:22 +0000 (18:27 +0200)
commit9a2393af1f35d1975204fc00035c64a1c792b278
treefb7aeeb5c4c7a6d877d62dd8a5cb56340ec5e98a
parent2322dd8c9d3d89319f222d90f0438a392dfcab9d
drm/amdgpu: fix possible UAF in amdgpu_cs_pass1()

commit 90e065677e0362a777b9db97ea21d43a39211399 upstream.

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>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c