lkml.org 
[lkml]   [2019]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3] KEYS: trusted: correctly initialize digests and fix locking issue
On Sun, Sep 08, 2019 at 07:45:42PM +0200, Roberto Sassu wrote:
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> index 1b4f95c13e00..1fffa91fc148 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -316,14 +316,14 @@ int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,
> int rc;
> int i;
>
> - chip = tpm_find_get_ops(chip);
> - if (!chip)
> - return -ENODEV;
> -
> for (i = 0; i < chip->nr_allocated_banks; i++)
> if (digests[i].alg_id != chip->allocated_banks[i].alg_id)
> return -EINVAL;
>
> + chip = tpm_find_get_ops(chip);
> + if (!chip)
> + return -ENODEV;
> +
> if (chip->flags & TPM_CHIP_FLAG_TPM2) {
> rc = tpm2_pcr_extend(chip, pcr_idx, digests);
> tpm_put_ops(chip);

You can only access chip's field when you hold the lock and have a legit
refcount. This would add a potential race. The bug is very much valid
and thank you for spotting that.

I sent a patch the fix the 2nd issue with your reported-by.

[1] https://www.kernel.org/doc/html/latest/process/submitting-patches.html#separate-your-changes

/Jarkko


\
 
 \ /
  Last update: 2019-09-10 16:26    [W:0.130 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site