U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: Masahisa Kojima <masahisa.kojima@linaro.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Alexander Graf <agraf@csgraf.de>,
	u-boot@lists.denx.de
Subject: Re: [PATCH v3 3/3] efi_loader: add DeployedMode and AuditMode variable measurement
Date: Fri, 1 Oct 2021 18:43:27 +0200	[thread overview]
Message-ID: <9944b9ef-e47b-7f57-1b78-ca797358d1cf@gmx.de> (raw)
In-Reply-To: <20211001111844.7422-4-masahisa.kojima@linaro.org>



On 10/1/21 13:18, Masahisa Kojima wrote:
> This commit adds the DeployedMode and AuditMode variable
> measurement required in TCG PC Client PFP Spec.
>
> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
> ---
>
> Changes in v3:
> - read variable first, then mesure the variable
>
>   lib/efi_loader/efi_tcg2.c | 50 +++++++++++++++++++++++++++++++++++++++
>   1 file changed, 50 insertions(+)
>
> diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
> index 28e0362bf2..7fba4bc458 100644
> --- a/lib/efi_loader/efi_tcg2.c
> +++ b/lib/efi_loader/efi_tcg2.c
> @@ -12,6 +12,7 @@
>   #include <dm.h>
>   #include <efi_loader.h>
>   #include <efi_tcg2.h>
> +#include <efi_variable.h>
>   #include <log.h>
>   #include <malloc.h>
>   #include <smbios.h>
> @@ -1822,6 +1823,53 @@ out:
>   	return ret;
>   }
>
> +/**
> + * tcg2_measure_deployed_audit_mode() - measure deployedmode and auditmode
> + *
> + * @dev:	TPM device
> + *
> + * Return:	status code
> + */
> +static efi_status_t tcg2_measure_deployed_audit_mode(struct udevice *dev)
> +{
> +	u8 deployed_mode;
> +	u8 audit_mode;
> +	efi_uintn_t size;
> +	efi_status_t ret;
> +	u32 pcr_index;
> +
> +	size = sizeof(deployed_mode);
> +	ret = efi_get_variable_int(L"DeployedMode", &efi_global_variable_guid,
> +				   NULL, &size, &deployed_mode, NULL);
> +	if (ret != EFI_SUCCESS)
> +		return ret;
> +
> +	size = sizeof(audit_mode);
> +	ret = efi_get_variable_int(L"AuditMode", &efi_global_variable_guid,
> +				   NULL, &size, &audit_mode, NULL);
> +	if (ret != EFI_SUCCESS)
> +		return ret;
> +
> +	pcr_index = (deployed_mode ? 1 : 7);
> +
> +	ret = tcg2_measure_variable(dev, pcr_index,
> +				    EV_EFI_VARIABLE_DRIVER_CONFIG,
> +				    L"DeployedMode",
> +				    &efi_global_variable_guid,
> +				    size, &deployed_mode);
> +	if (ret != EFI_SUCCESS)
> +		return ret;
> +
> +
> +	ret = tcg2_measure_variable(dev, pcr_index,
> +				    EV_EFI_VARIABLE_DRIVER_CONFIG,
> +				    L"AuditMode",
> +				    &efi_global_variable_guid,
> +				    size, &audit_mode);
> +
> +	return ret;
> +}
> +
>   /**
>    * tcg2_measure_secure_boot_variable() - measure secure boot variables
>    *
> @@ -1885,6 +1933,8 @@ static efi_status_t tcg2_measure_secure_boot_variable(struct udevice *dev)
>   		free(data);
>   	}
>
> +	ret = tcg2_measure_deployed_audit_mode(dev);

You do the same thing four times. A loop is preferable.

Best regards

Heinrich

> +
>   error:
>   	return ret;
>   }
>

  reply	other threads:[~2021-10-01 16:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01 11:18 [PATCH v3 0/3] Enhance Measured Boot Masahisa Kojima
2021-10-01 11:18 ` [PATCH v3 1/3] efi_loader: add SMBIOS table measurement Masahisa Kojima
2021-10-01 15:23   ` Simon Glass
2021-10-01 19:47     ` Ilias Apalodimas
2021-10-21  0:12   ` Heinrich Schuchardt
2021-10-21  8:38     ` Masahisa Kojima
2021-10-21  8:49       ` Heinrich Schuchardt
2021-10-21 12:52         ` Masahisa Kojima
2021-10-21 12:59           ` Heinrich Schuchardt
2021-10-21 13:41             ` Masahisa Kojima
2021-11-02 14:56               ` Simon Glass
2021-11-04  1:26                 ` Masahisa Kojima
2021-10-01 11:18 ` [PATCH v3 2/3] efi_loader: add UEFI GPT measurement Masahisa Kojima
2021-10-01 15:23   ` Simon Glass
2021-10-22 10:49     ` Masahisa Kojima
2021-10-01 16:28   ` Heinrich Schuchardt
2021-10-04  3:11     ` Masahisa Kojima
2021-10-01 11:18 ` [PATCH v3 3/3] efi_loader: add DeployedMode and AuditMode variable measurement Masahisa Kojima
2021-10-01 16:43   ` Heinrich Schuchardt [this message]
2021-10-04  2:30     ` Masahisa Kojima
2021-10-22  8:04       ` Masahisa Kojima

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9944b9ef-e47b-7f57-1b78-ca797358d1cf@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=agraf@csgraf.de \
    --cc=ilias.apalodimas@linaro.org \
    --cc=masahisa.kojima@linaro.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox