mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
tpm: Handle negative priv->response_len in tpm_common_read()
commita430e67d9aupstream. The priv->response_length can hold the size of an response or an negative error code, and the tpm_common_read() needs to handle both cases correctly. Changed the type of response_length to signed and accounted for negative value in tpm_common_read(). Cc: stable@vger.kernel.org Fixes:d23d124843("tpm: fix invalid locking in NONBLOCKING mode") Reported-by: Laura Abbott <labbott@redhat.com> Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
2e1a0a118a
commit
18c3955323
@@ -130,7 +130,7 @@ ssize_t tpm_common_read(struct file *file, char __user *buf,
|
|||||||
priv->response_read = true;
|
priv->response_read = true;
|
||||||
|
|
||||||
ret_size = min_t(ssize_t, size, priv->response_length);
|
ret_size = min_t(ssize_t, size, priv->response_length);
|
||||||
if (!ret_size) {
|
if (ret_size <= 0) {
|
||||||
priv->response_length = 0;
|
priv->response_length = 0;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ struct file_priv {
|
|||||||
struct work_struct timeout_work;
|
struct work_struct timeout_work;
|
||||||
struct work_struct async_work;
|
struct work_struct async_work;
|
||||||
wait_queue_head_t async_wait;
|
wait_queue_head_t async_wait;
|
||||||
size_t response_length;
|
ssize_t response_length;
|
||||||
bool response_read;
|
bool response_read;
|
||||||
bool command_enqueued;
|
bool command_enqueued;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user