diff options
| author | Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> | 2026-11-10 11:01:10 +0100 |
|---|---|---|
| committer | Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> | 2026-11-12 09:32:48 +0100 |
| commit | f8a4fdf57cedb9cb3f47d94269ff27fea8e819e8 (patch) | |
| tree | 0d0da9a271c4b0298db5abf5d6814d38abbac142 /rust/kernel/alloc/kvec/errors.rs | |
| parent | 53043b9e83cc7f4e30e70161b67ae93c4c9fdb87 (diff) | |
gpiolib: fix stack out-of-bounds access in gpiochip_add_hog()
In gpiochip_add_hog(), parsing a device tree with an excessively large
"#gpio-cells" property causes a stack out-of-bounds write when populating
the GPIO specification.
The value read from #gpio-cells is used to copy the values into right
places in struct fwnode_reference_args but that struct's args field is
an array of size NR_FWNODE_REFERENCE_ARGS so a value larger than it will
make the loop write past the end of that array.
If #gpio-cells is 0, we can trigger a divide-by-zero later when
calculating the actual number of hogs.
If #gpio-cells is 1, we can also perform an out-of-bounds read of
the "gpios" array.
Reject #gpio-cells larger than NR_FWNODE_REFERENCE_ARGS, lower than 1
and make sure #gpio-cells is larger than 1 before checking the
active-low flag.
Cc: stable@vger.kernel.org
Fixes: 802c51a83e9a ("gpiolib: fix hogs with multiple lines")
Closes: https://sashiko.dev/#/bug/linux-fdec1c0e-c6e3-4eb6-8746-d68a3f951374
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20261110-gpiolib-hog-stack-corruption-v2-1-c5b28cb8dc8e@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Diffstat (limited to 'rust/kernel/alloc/kvec/errors.rs')
0 files changed, 0 insertions, 0 deletions
