Subject: CVE-2021-47404: HID: betop: fix slab-out-of-bounds Write in betop_probe

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

HID: betop: fix slab-out-of-bounds Write in betop_probe

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

So this patch checks hid_device's input is non empty before it's been used.

The Linux kernel CVE team has assigned CVE-2021-47404 to this issue.

Affected and fixed versions
===========================

	Fixed in 4.4.286 with commit a4faa7153b87
	Fixed in 4.9.285 with commit 6fc4476dda58
	Fixed in 4.14.249 with commit 1c83c38dec83
	Fixed in 4.19.209 with commit bb8b72374db6
	Fixed in 5.4.151 with commit fe9bb925e709
	Fixed in 5.10.71 with commit dedfc35a2de2
	Fixed in 5.14.10 with commit 708107b80aa6
	Fixed in 5.15 with commit 1e4ce418b1cb

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2021-47404
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	drivers/hid/hid-betopff.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/a4faa7153b87fbcfe4be15f4278676f79ca6e019
	https://git.kernel.org/stable/c/6fc4476dda58f6c00097c7ddec3b772513f57525
	https://git.kernel.org/stable/c/1c83c38dec83d57bc18d0c01d82c413d3b34ccb9
	https://git.kernel.org/stable/c/bb8b72374db69afa25a5b65cf1c092860c6fe914
	https://git.kernel.org/stable/c/fe9bb925e7096509711660d39c0493a1546e9550
	https://git.kernel.org/stable/c/dedfc35a2de2bae9fa3da8210a05bfd515f83fee
	https://git.kernel.org/stable/c/708107b80aa616976d1c5fa60ac0c1390749db5e
	https://git.kernel.org/stable/c/1e4ce418b1cb1a810256b5fb3fd33d22d1325993