The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] HID: playstation: validate num_touch_reports in DualShock 4 reports
@ 2026-03-23 12:47 FirstName LastName
  2026-04-09 15:55 ` Jiri Kosina
  2026-07-13 11:22 ` Lee Jones
  0 siblings, 2 replies; 4+ messages in thread
From: FirstName LastName @ 2026-03-23 12:47 UTC (permalink / raw)
  To: Roderick Colenbrander, Jiri Kosina, Benjamin Tissoires
  Cc: linux-input, linux-kernel, Benoît Sevens

From: Benoît Sevens <bsevens@google.com>

The DualShock 4 HID driver fails to validate the num_touch_reports field
received from the device in both USB and Bluetooth input reports.
A malicious device could set this field to a value larger than the
allocated size of the touch_reports array (3 for USB, 4 for Bluetooth),
leading to an out-of-bounds read in dualshock4_parse_report().

This can result in kernel memory disclosure when processing malicious
HID reports.

Validate num_touch_reports against the array size for the respective
connection types before processing the touch data.

Signed-off-by: Benoît Sevens <bsevens@google.com>
---
 drivers/hid/hid-playstation.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c
index 3c0db8f93c82..c43caac20b61 100644
--- a/drivers/hid/hid-playstation.c
+++ b/drivers/hid/hid-playstation.c
@@ -2377,6 +2377,12 @@ static int dualshock4_parse_report(struct ps_device *ps_dev, struct hid_report *
 		struct dualshock4_input_report_usb *usb =
 			(struct dualshock4_input_report_usb *)data;
 
+		if (usb->num_touch_reports > ARRAY_SIZE(usb->touch_reports)) {
+			hid_err(hdev, "DualShock4 USB input report has invalid num_touch_reports=%d\n",
+				usb->num_touch_reports);
+			return -EINVAL;
+		}
+
 		ds4_report = &usb->common;
 		num_touch_reports = usb->num_touch_reports;
 		touch_reports = usb->touch_reports;
@@ -2391,6 +2397,12 @@ static int dualshock4_parse_report(struct ps_device *ps_dev, struct hid_report *
 			return -EILSEQ;
 		}
 
+		if (bt->num_touch_reports > ARRAY_SIZE(bt->touch_reports)) {
+			hid_err(hdev, "DualShock4 BT input report has invalid num_touch_reports=%d\n",
+				bt->num_touch_reports);
+			return -EINVAL;
+		}
+
 		ds4_report = &bt->common;
 		num_touch_reports = bt->num_touch_reports;
 		touch_reports = bt->touch_reports;
-- 
2.53.0.959.g497ff81fa9-goog


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

* Re: [PATCH] HID: playstation: validate num_touch_reports in DualShock 4 reports
  2026-03-23 12:47 [PATCH] HID: playstation: validate num_touch_reports in DualShock 4 reports FirstName LastName
@ 2026-04-09 15:55 ` Jiri Kosina
  2026-07-13 11:22 ` Lee Jones
  1 sibling, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2026-04-09 15:55 UTC (permalink / raw)
  To: FirstName LastName
  Cc: Roderick Colenbrander, Benjamin Tissoires, linux-input,
	linux-kernel

Dear FirstName LastName,

there seems to be a way to fix in your mail setup configuration :)

On Mon, 23 Mar 2026, FirstName LastName wrote:

> From: Beno=C3=AEt Sevens <bsevens@google.com>
> 
> The DualShock 4 HID driver fails to validate the num_touch_reports field
> received from the device in both USB and Bluetooth input reports.
> A malicious device could set this field to a value larger than the
> allocated size of the touch_reports array (3 for USB, 4 for Bluetooth),
> leading to an out-of-bounds read in dualshock4_parse_report().
> 
> This can result in kernel memory disclosure when processing malicious
> HID reports.
> 
> Validate num_touch_reports against the array size for the respective
> connection types before processing the touch data.
> 
> Signed-off-by: Beno=C3=AEt Sevens <bsevens@google.com>

Applied now to hid.git#for-7.0/upstream-fixes, thanks!

-- 
Jiri Kosina
SUSE Labs


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

* Re: [PATCH] HID: playstation: validate num_touch_reports in DualShock 4 reports
  2026-03-23 12:47 [PATCH] HID: playstation: validate num_touch_reports in DualShock 4 reports FirstName LastName
  2026-04-09 15:55 ` Jiri Kosina
@ 2026-07-13 11:22 ` Lee Jones
  2026-07-13 11:24   ` Lee Jones
  1 sibling, 1 reply; 4+ messages in thread
From: Lee Jones @ 2026-07-13 11:22 UTC (permalink / raw)
  To: FirstName LastName
  Cc: Roderick Colenbrander, Jiri Kosina, Benjamin Tissoires,
	linux-input, linux-kernel

Stable Team,

> From: Benoît Sevens <bsevens@google.com>
> 
> The DualShock 4 HID driver fails to validate the num_touch_reports field
> received from the device in both USB and Bluetooth input reports.
> A malicious device could set this field to a value larger than the
> allocated size of the touch_reports array (3 for USB, 4 for Bluetooth),
> leading to an out-of-bounds read in dualshock4_parse_report().
> 
> This can result in kernel memory disclosure when processing malicious
> HID reports.
> 
> Validate num_touch_reports against the array size for the respective
> connection types before processing the touch data.
> 
> Signed-off-by: Benoît Sevens <bsevens@google.com>
> ---
>  drivers/hid/hid-playstation.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

Could we have this in all branches up to and including linux-6.6.y please?

Upstream commit:

  Fixes: 82a4fc463309 ("HID: playstation: validate num_touch_reports in DualShock 4 reports")

-- 
Lee Jones

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

* Re: [PATCH] HID: playstation: validate num_touch_reports in DualShock 4 reports
  2026-07-13 11:22 ` Lee Jones
@ 2026-07-13 11:24   ` Lee Jones
  0 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-07-13 11:24 UTC (permalink / raw)
  To: FirstName LastName, stable
  Cc: Roderick Colenbrander, Jiri Kosina, Benjamin Tissoires,
	linux-input, linux-kernel

[This time with the Stable Team included #fail]

> Stable Team,
> 
> > From: Benoît Sevens <bsevens@google.com>
> > 
> > The DualShock 4 HID driver fails to validate the num_touch_reports field
> > received from the device in both USB and Bluetooth input reports.
> > A malicious device could set this field to a value larger than the
> > allocated size of the touch_reports array (3 for USB, 4 for Bluetooth),
> > leading to an out-of-bounds read in dualshock4_parse_report().
> > 
> > This can result in kernel memory disclosure when processing malicious
> > HID reports.
> > 
> > Validate num_touch_reports against the array size for the respective
> > connection types before processing the touch data.
> > 
> > Signed-off-by: Benoît Sevens <bsevens@google.com>
> > ---
> >  drivers/hid/hid-playstation.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> 
> Could we have this in all branches up to and including linux-6.6.y please?
> 
> Upstream commit:
> 
>   Fixes: 82a4fc463309 ("HID: playstation: validate num_touch_reports in DualShock 4 reports")

-- 
Lee Jones

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

end of thread, other threads:[~2026-07-13 11:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 12:47 [PATCH] HID: playstation: validate num_touch_reports in DualShock 4 reports FirstName LastName
2026-04-09 15:55 ` Jiri Kosina
2026-07-13 11:22 ` Lee Jones
2026-07-13 11:24   ` Lee Jones

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