linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] HID: bigben: fix slab-out-of-bounds Write in bigben_probe
@ 2022-05-06  7:24 Dongliang Mu
  2022-05-06  8:47 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Dongliang Mu @ 2022-05-06  7:24 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires
  Cc: Dongliang Mu, syzkaller, linux-input, linux-kernel

From: Dongliang Mu <mudongliangabcd@gmail.com>

There is a slab-out-of-bounds Write bug in hid-bigbenff driver.
The problem is the driver assumes the device must have an input but
some malicious devices violate this assumption.

Fix this by checking hid_device's input is non-empty before its usage.

Reported-by: syzkaller <syzkaller@googlegroups.com>
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
v1->v2: modify return directly to goto error_hw_stop;
 drivers/hid/hid-bigbenff.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/hid/hid-bigbenff.c b/drivers/hid/hid-bigbenff.c
index 74ad8bf98bfd..e8c5e3ac9fff 100644
--- a/drivers/hid/hid-bigbenff.c
+++ b/drivers/hid/hid-bigbenff.c
@@ -347,6 +347,12 @@ static int bigben_probe(struct hid_device *hid,
 	bigben->report = list_entry(report_list->next,
 		struct hid_report, list);
 
+	if (list_empty(&hid->inputs)) {
+		hid_err(hid, "no inputs found\n");
+		error = -ENODEV;
+		goto error_hw_stop;
+	}
+
 	hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
 	set_bit(FF_RUMBLE, hidinput->input->ffbit);
 
-- 
2.25.1


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

* Re: [PATCH v2] HID: bigben: fix slab-out-of-bounds Write in bigben_probe
  2022-05-06  7:24 [PATCH v2] HID: bigben: fix slab-out-of-bounds Write in bigben_probe Dongliang Mu
@ 2022-05-06  8:47 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2022-05-06  8:47 UTC (permalink / raw)
  To: Dongliang Mu
  Cc: Benjamin Tissoires, Dongliang Mu, syzkaller, linux-input, linux-kernel

On Fri, 6 May 2022, Dongliang Mu wrote:

> From: Dongliang Mu <mudongliangabcd@gmail.com>
> 
> There is a slab-out-of-bounds Write bug in hid-bigbenff driver.
> The problem is the driver assumes the device must have an input but
> some malicious devices violate this assumption.
> 
> Fix this by checking hid_device's input is non-empty before its usage.
> 
> Reported-by: syzkaller <syzkaller@googlegroups.com>
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>

Applied. thanks.

-- 
Jiri Kosina
SUSE Labs


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

end of thread, other threads:[~2022-05-06  8:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-06  7:24 [PATCH v2] HID: bigben: fix slab-out-of-bounds Write in bigben_probe Dongliang Mu
2022-05-06  8:47 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).