Re: [PATCH v4 2/3] rust: uaccess: add method to get UserPtr from u64
From: Alice Ryhl
Date: Wed Oct 21 2026 - 04:57:06 EST
On Tue, Oct 20, 2026 at 05:06:46PM -0700, Deborah Brouwer wrote:
> Currently a UserPtr can be created from a usize integer representing a
> userspace address. To create a UserPtr from a u64 integer, the u64 must
> be cast to usize. On 32-bit systems, this cast will discard the upper 32
> bits of the address.
>
> Provide a new method to create a UserPtr from a u64 integer. This avoids
> the caller having to cast before creating a UserPtr and also clarifies
> that the truncation is intended. This is equivalent to the C-side
> macro u64_to_user_ptr() that provides typechecking and casting to a __user
> pointer.
>
> Signed-off-by: Deborah Brouwer <deborah.brouwer@xxxxxxxxxxxxx>
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>