From: Andreas Hindborg <a.hindborg@kernel.org>
To: "Alice Ryhl" <aliceryhl@google.com>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Will Deacon" <will@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Lyude Paul" <lyude@redhat.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Christian Brauner" <brauner@kernel.org>,
"Carlos Llamas" <cmllamas@google.com>, "Zi Yan" <ziy@nvidia.com>
Cc: linux-mm@kvack.org, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
Andreas Hindborg <a.hindborg@kernel.org>
Subject: [PATCH 00/11] rust: page: improve access methods for racy memory regions
Date: Fri, 20 Nov 2026 11:26:59 +0100 [thread overview]
Message-ID: <20261120-page-shared-v1-0-66f8c4c62822@kernel.org> (raw)
`Page` has a number of methods for manipulating the memory of the page.
These use `core::ptr::{copy_nonoverlapping,write_bytes}`, which are not
valid for use when one end of the operation may be subject to concurrent
reads or writes.
With recent patches that allow pages to be exposed as `SysMem` regions, we
can use the `SysMem` infrastructure to do the operations as byte-wise
atomic operations, thus making the operations well defined.
This series builds on the atomic memcpy series [1], the `Ownable` series
[2] and the `Page` refactor series [3] to prepare for handling the pages of
a `Bio` in a well defined way. As part of this work:
Remove the `core::ptr` memory operations from page.
Add a safe method to get a `SysMem` view of a page and use that when
copying into pages from `UserSliceReader`. Remove code paths in
`UserSliceReader` that would make a `&mut [MaybeUninit<u8>]` to page
contents.
As `SysMem` is `Send` and `Sync` but pages are mapped with `kmap_local`,
add a `SysMemLocal` variant that is neither `Send` nor `Sync` and use this
for the views of page data.
Finally, remove `Page::copy_from_user_slice_raw` as it is no longer used.
The three dependency series do not compose without conflicts, so I have
provided my b4 tree with all of them applied [4].
[1] https://lore.kernel.org/all/20261113-page-volatile-io-v6-0-5603e527c919@kernel.org
[2] https://lore.kernel.org/all/20261116-unique-ref-v22-0-12029383206d@kernel.org
[3] https://lore.kernel.org/all/20261118-page-ownable-v22-0-d63ff73f4075@kernel.org
[4] https://github.com/metaspace/linux/tree/page-shared
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
---
Andreas Hindborg (11):
rust: page: tighten safety requirements of `SysMem` copy methods
rust: sync: atomic: add memset
rust: io: add `SysMem::fill_zero`
rust: page: use byte-wise atomic operations in raw accessors
rust: uaccess: take a raw pointer in `UserSliceReader::read_raw`
rust: uaccess: add `UserSliceReader::read_sysmem`
rust: page: add `Shared` page kind
rust: io: add `SysMemLocal`
rust: page: add `Page::with_page_as_sysmem_local`
rust_binder: access page data through `SysMemLocal`
rust: page: remove `Page::copy_from_user_slice_raw`
drivers/android/binder/page_range.rs | 35 ++--
rust/kernel/io.rs | 151 +++++++++++++--
rust/kernel/page.rs | 355 +++++++++++++++++++++++++----------
rust/kernel/sync/atomic.rs | 25 +++
rust/kernel/uaccess.rs | 79 ++++++--
5 files changed, 496 insertions(+), 149 deletions(-)
---
base-commit: fd9230005e85472b81c1c7c16afe93dd878996b1
change-id: 20261119-page-shared-9b748d499e3e
prerequisite-change-id: 20260130-page-volatile-io-05ff595507d3:v6
prerequisite-patch-id: 112f7ee8c101c766ba33128a08c053ff7dd1bd6f
prerequisite-patch-id: 4b725c8c4d3313096ea722ac2866bd5e36227b88
prerequisite-patch-id: bf25326b450044d86f2cc7392f67d17d674afe8a
prerequisite-patch-id: acbb5d7f331c45b8da915ea32bef91447ac0b234
prerequisite-change-id: 20250305-unique-ref-29fcd675f9e9:v22
prerequisite-patch-id: 4e3c7a1a2077aaa0ece2d557fa73486355903ae5
prerequisite-patch-id: d1073c5dcd6287fbcba7848a5d182108930230c1
prerequisite-patch-id: 3244def11bbdf2eabaa6e94e15ce06540b2f5814
prerequisite-patch-id: cef14c5bef5ba519ceaf0a0e7c9e93ef974db7b3
prerequisite-patch-id: 56410da35ed8dbe7b210adae0985af705cc0b5b0
prerequisite-change-id: 20261112-page-ownable-2e97941a83b2:v22
prerequisite-patch-id: 4e3c7a1a2077aaa0ece2d557fa73486355903ae5
prerequisite-patch-id: d1073c5dcd6287fbcba7848a5d182108930230c1
prerequisite-patch-id: 3244def11bbdf2eabaa6e94e15ce06540b2f5814
prerequisite-patch-id: cef14c5bef5ba519ceaf0a0e7c9e93ef974db7b3
prerequisite-patch-id: 56410da35ed8dbe7b210adae0985af705cc0b5b0
prerequisite-patch-id: 7454d72e9d18045c4b45c3be614c51288c7c437a
prerequisite-patch-id: edcc308e1ba9596e7939859cb50230ca56f0b265
prerequisite-patch-id: 90fcb80e26232818fea9472fa83871b6577bbddd
prerequisite-patch-id: 10e8ae82a9750cd76b42754393d3e39b9e849474
prerequisite-patch-id: 881055f06785a8df0ec9f8107065428900ca78d9
prerequisite-patch-id: e0759f2b41824d562a594c9e2452bf41ba514cbd
Best regards,
--
Andreas Hindborg <a.hindborg@kernel.org>
next reply other threads:[~2026-11-20 10:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 10:26 Andreas Hindborg [this message]
2026-11-20 10:27 ` [PATCH 01/11] rust: page: tighten safety requirements of `SysMem` copy methods Andreas Hindborg
2026-11-20 10:27 ` [PATCH 02/11] rust: sync: atomic: add memset Andreas Hindborg
2026-11-20 10:27 ` [PATCH 03/11] rust: io: add `SysMem::fill_zero` Andreas Hindborg
2026-11-20 10:27 ` [PATCH 04/11] rust: page: use byte-wise atomic operations in raw accessors Andreas Hindborg
2026-11-20 10:27 ` [PATCH 05/11] rust: uaccess: take a raw pointer in `UserSliceReader::read_raw` Andreas Hindborg
2026-11-20 10:27 ` [PATCH 06/11] rust: uaccess: add `UserSliceReader::read_sysmem` Andreas Hindborg
2026-11-20 10:27 ` [PATCH 07/11] rust: page: add `Shared` page kind Andreas Hindborg
2026-11-20 10:27 ` [PATCH 08/11] rust: io: add `SysMemLocal` Andreas Hindborg
2026-11-20 10:27 ` [PATCH 09/11] rust: page: add `Page::with_page_as_sysmem_local` Andreas Hindborg
2026-11-20 10:27 ` [PATCH 10/11] rust_binder: access page data through `SysMemLocal` Andreas Hindborg
2026-11-20 10:27 ` [PATCH 11/11] rust: page: remove `Page::copy_from_user_slice_raw` Andreas Hindborg
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=20261120-page-shared-v1-0-66f8c4c62822@kernel.org \
--to=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=arve@android.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=mark.rutland@arm.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tkjos@android.com \
--cc=tmgross@umich.edu \
--cc=will@kernel.org \
--cc=work@onurozkan.dev \
--cc=ziy@nvidia.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®