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 /> -&gt;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&amp;#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 -&gt;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.

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:*:*:*:*:*:*