msm: vidc: ensure the validity of video buffer access

During subsystem failure, the cause for failure is updated
in a specific video buffer by the video firmware. Video
firmware can even update the size of that specific buffer.
To ensure the validity of that buffer access, check if
the access is within the allocated size.

CRs-Fixed: 2585811
Change-Id: I30b8bf2e9ba3699d229f4acc104f46566fcb60fa
Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
This commit is contained in:
Vikash Garodia 2019-12-26 16:30:39 +05:30 • committed by Gerrit - the friendly Code Review server
commit 720369dfcf

View file

@ -2519,6 +2519,11 @@ static void print_sfr_message(struct venus_hfi_device *device)
vsfr = (struct hfi_sfr_struct *)device->sfr.align_virtual_addr;
if (vsfr) {
if (vsfr->bufSize != device->sfr.mem_size) {
d_vpr_e("Invalid SFR buf size %d actual %d\n",
vsfr->bufSize, device->sfr.mem_size);
return;
}
vsfr_size = vsfr->bufSize - sizeof(u32);
p = memchr(vsfr->rg_data, '\0', vsfr_size);
/* SFR isn't guaranteed to be NULL terminated */