]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
tpm: Use kfree_sensitive() to free auth session in tpm_dev_release()
authorGunnar Kudrjavets <gunnarku@amazon.com>
Thu, 9 Apr 2026 17:20:54 +0000 (17:20 +0000)
committerJarkko Sakkinen <jarkko@kernel.org>
Tue, 21 Apr 2026 15:54:28 +0000 (18:54 +0300)
commitc424d2664f08c77f08b4580b5f0cbaabf7c229b2
treedb919f7f875c90e0acbcdcda056fae0e1a61f480
parentf0f75a3d98b7959a8677b6363e23190f3018636b
tpm: Use kfree_sensitive() to free auth session in tpm_dev_release()

tpm_dev_release() uses plain kfree() to free chip->auth, which contains
sensitive cryptographic material including HMAC session keys, nonces,
and passphrase data (struct tpm2_auth).

Every other code path that frees this structure uses kfree_sensitive()
to zero the memory before releasing it: both tpm2_end_auth_session()
and tpm_buf_check_hmac_response() do so. The tpm_dev_release() path
is the only one that does not, leaving key material in freed slab
memory until it is eventually overwritten.

Use kfree_sensitive() for consistency with the rest of the driver and
to ensure session keys are scrubbed during device teardown.

Cc: stable@vger.kernel.org # v6.10+
Fixes: 699e3efd6c64 ("tpm: Add HMAC session start and end functions")
Signed-off-by: Gunnar Kudrjavets <gunnarku@amazon.com>
Reviewed-by: Justinien Bouron <jbouron@amazon.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
drivers/char/tpm/tpm-chip.c