diff mbox

acpi: tpm2: add check for zero control area address (LP: #1506442)

Message ID 1444909265-29824-1-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King Oct. 15, 2015, 11:41 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The kernel checks for zero addresses because of some AMI BIOS bugs
setting this to zero, so we should probably check for this too.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/tpm2/tpm2.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Alex Hung Oct. 21, 2015, 1:58 a.m. UTC | #1
On 10/15/2015 07:41 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The kernel checks for zero addresses because of some AMI BIOS bugs
> setting this to zero, so we should probably check for this too.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/tpm2/tpm2.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/src/acpi/tpm2/tpm2.c b/src/acpi/tpm2/tpm2.c
> index 50a0e85..fbbb6fa 100644
> --- a/src/acpi/tpm2/tpm2.c
> +++ b/src/acpi/tpm2/tpm2.c
> @@ -1,7 +1,7 @@
>  /*
>   * Copyright (C) 2010-2015 Canonical
>   *
> -  * This program is free software; you can redistribute it and/or
> + * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
>   * as published by the Free Software Foundation; either version 2
>   * of the License, or (at your option) any later version.
> @@ -74,6 +74,18 @@ static int tpm2_test1(fwts_framework *fw)
>  			"TPM2's Start Method must be between one to eight, got 0x%" PRIx16,
>  			tpm2->start_method);
>  	}
> +	/*
> +	 * Kernel: drivers/char/tpm/tpm_crb.c checks for a zero address for
> +	 * the control area because some versions of AMI BIOS have a bug where
> +	 * this address is zero and the kernel driver aborts on this.
> +         */
> +	if (!tpm2->address_of_control_area) {
> +		passed = false;
> +		fwts_failed(fw, LOG_LEVEL_HIGH,
> +			"TPM2BadControlAreaAddress",
> +			"TPM2's Control Area Address is expected to be non-zero, got 0x%16.16" PRIx64,
> +			tpm2->address_of_control_area);
> +	}
>  
>  	if (tpm2->start_method == 2 && table->length != sizeof(fwts_acpi_table_tpm2) + 4) {
>  		passed = false;
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu Oct. 21, 2015, 2:52 a.m. UTC | #2
On 2015年10月15日 19:41, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The kernel checks for zero addresses because of some AMI BIOS bugs
> setting this to zero, so we should probably check for this too.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/tpm2/tpm2.c | 14 +++++++++++++-
>   1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/src/acpi/tpm2/tpm2.c b/src/acpi/tpm2/tpm2.c
> index 50a0e85..fbbb6fa 100644
> --- a/src/acpi/tpm2/tpm2.c
> +++ b/src/acpi/tpm2/tpm2.c
> @@ -1,7 +1,7 @@
>   /*
>    * Copyright (C) 2010-2015 Canonical
>    *
> -  * This program is free software; you can redistribute it and/or
> + * This program is free software; you can redistribute it and/or
>    * modify it under the terms of the GNU General Public License
>    * as published by the Free Software Foundation; either version 2
>    * of the License, or (at your option) any later version.
> @@ -74,6 +74,18 @@ static int tpm2_test1(fwts_framework *fw)
>   			"TPM2's Start Method must be between one to eight, got 0x%" PRIx16,
>   			tpm2->start_method);
>   	}
> +	/*
> +	 * Kernel: drivers/char/tpm/tpm_crb.c checks for a zero address for
> +	 * the control area because some versions of AMI BIOS have a bug where
> +	 * this address is zero and the kernel driver aborts on this.
> +         */
> +	if (!tpm2->address_of_control_area) {
> +		passed = false;
> +		fwts_failed(fw, LOG_LEVEL_HIGH,
> +			"TPM2BadControlAreaAddress",
> +			"TPM2's Control Area Address is expected to be non-zero, got 0x%16.16" PRIx64,
> +			tpm2->address_of_control_area);
> +	}
>   
>   	if (tpm2->start_method == 2 && table->length != sizeof(fwts_acpi_table_tpm2) + 4) {
>   		passed = false;

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/acpi/tpm2/tpm2.c b/src/acpi/tpm2/tpm2.c
index 50a0e85..fbbb6fa 100644
--- a/src/acpi/tpm2/tpm2.c
+++ b/src/acpi/tpm2/tpm2.c
@@ -1,7 +1,7 @@ 
 /*
  * Copyright (C) 2010-2015 Canonical
  *
-  * This program is free software; you can redistribute it and/or
+ * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
@@ -74,6 +74,18 @@  static int tpm2_test1(fwts_framework *fw)
 			"TPM2's Start Method must be between one to eight, got 0x%" PRIx16,
 			tpm2->start_method);
 	}
+	/*
+	 * Kernel: drivers/char/tpm/tpm_crb.c checks for a zero address for
+	 * the control area because some versions of AMI BIOS have a bug where
+	 * this address is zero and the kernel driver aborts on this.
+         */
+	if (!tpm2->address_of_control_area) {
+		passed = false;
+		fwts_failed(fw, LOG_LEVEL_HIGH,
+			"TPM2BadControlAreaAddress",
+			"TPM2's Control Area Address is expected to be non-zero, got 0x%16.16" PRIx64,
+			tpm2->address_of_control_area);
+	}
 
 	if (tpm2->start_method == 2 && table->length != sizeof(fwts_acpi_table_tpm2) + 4) {
 		passed = false;