public inbox for linux-rtc@vger.kernel.org
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Ke Sun" <sk.alvin.x@gmail.com>
Cc: "Ke Sun" <sunke@kylinos.cn>,
	"Greg KH" <gregkh@linuxfoundation.org>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	linux-rtc@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [RFC PATCH v2 1/5] rtc: migrate driver data to RTC device
Date: Thu, 08 Jan 2026 12:06:58 +0100	[thread overview]
Message-ID: <DFJ5RE94Z5DL.ZVQ9N5TR8W7E@kernel.org> (raw)
In-Reply-To: <66e517b1-bc83-4c73-b2ea-73a31757ab44@gmail.com>

On Thu Jan 8, 2026 at 1:24 AM CET, Ke Sun wrote:
> Correction: Should use devm_request_irq(&ldata->rtc->dev, ...) instead
>
> of devm_request_irq(&adev->dev, ...).
>
>
> While a lifecycle chain exists (ldata -> rtc -> amba_device), the IRQ 
> should
>
> be bound to the device that uses it (the RTC device), matching where driver
>
> data is stored, to avoid UAF.

No, that is wrong.

Your RTC device is a class device, not a bus device. I.e. it is not a
representation of physical device on the bus.

However, the requested IRQ is a physical device resource that belongs to a bus
device, which in your case is an AMBA device. (Please also see my reply [1] from
the previous version again.)

Therefore device resources are only valid to access and hold on to for a driver
as long as it is bound to the corresponding bus device.

This is the fundamental reason why it is desirable to guard the lifetime of the
class device and its callbacks with devres, to ensure that it is always valid to
access device resources from class device callbacks.

In C drivers, you just have to do the right thing, otherwise you indeed end up
with UAFs. In Rust, we can leverage the type system to make it impossible for
drivers to mess this up.

[1] https://lore.kernel.org/all/DFHJM2HAG7Q3.1HGZ3P7H55FD2@kernel.org/

  reply	other threads:[~2026-01-08 11:07 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-07 14:37 [RFC PATCH v2 0/5] rust: Add RTC driver support Ke Sun
2026-01-07 14:37 ` [RFC PATCH v2 1/5] rtc: migrate driver data to RTC device Ke Sun
2026-01-07 14:41   ` Ke Sun
2026-01-07 16:12   ` Greg KH
2026-01-07 23:18     ` Ke Sun
2026-01-08  0:24       ` Ke Sun
2026-01-08 11:06         ` Danilo Krummrich [this message]
2026-01-08  5:46       ` Greg KH
2026-01-08  9:02         ` Ke Sun
2026-01-08  9:10           ` Greg KH
2026-01-08 11:12   ` Danilo Krummrich
2026-01-08 13:45     ` Ke Sun
2026-01-08 13:52       ` Danilo Krummrich
2026-01-08 14:01         ` Ke Sun
2026-01-08 14:01         ` Alexandre Belloni
2026-01-08 14:06           ` Danilo Krummrich
2026-02-20 23:19             ` Alexandre Belloni
2026-01-14 23:23           ` Ke Sun
2026-01-14 23:48             ` Danilo Krummrich
2026-01-07 14:37 ` [RFC PATCH v2 2/5] rust: add AMBA bus driver support Ke Sun
2026-01-08 11:29   ` Danilo Krummrich
2026-01-07 14:37 ` [RFC PATCH v2 3/5] rust: add device wakeup capability support Ke Sun
2026-01-07 14:57   ` Greg KH
2026-01-07 23:35     ` Ke Sun
2026-01-07 14:37 ` [RFC PATCH v2 4/5] rust: add RTC core abstractions and data structures Ke Sun
2026-01-08 11:50   ` Danilo Krummrich
2026-01-08 13:17     ` Ke Sun
2026-01-08 13:49       ` Miguel Ojeda
2026-01-08 13:56         ` Ke Sun
2026-01-08 23:31   ` Kari Argillander
2026-01-07 14:37 ` [RFC PATCH v2 5/5] rust: add PL031 RTC driver Ke Sun
2026-01-08 11:57   ` Danilo Krummrich

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=DFJ5RE94Z5DL.ZVQ9N5TR8W7E@kernel.org \
    --to=dakr@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sk.alvin.x@gmail.com \
    --cc=sunke@kylinos.cn \
    --cc=tmgross@umich.edu \
    /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