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: Thu, 04 Apr 2024 13:28:16 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Andrew Morton <akpm@...ux-foundation.org>, Alex Gaynor <alex.gaynor@...il.com>, Wedson Almeida Filho <wedsonaf@...il.com>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, Björn Roy Baron <bjorn3_gh@...tonmail.com>, Andreas Hindborg <a.hindborg@...sung.com>, Marco Elver <elver@...gle.com>, Kees Cook <keescook@...omium.org>, Coly Li <colyli@...e.de>, Paolo Abeni <pabeni@...hat.com>, Pierre Gondois <pierre.gondois@....com>, Ingo Molnar <mingo@...nel.org>, Jakub Kicinski <kuba@...nel.org>, Wei Yang <richard.weiyang@...il.com>, Matthew Wilcox <willy@...radead.org>, linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH 7/9] rust: list: add cursor

On 03.04.24 14:49, Alice Ryhl wrote:
> On Wed, Apr 3, 2024 at 2:19 PM Benno Lossin <benno.lossin@...ton.me> wrote:
>> On 02.04.24 14:17, Alice Ryhl wrote:
>>> +impl<'a, T: ?Sized + ListItem<ID>, const ID: u64> Cursor<'a, T, ID> {
>>> +    /// Access the current element of this cursor.
>>> +    pub fn current(&self) -> ArcBorrow<'_, T> {
>>> +        // SAFETY: The `current` pointer points a value in the list.
>>> +        let me = unsafe { T::view_value(ListLinks::from_fields(self.current)) };
>>> +        // SAFETY:
>>> +        // * All values in a list are stored in an `Arc`.
>>> +        // * The value cannot be removed from the list for the duration of the lifetime annotated
>>> +        //   on the returned `ArcBorrow`, because removing it from the list would require mutable
>>> +        //   access to the cursor or the list. However, the `ArcBorrow` holds an immutable borrow
>>> +        //   on the cursor, which in turn holds an immutable borrow on the list, so any such
>>
>> The cursor has a mutable borrow on the list.
>>
>>
>>> +        //   mutable access requires first releasing the immutable borrow on the cursor.
>>> +        // * Values in a list never have a `UniqueArc` reference.
>>
>> Is there some type invariant guaranteeing this?
> 
> The List owns a ListArc reference to the value. It would be unsound
> for there to also be a UniqueArc reference to it.

I think it would be good to add the existence of the `ListArc` as an
explanation.

-- 
Cheers,
Benno


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ