CVE-2021-47282·Kernel vulnerability
In the Linux kernel, the following vulnerability has been resolved: spi: bcm2835: Fix out-of-bounds access with more than 4 slaves Commit 571e31fa60b3 ("spi: bcm2835: Cache CS register value for ->prepare_message()") limited the number of slaves to 3 at compile-time. The limitation was necessitated by a statically-sized array prepare_cs[] in the driver private data which contains a per-slave register value. The commit sought to enforce the limitation at run-time by setting the controller's num_chipselect to 3: Slaves with a higher chipselect are rejected by spi_add_device(). However the commit neglected that num_chipselect only limits the number of *native* chipselects. If GPIO chipselects are specified in the device tree for more than 3 slaves, num_chipselect is silently raised by of_spi_get_gpio_numbers() and the result are out-of-bounds accesses to the statically-sized array prepare_cs[]. As a bandaid fix which is backportable to stable, raise the number of allowed slaves to 24 (which "ought to be enough for anybody"), enforce the limitation on slave ->setup and revert num_chipselect to 3 (which is the number of native chipselects supported by the controller). An upcoming for-next commit will allow an arbitrary number of slaves.
- Severity
- high
- Software
- Kernel
- Fixed in
- 5.12.11
- Published
- 2024-05-21
Affected versions
From: 5.11
Until: 5.12.11
Fixed in: 5.12.11
How to fix this CVE
Update your Linux kernel to version 5.12.11 or later to resolve this memory access vulnerability affecting the Broadcom SPI controller driver. The issue occurs when GPIO chipselects are configured for more than 3 SPI slaves, causing out-of-bounds array access. Prioritize this update for systems using bcm2835 SPI interfaces with multiple slave devices.
sudo dnf update kernel kernel-develDefensia detects this vulnerability
How to check if you are affected
- Check kernel version: uname -r (vulnerable if output shows 5.11.x through 5.12.10)
- Verify bcm2835 driver presence: lsmod | grep spi_bcm2835 (confirms if SPI driver is loaded)
- Inspect device tree for multiple GPIO chipselects: grep -r 'cs-gpios' /boot/dtbs/ or cat /proc/device-tree/soc/spi@*/cs-gpios (shows if more than 3 SPI slaves configured)
- Validate kernel patch applied: grep -i 'fix.*out-of-bounds.*spi' /var/log/apt/history.log or check uname -r returns 5.12.11+ with bcm2835 module loaded
FAQ
What is CVE-2021-47282?
This vulnerability is a memory safety issue in the Linux kernel's Broadcom SPI (bcm2835) driver that occurs when device trees configure more than 3 GPIO-based chip select lines. The driver allocates a fixed-size array for only 3 slaves but fails to properly enforce this limit when GPIO chipselects are present, leading to out-of-bounds memory access.
Is CVE-2021-47282 being actively exploited?
No, CVE-2021-47282 is not listed in CISA's Known Exploited Vulnerabilities catalog and no public exploits are available. However, it remains a high-severity local privilege escalation risk due to its CVSS score of 7.8.
What versions of Kernel are affected by CVE-2021-47282?
Linux kernel versions 5.11.0 through 5.12.10 are vulnerable. The fix was integrated into kernel 5.12.11 and later stable releases.
How do I check if my server is vulnerable to CVE-2021-47282?
Run: uname -r (if output shows 5.11.x-5.12.10) and lsmod | grep spi_bcm2835 (confirms driver is in use). If both conditions are true and your device tree has 4+ GPIO chipselects, the system is vulnerable.
Does Defensia detect CVE-2021-47282?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If the Linux kernel package is installed on a monitored server, CVE-2021-47282 will appear in your dashboard with remediation steps.
Related Kernel CVEs
References
- 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
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2021-47282. Free for 1 server.
Get started free