Skip to content

Commit 5bb5faf

Browse files
lolzballsgregkh
authored andcommitted
drm/amdgpu/vcn4: Avoid overflow on msg bound check
commit 65bce27 upstream. As pointed out by SDL, the previous condition may be vulnerable to overflow. Fixes: 0a78f2b ("drm/amdgpu/vcn4: 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 3c5367d) Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1936310 commit 5bb5faf

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

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

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

17321732
for (i = 0, msg = &msg[6]; i < num_buffers; ++i, msg += 4) {
17331733
uint32_t offset, size, *create;
1734+
uint64_t buf_end;
17341735

17351736
if (msg[0] != RDECODE_MESSAGE_CREATE)
17361737
continue;
17371738

17381739
offset = msg[1];
17391740
size = msg[2];
17401741

1741-
if (size < 4 || offset + size > end - addr) {
1742+
if (size < 4 || check_add_overflow(offset, size, &buf_end) ||
1743+
buf_end > end - addr) {
17421744
DRM_ERROR("VCN message buffer exceeds BO bounds!\n");
17431745
r = -EINVAL;
17441746
goto out;

0 commit comments

Comments
 (0)