tpm: fix off-by-four bounds check in tpm2_get_random()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
tpm: fix off-by-four bounds check in tpm2_get_random()
When the response carries the TPM2_ST_SESSIONS tag, tpm2_get_random() skips the 4-byte parameter size field before locating the random data, but the bounds check still validates the response length against TPM_HEADER_SIZE. 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.
From the CVE record · Linux
The Linux kernel’s tpm2_get_random() uses an insufficient bounds check for responses tagged TPM2_ST_SESSIONS. A truncated response can cause it to read up to four bytes past the response end, placing stale buffer contents in the caller’s random bytes. The input does not specify how an attacker could cause such a response or whether authentication or user interaction is required.
Engineers running Linux kernels with the affected tpm2_get_random() implementation should check their versions; affected versions were not provided.