diff mbox

[06/14] HID: pantherlord: validate output report details

Message ID alpine.LNX.2.00.1308282218580.22181@pobox.suse.cz (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Jiri Kosina Aug. 28, 2013, 8:30 p.m. UTC
From: Kees Cook <keescook@chromium.org>

A HID device could send a malicious output report that would cause the
pantherlord HID driver to write beyond the output report allocation
during initialization, causing a heap overflow:

[  310.939483] usb 1-1: New USB device found, idVendor=0e8f, idProduct=0003
...
[  315.980774] BUG kmalloc-192 (Tainted: G        W   ): Redzone overwritten

CVE-2013-2892

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: stable@kernel.org
---
 drivers/hid/hid-pl.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Jiri Kosina Sept. 4, 2013, 9:58 a.m. UTC | #1
On Wed, 28 Aug 2013, Jiri Kosina wrote:

> From: Kees Cook <keescook@chromium.org>
> 
> A HID device could send a malicious output report that would cause the
> pantherlord HID driver to write beyond the output report allocation
> during initialization, causing a heap overflow:
> 
> [  310.939483] usb 1-1: New USB device found, idVendor=0e8f, idProduct=0003
> ...
> [  315.980774] BUG kmalloc-192 (Tainted: G        W   ): Redzone overwritten
> 
> CVE-2013-2892

Applying this one, thanks.

> 
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Cc: stable@kernel.org
> ---
>  drivers/hid/hid-pl.c |   10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/hid-pl.c b/drivers/hid/hid-pl.c
> index d29112f..2dcd7d9 100644
> --- a/drivers/hid/hid-pl.c
> +++ b/drivers/hid/hid-pl.c
> @@ -132,8 +132,14 @@ static int plff_init(struct hid_device *hid)
>  			strong = &report->field[0]->value[2];
>  			weak = &report->field[0]->value[3];
>  			debug("detected single-field device");
> -		} else if (report->maxfield >= 4 && report->field[0]->maxusage == 1 &&
> -				report->field[0]->usage[0].hid == (HID_UP_LED | 0x43)) {
> +		} else if (report->field[0]->maxusage == 1 &&
> +			   report->field[0]->usage[0].hid ==
> +				(HID_UP_LED | 0x43) &&
> +			   report->maxfield >= 4 &&
> +			   report->field[0]->report_count >= 1 &&
> +			   report->field[1]->report_count >= 1 &&
> +			   report->field[2]->report_count >= 1 &&
> +			   report->field[3]->report_count >= 1) {
>  			report->field[0]->value[0] = 0x00;
>  			report->field[1]->value[0] = 0x00;
>  			strong = &report->field[2]->value[0];
diff mbox

Patch

diff --git a/drivers/hid/hid-pl.c b/drivers/hid/hid-pl.c
index d29112f..2dcd7d9 100644
--- a/drivers/hid/hid-pl.c
+++ b/drivers/hid/hid-pl.c
@@ -132,8 +132,14 @@  static int plff_init(struct hid_device *hid)
 			strong = &report->field[0]->value[2];
 			weak = &report->field[0]->value[3];
 			debug("detected single-field device");
-		} else if (report->maxfield >= 4 && report->field[0]->maxusage == 1 &&
-				report->field[0]->usage[0].hid == (HID_UP_LED | 0x43)) {
+		} else if (report->field[0]->maxusage == 1 &&
+			   report->field[0]->usage[0].hid ==
+				(HID_UP_LED | 0x43) &&
+			   report->maxfield >= 4 &&
+			   report->field[0]->report_count >= 1 &&
+			   report->field[1]->report_count >= 1 &&
+			   report->field[2]->report_count >= 1 &&
+			   report->field[3]->report_count >= 1) {
 			report->field[0]->value[0] = 0x00;
 			report->field[1]->value[0] = 0x00;
 			strong = &report->field[2]->value[0];