public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: usb/cpia2: fix start_offset+size Integer Overflow in, cpia2_remap_buffer
@ 2019-12-11  2:47 Zhiqiang Liu
  2019-12-11  7:57 ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Zhiqiang Liu @ 2019-12-11  2:47 UTC (permalink / raw)
  To: tglx, crope, linux-media, rfontana, gregkh, erik.andren, hverkuil,
	brijohn, lcostantino, hverkuil, suweifeng1
  Cc: Mingfangsen, guiyao

From: Weifeng Su <suweifeng1@huawei.com>

CVE-2019-18675: The Linux kernel through 5.3.13 has a start_offset+size
IntegerOverflow in cpia2_remap_buffer in drivers/media/usb/cpia2/cpia2_core.c
because cpia2 has its own mmap implementation. This allows local users
(with /dev/video0 access) to obtain read and write permissions on kernel
physical pages, which can possibly result in a privilege escalation.

Here, we fix it through proper start_offset value check.

CVE Link: https://nvd.nist.gov/vuln/detail/CVE-2019-18675
Signed-off-by: Weifeng Su <suweifeng1@huawei.com>
Reviewed-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
 drivers/media/usb/cpia2/cpia2_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/cpia2/cpia2_core.c b/drivers/media/usb/cpia2/cpia2_core.c
index 20c50c2d042e..26ae7a5e3783 100644
--- a/drivers/media/usb/cpia2/cpia2_core.c
+++ b/drivers/media/usb/cpia2/cpia2_core.c
@@ -2401,7 +2401,7 @@ int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma)

 	if (size > cam->frame_size*cam->num_frames  ||
 	    (start_offset % cam->frame_size) != 0 ||
-	    (start_offset+size > cam->frame_size*cam->num_frames))
+	    (start_offset > cam->frame_size*cam->num_frames - size))
 		return -EINVAL;

 	pos = ((unsigned long) (cam->frame_buffer)) + start_offset;
-- 
2.24.0.windows.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-12-12 10:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-11  2:47 [PATCH] media: usb/cpia2: fix start_offset+size Integer Overflow in, cpia2_remap_buffer Zhiqiang Liu
2019-12-11  7:57 ` Greg KH
2019-12-12  1:48   ` Zhiqiang Liu
2019-12-12  7:47     ` Greg KH
2019-12-12  9:40       ` Zhiqiang Liu
2019-12-12 10:01         ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox