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: <DAKI7G567TFV.14ODG2Q5AMAVL@kernel.org>
Date: Thu, 12 Jun 2025 13:04:57 +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>, <benno.lossin@...ton.me>,
 <a.hindborg@...nel.org>, <aliceryhl@...gle.com>, <tmgross@...ch.edu>,
 <chrisi.schrefl@...il.com>, <rust-for-linux@...r.kernel.org>,
 <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/3] rust: devres: fix race in Devres::drop()

On Thu Jun 12, 2025 at 12:31 PM CEST, Danilo Krummrich wrote:
> On Thu, Jun 12, 2025 at 10:13:29AM +0200, Benno Lossin wrote:
>> On Tue Jun 3, 2025 at 10:48 PM CEST, Danilo Krummrich wrote:
>> >  impl<T> Drop for Devres<T> {
>> >      fn drop(&mut self) {
>> > -        DevresInner::remove_action(&self.0);
>> > +        // SAFETY: When `drop` runs, it is guaranteed that nobody is accessing the revocable data
>> > +        // anymore, hence it is safe not to wait for the grace period to finish.
>> > +        if unsafe { self.revoke_nosync() } {
>> > +            // We revoked `self.0.data` before the devres action did, hence try to remove it.
>> > +            if !DevresInner::remove_action(&self.0) {
>> 
>> Shouldn't this not be inverted? (ie 's/!//')
>> 
>> Otherwise this will return `true`, get negated and we don't run the code
>> below and the `inner.data.revoke()` in `devres_callback` will return
>> `false` which will get negated and thus it will never return.
>
> DevresInner::remove_action() returns false it means that the devres action has
> already been taken from the list and will be run eventually, hence we have to
> complete the completion.
>
> If DevresInner::remove_action() returns true, it means that we removed the
> action from the list and the callback will never be exectuted, hence nothing to
> do.

Ahh I mixed up which call was which, I thought this was
`self.revoke_nosync()`...

---
Cheers,
Benno

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ