* [PATCH 00/10] iio: Fix memory corruption, teardown races and bounds checks
@ 2026-11-19 15:30 Lee Jones
2026-11-19 15:30 ` [PATCH 04/10] iio: adc: stm32-adc: Validate channel index before writing chan_name Lee Jones
2026-11-19 15:30 ` [PATCH 05/10] iio: adc: stm32-adc: Detach chained IRQ handler before removing domain Lee Jones
0 siblings, 2 replies; 8+ messages in thread
From: Lee Jones @ 2026-11-19 15:30 UTC (permalink / raw)
To: lee
Cc: linux-kernel, Alexandre Torgue, Alexandru Ardelean,
Andy Shevchenko, Bogdan Bolocan, David Lechner, Fabrice Gasnier,
Jishnu Prakash, Joe Sandom, Jonathan Cameron, Lars-Peter Clausen,
linux, linux-arm-kernel, linux-arm-msm, linux-iio, linux-stm32,
Lothar Rubusch, Lucas Stankus, Marius Cristea, Mathieu Othacehe,
Maxime Coquelin, Michael Hennerich, Nuno Sá, Olivier Moysan
These issues were reported by Sashiko.
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Alexandru Ardelean <ardeleanalex@gmail.com>
Cc: Andy Shevchenko <andy@kernel.org>
Cc: Bogdan Bolocan <bogdan.bolocan@microchip.com>
Cc: David Lechner <dlechner@baylibre.com>
Cc: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Cc: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
Cc: Joe Sandom <joe.g.sandom@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: linux@analog.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-iio@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: Lothar Rubusch <l.rubusch@gmail.com>
Cc: Lucas Stankus <lucas.p.stankus@gmail.com>
Cc: Marius Cristea <marius.cristea@microchip.com>
Cc: Mathieu Othacehe <othacehe@gnu.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>
Cc: Olivier Moysan <olivier.moysan@foss.st.com>
Lee Jones (10):
iio: imu: adis: Clear pointers after freeing in
adis_update_scan_mode()
iio: accel: adxl313: Prevent FIFO buffer overflow in
adxl313_fifo_transfer()
iio: accel: adxl313: Reject sub-base ODR codes in adxl313_read_raw()
iio: adc: stm32-adc: Validate channel index before writing chan_name
iio: adc: stm32-adc: Detach chained IRQ handler before removing domain
iio: adc: pac1934: Fix custom attribute allocation and channel bounds
iio: adc: qcom-spmi-adc5-gen3: Free TM auxiliary device wrapper in
release callback
iio: adc: qcom-spmi-adc5-gen3: Reject empty reg property in probe
iio: proximity: isl29501: Fix division by zero and overflow in
isl29501_set_freq()
iio: light: tsl2591: Prevent infinite recursion on threshold
boundaries
drivers/iio/accel/adxl313.h | 2 +-
drivers/iio/accel/adxl313_core.c | 13 +++++++++--
drivers/iio/adc/pac1934.c | 33 ++++++++++++---------------
drivers/iio/adc/qcom-spmi-adc5-gen3.c | 32 +++++++++++++++++++++-----
drivers/iio/adc/stm32-adc-core.c | 6 ++---
drivers/iio/adc/stm32-adc.c | 12 +++++-----
drivers/iio/imu/adis_buffer.c | 2 ++
drivers/iio/light/tsl2591.c | 25 ++++++++++++--------
drivers/iio/proximity/isl29501.c | 10 ++++++--
9 files changed, 87 insertions(+), 48 deletions(-)
--
2.56.1.708.g77570a6a1d-goog
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 04/10] iio: adc: stm32-adc: Validate channel index before writing chan_name 2026-11-19 15:30 [PATCH 00/10] iio: Fix memory corruption, teardown races and bounds checks Lee Jones @ 2026-11-19 15:30 ` Lee Jones 2026-11-19 17:24 ` Andy Shevchenko 2026-11-19 15:30 ` [PATCH 05/10] iio: adc: stm32-adc: Detach chained IRQ handler before removing domain Lee Jones 1 sibling, 1 reply; 8+ messages in thread From: Lee Jones @ 2026-11-19 15:30 UTC (permalink / raw) To: lee, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Maxime Coquelin, Alexandre Torgue, Fabrice Gasnier, Olivier Moysan, linux-iio, linux-stm32, linux-arm-kernel Cc: linux-kernel, stable stm32_adc_generic_chan_init() reads the child node's reg property into a signed int and, when the optional label property is present, writes into adc->chan_name[val] and calls stm32_adc_populate_int_ch() before checking whether val exceeds adc_info->max_channels. Because val is signed, values with the top bit set also become negative and bypass the upper-bound check altogether. Store val as a u32, matching fwnode_property_read_u32(), and move the max_channels bounds check immediately after reading reg. Fixes: 95bc818404b2 ("iio: adc: stm32-adc: add support of generic channels binding") Closes: https://sashiko.dev/#/bug/linux-efd2944a-ec30-488d-b2ac-1c7feb831095 Cc: stable@vger.kernel.org Signed-off-by: Lee Jones <lee@kernel.org> --- drivers/iio/adc/stm32-adc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index ab99116aea0a..42f1fc64250a 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -2745,9 +2745,9 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev, const struct stm32_adc_info *adc_info = adc->cfg->adc_info; struct device *dev = &indio_dev->dev; const char *name; - int val, scan_index = 0, ret; + int scan_index = 0, ret; bool differential; - u32 vin[2]; + u32 val, vin[2]; device_for_each_child_node_scoped(dev, child) { ret = fwnode_property_read_u32(child, "reg", &val); @@ -2755,6 +2755,10 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev, return dev_err_probe(dev, ret, "Missing channel index\n"); + if (val >= adc_info->max_channels) + return dev_err_probe(dev, -EINVAL, + "Invalid channel %u\n", val); + ret = fwnode_property_read_string(child, "label", &name); /* label is optional */ if (!ret) { @@ -2773,10 +2777,6 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev, return dev_err_probe(dev, ret, "Invalid label\n"); } - if (val >= adc_info->max_channels) - return dev_err_probe(dev, -EINVAL, - "Invalid channel %d\n", val); - differential = false; ret = fwnode_property_read_u32_array(child, "diff-channels", vin, 2); /* diff-channels is optional */ -- 2.56.1.708.g77570a6a1d-goog ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 04/10] iio: adc: stm32-adc: Validate channel index before writing chan_name 2026-11-19 15:30 ` [PATCH 04/10] iio: adc: stm32-adc: Validate channel index before writing chan_name Lee Jones @ 2026-11-19 17:24 ` Andy Shevchenko 2026-11-20 17:22 ` Fabrice Gasnier 0 siblings, 1 reply; 8+ messages in thread From: Andy Shevchenko @ 2026-11-19 17:24 UTC (permalink / raw) To: Lee Jones Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Maxime Coquelin, Alexandre Torgue, Fabrice Gasnier, Olivier Moysan, linux-iio, linux-stm32, linux-arm-kernel, linux-kernel, stable On Thu, Nov 19, 2026 at 03:30:37PM +0000, Lee Jones wrote: > stm32_adc_generic_chan_init() reads the child node's reg property into a > signed int and, when the optional label property is present, writes into > adc->chan_name[val] and calls stm32_adc_populate_int_ch() before > checking whether val exceeds adc_info->max_channels. Because val is > signed, values with the top bit set also become negative and bypass the > upper-bound check altogether. > > Store val as a u32, matching fwnode_property_read_u32(), and move the > max_channels bounds check immediately after reading reg. ... > + if (val >= adc_info->max_channels) > + return dev_err_probe(dev, -EINVAL, -ECHRNG However it seems in the original code like this. > + "Invalid channel %u\n", val); > + > ret = fwnode_property_read_string(child, "label", &name); -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 04/10] iio: adc: stm32-adc: Validate channel index before writing chan_name 2026-11-19 17:24 ` Andy Shevchenko @ 2026-11-20 17:22 ` Fabrice Gasnier 2026-11-21 22:45 ` Jonathan Cameron 0 siblings, 1 reply; 8+ messages in thread From: Fabrice Gasnier @ 2026-11-20 17:22 UTC (permalink / raw) To: Andy Shevchenko, Lee Jones Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Maxime Coquelin, Alexandre Torgue, Olivier Moysan, linux-iio, linux-stm32, linux-arm-kernel, linux-kernel, stable On 11/19/26 18:24, Andy Shevchenko wrote: > On Thu, Nov 19, 2026 at 03:30:37PM +0000, Lee Jones wrote: >> stm32_adc_generic_chan_init() reads the child node's reg property into a >> signed int and, when the optional label property is present, writes into >> adc->chan_name[val] and calls stm32_adc_populate_int_ch() before >> checking whether val exceeds adc_info->max_channels. Because val is >> signed, values with the top bit set also become negative and bypass the >> upper-bound check altogether. >> >> Store val as a u32, matching fwnode_property_read_u32(), and move the >> max_channels bounds check immediately after reading reg. > > ... > >> + if (val >= adc_info->max_channels) >> + return dev_err_probe(dev, -EINVAL, > > -ECHRNG > > However it seems in the original code like this. Hi Lee, Andy I've no strong opinion on this remark, whether to change the error code here, and if it belongs to this fix ? In all case, Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Best Regards, Thanks, Fabrice > >> + "Invalid channel %u\n", val); >> + >> ret = fwnode_property_read_string(child, "label", &name); > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 04/10] iio: adc: stm32-adc: Validate channel index before writing chan_name 2026-11-20 17:22 ` Fabrice Gasnier @ 2026-11-21 22:45 ` Jonathan Cameron 0 siblings, 0 replies; 8+ messages in thread From: Jonathan Cameron @ 2026-11-21 22:45 UTC (permalink / raw) To: Fabrice Gasnier Cc: Andy Shevchenko, Lee Jones, David Lechner, Nuno Sá, Andy Shevchenko, Maxime Coquelin, Alexandre Torgue, Olivier Moysan, linux-iio, linux-stm32, linux-arm-kernel, linux-kernel, stable On Fri, 20 Nov 2026 18:22:26 +0100 Fabrice Gasnier <fabrice.gasnier@foss.st.com> wrote: > On 11/19/26 18:24, Andy Shevchenko wrote: > > On Thu, Nov 19, 2026 at 03:30:37PM +0000, Lee Jones wrote: > >> stm32_adc_generic_chan_init() reads the child node's reg property into a > >> signed int and, when the optional label property is present, writes into > >> adc->chan_name[val] and calls stm32_adc_populate_int_ch() before > >> checking whether val exceeds adc_info->max_channels. Because val is > >> signed, values with the top bit set also become negative and bypass the > >> upper-bound check altogether. > >> > >> Store val as a u32, matching fwnode_property_read_u32(), and move the > >> max_channels bounds check immediately after reading reg. > > > > ... > > > >> + if (val >= adc_info->max_channels) > >> + return dev_err_probe(dev, -EINVAL, > > > > -ECHRNG > > > > However it seems in the original code like this. > > Hi Lee, Andy > > I've no strong opinion on this remark, whether to change the error code here, and if it belongs to > this fix ? > > In all case, > > Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Let us not over think it. Applied. Given it's hardening against a bad DT, not rushing this one in. It can wait for the next merge window. Thanks, Jonathan > > Best Regards, > Thanks, > Fabrice > > > >> + "Invalid channel %u\n", val); > >> + > >> ret = fwnode_property_read_string(child, "label", &name); > > > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 05/10] iio: adc: stm32-adc: Detach chained IRQ handler before removing domain 2026-11-19 15:30 [PATCH 00/10] iio: Fix memory corruption, teardown races and bounds checks Lee Jones 2026-11-19 15:30 ` [PATCH 04/10] iio: adc: stm32-adc: Validate channel index before writing chan_name Lee Jones @ 2026-11-19 15:30 ` Lee Jones 2026-11-20 17:23 ` Fabrice Gasnier 1 sibling, 1 reply; 8+ messages in thread From: Lee Jones @ 2026-11-19 15:30 UTC (permalink / raw) To: lee, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Maxime Coquelin, Alexandre Torgue, Fabrice Gasnier, linux-iio, linux-stm32, linux-arm-kernel Cc: linux-kernel, stable stm32_adc_irq_remove() disposes of the child IRQ mappings and removes priv->domain before clearing the parent chained IRQ handlers. Because the parent hardware interrupt lines remain unmasked while child devices use dummy_irq_chip, an interrupt arriving during teardown invokes stm32_adc_irq_handler() after irq_domain_remove() has freed priv->domain, and irq_set_chained_handler() also leaves handler_data dangling. Detach the chained handlers and clear handler_data with irq_set_chained_handler_and_data() before tearing down the mappings and removing the domain. Fixes: 1add69880240 ("iio: adc: Add support for STM32 ADC core") Closes: https://sashiko.dev/#/bug/linux-27c38690-bc20-43aa-a3fc-1ddd6f1bb74e Cc: stable@vger.kernel.org Signed-off-by: Lee Jones <lee@kernel.org> --- drivers/iio/adc/stm32-adc-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c index 4b532db3db62..13b75475046c 100644 --- a/drivers/iio/adc/stm32-adc-core.c +++ b/drivers/iio/adc/stm32-adc-core.c @@ -467,12 +467,12 @@ static void stm32_adc_irq_remove(struct platform_device *pdev, int hwirq; unsigned int i; + for (i = 0; i < priv->nb_irqs; i++) + irq_set_chained_handler_and_data(priv->irq[i], NULL, NULL); + for (hwirq = 0; hwirq < priv->nb_adc_max; hwirq++) irq_dispose_mapping(irq_find_mapping(priv->domain, hwirq)); irq_domain_remove(priv->domain); - - for (i = 0; i < priv->nb_irqs; i++) - irq_set_chained_handler(priv->irq[i], NULL); } static int stm32_adc_core_switches_supply_en(struct stm32_adc_priv *priv, -- 2.56.1.708.g77570a6a1d-goog ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 05/10] iio: adc: stm32-adc: Detach chained IRQ handler before removing domain 2026-11-19 15:30 ` [PATCH 05/10] iio: adc: stm32-adc: Detach chained IRQ handler before removing domain Lee Jones @ 2026-11-20 17:23 ` Fabrice Gasnier 2026-11-21 22:51 ` Jonathan Cameron 0 siblings, 1 reply; 8+ messages in thread From: Fabrice Gasnier @ 2026-11-20 17:23 UTC (permalink / raw) To: Lee Jones, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Maxime Coquelin, Alexandre Torgue, linux-iio, linux-stm32, linux-arm-kernel Cc: linux-kernel, stable On 11/19/26 16:30, Lee Jones wrote: > stm32_adc_irq_remove() disposes of the child IRQ mappings and removes > priv->domain before clearing the parent chained IRQ handlers. Because > the parent hardware interrupt lines remain unmasked while child devices > use dummy_irq_chip, an interrupt arriving during teardown invokes > stm32_adc_irq_handler() after irq_domain_remove() has freed > priv->domain, and irq_set_chained_handler() also leaves handler_data > dangling. > > Detach the chained handlers and clear handler_data with > irq_set_chained_handler_and_data() before tearing down the mappings and > removing the domain. > > Fixes: 1add69880240 ("iio: adc: Add support for STM32 ADC core") > Closes: https://sashiko.dev/#/bug/linux-27c38690-bc20-43aa-a3fc-1ddd6f1bb74e > Cc: stable@vger.kernel.org > Signed-off-by: Lee Jones <lee@kernel.org> > --- Hi Lee, Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Best Regards, Thanks, Fabrice > drivers/iio/adc/stm32-adc-core.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c > index 4b532db3db62..13b75475046c 100644 > --- a/drivers/iio/adc/stm32-adc-core.c > +++ b/drivers/iio/adc/stm32-adc-core.c > @@ -467,12 +467,12 @@ static void stm32_adc_irq_remove(struct platform_device *pdev, > int hwirq; > unsigned int i; > > + for (i = 0; i < priv->nb_irqs; i++) > + irq_set_chained_handler_and_data(priv->irq[i], NULL, NULL); > + > for (hwirq = 0; hwirq < priv->nb_adc_max; hwirq++) > irq_dispose_mapping(irq_find_mapping(priv->domain, hwirq)); > irq_domain_remove(priv->domain); > - > - for (i = 0; i < priv->nb_irqs; i++) > - irq_set_chained_handler(priv->irq[i], NULL); > } > > static int stm32_adc_core_switches_supply_en(struct stm32_adc_priv *priv, ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 05/10] iio: adc: stm32-adc: Detach chained IRQ handler before removing domain 2026-11-20 17:23 ` Fabrice Gasnier @ 2026-11-21 22:51 ` Jonathan Cameron 0 siblings, 0 replies; 8+ messages in thread From: Jonathan Cameron @ 2026-11-21 22:51 UTC (permalink / raw) To: Fabrice Gasnier Cc: Lee Jones, David Lechner, Nuno Sá, Andy Shevchenko, Maxime Coquelin, Alexandre Torgue, linux-iio, linux-stm32, linux-arm-kernel, linux-kernel, stable On Fri, 20 Nov 2026 18:23:19 +0100 Fabrice Gasnier <fabrice.gasnier@foss.st.com> wrote: > On 11/19/26 16:30, Lee Jones wrote: > > stm32_adc_irq_remove() disposes of the child IRQ mappings and removes > > priv->domain before clearing the parent chained IRQ handlers. Because > > the parent hardware interrupt lines remain unmasked while child devices > > use dummy_irq_chip, an interrupt arriving during teardown invokes > > stm32_adc_irq_handler() after irq_domain_remove() has freed > > priv->domain, and irq_set_chained_handler() also leaves handler_data > > dangling. > > > > Detach the chained handlers and clear handler_data with > > irq_set_chained_handler_and_data() before tearing down the mappings and > > removing the domain. > > > > Fixes: 1add69880240 ("iio: adc: Add support for STM32 ADC core") > > Closes: https://sashiko.dev/#/bug/linux-27c38690-bc20-43aa-a3fc-1ddd6f1bb74e > > Cc: stable@vger.kernel.org > > Signed-off-by: Lee Jones <lee@kernel.org> > > --- > > Hi Lee, > > Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> This one seems a little more likely to be hit in practice, but it doesn't apply to the fixes tree due to some other recent changes and I'm lazy. Hence applied to the testing branch of iio.git to line it up for next merge cycle. We are getting late enough I should be keeping fixes to critical stuff only and I'm going to assume this one isn't. Jonathan > Best Regards, > Thanks, > Fabrice > > > drivers/iio/adc/stm32-adc-core.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c > > index 4b532db3db62..13b75475046c 100644 > > --- a/drivers/iio/adc/stm32-adc-core.c > > +++ b/drivers/iio/adc/stm32-adc-core.c > > @@ -467,12 +467,12 @@ static void stm32_adc_irq_remove(struct platform_device *pdev, > > int hwirq; > > unsigned int i; > > > > + for (i = 0; i < priv->nb_irqs; i++) > > + irq_set_chained_handler_and_data(priv->irq[i], NULL, NULL); > > + > > for (hwirq = 0; hwirq < priv->nb_adc_max; hwirq++) > > irq_dispose_mapping(irq_find_mapping(priv->domain, hwirq)); > > irq_domain_remove(priv->domain); > > - > > - for (i = 0; i < priv->nb_irqs; i++) > > - irq_set_chained_handler(priv->irq[i], NULL); > > } > > > > static int stm32_adc_core_switches_supply_en(struct stm32_adc_priv *priv, > > ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-21 22:51 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-19 15:30 [PATCH 00/10] iio: Fix memory corruption, teardown races and bounds checks Lee Jones 2026-11-19 15:30 ` [PATCH 04/10] iio: adc: stm32-adc: Validate channel index before writing chan_name Lee Jones 2026-11-19 17:24 ` Andy Shevchenko 2026-11-20 17:22 ` Fabrice Gasnier 2026-11-21 22:45 ` Jonathan Cameron 2026-11-19 15:30 ` [PATCH 05/10] iio: adc: stm32-adc: Detach chained IRQ handler before removing domain Lee Jones 2026-11-20 17:23 ` Fabrice Gasnier 2026-11-21 22:51 ` Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox