]> www.infradead.org Git - users/jedix/linux-maple.git/commit
xfrm: use kfree_sensitive() for SA secret zeroization
authorZilin Guan <zilin@seu.edu.cn>
Wed, 14 May 2025 08:48:39 +0000 (08:48 +0000)
committerSteffen Klassert <steffen.klassert@secunet.com>
Tue, 20 May 2025 05:55:00 +0000 (07:55 +0200)
commite7a37c9e428a2912a4eec160e633503cd72e1ee6
treeb2700c31f3b7b1310755dc1756ba71aac3eef2f0
parentc82b48b63a939e9b0f40bd00f95bcea4502fcada
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 <zilin@seu.edu.cn>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_state.c