CVE-2022-49478: media: pvrusb2: fix array-index-out-of-bounds in pvr2_i2c_core_init
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
media: pvrusb2: fix array-index-out-of-bounds in pvr2_i2c_core_init
Syzbot reported that -1 is used as array index. The problem was in missing validation check.
hdw->unit_number is initialized with -1 and then if init table walk fails this value remains unchanged. Since code blindly uses this member for array indexing adding sanity check is the easiest fix for that.
hdw->workpoll initialization moved upper to prevent warning in __flush_work.
The Linux kernel CVE team has assigned CVE-2022-49478 to this issue.
Affected and fixed versions
===========================
Issue introduced in 2.6.18 with commit d855497edbfbf9e19a17f4a1154bca69cb4bd9ba and fixed in 4.9.318 with commit 4351bfe36aba9fa7dc9d68d498d25d41a0f45e67 Issue introduced in 2.6.18 with commit d855497edbfbf9e19a17f4a1154bca69cb4bd9ba and fixed in 4.14.283 with commit 2e004fe914b243db41fa96f9e583385f360ea58e Issue introduced in 2.6.18 with commit d855497edbfbf9e19a17f4a1154bca69cb4bd9ba and fixed in 4.19.247 with commit a3660e06675bccec4bf149c7229ea1d491ba10d7 Issue introduced in 2.6.18 with commit d855497edbfbf9e19a17f4a1154bca69cb4bd9ba and fixed in 5.4.198 with commit 1310fc3538dcc375a2f46ef0a438512c2ca32827 Issue introduced in 2.6.18 with commit d855497edbfbf9e19a17f4a1154bca69cb4bd9ba and fixed in 5.10.121 with commit a3304766d9384886e6d3092c776273526947a2e9 Issue introduced in 2.6.18 with commit d855497edbfbf9e19a17f4a1154bca69cb4bd9ba and fixed in 5.15.46 with commit 3309c2c574e13b21b44729f5bdbf21f60189b79a Issue introduced in 2.6.18 with commit d855497edbfbf9e19a17f4a1154bca69cb4bd9ba and fixed in 5.17.14 with commit f99a8b1ec0eddc2931aeaa4f490277a15b39f511 Issue introduced in 2.6.18 with commit d855497edbfbf9e19a17f4a1154bca69cb4bd9ba and fixed in 5.18.3 with commit 24e807541e4a9263ed928e6ae3498de3ad43bd1e Issue introduced in 2.6.18 with commit d855497edbfbf9e19a17f4a1154bca69cb4bd9ba and fixed in 5.19 with commit 471bec68457aaf981add77b4f590d65dd7da1059
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-2022-49478
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/media/usb/pvrusb2/pvrusb2-hdw.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/4351bfe36aba9fa7dc9d68d498d25d41a0f45e67 https://git.kernel.org/stable/c/2e004fe914b243db41fa96f9e583385f360ea58e https://git.kernel.org/stable/c/a3660e06675bccec4bf149c7229ea1d491ba10d7 https://git.kernel.org/stable/c/1310fc3538dcc375a2f46ef0a438512c2ca32827 https://git.kernel.org/stable/c/a3304766d9384886e6d3092c776273526947a2e9 https://git.kernel.org/stable/c/3309c2c574e13b21b44729f5bdbf21f60189b79a https://git.kernel.org/stable/c/f99a8b1ec0eddc2931aeaa4f490277a15b39f511 https://git.kernel.org/stable/c/24e807541e4a9263ed928e6ae3498de3ad43bd1e https://git.kernel.org/stable/c/471bec68457aaf981add77b4f590d65dd7da1059