Re: [PATCH] tpm: factor out the user space mm from tpm_vtpm_set_locality()
From: Jarkko Sakkinen
Date: Tue May 30 2023 - 17:49:47 EST
On Tue, 2023-05-30 at 23:50 +0300, Jarkko Sakkinen wrote:
> - if (!(proxy_dev->state & STATE_DRIVER_COMMAND) &&
> - vtpm_proxy_is_driver_command(chip, buf, count))
> + if ((chip->flags & TPM_CHIP_FLAG_TPM2) && ord == TPM2_CC_SET_LOCALITY)
> + return -EFAULT;
> +
> + if (ord == TPM_ORD_SET_LOCALITY)
> return -EFAULT;
Oops, should really be:
diff --git a/drivers/char/tpm/tpm_vtpm_proxy.c b/drivers/char/tpm/tpm_vtpm_proxy.c
index 83496742cc19..6da878952a0d 100644
--- a/drivers/char/tpm/tpm_vtpm_proxy.c
+++ b/drivers/char/tpm/tpm_vtpm_proxy.c
@@ -337,8 +337,7 @@ static int vtpm_proxy_tpm_op_send(struct tpm_chip *chip, u8 *buf, size_t count)
if ((chip->flags & TPM_CHIP_FLAG_TPM2) && ord == TPM2_CC_SET_LOCALITY)
return -EFAULT;
-
- if (ord == TPM_ORD_SET_LOCALITY)
+ else if (ord == TPM_ORD_SET_LOCALITY) /* TPM 1.2 */
return -EFAULT;
mutex_lock(&proxy_dev->buf_lock);
BR, Jarkko