diff mbox

ima-evm-utils: check the return code from tpm_pcr_read() in ima_measurement()

Message ID 20180626162718.4916-1-gcwilson@linux.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

George Wilson June 26, 2018, 4:27 p.m. UTC
Don't log garbage when neither /sys/class/tpm/tpm0/device/pcrs nor
/sys/class/misc/tpm0/device/pcrs can be read and exit nicely with a
value of 1.

Signed-off-by: George Wilson <gcwilson@linux.ibm.com>
---
 src/evmctl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Mimi Zohar July 1, 2018, 8:28 p.m. UTC | #1
Hi George,

On Tue, 2018-06-26 at 10:27 -0600, George Wilson wrote:
> Don't log garbage when neither /sys/class/tpm/tpm0/device/pcrs nor
> /sys/class/misc/tpm0/device/pcrs can be read and exit nicely with a
> value of 1.
> 
> Signed-off-by: George Wilson <gcwilson@linux.ibm.com>

Thanks, this patch has been pushed to master.

Mimi

> ---
>  src/evmctl.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/evmctl.c b/src/evmctl.c
> index 2ffee78..a5c6221 100644
> --- a/src/evmctl.c
> +++ b/src/evmctl.c
> @@ -1514,7 +1514,8 @@ static int ima_measurement(const char *file)
>  		log_info("PCRAgg %.2d: ", i);
>  		log_dump(pcr[i], SHA_DIGEST_LENGTH);
> 
> -		tpm_pcr_read(i, hwpcr, sizeof(hwpcr));
> +		if (tpm_pcr_read(i, hwpcr, sizeof(hwpcr)))
> +			exit(1);
>  		log_info("HW PCR-%d: ", i);
>  		log_dump(hwpcr, sizeof(hwpcr));
>
diff mbox

Patch

diff --git a/src/evmctl.c b/src/evmctl.c
index 2ffee78..a5c6221 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -1514,7 +1514,8 @@  static int ima_measurement(const char *file)
 		log_info("PCRAgg %.2d: ", i);
 		log_dump(pcr[i], SHA_DIGEST_LENGTH);
 
-		tpm_pcr_read(i, hwpcr, sizeof(hwpcr));
+		if (tpm_pcr_read(i, hwpcr, sizeof(hwpcr)))
+			exit(1);
 		log_info("HW PCR-%d: ", i);
 		log_dump(hwpcr, sizeof(hwpcr));