patch "iio: adc: at91-sama5d2_adc: Fix potential use-after-free in" added to char-misc-linus
Subsystems (4)
This is a note to let you know that I've just added the patch titled
iio: adc: at91-sama5d2_adc: Fix potential use-after-free in
to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From dbdb442218cd9d613adeab31a88ac973f22c4873 Mon Sep 17 00:00:00 2001
From: Pei Xiao <[email protected]>
Date: Wed, 29 Oct 2025 10:40:16 +0800
Subject: iio: adc: at91-sama5d2_adc: Fix potential use-after-free in
sama5d2_adc driver
at91_adc_interrupt can call at91_adc_touch_data_handler function to start the work by schedule_work(&st->touch_st.workq).
If we remove the module which will call at91_adc_remove to make cleanup, it will free indio_dev through iio_device_unregister but quite a bit later. While the work mentioned above will be used. The sequence of operations that may lead to a UAF bug is as follows:
CPU0 CPU1
| at91_adc_workq_handler
at91_adc_remove |
iio_device_unregister(indio_dev) |
//free indio_dev a bit later |
| iio_push_to_buffers(indio_dev)
| //use indio_devFix it by ensuring that the work is canceled before proceeding with the cleanup in at91_adc_remove.
--- drivers/iio/adc/at91-sama5d2_adc.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/adc/at91-sama5d2_adc.c +1 -0
@@ -2481,6 +2481,7 @@ static void at91_adc_remove(struct platform_device *pdev)struct at91_adc_state *st =iio_priv (indio_dev);iio_device_unregister (indio_dev); +cancel_work_sync (&st->touch_st.workq);at91_adc_dma_disable (st);
Signature · 1 line
2.52.0