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] [day] [month] [year] [list]
Date: Fri, 17 May 2024 10:37:35 +0200
From: Alice Ryhl <aliceryhl@...gle.com>
To: Ariel Miculas <amiculas@...co.com>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org, 
	linux-fsdevel@...r.kernel.org, tycho@...ho.pizza, brauner@...nel.org, 
	viro@...iv.linux.org.uk, ojeda@...nel.org, alex.gaynor@...il.com, 
	wedsonaf@...il.com, shallyn@...co.com, Benno Lossin <benno.lossin@...ton.me>, 
	Martin Rodriguez Reboredo <yakoyoku@...il.com>, Boqun Feng <boqun.feng@...il.com>
Subject: Re: [RFC PATCH v3 18/22] rust: add improved version of `ForeignOwnable::borrow_mut`

On Thu, May 16, 2024 at 9:04 PM Ariel Miculas <amiculas@...co.com> wrote:
>
> From: Alice Ryhl <aliceryhl@...gle.com>
>
> Previously, the `ForeignOwnable` trait had a method called `borrow_mut`
> that was intended to provide mutable access to the inner value. However,
> the method accidentally made it possible to change the address of the
> object being modified, which usually isn't what we want. (And when we
> want that, it can be done by calling `from_foreign` and `into_foreign`,
> like how the old `borrow_mut` was implemented.)
>
> In this patch, we introduce an alternate definition of `borrow_mut` that
> solves the previous problem. Conceptually, given a pointer type `P` that
> implements `ForeignOwnable`, the `borrow_mut` method gives you the same
> kind of access as an `&mut P` would, except that it does not let you
> change the pointer `P` itself.
>
> This is analogous to how the existing `borrow` method provides the same
> kind of access to the inner value as an `&P`.
>
> Note that for types like `Arc`, having an `&mut Arc<T>` only gives you
> immutable access to the inner `T`. This is because mutable references
> assume exclusive access, but there might be other handles to the same
> reference counted value, so the access isn't exclusive. The `Arc` type
> implements this by making `borrow_mut` return the same type as `borrow`.
>
> Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
> Reviewed-by: Benno Lossin <benno.lossin@...ton.me>
> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@...il.com>
> Reviewed-by: Boqun Feng <boqun.feng@...il.com>
> Link: https://lore.kernel.org/r/20230710074642.683831-1-aliceryhl@google.com
> Signed-off-by: Ariel Miculas <amiculas@...co.com>

This particular patch something that I have abandoned because I did
not end up having any user for it. If you have a user for it, then I
recommend that you resend my patch and ask Miguel to take it.

Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ