Skip to contentSkip to conversation

Fix a CVE related to patches backported to the CIP kernel

PATCH Applied Nobuhiro Iwamatsu 3 participants 8 messages Oct 26 – Nov 3

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Fix a CVE related to patches backported to the CIP kernel

Hi all,

This is a patch series that fixes a CVE related to patches backported to CIP kernel.
The following CVE and commit are addressed in this:

- CVE-2025-39774:
introduced-commits:
- 2e775fffefca9fe71cabdb4533f13598b29e9631

Best regards,
Nobuhiro

Claudiu Beznea (1):
iio: adc: rzg2l_adc: Set driver data before enabling runtime PM

 drivers/iio/adc/rzg2l_adc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/1 iio: adc: rzg2l_adc: Set driver data before enabling runtime PM

From: Claudiu Beznea <[email protected]>

commit c69e13965f26b8058f538ea8bdbd2d7718cf1fbe upstream.

When stress-testing the system by repeatedly unbinding and binding the ADC device in a loop, and the ADC is a supplier for another device (e.g., a thermal hardware block that reads temperature through the ADC), it may happen that the ADC device is runtime-resumed immediately after runtime PM is enabled, triggered by its consumer. At this point, since drvdata is not yet set and the driver's runtime PM callbacks rely on it, a crash can occur. To avoid this, set drvdata just after it was allocated.

Fixes 89ee8174e8c8 ("iio: adc: rzg2l_adc: Simplify the runtime PM code")
---
 drivers/iio/adc/rzg2l_adc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/rzg2l_adc.c +2 -2
index d48aec92add9ac..418211c06f1fe2 100644
@@ -436,6 +436,8 @@ static int rzg2l_adc_probe(struct platform_device *pdev)
 	if (!indio_dev)
 		return -ENOMEM;
 
+	platform_set_drvdata(pdev, indio_dev);
+
 	adc = iio_priv(indio_dev);
 
 	adc->hw_params = device_get_match_data(dev);
@@ -490,8 +492,6 @@ static int rzg2l_adc_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	platform_set_drvdata(pdev, indio_dev);
-
 	ret = rzg2l_adc_hw_init(dev, adc);
 	if (ret)
 		return dev_err_probe(&pdev->dev, ret,
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#2 lore raw

Re: [cip-dev] [PATCH 5.10.y-cip 1/1] iio: adc: rzg2l_adc: Set driver data before enabling runtime PM

Quoted 12 lines · Nobuhiro Iwamatsu via lists.cip-project.org

From: Claudiu Beznea<[email protected]>

commit c69e13965f26b8058f538ea8bdbd2d7718cf1fbe upstream.

When stress-testing the system by repeatedly unbinding and binding the ADC device in a loop, and the ADC is a supplier for another device (e.g., a thermal hardware block that reads temperature through the ADC), it may happen that the ADC device is runtime-resumed immediately after runtime PM is enabled, triggered by its consumer. At this point, since drvdata is not yet set and the driver's runtime PM callbacks rely on it, a crash can occur. To avoid this, set drvdata just after it was allocated.

Quoted 6 lines
Fixes 89ee8174e8c8 ("iio: adc: rzg2l_adc: Simplify the runtime PM code")
#3 lore raw

Re: [cip-dev] [PATCH 5.10.y-cip 1/1] iio: adc: rzg2l_adc: Set driver data before enabling runtime PM

Hi!

Quoted 12 lines
Quoted 12 lines

From: Claudiu Beznea<[email protected]>

commit c69e13965f26b8058f538ea8bdbd2d7718cf1fbe upstream.

When stress-testing the system by repeatedly unbinding and binding the ADC device in a loop, and the ADC is a supplier for another device (e.g., a thermal hardware block that reads temperature through the ADC), it may happen that the ADC device is runtime-resumed immediately after runtime PM is enabled, triggered by its consumer. At this point, since drvdata is not yet set and the driver's runtime PM callbacks rely on it, a crash can occur. To avoid this, set drvdata just after it was allocated.

Quoted 8 lines
Quoted 6 lines
Fixes 89ee8174e8c8 ("iio: adc: rzg2l_adc: Simplify the runtime PM code")

Thanks for review, applied.

Best regards,
Pavel

#4 lore raw

Re: [cip-dev] [PATCH 5.10.y-cip 1/1] iio: adc: rzg2l_adc: Set driver data before enabling runtime PM

In reply to Nobuhiro Iwamatsu

Hi!

Quoted 11 lines

From: Claudiu Beznea <[email protected]>

commit c69e13965f26b8058f538ea8bdbd2d7718cf1fbe upstream.

When stress-testing the system by repeatedly unbinding and binding the ADC device in a loop, and the ADC is a supplier for another device (e.g., a thermal hardware block that reads temperature through the ADC), it may happen that the ADC device is runtime-resumed immediately after runtime PM is enabled, triggered by its consumer. At this point, since drvdata is not yet set and the driver's runtime PM callbacks rely on it, a crash can occur. To avoid this, set drvdata just after it was allocated.

I'm not sure this was diagnosed properly. Ok, I guess that fixes immediate problem.

We now publish indo_dev pointer before ->hw_params is initialized, before mutex is initialized, and before ioremap is done (and others). If that races with PM callbacks, bad things are going to happen.

Actually I'm not 100% convinced that this patch solves all the problems, are suspend/resume callbacks fine running while adc_hw_init() is running / before irq is initialized?

What happens if PM callbacks are running, then devm_request_irq() fails and device is unregistered racing with callbacks?

Quoted 14 lines
drivers/iio/adc/rzg2l_adc.c +2 -0
index d48aec92add9ac..418211c06f1fe2 100644
@@ -436,6 +436,8 @@ static int rzg2l_adc_probe(struct platform_device *pdev)
 	if (!indio_dev)
 		return -ENOMEM;
 
+	platform_set_drvdata(pdev, indio_dev);
+
 	adc = iio_priv(indio_dev);
 
 	adc->hw_params = device_get_match_data(dev);

drivers/iio/adc/rzg2l_adc.c static int rzg2l_adc_probe(struct platform_device *pdev) · line 497

Quoted 8 lines
drivers/iio/adc/rzg2l_adc.c +0 -2
@@ -490,8 +492,6 @@ static int rzg2l_adc_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	platform_set_drvdata(pdev, indio_dev);
-
 	ret = rzg2l_adc_hw_init(dev, adc);
 	if (ret)
 		return dev_err_probe(&pdev->dev, ret,

Consider moving platform_set_drvdata() immediately before pm_runtime_set_autosuspend_delay().

I'm okay with taking this patch, but someone should take second look at the mainline.

Best regards,
Pavel

#5 lore raw

RE: [cip-dev] [PATCH 5.10.y-cip 1/1] iio: adc: rzg2l_adc: Set driver data before enabling runtime PM

Hi Pavel,

Thanks for your comment.

Quoted 28 lines

-----Original Message-----
From: Pavel Machek <[email protected]>
Sent: Tuesday, October 27, 2026 1:44 AM
To: iwamatsu nobuhiro(岩松 信洋 □DITC○CPT) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [cip-dev] [PATCH 5.10.y-cip 1/1] iio: adc: rzg2l_adc: Set driver data before enabling runtime PM

Hi!

Quoted 11 lines

From: Claudiu Beznea <[email protected]>

commit c69e13965f26b8058f538ea8bdbd2d7718cf1fbe upstream.

When stress-testing the system by repeatedly unbinding and binding the ADC device in a loop, and the ADC is a supplier for another device (e.g., a thermal hardware block that reads temperature through the ADC), it may happen that the ADC device is runtime-resumed immediately after runtime PM is enabled, triggered by its consumer. At this point, since drvdata is not yet set and the driver's runtime PM callbacks rely on it, a crash can occur. To avoid this, set drvdata just after it was

allocated.

I'm not sure this was diagnosed properly. Ok, I guess that fixes immediate problem.

Quoted 7 lines

We now publish indo_dev pointer before ->hw_params is initialized, before mutex is initialized, and before ioremap is done (and others). If that races with PM callbacks, bad things are going to happen.

Actually I'm not 100% convinced that this patch solves all the problems, are suspend/resume callbacks fine running while
adc_hw_init() is running / before irq is initialized?

Since rzg2l_adc_pm_runtime_resume() does not access the IRQ, I think there is no issue.

Quoted 3 lines

What happens if PM callbacks are running, then devm_request_irq() fails and device is unregistered racing with callbacks?

As synchronization is handled by devm and the Runtime PM core, I think there is no issue.

Quoted 29 lines

drivers/iio/adc/rzg2l_adc.c static int rzg2l_adc_probe(struct platform_device

Quoted 6 lines
drivers/iio/adc/rzg2l_adc.c +0 -0
index d48aec92add9ac..418211c06f1fe2 100644
@@ -436,6 +436,8 @@ static int rzg2l_adc_probe(struct platform_device

*pdev)

drivers/iio/adc/rzg2l_adc.c static int rzg2l_adc_probe(struct platform_device *pdev)

Quoted 8 lines
drivers/iio/adc/rzg2l_adc.c +2 -0
 	if (!indio_dev)
 		return -ENOMEM;
 
+	platform_set_drvdata(pdev, indio_dev);
+
 	adc = iio_priv(indio_dev);
 
 	adc->hw_params = device_get_match_data(dev); @@ -490,8 +492,6

@@

drivers/iio/adc/rzg2l_adc.c static int rzg2l_adc_probe(struct platform_device *pdev) · line 497

Quoted 9 lines

static int rzg2l_adc_probe(struct platform_device *pdev)

drivers/iio/adc/rzg2l_adc.c +0 -2
 	if (ret)
 		return ret;
 
-	platform_set_drvdata(pdev, indio_dev);
-
 	ret = rzg2l_adc_hw_init(dev, adc);
 	if (ret)
 		return dev_err_probe(&pdev->dev, ret,

Consider moving platform_set_drvdata() immediately before pm_runtime_set_autosuspend_delay().

Quoted 2 lines

I'm okay with taking this patch, but someone should take second look at the mainline.

+1, that proposed change sounds good.
Moving it to just before runtime PM is enabled would be safer.

Best regards,
Nobuhiro

Applied
#6 lore raw

Re: [cip-dev] [PATCH 5.10.y-cip 1/1] iio: adc: rzg2l_adc: Set driver data before enabling runtime PM

Hi!

Quoted 10 lines
Quoted 7 lines
Quoted 2 lines

From: Claudiu Beznea <[email protected]>

Consider moving platform_set_drvdata() immediately before pm_runtime_set_autosuspend_delay().

I'm okay with taking this patch, but someone should take second look at the mainline.

+1, that proposed change sounds good.
Moving it to just before runtime PM is enabled would be safer.

I applied the patch. I would still like for someone to take a look at the mainline, as the code is quite confusing.

Best regards,
Pavel

#7 lore raw

Re: [cip-dev] [PATCH 5.10.y-cip 1/1] iio: adc: rzg2l_adc: Set driver data before enabling runtime PM

In reply to Pavel Machek

Hi, Pavel,

Quoted 14 lines · Pavel Machek via lists.cip-project.org

Hi!

Quoted 11 lines

From: Claudiu Beznea <[email protected]>

commit c69e13965f26b8058f538ea8bdbd2d7718cf1fbe upstream.

When stress-testing the system by repeatedly unbinding and binding the ADC device in a loop, and the ADC is a supplier for another device (e.g., a thermal hardware block that reads temperature through the ADC), it may happen that the ADC device is runtime-resumed immediately after runtime PM is enabled, triggered by its consumer. At this point, since drvdata is not yet set and the driver's runtime PM callbacks rely on it, a crash can occur. To avoid this, set drvdata just after it was allocated.

Quoted 6 lines

I'm not sure this was diagnosed properly. Ok, I guess that fixes immediate problem.

We now publish indo_dev pointer before ->hw_params is initialized, before mutex is initialized, and before ioremap is done (and others).

I may be missing some bits here but, at the moment we set the indio_dev as platform data it is just allocated though IIO specific calls. An IIO device is registered for the allocated indio_dev at the end of the probe. Until the devm_iio_device_register() is called there should be no IIO subsystem call reaching the driver code.

Quoted 2 lines

If that races with PM callbacks, bad things are going to happen.

The PM callbacks should be called only after devm_pm_runtime_enable() is called.

device_initialize() ->
pm_runtime_init() ->

    // ...
    dev->power.disable_depth = 1;

and rpm_resume() returns if disable_depth > 0.

pm_runtime_enable() decrements disable_depth.

Please let me know if I'm missing something.

Quoted 4 lines

Actually I'm not 100% convinced that this patch solves all the problems, are suspend/resume callbacks fine running while adc_hw_init() is running / before irq is initialized?

adc_hw_init() calls pm_runtime_resume_and_get() on its own. That should increment the RPM counter and avoid powering off the HW while any adc_hw_init() operations are in progress.

If there is conversion started before the hw_init (e.g. by previous applications), runtime resuming the device at that time should not trigger anything to Linux since the IRQ is not requested.

Quoted 3 lines

What happens if PM callbacks are running, then devm_request_irq() fails and device is unregistered racing with callbacks?

I expect this is properly handled by the subsystem: it should detect when a parent device got unregistered or fail to complete registration.

Quoted 18 lines
Quoted 18 lines
drivers/iio/adc/rzg2l_adc.c +2 -0
index d48aec92add9ac..418211c06f1fe2 100644
@@ -436,6 +436,8 @@ static int rzg2l_adc_probe(struct platform_device *pdev)
  	if (!indio_dev)
  		return -ENOMEM;
 
+	platform_set_drvdata(pdev, indio_dev);
+
  	adc = iio_priv(indio_dev);
 
  	adc->hw_params = device_get_match_data(dev);
@@ -490,8 +492,6 @@ static int rzg2l_adc_probe(struct platform_device *pdev)
  	if (ret)
  		return ret;
 
Quoted 8 lines

drivers/iio/adc/rzg2l_adc.c static int rzg2l_adc_probe(struct platform_device *pdev) · line 497

Quoted 5 lines
drivers/iio/adc/rzg2l_adc.c +0 -2
-	platform_set_drvdata(pdev, indio_dev);
-
  	ret = rzg2l_adc_hw_init(dev, adc);
  	if (ret)
  		return dev_err_probe(&pdev->dev, ret,

Consider moving platform_set_drvdata() immediately before pm_runtime_set_autosuspend_delay().

That can be done but, unless I'm missing something, that should not influence the behavior currently present with this patch.

Please let me know otherwise.

Thank you,
Claudiu

Quoted 16 lines

I'm okay with taking this patch, but someone should take second look at the mainline.

Best regards,
Pavel

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#24546): https://lists.cip-project.org/g/cip-dev/message/24546
Mute This Topic: https://lists.cip-project.org/mt/121936051/8377987
Group Owner: [email protected]
Unsubscribe: https://lists.cip-project.org/g/cip-dev/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-