diff options
| author | Benno Lossin <lossin@kernel.org> | 2026-08-28 02:44:30 +0000 |
|---|---|---|
| committer | Paul Moore <paul@paul-moore.com> | 2026-09-10 15:00:17 -0400 |
| commit | cd1f696de880c41ef0983d2c54999384a5cbf393 (patch) | |
| tree | 7aa92ca687303681c5ed187b8305f7281512cdbd | |
| parent | 01f10e8c6a46d93c1c4e7de228d9b39390337ffa (diff) | |
| download | linux-next-cd1f696de880c41ef0983d2c54999384a5cbf393.tar.gz linux-next-cd1f696de880c41ef0983d2c54999384a5cbf393.zip | |
rust: lsm: replace `core::mem::zeroed` with `pin_init::zeroed`
All types in `bindings` implement `Zeroable` if they can, so use
`pin_init::zeroed` instead of relying on `unsafe` code.
If this ends up not compiling in the future, something in bindgen or on
the C side changed and is most likely incorrect.
Link: https://lore.kernel.org/r/20250814093046.2071971-8-lossin@kernel.org
Link: https://github.com/Rust-for-Linux/linux/issues/1189
Signed-off-by: Benno Lossin <lossin@kernel.org>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Nils Lehnen <nils.lehnen@proton.me>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
[PM: subject tweak]
Signed-off-by: Paul Moore <paul@paul-moore.com>
| -rw-r--r-- | rust/kernel/security.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/rust/kernel/security.rs b/rust/kernel/security.rs index 9d271695265f..4dc3eba6ce84 100644 --- a/rust/kernel/security.rs +++ b/rust/kernel/security.rs @@ -62,8 +62,7 @@ impl SecurityCtx { /// Get the security context given its id. #[inline] pub fn from_secid(secid: u32) -> Result<Self> { - // SAFETY: `struct lsm_context` can be initialized to all zeros. - let mut ctx: bindings::lsm_context = unsafe { core::mem::zeroed() }; + let mut ctx: bindings::lsm_context = pin_init::zeroed(); // SAFETY: Just a C FFI call. The pointer is valid for writes. to_result(unsafe { bindings::security_secid_to_secctx(secid, &mut ctx) })?; |
