summaryrefslogtreecommitdiff
path: root/rust/kernel/alloc/allocator
diff options
context:
space:
mode:
authorAlexandre Becholey <alex@becholey.ch>2026-11-13 14:44:58 +0000
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>2026-11-17 11:19:28 +0100
commite6e2181c6920ff59ded349a100f80cf85d074601 (patch)
tree83d7003202786c5496633bae16d8ed21794c69b9 /rust/kernel/alloc/allocator
parent2e002a1d05b1979006f3c46eb6cb5cc36e5630ac (diff)
gpio: ljca: Validate the pin index of interrupt events
ljca_gpio_event_cb() takes the pin index of every item in a GPIO interrupt event from the device and passes it to set_bit() on the reenable_irqs bitmap, which is only LJCA_MAX_GPIO_NUM (64) bits long. The index is a u8, so a malfunctioning or malicious device can set bits past the end of the bitmap, in the members that follow it in struct ljca_gpio_dev: the output_enabled bitmap, the connect_mode pointer and the irq_lock mutex. connect_mode is later dereferenced and written to by ljca_gpio_set_config() and ljca_irq_set_type(), so the device can flip bits of a kernel pointer that is then used for a write. Until commit 4c4e6ea4a120 ("gpio: ljca: Fix duplicated IRQ mapping") an index without an IRQ mapping made irq_find_mapping() fail and the handler returned before set_bit(). Since that change nothing checks the index. A device bound to usb-ljca can trigger this by sending one GPIO interrupt event, once the gpiochip is registered, with an index that sets a bit of connect_mode which is still clear in a kernel pointer: 175 (bit 47) on arm64, 174 (bit 46) on x86_64. The next GPIO line request then faults in ljca_gpio_set_config(). With dummy_hcd and KASAN, on arm64 (torvalds/master 067c5c24cef2): Unable to handle kernel paging request at virtual address ffff7000023dfd30 pc : ljca_gpio_set_config (drivers/gpio/gpio-ljca.c:212) and on x86_64 (torvalds/master 7e1392a42ea2, nokaslr): BUG: unable to handle page fault for address: ffffc8800f5452b8 RIP: 0010:ljca_gpio_set_config (drivers/gpio/gpio-ljca.c:212) Ignore event items whose pin index is not below the number of GPIOs of the chip. That number never exceeds LJCA_MAX_GPIO_NUM, because usb-ljca rejects larger values at enumeration, so set_bit() stays inside the bitmap. Valid items in the same event are still handled. The bug was found by AI agents (Claude Mythos and Claude Opus models). The analysis and the patch were reviewed by a human, who also reproduced the bug on x86_64 and aarch64 with current master. Fixes: 4c4e6ea4a120 ("gpio: ljca: Fix duplicated IRQ mapping") Cc: stable@vger.kernel.org Signed-off-by: Alexandre Becholey <alex@becholey.ch> Link: https://patch.msgid.link/20261113144432.1354180-1-alex@becholey.ch Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Diffstat (limited to 'rust/kernel/alloc/allocator')
0 files changed, 0 insertions, 0 deletions