Commit 5d0a9c79 authored by Simon Arlott's avatar Simon Arlott Committed by Greg Kroah-Hartman

USB: cxacru: check data length is not negative

When attempting to read data that is not actually
an array of values, the length may be negative
which causes an Oops due to a likely access off
the end of the data array.

This bug should not occur under normal use unless
the device returns an invalid response.
Signed-off-by: default avatarSimon Arlott <simon@fire.lp0.eu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 1bfbd283
...@@ -596,7 +596,7 @@ static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_requ ...@@ -596,7 +596,7 @@ static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_requ
len = ret / 4; len = ret / 4;
for (offb = 0; offb < len; ) { for (offb = 0; offb < len; ) {
int l = le32_to_cpu(buf[offb++]); int l = le32_to_cpu(buf[offb++]);
if (l > stride || l > (len - offb) / 2) { if (l < 0 || l > stride || l > (len - offb) / 2) {
if (printk_ratelimit()) if (printk_ratelimit())
usb_err(instance->usbatm, "invalid data length from cm %#x: %d\n", usb_err(instance->usbatm, "invalid data length from cm %#x: %d\n",
cm, l); cm, l);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment