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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aJyCC9E1kr4onwJ3@google.com>
Date: Wed, 13 Aug 2025 12:16:11 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: Danilo Krummrich <dakr@...nel.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Alexander Viro <viro@...iv.linux.org.uk>, 
	Arnd Bergmann <arnd@...db.de>, Miguel Ojeda <ojeda@...nel.org>, Boqun Feng <boqun.feng@...il.com>, 
	Gary Guo <gary@...yguo.net>, 
	"Björn Roy Baron" <bjorn3_gh@...tonmail.com>, Andreas Hindborg <a.hindborg@...nel.org>, 
	Trevor Gross <tmgross@...ch.edu>, Matthew Maurer <mmaurer@...gle.com>, Lee Jones <lee@...nel.org>, 
	linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org, 
	Benno Lossin <lossin@...nel.org>
Subject: Re: [PATCH v4 1/4] rust: iov: add iov_iter abstractions for ITER_SOURCE

On Wed, Aug 13, 2025 at 01:27:41PM +0200, Danilo Krummrich wrote:
> On Wed Aug 13, 2025 at 10:27 AM CEST, Alice Ryhl wrote:
> > +    /// Read data from this IO vector and append it to a vector.
> > +    ///
> > +    /// Returns the number of bytes that have been copied.
> > +    #[inline]
> > +    pub fn copy_from_iter_vec<A: Allocator>(
> > +        &mut self,
> > +        out: &mut Vec<u8, A>,
> > +        flags: Flags,
> > +    ) -> Result<usize> {
> > +        out.reserve(self.len(), flags)?;
> > +        let len = self.copy_from_iter_raw(out.spare_capacity_mut()).len();
> > +        // SAFETY: `Self::copy_from_iter_raw` guarantees that the first `len` bytes of the spare
> > +        // capacity have been initialized.
> 
> Technically, this covers the safety requirements from inc_len(). However, do we
> want to provide a list of justifications if the unsafe functions has a list of
> requirements, such that they are easier to match?

I will reword to:

// SAFETY:
// - `len` is the length of a subslice of the spare capacity, so `len`
//   is at most the length of the spare capacity.
// - `Self::copy_from_iter_raw` guarantees that the first `len` bytes of
//   the spare capacity have been initialized.

Ok?

> > +        unsafe { out.inc_len(len) };
> > +        Ok(len)
> > +    }
> 
> Either way,
> 
> Reviewed-by: Danilo Krummrich <dakr@...nel.org>

Thanks!

Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ