Skip to content

Commit 1936310

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 9b2c795 commit 1936310

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
@@ -1852,14 +1852,16 @@ static int vcn_v3_0_dec_msg(struct amdgpu_cs_parser *p, struct amdgpu_job *job,
18521852

18531853
for (i = 0, msg = &msg[6]; i < num_buffers; ++i, msg += 4) {
18541854
uint32_t offset, size, *create;
1855+
uint64_t buf_end;
18551856

18561857
if (msg[0] != RDECODE_MESSAGE_CREATE)
18571858
continue;
18581859

18591860
offset = msg[1];
18601861
size = msg[2];
18611862

1862-
if (size < 4 || offset + size > end - addr) {
1863+
if (size < 4 || check_add_overflow(offset, size, &buf_end) ||
1864+
buf_end > end - addr) {
18631865
DRM_ERROR("VCN message buffer exceeds BO bounds!\n");
18641866
r = -EINVAL;
18651867
goto out;

0 commit comments

Comments
 (0)