Skip to content

Commit a1a151e

Browse files
lolzballsopsiff
authored andcommitted
drm/amdgpu/vcn4: Avoid overflow on msg bound check
commit 65bce27ea6192320448c30267ffc17ffa094e713 upstream. As pointed out by SDL, the previous condition may be vulnerable to overflow. Fixes: 0a78f2bac142 ("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 3c5367d950140d4ec7af830b2268a5a6fdaa3885) Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 5bb5faff4837b1d98fd655cf8bd7b5d4da0fc4dc) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent afb6898 commit a1a151e

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)