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]
Message-ID: <CANiq72=n68DB+hZ77GT4d7odPSS=wxc+YLvaBhU8-H7PyK25Rw@mail.gmail.com>
Date: Tue, 6 May 2025 15:59:20 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alexander Viro <viro@...iv.linux.org.uk>, 
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Arnd Bergmann <arnd@...db.de>, 
	Andrew Morton <akpm@...ux-foundation.org>, Boqun Feng <boqun.feng@...il.com>, 
	Gary Guo <gary@...yguo.net>, Björn Roy Baron <bjorn3_gh@...tonmail.com>, 
	Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...nel.org>, 
	Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>, rust-for-linux@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] uaccess: rust: use newtype for user pointers

On Tue, May 6, 2025 at 3:26 PM Alice Ryhl <aliceryhl@...gle.com> wrote:
>
> The UserPtr type is not marked with #[derive(Debug)], which means that
> it's not possible to print values of this type. This avoids ASLR
> breakage.

By breakage you mean leaking the information by mistake?

Since it is `pub`, should we make it even harder to make a mistake
here by making it private? You are already providing and using the
`as_` methods anyway, so we would only need a `new` or conversion
method or `Into` similar (not sure which one would be best -- perhaps
a single one with a descriptive name is a good idea to grep for it
easily).

> +    /// Increment this user pointer by `add` bytes.
> +    ///
> +    /// This is addition is wrapping, so wrapping around the address space does not result in a

s/is//

> +    /// panic even if `CONFIG_RUST_OVERFLOW_CHECKS` is enabled.
> +    pub fn wrapping_add(self, add: usize) -> UserPtr {
> +        UserPtr(self.0.wrapping_add(add))
> +    }
> +}

I guess you are using `wrapping_add` since we have a `usize` internal
type, but I wonder if we should use the pointer-related naming, i.e.
`wrapping_byte_add`.

Also, perhaps it is best to use another name for the parameter -- I
would pick `count` like the standard library.

In addition, should we get this directly into the `prelude`? `__user`
is also global and fairly short. It may not be heavily used all the
time like other things, but it is fairly fundamental, like the `c_*`
ones.

Thanks!

Cheers,
Miguel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ