summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-bigbenff.c
AgeCommit message (Collapse)AuthorFilesLines
2023-02-16hid: bigben_probe(): validate report countPietro Borrello1-5/+2
bigben_probe() does not validate that the output report has the needed report values in the first field. A malicious device registering a report with one field and a single value causes an head OOB write in bigben_worker() when accessing report_field->value[1] to report_field->value[7]. Use hid_validate_values() which takes care of all the needed checks. Fixes: 256a90ed9e46 ("HID: hid-bigbenff: driver for BigBen Interactive PS3OFMINIPAD gamepad") Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it> Link: https://lore.kernel.org/r/20230211-bigben-oob-v1-1-d2849688594c@diag.uniroma1.it Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-02-15HID: bigben: use spinlock to safely schedule workersPietro Borrello1-6/+12
Use spinlocks to deal with workers introducing a wrapper bigben_schedule_work(), and several spinlock checks. Otherwise, bigben_set_led() may schedule bigben->worker after the structure has been freed, causing a use-after-free. Fixes: 4eb1b01de5b9 ("HID: hid-bigbenff: fix race condition for scheduled work during removal") Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it> Link: https://lore.kernel.org/r/20230125-hid-unregister-leds-v4-3-7860c5763c38@diag.uniroma1.it Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-02-15HID: bigben_worker() remove unneeded check on report_fieldPietro Borrello1-1/+1
bigben_worker() checks report_field to be non-NULL. The check has been added in commit 918aa1ef104d ("HID: bigbenff: prevent null pointer dereference") to prevent a NULL pointer crash. However, the true root cause was a missing check for output reports, patched in commit c7bf714f8755 ("HID: check empty report_list in bigben_probe()"), where the type-confused report list_entry was overlapping with a NULL pointer, which was then causing the crash. Fixes: 918aa1ef104d ("HID: bigbenff: prevent null pointer dereference") Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it> Link: https://lore.kernel.org/r/20230125-hid-unregister-leds-v4-2-7860c5763c38@diag.uniroma1.it Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-02-15HID: bigben: use spinlock to protect concurrent accessesPietro Borrello1-2/+50
bigben driver has a worker that may access data concurrently. Proct the accesses using a spinlock. Fixes: 256a90ed9e46 ("HID: hid-bigbenff: driver for BigBen Interactive PS3OFMINIPAD gamepad") Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it> Link: https://lore.kernel.org/r/20230125-hid-unregister-leds-v4-1-7860c5763c38@diag.uniroma1.it Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-01-17HID: check empty report_list in bigben_probe()Pietro Borrello1-0/+5
Add a check for empty report_list in bigben_probe(). The missing check causes a type confusion when issuing a list_entry() on an empty report_list. The problem is caused by the assumption that the device must have valid report_list. While this will be true for all normal HID devices, a suitably malicious device can violate the assumption. Fixes: 256a90ed9e46 ("HID: hid-bigbenff: driver for BigBen Interactive PS3OFMINIPAD gamepad") Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-05-06HID: bigben: fix slab-out-of-bounds Write in bigben_probeDongliang Mu1-0/+6
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> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-12-02HID: bigbenff: prevent null pointer dereferenceBenjamin Tissoires1-1/+1
When emulating the device through uhid, there is a chance we don't have output reports and so report_field is null. Cc: stable@vger.kernel.org Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20211202095334.14399-3-benjamin.tissoires@redhat.com
2020-02-18HID: hid-bigbenff: fix race condition for scheduled work during removalHanno Zulla1-0/+6
It's possible that there is scheduled work left while the device is already being removed, which can cause a kernel crash. Adding a flag will avoid this. Signed-off-by: Hanno Zulla <kontakt@hanno.de> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2020-02-18HID: hid-bigbenff: call hid_hw_stop() in case of errorHanno Zulla1-5/+10
It's required to call hid_hw_stop() once hid_hw_start() was called previously, so error cases need to handle this. Also, hid_hw_close() is not necessary during removal. Signed-off-by: Hanno Zulla <kontakt@hanno.de> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2020-02-18HID: hid-bigbenff: fix general protection fault caused by double kfreeHanno Zulla1-2/+8
The struct *bigben was allocated via devm_kzalloc() and then used as a parameter in input_ff_create_memless(). This caused a double kfree during removal of the device, since both the managed resource API and ml_ff_destroy() in drivers/input/ff-memless.c would call kfree() on it. Signed-off-by: Hanno Zulla <kontakt@hanno.de> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2018-09-24HID: hid-bigbenff: driver for BigBen Interactive PS3OFMINIPAD gamepadHanno Zulla1-0/+414
This is a driver to fix input mapping and add LED & force feedback support for the "BigBen Interactive Kid-friendly Wired Controller PS3OFMINIPAD SONY" gamepad with USB id 146b:0902. It was originally sold as a PS3 accessory and makes a very nice gamepad for Retropie. Signed-off-by: Hanno Zulla <kontakt@hanno.de> Signed-off-by: Jiri Kosina <jkosina@suse.cz>