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] [day] [month] [year] [list]
Message-Id: <DC09F4MPGE3B.1HCG1U3C0KVAA@kernel.org>
Date: Tue, 12 Aug 2025 09:10:26 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "Danilo Krummrich" <dakr@...nel.org>
Cc: <gregkh@...uxfoundation.org>, <rafael@...nel.org>, <ojeda@...nel.org>,
 <alex.gaynor@...il.com>, <boqun.feng@...il.com>, <gary@...yguo.net>,
 <bjorn3_gh@...tonmail.com>, <a.hindborg@...nel.org>,
 <aliceryhl@...gle.com>, <tmgross@...ch.edu>,
 <rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
 <stable@...r.kernel.org>
Subject: Re: [PATCH] rust: devres: fix leaking call to devm_add_action()

On Tue Aug 12, 2025 at 1:15 AM CEST, Danilo Krummrich wrote:
> On Tue Aug 12, 2025 at 12:45 AM CEST, Benno Lossin wrote:
>> On Mon Aug 11, 2025 at 11:44 PM CEST, Danilo Krummrich wrote:
>> One solution would be to use `pin_chain` on the initializer for `Inner`
>> (not opaque). Another one would be to not use opaque, `UnsafePinned`
>> actually looks like the better fit for this use-case.
>
> Yeah, the problem should go away with UnsafePinned. Maybe, until we have it, we
> can just do the following:
>
> diff --git a/rust/kernel/devres.rs b/rust/kernel/devres.rs
> index bfccf4177644..1981201fa7f9 100644
> --- a/rust/kernel/devres.rs
> +++ b/rust/kernel/devres.rs
> @@ -161,6 +161,9 @@ pub fn new<'a, E>(
>                  //    live at least as long as the returned `impl PinInit<Self, Error>`.
>                  to_result(unsafe {
>                      bindings::devm_add_action(dev.as_raw(), Some(callback), inner.cast())
> +                }).inspect_err(|_| {
> +                    // SAFETY: `inner` is valid for dropping.
> +                    unsafe { core::ptr::drop_in_place(inner) };

Yeah that works too. Though I'd add a comment & improve the safety
comment.

---
Cheers,
Benno

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ