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, 27 May 2024 10:37:34 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Alice Ryhl <aliceryhl@...gle.com>, Miguel Ojeda <ojeda@...nel.org>, Andrew Morton <akpm@...ux-foundation.org>
Cc: 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 v2 7/9] rust: list: add cursor

On 06.05.24 11:53, Alice Ryhl wrote:
> The cursor is very similar to the list iterator, but it has one
> important feature that the iterator doesn't: it can be used to remove
> items from the linked list.
> 
> This feature cannot be added to the iterator because the references you
> get from the iterator are considered borrows of the original list,
> rather than borrows of the iterator. This means that there's no way to
> prevent code like this:
> 
> let item = iter.next();
> iter.remove();
> use(item);
> 
> If `iter` was a cursor instead of an iterator, then `item` will be
> considered a borrow of `iter`. Since `remove` destroys `iter`, this
> means that the borrow-checker will prevent uses of `item` after the call
> to `remove`.
> 
> So there is a trade-off between supporting use in traditional for loops,
> and supporting removal of elements as you iterate. Iterators and cursors
> represents two different choices on that spectrum.
> 
> Rust Binder needs cursors for the list of death notifications that a
> process is currently handling. When userspace tells Binder that it has
> finished processing the death notification, Binder will iterate the list
> to search for the relevant item and remove it.
> 
> Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
> ---
>  rust/kernel/list.rs | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 82 insertions(+)

Reviewed-by: Benno Lossin <benno.lossin@...ton.me>

---
Cheers,
Benno


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ