]> git.ipfire.org Git - thirdparty/linux.git/commit
rust: uaccess: add UserSliceWriter::write_slice_partial()
authorDanilo Krummrich <dakr@kernel.org>
Wed, 22 Oct 2025 14:30:38 +0000 (16:30 +0200)
committerDanilo Krummrich <dakr@kernel.org>
Tue, 4 Nov 2025 23:35:27 +0000 (00:35 +0100)
commit86150533476774ee6ad5875e764ff6acc9a2e48a
tree4b3b5a76a897fe6803d1392ba95cae78c14c2184
parent5829e330482b67a14c8c6d2d500431846d493d67
rust: uaccess: add UserSliceWriter::write_slice_partial()

The existing write_slice() method is a wrapper around copy_to_user() and
expects the user buffer to be larger than the source buffer.

However, userspace may split up reads in multiple partial operations
providing an offset into the source buffer and a smaller user buffer.

In order to support this common case, provide a helper for partial
writes.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Matthew Maurer <mmaurer@google.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Miguel Ojeda <ojeda@kernel.org>
[ Replace map_or() with let-else; use saturating_add(). - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/kernel/uaccess.rs