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, 18 Mar 2024 12:33:32 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Matthew Wilcox <willy@...radead.org>,
	Al Viro <viro@...iv.linux.org.uk>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Kees Cook <keescook@...omium.org>,
	Alex Gaynor <alex.gaynor@...il.com>,
	Wedson Almeida Filho <wedsonaf@...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@...sung.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Arve Hjønnevåg <arve@...roid.com>,
	Todd Kjos <tkjos@...roid.com>, Martijn Coenen <maco@...roid.com>,
	Joel Fernandes <joel@...lfernandes.org>,
	Carlos Llamas <cmllamas@...gle.com>,
	Suren Baghdasaryan <surenb@...gle.com>,
	Arnd Bergmann <arnd@...db.de>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
	Christian Brauner <brauner@...nel.org>
Subject: Re: [PATCH v3 1/4] rust: uaccess: add userspace pointers

On Mon, Mar 18, 2024 at 08:12:27PM +0100, Alice Ryhl wrote:
> On Mon, Mar 18, 2024 at 7:59 PM Boqun Feng <boqun.feng@...il.com> wrote:
> >
> > On Mon, Mar 11, 2024 at 10:47:13AM +0000, Alice Ryhl wrote:
> > > +
> > > +    /// Reads raw data from the user slice into a raw kernel buffer.
> > > +    ///
> > > +    /// Fails with `EFAULT` if the read encounters a page fault.
> > > +    ///
> > > +    /// # Safety
> > > +    ///
> > > +    /// The `out` pointer must be valid for writing `len` bytes.
> > > +    pub unsafe fn read_raw(&mut self, out: *mut u8, len: usize) -> Result {
> >
> > I don't think we want to promote the pub usage of this unsafe function,
> > right? We can provide a safe version:
> >
> >         pub fn read_slice(&mut self, to: &[u8]) -> Result
> >
> > and all users can just use the safe version (with the help of
> > slice::from_raw_parts_mut() if necessary).
> 
> Personally, I think having the function be unsafe is plenty discouragement.
> 
> Also, this method would need an &mut [u8], which opens the can of
> worms related to uninitialized memory. The _raw version of this method

make it a `&mut [MayUninit<u8>]` then? If that works, then _raw version
is not more powerful therefore no need to pub it.

> is strictly more powerful.
> 
> I don't think I actually use it directly in Binder, so I can make it
> private if you think that's important. It needs to be pub(crate),

I might be too picky, but avoiding pub unsafe functions if not necessary
could help us reduce unnecessary unsafe code ;-)

Regards,
Boqun

> though, since it is used in `Page`.
> 
> Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ