From: sashiko-bot@kernel.org
To: "Deborah Brouwer" <deborah.brouwer@collabora.com>
Cc: dri-devel@lists.freedesktop.org, ojeda@kernel.org, gary@garyguo.net
Subject: Re: [PATCH 1/2] rust: uaccess: add UserSliceWriter::clear()
Date: Thu, 15 Oct 2026 01:08:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-172076@kernel.org> (raw)
In-Reply-To: <20261014-b4-dev_query_fixes-v1-1-92043100b472@collabora.com>
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 <deborah.brouwer@collabora.com>
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/20261014-b4-dev_query_fixes-v1-0-92043100b472@collabora.com?part=1
next prev parent reply other threads:[~2026-10-15 1:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 1:02 [PATCH 0/2] drm/tyr: allow mismatched buffers for dev_query Deborah Brouwer
2026-10-15 1:02 ` [PATCH 1/2] rust: uaccess: add UserSliceWriter::clear() Deborah Brouwer
2026-10-15 1:08 ` sashiko-bot [this message]
2026-10-15 1:02 ` [PATCH 2/2] drm/tyr: allow userspace buffers to be mismatched Deborah Brouwer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-172076@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=deborah.brouwer@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=ojeda@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.