Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] rust: uaccess: UserSliceWriter::clear() missing #[inline] attribute --
commit 3db28db591b863b3412fb9ace61521aee539bc5a Author: Deborah Brouwer <[email protected]> rust: uaccess: add UserSliceWriter::clear() This commit adds a clear() method to UserSliceWriter to zero out the remaining buffer in userspace, preventing uninitialized memory consumption. It also introduces a rust_helper_clear_user() wrapper for the architecturally defined clear_user() C function so it can be called from Rust. > diff --git a/rust/kernel/uaccess.rs b/rust/kernel/uaccess.rs > index f1aecda7a90ce..6838e7f90abb5 100644 > --- a/rust/kernel/uaccess.rs > +++ b/rust/kernel/uaccess.rs [ ... ] > @@ -638,6 +638,29 @@ pub fn write<T: AsBytes>(&mut self, value: &T) -> Result > { > pub fn write_truncated<T: AsBytes>(&mut self, value: &T) -> > Result<usize> { > self.write_slice_partial(value.as_bytes(), 0) > } > + > + /// Zeros remaining bytes in the userspace buffer. > + /// > + /// Fails with [`EFAULT`] if the userspace memory cannot be cleared. > + pub fn clear(&mut self) -> Result { [Severity: Low] This isn't a bug, but should this method be marked with the #[inline] attribute? Small wrapper functions in abstractions that primarily forward to C bindings (like bindings::clear_user in this case) typically include the #[inline] annotation as recommended by the Rust subsystem coding guidelines. > + let len = self.length; > + > + if len == 0 { > + return Ok(()); > + } > + // SAFETY: `clear_user` checks the userspace address and range and > handles > + // faults when accessing userspace memory > + let res = unsafe { bindings::clear_user(self.ptr.as_mut_ptr(), len) > }; -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
