From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: Yaohan Li <shunsheng1218@gmail.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Magnus Damm <magnus.damm@gmail.com>,
Eduardo Valentin <edubezval@gmail.com>,
linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] thermal/drivers/rcar_thermal: disable the work before masking the interrupt
Date: Sun, 22 Nov 2026 15:09:06 +0100 [thread overview]
Message-ID: <20261122140906.GA3898744@ragnatech.se> (raw)
In-Reply-To: <179516779969.759914.14349189301325900521@gmail.com>
Hi Yaohan,
On 2026-11-20 17:43:19 +0800, Yaohan Li wrote:
> Hi Niklas,
>
> Thanks for offering to test this on Koelsch.
No worries. I was mostly offering to run a test, not create one ;-)
I know how to try and trigger it, my point was this is a very hard issue
to trigger and was wondering if you had anything already which do so.
Ideally I would like run a test see the old code fail and then apply
this fix and see it solved.
Triggering an interrupt by modifying the temperature, be it with cpuburn
or a hairdryer at the exact same time that the driver is being unbound
seems extremely tricky too me. Even if the bind/unbind operation is put
in a loop. And I though since you where fix lot of drivers you had
something from a hardware setup you had access too.
>
> I went through the Gen2 thermal driver again. One detail worth clarifying is
> that rcar_thermal_update_temp() programs INTCTRL from the current ctemp and
> ctemp - 1, not from the critical trip in the device tree.
>
> Gen2 reports the temperature in 5 C code steps. That does not mean the
> physical temperature has to move a full 5 C to trigger an interrupt: it
> depends on how close the sensor sits to a comparator boundary when the window
> is programmed.
>
> The handler masks the sensor source and schedules the work 300 ms later; the
> work updates the comparator and re-enables the interrupt. So this path
> normally limits how often successive sensor events are handled. Reading the
> zone also goes through the same function and reprograms the comparator, so I
> would avoid tight temperature polling while trying to observe interrupts.
>
> For the first step I would check the e61f0000 entry in /proc/interrupts. The
> line is shared and the handler reports it as handled either way, so the
> counter alone does not prove a thermal event. The driver has a dev_dbg() in
> rcar_thermal_had_changed() that prints rising/falling, so
>
> echo 'file rcar_thermal.c +p' > /proc/dynamic_debug/control
>
> should show whether it really saw an unmasked status change. That needs a
> kernel with dynamic debug enabled; if the file is not there but debugfs is
> mounted, the same control file is at
> /sys/kernel/debug/dynamic_debug/control.
>
> If real sensor interrupts show up during a controlled temperature change,
> then a small number of bind/unbind cycles comparing the original and the
> patched kernel would be the next step. I would not keep a sustained CPU load
> running while the driver is unbound: with it unbound there is no thermal
> monitoring from this driver, and the trip is only a shutdown.
>
> There is also a condition that may be easier to observe than the UAF: in the
> original code a work that is already running re-enables the source after
> ->remove() has masked it, because cancel_delayed_work_sync() waits for it.
> A test-only trace of the mask and enable in _rcar_thermal_irq_ctrl() would
> show that ordering:
>
> original: remove: mask / work: enable / remove: done
> patched: work: done / remove: mask / remove: done
>
> If the natural race turns out to be too rare, I can prepare a separate
> debug-only instrumentation patch to make the interleaving easier to see.
>
> Thanks again for offering the hardware,
> Yaohan
--
Kind Regards,
Niklas Söderlund
prev parent reply other threads:[~2026-11-22 14:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 7:23 [PATCH] thermal/drivers/rcar_thermal: wait for IRQs before cancelling work Yaohan Li
2026-11-18 9:00 ` Niklas Söderlund
2026-11-19 2:29 ` [PATCH v2] thermal/drivers/rcar_thermal: disable the work before masking the interrupt Yaohan Li
2026-11-19 6:22 ` Niklas Söderlund
2026-11-19 11:18 ` Yaohan Li
2026-11-19 16:25 ` Niklas Söderlund
2026-11-20 4:27 ` Yaohan Li
2026-11-20 7:30 ` Niklas Söderlund
2026-11-20 9:43 ` Yaohan Li
2026-11-22 14:09 ` Niklas Söderlund [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261122140906.GA3898744@ragnatech.se \
--to=niklas.soderlund@ragnatech.se \
--cc=daniel.lezcano@kernel.org \
--cc=edubezval@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=magnus.damm@gmail.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=shunsheng1218@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox