| ab938b59 | 04-Mar-2025 |
Alice Ryhl <[email protected]> |
cred,rust: mark Credential methods inline
When you build the kernel using the llvm-19.1.4-rust-1.83.0-x86_64 toolchain provided by kernel.org with ARCH=arm64, the following symbols are generated:
$
cred,rust: mark Credential methods inline
When you build the kernel using the llvm-19.1.4-rust-1.83.0-x86_64 toolchain provided by kernel.org with ARCH=arm64, the following symbols are generated:
$ nm out-linux/vmlinux | grep ' _R'.*Credential | rustfilt ... T <kernel::cred::Credential>::get_secid ... T <kernel::cred::Credential as kernel::types::AlwaysRefCounted>::dec_ref ... T <kernel::cred::Credential as kernel::types::AlwaysRefCounted>::inc_ref
However, these Rust symbols are trivial wrappers around the functions security_cred_getsecid, get_cred, and put_cred respectively. It doesn't make sense to go through a trivial wrapper for these functions, so mark them inline. Also mark other trivial methods inline to prevent similar cases in the future.
After applying this patch, the above command will produce no output.
Reviewed-by: Boqun Feng <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Reviewed-by: Christian Brauner <[email protected]> Signed-off-by: Alice Ryhl <[email protected]> [PM: subject tweak, description line trims] Signed-off-by: Paul Moore <[email protected]>
show more ...
|
| 0a01beac | 04-Mar-2025 |
Alice Ryhl <[email protected]> |
lsm,rust: reword "destroy" -> "release" in SecurityCtx
What happens inside the individual LSMs for a given LSM hook can vary quite a bit, so it is best to use the terminology "release" instead of "d
lsm,rust: reword "destroy" -> "release" in SecurityCtx
What happens inside the individual LSMs for a given LSM hook can vary quite a bit, so it is best to use the terminology "release" instead of "destroy" or "free".
Suggested-by: Casey Schaufler <[email protected]> Signed-off-by: Alice Ryhl <[email protected]> Acked-by: Casey Schaufler <[email protected]> Reviewed-by: Fiona Behrens <[email protected]> [PM: subj tweak] Signed-off-by: Paul Moore <[email protected]>
show more ...
|
| 95cb0cb5 | 27-Feb-2025 |
Lyude Paul <[email protected]> |
rust/faux: Add missing parent argument to Registration::new()
A little late in the review of the faux device interface, we added the ability to specify a parent device when creating new faux devices
rust/faux: Add missing parent argument to Registration::new()
A little late in the review of the faux device interface, we added the ability to specify a parent device when creating new faux devices - but this never got ported over to the rust bindings. So, let's add the missing argument now so we don't have to convert other users later down the line.
Signed-off-by: Lyude Paul <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
| 6853d9d1 | 25-Feb-2025 |
Lyude Paul <[email protected]> |
rust/faux: Drop #[repr(transparent)] from faux::Registration
I think this change got missed during review, we don't need #[repr(transparent)] since Registration just holds a single NonNull. This at
rust/faux: Drop #[repr(transparent)] from faux::Registration
I think this change got missed during review, we don't need #[repr(transparent)] since Registration just holds a single NonNull. This attribute had originally been added by me when I was still figuring out how the bindings should look like but got committed by mistake. So, just drop it.
Signed-off-by: Lyude Paul <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Reviewed-by: Fiona Behrens <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
| 040b17ae | 24-Feb-2025 |
Fiona Behrens <[email protected]> |
rust: io: fix devres test with new io accessor functions
Fix doctest of `Devres` which still used `writeb` instead of `write8`.
Fixes: 354fd6e86fac ("rust: io: rename `io::Io` accessors") Signed-of
rust: io: fix devres test with new io accessor functions
Fix doctest of `Devres` which still used `writeb` instead of `write8`.
Fixes: 354fd6e86fac ("rust: io: rename `io::Io` accessors") Signed-off-by: Fiona Behrens <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
| e1cd24af | 16-Jan-2025 |
Viresh Kumar <[email protected]> |
rust: device: Replace CString with CStr in property_present()
The property_present() method expects a &CString currently and will work only with heap allocated C strings.
In order to make it work w
rust: device: Replace CString with CStr in property_present()
The property_present() method expects a &CString currently and will work only with heap allocated C strings.
In order to make it work with compile-time string constants too, change the argument type to &CStr.
Signed-off-by: Viresh Kumar <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Link: https://lore.kernel.org/r/e97dcbe0418cc1053fb4bcfac65cc02a0afcdf78.1737005078.git.viresh.kumar@linaro.org Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
| c80dd3fc | 07-Jan-2025 |
Filipe Xavier <[email protected]> |
rust: uaccess: generalize userSliceReader to support any Vec
The UserSliceReader::read_all function is currently restricted to use only Vec with the kmalloc allocator. However, there is no reason fo
rust: uaccess: generalize userSliceReader to support any Vec
The UserSliceReader::read_all function is currently restricted to use only Vec with the kmalloc allocator. However, there is no reason for this limitation.
This patch generalizes the function to accept any Vec regardless of the allocator used.
There's a use-case for a KVVec in Binder to avoid maximum sizes for a certain array.
Link: https://github.com/Rust-for-Linux/linux/issues/1136 Signed-off-by: Filipe Xavier <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Reflowed and slightly reworded title. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| c27e705c | 20-Nov-2024 |
Alice Ryhl <[email protected]> |
rust: kernel: add improved version of `ForeignOwnable::borrow_mut`
Previously, the `ForeignOwnable` trait had a method called `borrow_mut` that was intended to provide mutable access to the inner va
rust: kernel: add improved version of `ForeignOwnable::borrow_mut`
Previously, the `ForeignOwnable` trait had a method called `borrow_mut` that was intended to provide mutable access to the inner value. However, the method accidentally made it possible to change the address of the object being modified, which usually isn't what we want. (And when we want that, it can be done by calling `from_foreign` and `into_foreign`, like how the old `borrow_mut` was implemented.)
In this patch, we introduce an alternate definition of `borrow_mut` that solves the previous problem. Conceptually, given a pointer type `P` that implements `ForeignOwnable`, the `borrow_mut` method gives you the same kind of access as an `&mut P` would, except that it does not let you change the pointer `P` itself.
This is analogous to how the existing `borrow` method provides the same kind of access to the inner value as an `&P`.
Note that for types like `Arc`, having an `&mut Arc<T>` only gives you immutable access to the inner `T`. This is because mutable references assume exclusive access, but there might be other handles to the same reference counted value, so the access isn't exclusive. The `Arc` type implements this by making `borrow_mut` return the same type as `borrow`.
Signed-off-by: Alice Ryhl <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Martin Rodriguez Reboredo <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Updated to `crate::ffi::`. Reworded title slightly. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| c6b97538 | 20-Nov-2024 |
Tamir Duberstein <[email protected]> |
rust: kernel: reorder `ForeignOwnable` items
`{into,from}_foreign` before `borrow` is slightly more logical.
This removes an inconsistency with `kbox.rs` which already uses this ordering.
Reviewed
rust: kernel: reorder `ForeignOwnable` items
`{into,from}_foreign` before `borrow` is slightly more logical.
This removes an inconsistency with `kbox.rs` which already uses this ordering.
Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Reworded title slightly. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| 14686571 | 20-Nov-2024 |
Tamir Duberstein <[email protected]> |
rust: kernel: change `ForeignOwnable` pointer to mut
It is slightly more convenient to operate on mut pointers, and this also properly conveys the desired ownership semantics of the trait.
Reviewed
rust: kernel: change `ForeignOwnable` pointer to mut
It is slightly more convenient to operate on mut pointers, and this also properly conveys the desired ownership semantics of the trait.
Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Reworded title slightly. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| 5d385a35 | 20-Nov-2024 |
Tamir Duberstein <[email protected]> |
rust: arc: split unsafe block, add missing comment
The new SAFETY comment style is taken from existing comments in `deref` and `drop.
Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: And
rust: arc: split unsafe block, add missing comment
The new SAFETY comment style is taken from existing comments in `deref` and `drop.
Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| aa991a2a | 20-Nov-2024 |
Tamir Duberstein <[email protected]> |
rust: types: avoid `as` casts
Replace `as` casts with `cast{,_mut}` calls which are a bit safer.
In one instance, remove an unnecessary `as` cast without replacement.
Reviewed-by: Alice Ryhl <alic
rust: types: avoid `as` casts
Replace `as` casts with `cast{,_mut}` calls which are a bit safer.
In one instance, remove an unnecessary `as` cast without replacement.
Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| 47cb6bf7 | 03-Dec-2024 |
Xiangfei Ding <[email protected]> |
rust: use derive(CoercePointee) on rustc >= 1.84.0
The `kernel` crate relies on both `coerce_unsized` and `dispatch_from_dyn` unstable features.
Alice Ryhl has proposed [1] the introduction of the
rust: use derive(CoercePointee) on rustc >= 1.84.0
The `kernel` crate relies on both `coerce_unsized` and `dispatch_from_dyn` unstable features.
Alice Ryhl has proposed [1] the introduction of the unstable macro `SmartPointer` to reduce such dependence, along with a RFC patch [2]. Since Rust 1.81.0 this macro, later renamed to `CoercePointee` in Rust 1.84.0 [3], has been fully implemented with the naming discussion resolved.
This feature is now on track to stabilization in the language. In order to do so, we shall start using this macro in the `kernel` crate to prove the functionality and utility of the macro as the justification of its stabilization.
This patch makes this switch in such a way that the crate remains backward compatible with older Rust compiler versions, via the new Kconfig option `RUSTC_HAS_COERCE_POINTEE`.
A minimal demonstration example is added to the `samples/rust/rust_print_main.rs` module.
Link: https://rust-lang.github.io/rfcs/3621-derive-smart-pointer.html [1] Link: https://lore.kernel.org/all/[email protected]/ [2] Link: https://github.com/rust-lang/rust/pull/131284 [3] Signed-off-by: Xiangfei Ding <[email protected]> Reviewed-by: Fiona Behrens <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Fixed version to 1.84. Renamed option to `RUSTC_HAS_COERCE_POINTEE` to match `CC_HAS_*` ones. Moved up new config option, closer to the `CC_HAS_*` ones. Simplified Kconfig line. Fixed typos and slightly reworded example and commit. Added Link to PR. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| 91da5a24 | 20-Dec-2024 |
Jimmy Ostler <[email protected]> |
rust: alloc: add doctest for `ArrayLayout::new()`
Add a rustdoc example and Kunit test to the `ArrayLayout` struct's `ArrayLayout::new()` function.
This patch depends on the first patch in this ser
rust: alloc: add doctest for `ArrayLayout::new()`
Add a rustdoc example and Kunit test to the `ArrayLayout` struct's `ArrayLayout::new()` function.
This patch depends on the first patch in this series in order for the KUnit test to compile.
Suggested-by: Boqun Feng <[email protected]> Link: https://github.com/Rust-for-Linux/linux/issues/1131 Reviewed-by: Danilo Krummrich <[email protected]> Signed-off-by: Jimmy Ostler <[email protected]> Link: https://lore.kernel.org/r/f1564da5bcaa6be87aee312767a1d1694a03d1b7.1734674670.git.jtostler1@gmail.com [ Added periods to example comments. Reworded title. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| 59d58465 | 20-Dec-2024 |
Jimmy Ostler <[email protected]> |
rust: init: update `stack_try_pin_init` examples
Change documentation imports to use `kernel::alloc::AllocError`, because `KBox::new()` now returns that, instead of the `core`'s `AllocError`.
Revie
rust: init: update `stack_try_pin_init` examples
Change documentation imports to use `kernel::alloc::AllocError`, because `KBox::new()` now returns that, instead of the `core`'s `AllocError`.
Reviewed-by: Danilo Krummrich <[email protected]> Signed-off-by: Jimmy Ostler <[email protected]> Link: https://lore.kernel.org/r/ec8badbe94c5e78f22315325a7f2ae96129d6a65.1734674670.git.jtostler1@gmail.com [ Fixed formatting of imports (still unordered). Slightly reworded commit. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|