Skip to content

Commit e7a37c9

Browse files
GoodLuck612klassert
authored andcommitted
xfrm: use kfree_sensitive() for SA secret zeroization
High-level copy_to_user_* APIs already redact SA secret fields when redaction is enabled, but the state teardown path still freed aead, aalg and ealg structs with plain kfree(), which does not clear memory before deallocation. This can leave SA keys and other confidential data in memory, risking exposure via post-free vulnerabilities. Since this path is outside the packet fast path, the cost of zeroization is acceptable and prevents any residual key material. This patch replaces those kfree() calls unconditionally with kfree_sensitive(), which zeroizes the entire buffer before freeing. Signed-off-by: Zilin Guan <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent c82b48b commit e7a37c9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/xfrm/xfrm_state.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,9 @@ static void ___xfrm_state_destroy(struct xfrm_state *x)
599599
x->mode_cbs->destroy_state(x);
600600
hrtimer_cancel(&x->mtimer);
601601
timer_delete_sync(&x->rtimer);
602-
kfree(x->aead);
603-
kfree(x->aalg);
604-
kfree(x->ealg);
602+
kfree_sensitive(x->aead);
603+
kfree_sensitive(x->aalg);
604+
kfree_sensitive(x->ealg);
605605
kfree(x->calg);
606606
kfree(x->encap);
607607
kfree(x->coaddr);

0 commit comments

Comments
 (0)