{"id":"CVE-2021-47282","aliases":["CVE-2021-47282"],"related":[],"kind":"vulnerability","state":"published","title":"spi: bcm2835: Fix out-of-bounds access with more than 4 slaves","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nspi: bcm2835: Fix out-of-bounds access with more than 4 slaves\n\nCommit 571e31fa60b3 (\"spi: bcm2835: Cache CS register value for\n->prepare_message()\") limited the number of slaves to 3 at compile-time.\nThe limitation was necessitated by a statically-sized array prepare_cs[]\nin the driver private data which contains a per-slave register value.\n\nThe commit sought to enforce the limitation at run-time by setting the\ncontroller's num_chipselect to 3:  Slaves with a higher chipselect are\nrejected by spi_add_device().\n\nHowever the commit neglected that num_chipselect only limits the number\nof *native* chipselects.  If GPIO chipselects are specified in the\ndevice tree for more than 3 slaves, num_chipselect is silently raised by\nof_spi_get_gpio_numbers() and the result are out-of-bounds accesses to\nthe statically-sized array prepare_cs[].\n\nAs a bandaid fix which is backportable to stable, raise the number of\nallowed slaves to 24 (which \"ought to be enough for anybody\"), enforce\nthe limitation on slave ->setup and revert num_chipselect to 3 (which is\nthe number of native chipselects supported by the controller).\nAn upcoming for-next commit will allow an arbitrary number of slaves.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nspi: bcm2835: Fix out-of-bounds access with more than 4 slaves\n\nCommit 571e31fa60b3 (\"spi: bcm2835: Cache CS register value for\n->prepare_message()\") limited the number of slaves to 3 at compile-time.\nThe limitation was necessitated by a statically-sized array prepare_cs[]\nin the driver private data which contains a per-slave register value.\n\nThe commit sought to enforce the limitation at run-time by setting the\ncontroller's num_chipselect to 3:  Slaves with a higher chipselect are\nrejected by spi_add_device().\n\nHowever the commit neglected that num_chipselect only limits the number\nof *native* chipselects.  If GPIO chipselects are specified in the\ndevice tree for more than 3 slaves, num_chipselect is silently raised by\nof_spi_get_gpio_numbers() and the result are out-of-bounds accesses to\nthe statically-sized array prepare_cs[].\n\nAs a bandaid fix which is backportable to stable, raise the number of\nallowed slaves to 24 (which \"ought to be enough for anybody\"), enforce\nthe limitation on slave ->setup and revert num_chipselect to 3 (which is\nthe number of native chipselects supported by the controller).\nAn upcoming for-next commit will allow an arbitrary number of slaves.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: spi: bcm2835: corrige el acceso fuera de los límites con más de 4 esclavos. La confirmación 571e31fa60b3 (\"spi: bcm2835: valor de registro CS de caché para -&gt;prepare_message()\") limitó el número de esclavos a 3 en tiempo de compilación. La limitación fue necesaria por una matriz de tamaño estático prepare_cs[] en los datos privados del controlador que contiene un valor de registro por esclavo. La confirmación buscaba hacer cumplir la limitación en tiempo de ejecución estableciendo num_chipselect del controlador en 3: spi_add_device() rechaza los esclavos con una selección de chip más alta. Sin embargo, la confirmación omitió que num_chipselect solo limita el número de selecciones de chips *nativas*. Si se especifican selecciones de chips GPIO en el árbol de dispositivos para más de 3 esclavos, of_spi_get_gpio_numbers() genera silenciosamente num_chipselect y el resultado son accesos fuera de los límites a la matriz de tamaño estático prepare_cs[]. Como solución curita que se puede volver a transferir a estable, aumente la cantidad de esclavos permitidos a 24 (lo que \"debería ser suficiente para cualquiera\"), aplique la limitación en esclavo -&gt; configuración y revierta num_chipselect a 3 (que es la cantidad de nativos selecciones de chips admitidas por el controlador). Una próxima confirmación para la próxima permitirá una cantidad arbitraria de esclavos.","source":"nvd"}],"published":"2024-05-21T14:20:08.155Z","modified":"2026-08-05T08:47:04.965Z","severity":{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},"severities":[{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"}],"cwes":["CWE-787"],"affected":[{"ranges":[{"type":"git","introduced":"571e31fa60b3697d5db26140e16d5c45c51c9815","fixed":"b5502580cf958b094f3b69dfe4eece90eae01fbc","status":"affected"},{"type":"git","introduced":"571e31fa60b3697d5db26140e16d5c45c51c9815","fixed":"82a8ffba54d31e97582051cb56ba1f988018681e","status":"affected"},{"type":"git","introduced":"571e31fa60b3697d5db26140e16d5c45c51c9815","fixed":"01415ff85a24308059e06ca3e97fd7bf75648690","status":"affected"},{"type":"git","introduced":"571e31fa60b3697d5db26140e16d5c45c51c9815","fixed":"13817d466eb8713a1ffd254f537402f091d48444","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"5.4","status":"affected"},{"type":"semver","introduced":"0","fixed":"5.4","status":"unaffected"},{"type":"semver","introduced":"5.4.126","lastAffected":"5.4.*","status":"unaffected"},{"type":"semver","introduced":"5.10.44","lastAffected":"5.10.*","status":"unaffected"},{"type":"semver","introduced":"5.12.11","lastAffected":"5.12.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"5.13","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"status":"affected","introduced":"5.4","fixed":"5.4.126"},{"status":"affected","introduced":"5.5","fixed":"5.10.44"},{"status":"affected","introduced":"5.11","fixed":"5.12.11"},{"status":"affected","version":"5.13"},{"status":"affected","version":"5.13"},{"status":"affected","version":"5.13"},{"status":"affected","version":"5.13"},{"status":"affected","version":"5.13"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/b5502580cf958b094f3b69dfe4eece90eae01fbc","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/82a8ffba54d31e97582051cb56ba1f988018681e","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/01415ff85a24308059e06ca3e97fd7bf75648690","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/13817d466eb8713a1ffd254f537402f091d48444","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2024-05-23T17:10:17.644Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-47282","url":"https://www.cve.org/CVERecord?id=CVE-2021-47282","licence":"CVE Terms of Use","modified":"2026-08-05T08:47:04.965Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-47282","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-47282","licence":"Public domain","modified":"2026-08-04T10:16:56.300Z"}],"updatedAt":"2026-11-25T22:58:08.775Z","epss":{"score":0.00233,"percentile":0.15132,"date":"2026-12-01T12:00:22.000Z"}}