CVE-2026-98728: tpm: fix off-by-four bounds check in tpm2_get_random()
In the Linux kernel, the following vulnerability has been resolved:
tpm: fix off-by-four bounds check in tpm2getrandom()
When the response carries the TPM2STSESSIONS tag, tpm2getrandom() skips the 4-byte parameter size field before locating the random data, but the bounds check still validates the response length against TPMHEADERSIZE. A truncated response can pass the check and make memcpy() read up to 4 bytes past the response end, so stale buffer contents end up in the caller's random bytes.
Fix this by checking the response length against 'offset', which already includes the skipped parameter size field.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In tpm2_get_random(), fix the off-by-four bounds check by validating the response length against the 'offset' value after skipping the 4-byte parameter size field.