rust: security: use `pin_init::zeroed()` for LSM context initialization
Subsystems (2)
PATCH 1/1 rust: security: use `pin_init::zeroed()` for LSM context initialization
Replace the previous unsafe { core::mem::zeroed() } initialization of bindings::lsm_context with pin_init::zeroed().
Signed-off-by Atharv Dubey <[email protected]>
--- rust/kernel/security.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
rust/kernel/security.rs +1 -2
@@ -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) })?;
Signature · 1 line
2.43.0
Quoted 14 lines · Atharv Dubey
Replace the previous
unsafe { core::mem::zeroed() }initialization ofbindings::lsm_contextwithpin_init::zeroed().Signed-off-by Atharv Dubey <[email protected]>--- rust/kernel/security.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)rust/kernel/security.rs +0
-0
rust/kernel/security.rs impl SecurityCtx { · line 65
Quoted 6 lines
rust/kernel/security.rs +1
-2@@ -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 ();
Reviewed-by Alexandre Courbot <[email protected]>
Quoted 6 lines · Atharv Dubey
Replace the previous
unsafe { core::mem::zeroed() }initialization ofbindings::lsm_contextwithpin_init::zeroed().
These were also sent by Benno, and in the issue he mentions "re-sending", which usually means just adding your Signed-off-by below his:
https://lore.kernel.org/all/[email protected]/
Otherwise, if he is OK without authorship, this should most likely have:
Suggested-by Benno Lossin <[email protected]>
Cheers,
Miguel