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]
Date:   Wed, 23 Aug 2023 23:28:12 -0300
From:   Martin Rodriguez Reboredo <yakoyoku@...il.com>
To:     Miguel Ojeda <ojeda@...nel.org>,
        Wedson Almeida Filho <wedsonaf@...il.com>,
        Alex Gaynor <alex.gaynor@...il.com>
Cc:     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@...sung.com>,
        Alice Ryhl <aliceryhl@...gle.com>,
        rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
        patches@...ts.linux.dev
Subject: Re: [PATCH 1/2] rust: arc: add explicit `drop()` around
 `Box::from_raw()`

On 8/23/23 13:02, Miguel Ojeda wrote:
> `Box::from_raw()` is `#[must_use]`, which means the result cannot
> go unused.
> 
> In Rust 1.71.0, this was not detected because the block expression
> swallows the diagnostic [1]:
> 
>      unsafe { Box::from_raw(self.ptr.as_ptr()) };
> 
> It would have been detected, however, if the line had been instead:
> 
>      unsafe { Box::from_raw(self.ptr.as_ptr()); }
> 
> i.e. the semicolon being inside the `unsafe` block, rather than
> outside.
> 
> In Rust 1.72.0, the compiler started warning about this [2], so
> without this patch we will get:
> 
>          error: unused return value of `alloc::boxed::Box::<T>::from_raw` that must be used
>          --> rust/kernel/sync/arc.rs:302:22
>          |
>      302 |             unsafe { Box::from_raw(self.ptr.as_ptr()) };
>          |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>          |
>          = note: call `drop(Box::from_raw(ptr))` if you intend to drop the `Box`
>          = note: `-D unused-must-use` implied by `-D warnings`
>      help: use `let _ = ...` to ignore the resulting value
>          |
>      302 |             unsafe { let _ = Box::from_raw(self.ptr.as_ptr()); };
>          |                      +++++++                                 +
> 
> Thus add an add an explicit `drop()` as the `#[must_use]`'s
> annotation suggests (instead of the more general help line).
> 
> Link: https://github.com/rust-lang/rust/issues/104253 [1]
> Link: https://github.com/rust-lang/rust/pull/112529 [2]
> Signed-off-by: Miguel Ojeda <ojeda@...nel.org>
> ---
> [...]
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ