Re: [PATCH v2 1/2] rust: uaccess: add UserSliceWriter::clear()
From: Alice Ryhl
Date: Fri Oct 16 2026 - 04:09:05 EST
On Thu, Oct 15, 2026 at 8:35 PM Deborah Brouwer
<deborah.brouwer@xxxxxxxxxxxxx> wrote:
>
> Add a method to zero the remaining bytes in a UserSliceWriter.
>
> If userspace provides a buffer that is larger than necessary, provide
> a method to zero out the remaining UserSliceWriter buffer. This avoids
> userspace consuming potentially uninitialized memory and/or mistaking it
> for data intentionally provided by the kernel.
>
> Use the #[inline] annotation to make this clear() method available for
> inlining outside of the kernel crate.
>
> Since clear_user() is architecturally defined and may be a macro or inline
> function, add a rust helper to make clear_user() callable from rust.
>
> Signed-off-by: Deborah Brouwer <deborah.brouwer@xxxxxxxxxxxxx>
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>