Skip to content

Commit e812412

Browse files
lolzballsgregkh
authored andcommitted
drm/amdgpu/vcn3: Avoid overflow on msg bound check
commit e6e9fab upstream. As pointed out by SDL, the previous condition may be vulnerable to overflow. Fixes: b193019 ("drm/amdgpu/vcn3: Prevent OOB reads when parsing dec msg") Cc: SDL <sdl@nppct.ru> Signed-off-by: Benjamin Cheng <benjamin.cheng@amd.com> Reviewed-by: Ruijing Dong <ruijing.dong@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit db00257) Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 29371f3 commit e812412

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,14 +1906,16 @@ static int vcn_v3_0_dec_msg(struct amdgpu_cs_parser *p, struct amdgpu_job *job,
19061906

19071907
for (i = 0, msg = &msg[6]; i < num_buffers; ++i, msg += 4) {
19081908
uint32_t offset, size, *create;
1909+
uint64_t buf_end;
19091910

19101911
if (msg[0] != RDECODE_MESSAGE_CREATE)
19111912
continue;
19121913

19131914
offset = msg[1];
19141915
size = msg[2];
19151916

1916-
if (size < 4 || offset + size > end - addr) {
1917+
if (size < 4 || check_add_overflow(offset, size, &buf_end) ||
1918+
buf_end > end - addr) {
19171919
DRM_ERROR("VCN message buffer exceeds BO bounds!\n");
19181920
r = -EINVAL;
19191921
goto out;

0 commit comments

Comments
 (0)