]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
rust: alloc: implement `Cmalloc` in module allocator_test
authorDanilo Krummrich <dakr@kernel.org>
Fri, 7 Mar 2025 22:49:51 +0000 (23:49 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 12:01:46 +0000 (13:01 +0100)
commit575f8f47112a2089af008c3a379d536a3f8694b6
tree43643db04817f1d4cf0f7c2629ef977243028e5a
parent8079b1b73c4fbc762ef850dd8e7ca97b45b21dd1
rust: alloc: implement `Cmalloc` in module allocator_test

commit dd09538fb4093176a818fcecd45114430cc5840f upstream.

So far the kernel's `Box` and `Vec` types can't be used by userspace
test cases, since all users of those types (e.g. `CString`) use kernel
allocators for instantiation.

In order to allow userspace test cases to make use of such types as
well, implement the `Cmalloc` allocator within the allocator_test module
and type alias all kernel allocators to `Cmalloc`. The `Cmalloc`
allocator uses libc's `realloc()` function as allocator backend.

Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Link: https://lore.kernel.org/r/20241004154149.93856-26-dakr@kernel.org
[ Removed the temporary `allow(dead_code)` as discussed in the list and
  fixed typo, added backticks. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
rust/kernel/alloc.rs
rust/kernel/alloc/allocator_test.rs