summaryrefslogtreecommitdiff
path: root/sound/pci/ac97
diff options
context:
space:
mode:
authorPeter Huewe <peter.huewe@infineon.com>2012-09-27 16:09:33 +0200
committerBen Hutchings <ben@decadent.org.uk>2012-10-30 23:27:09 +0000
commit4be11470a33359ac885539737a79dac6ba9f3495 (patch)
tree5a894bbec8898405a0f1b1f3b3e3ab27960b50af /sound/pci/ac97
parentcc1b75d796ad050c83c95733c4220aaa04fa1304 (diff)
downloadlwn-4be11470a33359ac885539737a79dac6ba9f3495.tar.gz
lwn-4be11470a33359ac885539737a79dac6ba9f3495.zip
tpm: Propagate error from tpm_transmit to fix a timeout hang
commit abce9ac292e13da367bbd22c1f7669f988d931ac upstream. tpm_write calls tpm_transmit without checking the return value and assigns the return value unconditionally to chip->pending_data, even if it's an error value. This causes three bugs. So if we write to /dev/tpm0 with a tpm_param_size bigger than TPM_BUFSIZE=0x1000 (e.g. 0x100a) and a bufsize also bigger than TPM_BUFSIZE (e.g. 0x100a) tpm_transmit returns -E2BIG which is assigned to chip->pending_data as -7, but tpm_write returns that TPM_BUFSIZE bytes have been successfully been written to the TPM, altough this is not true (bug #1). As we did write more than than TPM_BUFSIZE bytes but tpm_write reports that only TPM_BUFSIZE bytes have been written the vfs tries to write the remaining bytes (in this case 10 bytes) to the tpm device driver via tpm_write which then blocks at /* cannot perform a write until the read has cleared either via tpm_read or a user_read_timer timeout */ while (atomic_read(&chip->data_pending) != 0) msleep(TPM_TIMEOUT); for 60 seconds, since data_pending is -7 and nobody is able to read it (since tpm_read luckily checks if data_pending is greater than 0) (#bug 2). After that the remaining bytes are written to the TPM which are interpreted by the tpm as a normal command. (bug #3) So if the last bytes of the command stream happen to be a e.g. tpm_force_clear this gets accidentally sent to the TPM. This patch fixes all three bugs, by propagating the error code of tpm_write and returning -E2BIG if the input buffer is too big, since the response from the tpm for a truncated value is bogus anyway. Moreover it returns -EBUSY to userspace if there is a response ready to be read. Signed-off-by: Peter Huewe <peter.huewe@infineon.com> Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'sound/pci/ac97')
0 files changed, 0 insertions, 0 deletions