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:   Mon, 17 Jul 2023 13:47:40 +0000
From:   Alice Ryhl <aliceryhl@...gle.com>
To:     benno.lossin@...ton.me
Cc:     alex.gaynor@...il.com, aliceryhl@...gle.com,
        bjorn3_gh@...tonmail.com, boqun.feng@...il.com, gary@...yguo.net,
        jiangshanlai@...il.com, linux-kernel@...r.kernel.org,
        ojeda@...nel.org, patches@...ts.linux.dev,
        rust-for-linux@...r.kernel.org, tj@...nel.org,
        walmeida@...rosoft.com, wedsonaf@...il.com
Subject: Re: [PATCH v3 2/9] rust: sync: add `Arc::{from_raw, into_raw}`

Benno Lossin <benno.lossin@...ton.me> writes:
>> +    /// This code relies on the `repr(C)` layout of structs as described in
>> +    /// <https://doc.rust-lang.org/reference/type-layout.html#reprc-structs>.
> 
> Why is this in the documentation? I feel like it should be a normal code
> comment at the very start of the function.

In fact, I think we can drop this comment entirely. The motivation
behind using `Layout::extend` for computing `val_offset` is that its
correctness does not rely on how the repr(C) layout algorithm works.

(As opposed to how the previous implementation's correctness *does*
depend on knowing the repr(C) layout algorithm:
    Layout::new::<ArcInner<()>>().align_to(align).unwrap().pad_to_align().size()
)

>> +    ///
>> +    /// # Safety
>> +    ///
>> +    /// `ptr` must have been returned by a previous call to [`Arc::into_raw`]. Additionally, it
>> +    /// can only be called once for each previous call to [`Arc::into_raw`].
> 
> "it can only" -> "it must only"

Sounds good. I'll change it to use "must" in the next version.

Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ