Re: [LTP] [PATCH] ima: skip verifying TPM 2.0 PCR values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2019-10-24 at 14:38 -0700, Jerry Snitselaar wrote:
> On Thu Oct 24 19, Jarkko Sakkinen wrote:
> >On Thu, Oct 24, 2019 at 02:18:48PM +0200, Petr Vorel wrote:
> >> Hi all,
> >>
> >> I wonder what to do with this patch "ima: skip verifying TPM 2.0 PCR values" [1].
> >> Is it a correct way to differentiate between TPM 1.2 and TPM 2.0?
> >> Or something else should be applied?
> >>
> >> How is the work on TPM 2.0 Linux sysfs interface?
> >> But even it's done in near future, we'd still need some way for older kernels.
> >>
> >> Kind regards,
> >> Petr
> >>
> >> [1] https://patchwork.ozlabs.org/patch/1100733/
> >
> >version_major sysfs file would be acceptable if someone wants to proceed
> >and send such patch.
> >
> >Also replicants for durations and timeouts files would make sense for
> >TPM 2.0.
> >
> >/Jarkko
> 
> Is it as simple as doing this?
> 
> diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
> index edfa89160010..fd8eb8d8945c 100644
> --- a/drivers/char/tpm/tpm-sysfs.c
> +++ b/drivers/char/tpm/tpm-sysfs.c
> @@ -309,7 +309,17 @@ static ssize_t timeouts_show(struct device *dev, struct device_attribute *attr,
>  }
>  static DEVICE_ATTR_RO(timeouts);
>  
> -static struct attribute *tpm_dev_attrs[] = {
> +static ssize_t version_major_show(struct device *dev,
> +                                 struct device_attribute *attr, char *buf)
> +{
> +       struct tpm_chip *chip = to_tpm_chip(dev);
> +
> +       return sprintf(buf, "TPM%s\n", chip->flags & TPM_CHIP_FLAG_TPM2
> +                      ? "2.0" : "1.2");
> +}
> +static DEVICE_ATTR_RO(version_major);
> +
> +static struct attribute *tpm12_dev_attrs[] = {
>         &dev_attr_pubek.attr,
>         &dev_attr_pcrs.attr,
>         &dev_attr_enabled.attr,
> @@ -320,18 +330,28 @@ static struct attribute *tpm_dev_attrs[] = {
>         &dev_attr_cancel.attr,
>         &dev_attr_durations.attr,
>         &dev_attr_timeouts.attr,
> +       &dev_attr_version_major.attr,
>         NULL,
>  };
>  

The TPM version seems to be included in "dev_attr_caps.attr".

> -static const struct attribute_group tpm_dev_group = {
> -       .attrs = tpm_dev_attrs,
> +static struct attribute *tpm20_dev_attrs[] = {
> +       &dev_attr_version_major.attr,
> +       NULL
> +};

This should work, but wouldn't exporting this information under
security/tpmX, like the binary_bios_measurements, be a lot easier to
find and use?

Mimi

> +
> +static const struct attribute_group tpm12_dev_group = {
> +       .attrs = tpm12_dev_attrs,
> +};
> +
> +static const struct attribute_group tpm20_dev_group = {
> +       .attrs = tpm20_dev_attrs,
>  };
>  
>  void tpm_sysfs_add_device(struct tpm_chip *chip)
>  {
> -       if (chip->flags & TPM_CHIP_FLAG_TPM2)
> -               return;
> -
>         WARN_ON(chip->groups_cnt != 0);
> -       chip->groups[chip->groups_cnt++] = &tpm_dev_group;
> +       if (chip->flags & TPM_CHIP_FLAG_TPM2)
> +               chip->groups[chip->groups_cnt++] = &tpm20_dev_group;
> +       else
> +               chip->groups[chip->groups_cnt++] = &tpm12_dev_group;
>  }
> 
> 
> Did a quick test on 2 systems here.




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux