[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <878qp2hx9o.fsf@kernel.org>
Date: Tue, 18 Mar 2025 21:57:55 +0100
From: Andreas Hindborg <a.hindborg@...nel.org>
To: "Greg Kroah-Hartman" <gregkh@...uxfoundation.org>
Cc: "Alice Ryhl" <aliceryhl@...gle.com>, "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>,
"Benno Lossin" <benno.lossin@...ton.me>, "Trevor Gross"
<tmgross@...ch.edu>, "Danilo Krummrich" <dakr@...nel.org>, "Matthew
Maurer" <mmaurer@...gle.com>, "Lee Jones" <lee@...nel.org>,
<linux-kernel@...r.kernel.org>, <rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH 0/5] Rust support for `struct iov_iter`
"Greg Kroah-Hartman" <gregkh@...uxfoundation.org> writes:
> On Tue, Mar 11, 2025 at 02:25:11PM +0000, Alice Ryhl wrote:
>> This series adds support for the `struct iov_iter` type. This type
>> represents an IO buffer for reading or writing, and can be configured
>> for either direction of communication.
>>
>> In Rust, we define separate types for reading and writing. This will
>> ensure that you cannot mix them up and e.g. call copy_from_iter in a
>> read_iter syscall.
>>
>> To use the new abstractions, miscdevices are given new methods read_iter
>> and write_iter that can be used to implement the read/write syscalls on
>> a miscdevice. The miscdevice sample is updated to provide read/write
>> operations.
>
> Nice, this is good to have, but what's the odds of tieing in the
> "untrusted buffer" logic here so that all misc drivers HAVE to properly
> validate the data sent to them before they can touch it:
> https://lore.kernel.org/r/20240925205244.873020-1-benno.lossin@proton.me
>
> I'd like to force drivers to do this, otherwise it's just going to force
> us to audit all paths from userspace->kernel that happen.
>
I think that for user backed iterators (`user_backed_iter(iter) != 0`)
we will have the same problems as discussed in [1]. To validate, we
would have to copy the data to another buffer and then validate it
there, in a race free place. But the copying is apparently a problem.
Best regards,
Andreas Hindborg
[1] https://lore.kernel.org/all/ab8fd525-9a63-46e2-a443-b9d94eed6004@ralfj.de/
Powered by blists - more mailing lists