mirror of
https://github.com/S3NEO/android_kernel_samsung_msm8226.git
synced 2024-11-07 03:47:13 +00:00
ANDROID: HID: debug: check length in hid_debug_events_read() before copy_to_user()
If our length is greater than the size of the buffer, we overflow the buffer Change-Id: I113a1955a2bac83c83084d5cd28d886175673219 Bug: 71361580 Signed-off-by: Daniel Rosenberg <drosen@google.com> CVE-2018-9516 Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
This commit is contained in:
parent
ca2d6dd04b
commit
8b6702e108
1 changed files with 7 additions and 1 deletions
|
@ -1021,6 +1021,8 @@ copy_rest:
|
|||
goto out;
|
||||
if (list->tail > list->head) {
|
||||
len = list->tail - list->head;
|
||||
if (len > count)
|
||||
len = count;
|
||||
|
||||
if (copy_to_user(buffer + ret, &list->hid_debug_buf[list->head], len)) {
|
||||
ret = -EFAULT;
|
||||
|
@ -1030,6 +1032,8 @@ copy_rest:
|
|||
list->head += len;
|
||||
} else {
|
||||
len = HID_DEBUG_BUFSIZE - list->head;
|
||||
if (len > count)
|
||||
len = count;
|
||||
|
||||
if (copy_to_user(buffer, &list->hid_debug_buf[list->head], len)) {
|
||||
ret = -EFAULT;
|
||||
|
@ -1037,7 +1041,9 @@ copy_rest:
|
|||
}
|
||||
list->head = 0;
|
||||
ret += len;
|
||||
goto copy_rest;
|
||||
count -= len;
|
||||
if (count > 0)
|
||||
goto copy_rest;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue