mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yaohan Li <shunsheng1218@gmail.com>
To: Niklas Söderlund <niklas.soderlund@ragnatech.se>
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: Fri, 20 Nov 2026 17:43:19 +0800	[thread overview]
Message-ID: <179516779969.759914.14349189301325900521@gmail.com> (raw)
In-Reply-To: <20261120073021.GA3126029@ragnatech.se>

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

      reply	other threads:[~2026-11-20  9:43 UTC|newest]

Thread overview: 9+ 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 [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=179516779969.759914.14349189301325900521@gmail.com \
    --to=shunsheng1218@gmail.com \
    --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=niklas.soderlund@ragnatech.se \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.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

all inboxes | Powered by JetHome®