[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH5fLgh9xuYs97SDn61yEm08Tx9PDPMWw40BsFeMPuHASq_s2A@mail.gmail.com>
Date: Tue, 27 Feb 2024 14:12:32 +0100
From: Alice Ryhl <aliceryhl@...gle.com>
To: Carlos López <clopez@...e.de>
Cc: 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>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>, Wedson Almeida Filho <wedsonaf@...il.com>,
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@...sung.com>,
Kees Cook <keescook@...omium.org>, Al Viro <viro@...iv.linux.org.uk>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v2 1/4] rust: uaccess: add userspace pointers
On Tue, Feb 27, 2024 at 11:05 AM Carlos López <clopez@...e.de> wrote:
>
>
> On 8/2/24 16:47, Alice Ryhl wrote:
> > + /// Create a reader that can access the same range of data.
> > + ///
> > + /// Reading from the clone does not advance the current reader.
> > + ///
> > + /// The caller should take care to not introduce TOCTOU issues, as described
> > + /// in the documentation for [`UserSlice`].
> > + pub fn clone_reader(&self) -> UserSliceReader {
> > + UserSliceReader {
> > + ptr: self.ptr,
> > + length: self.length,
> > + }
> > + }
>
> Just out of curiosity, is there any reason why this is not implemented
> in terms of the Clone trait?
I think people find a non-Clone-trait method higher friction than just
calling .clone(), so this nudges people towards not using it if they
don't really need it.
But really, it could go either way. It would be okay to use the Clone trait.
Alice
Powered by blists - more mailing lists