Re: [PATCH v4 1/3] rust: uaccess: add UserSliceWriter::clear()
From: Gary Guo
Date: Sat Nov 21 2026 - 11:21:38 EST
On Wed Oct 21, 2026 at 1:06 AM BST, Deborah Brouwer 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.
>
> Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> Signed-off-by: Deborah Brouwer <deborah.brouwer@xxxxxxxxxxxxx>
Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
> ---
> rust/helpers/uaccess.c | 6 ++++++
> rust/kernel/uaccess.rs | 24 ++++++++++++++++++++++++
> 2 files changed, 30 insertions(+)