Re: [PATCH v2] thermal/drivers/rcar_thermal: disable the work before masking the interrupt

From: Yaohan Li

Date: Fri Nov 20 2026 - 04:43:36 EST


Hi Niklas,

Thanks for offering to test this on Koelsch.

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