lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aD7JuyVRVr5dSqE9@cassiopeiae>
Date: Tue, 3 Jun 2025 12:08:59 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Daniel Almeida <daniel.almeida@...labora.com>,
	Miguel Ojeda <ojeda@...nel.org>,
	Alex Gaynor <alex.gaynor@...il.com>,
	Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>,
	Benno Lossin <benno.lossin@...ton.me>,
	Andreas Hindborg <a.hindborg@...nel.org>,
	Trevor Gross <tmgross@...ch.edu>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	"Rafael J. Wysocki" <rafael@...nel.org>,
	Thomas Gleixner <tglx@...utronix.de>, linux-kernel@...r.kernel.org,
	rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v3 1/2] rust: irq: add support for request_irq()

On Tue, Jun 03, 2025 at 11:57:22AM +0200, Alice Ryhl wrote:
> On Tue, Jun 3, 2025 at 11:43 AM Danilo Krummrich <dakr@...nel.org> wrote:
> >
> > On Tue, Jun 03, 2025 at 11:18:40AM +0200, Alice Ryhl wrote:
> > > I don't think that helps. If Devres::drop gets to swap is_available
> > > before the devm callback performs the swap, then the devm callback is
> > > just a no-op and the device still doesn't wait for free_irq() to
> > > finish running.
> >
> > True, this will indeed always be racy. The rule from the C API has always been
> > that devm_{remove,release}_action() must not be called if a concurrent unbind
> > can't be ruled out. Consequently, the same is true for Revocable::revoke() in
> > this case.
> >
> > I think Devres::drop() shouldn't do anything then and instead we should provide
> > Devres::release() and Devres::remove(), which require the &Device<Bound>
> > reference the Devres object was created with, in order to prove that there
> > can't be a concurrent unbind, just like Devres::access().
> 
> What I suggested with the mutex would work if you remove the devm
> callback *after* calling free_irq.
> 
>     // drop Registration
>     mutex_lock();
>     free_irq();
>     mutex_unlock();
>     devm_remove_callback();

I think it would need to be

	if (!devm_remove_callback()) {
		mutex_lock();
		free_irq();
		mutex_unlock();
	}

>     // devm callback
>     mutex_lock();
>     free_irq();
>     mutex_unlock();

Yes, we could solve this with a lock as well, but it would be an additional
lock, just to maintain the current drop() semantics, which I don't see much
value in.

The common case is that the object wrapped in a Devres is meant to live for the
entire duration the device is bound to the driver.

> Another simpler option is to just not support unregistering the irq
> callback except through devm. Then you don't have a registration at
> all. Creating the callback can take an irq number and a ForeignOwnable
> to put in the void pointer. The devm callback calls free_irq and drops
> the ForeignOwnable.

That's basically what Devres::new_foreign_owned() already does.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ