CVE-2021-47282
Severity CVSS v4.0:
Pending analysis
Type:
CWE-787
Out-of-bounds Write
Publication date:
21/05/2024
Last modified:
30/04/2025
Description
In the Linux kernel, the following vulnerability has been resolved:<br />
<br />
spi: bcm2835: Fix out-of-bounds access with more than 4 slaves<br />
<br />
Commit 571e31fa60b3 ("spi: bcm2835: Cache CS register value for<br />
->prepare_message()") limited the number of slaves to 3 at compile-time.<br />
The limitation was necessitated by a statically-sized array prepare_cs[]<br />
in the driver private data which contains a per-slave register value.<br />
<br />
The commit sought to enforce the limitation at run-time by setting the<br />
controller&#39;s num_chipselect to 3: Slaves with a higher chipselect are<br />
rejected by spi_add_device().<br />
<br />
However the commit neglected that num_chipselect only limits the number<br />
of *native* chipselects. If GPIO chipselects are specified in the<br />
device tree for more than 3 slaves, num_chipselect is silently raised by<br />
of_spi_get_gpio_numbers() and the result are out-of-bounds accesses to<br />
the statically-sized array prepare_cs[].<br />
<br />
As a bandaid fix which is backportable to stable, raise the number of<br />
allowed slaves to 24 (which "ought to be enough for anybody"), enforce<br />
the limitation on slave ->setup and revert num_chipselect to 3 (which is<br />
the number of native chipselects supported by the controller).<br />
An upcoming for-next commit will allow an arbitrary number of slaves.
Impact
Base Score 3.x
7.80
Severity 3.x
HIGH
Vulnerable products and versions
| CPE | From | Up to |
|---|---|---|
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.4 (including) | 5.4.126 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.5 (including) | 5.10.44 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.11 (including) | 5.12.11 (excluding) |
| cpe:2.3:o:linux:linux_kernel:5.13:rc1:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:5.13:rc2:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:5.13:rc3:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:5.13:rc4:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:5.13:rc5:*:*:*:*:*:* |
To consult the complete list of CPE names with products and versions, see this page
References to Advisories, Solutions, and Tools
- https://git.kernel.org/stable/c/01415ff85a24308059e06ca3e97fd7bf75648690
- https://git.kernel.org/stable/c/13817d466eb8713a1ffd254f537402f091d48444
- https://git.kernel.org/stable/c/82a8ffba54d31e97582051cb56ba1f988018681e
- https://git.kernel.org/stable/c/b5502580cf958b094f3b69dfe4eece90eae01fbc
- https://git.kernel.org/stable/c/01415ff85a24308059e06ca3e97fd7bf75648690
- https://git.kernel.org/stable/c/13817d466eb8713a1ffd254f537402f091d48444
- https://git.kernel.org/stable/c/82a8ffba54d31e97582051cb56ba1f988018681e
- https://git.kernel.org/stable/c/b5502580cf958b094f3b69dfe4eece90eae01fbc



