Commit e7a37c9e authored by Zilin Guan's avatar Zilin Guan Committed by Steffen Klassert
Browse files

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: default avatarZilin Guan <zilin@seu.edu.cn>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent c82b48b6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -599,9 +599,9 @@ static void ___xfrm_state_destroy(struct xfrm_state *x)
		x->mode_cbs->destroy_state(x);
	hrtimer_cancel(&x->mtimer);
	timer_delete_sync(&x->rtimer);
	kfree(x->aead);
	kfree(x->aalg);
	kfree(x->ealg);
	kfree_sensitive(x->aead);
	kfree_sensitive(x->aalg);
	kfree_sensitive(x->ealg);
	kfree(x->calg);
	kfree(x->encap);
	kfree(x->coaddr);