tpm2-sessions: Fix tpm2_read_public range checks

commit bda1cbf73c upstream.

tpm2_read_public() has some rudimentary range checks but the function does
not ensure that the response buffer has enough bytes for the full TPMT_HA
payload.

Re-implement the function with necessary checks and validation, and return
name and name size for all handle types back to the caller.

Cc: stable@vger.kernel.org # v6.10+
Fixes: d0a25bb961 ("tpm: Add HMAC session name/handle append")
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Jonathan McDowell <noodles@meta.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jarkko Sakkinen 2025-12-01 15:38:02 +02:00 • committed by Greg Kroah-Hartman
commit 20eda7c74b
2 changed files with 53 additions and 44 deletions