Patchwork acpi: acpidump: abort dumping of SLIC if length is zero

login
register
mail settings
Submitter Colin King
Date March 18, 2013, 3:32 p.m.
Message ID <1363620775-31275-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/228676/
State Accepted
Headers show

Comments

Colin King - March 18, 2013, 3:32 p.m.
From: Colin Ian King <colin.king@canonical.com>

Some systems have a length specified as zero in the SLIC header
length field which means we get stuck dumping the null headers
forever.  Add a check so we can break out early.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/acpidump/acpidump.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
Alex Hung - March 19, 2013, 2:13 a.m.
On 03/18/2013 11:32 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Some systems have a length specified as zero in the SLIC header
> length field which means we get stuck dumping the null headers
> forever.  Add a check so we can break out early.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/acpidump/acpidump.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
>
> diff --git a/src/acpi/acpidump/acpidump.c b/src/acpi/acpidump/acpidump.c
> index 5f3e25e..ecb6592 100644
> --- a/src/acpi/acpidump/acpidump.c
> +++ b/src/acpi/acpidump/acpidump.c
> @@ -1452,6 +1452,17 @@ static void acpidump_slic(fwts_framework *fw, fwts_acpi_table_info *table)
>   		fwts_acpi_table_slic_header *header =
>   			(fwts_acpi_table_slic_header *)ptr;
>
> +		/*
> +		 *  Some machines such as the Acer Veritas have a SLIC header that
> +		 *  declares it's length as zero.  So to avoid spinning forever
> +		 *  break out of the loop.
> +		 */
> +		if ((ptr + sizeof(fwts_acpi_table_slic_header) < data + length) &&
> +		    (header->length == 0)) {
> +			fwts_log_info(fw, "SLIC header length is zero, aborting dump of SLIC.");
> +			break;
> +		}
> +
>   		switch(header->type) {
>   		case 0:
>   			__acpi_dump_table_fields(fw, ptr, slic_header_fields, ptr - data);
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - March 26, 2013, 5:54 a.m.
On Mon, Mar 18, 2013 at 11:32 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Some systems have a length specified as zero in the SLIC header
> length field which means we get stuck dumping the null headers
> forever.  Add a check so we can break out early.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/acpidump/acpidump.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/src/acpi/acpidump/acpidump.c b/src/acpi/acpidump/acpidump.c
> index 5f3e25e..ecb6592 100644
> --- a/src/acpi/acpidump/acpidump.c
> +++ b/src/acpi/acpidump/acpidump.c
> @@ -1452,6 +1452,17 @@ static void acpidump_slic(fwts_framework *fw, fwts_acpi_table_info *table)
>                 fwts_acpi_table_slic_header *header =
>                         (fwts_acpi_table_slic_header *)ptr;
>
> +               /*
> +                *  Some machines such as the Acer Veritas have a SLIC header that
> +                *  declares it's length as zero.  So to avoid spinning forever
> +                *  break out of the loop.
> +                */
> +               if ((ptr + sizeof(fwts_acpi_table_slic_header) < data + length) &&
> +                   (header->length == 0)) {
> +                       fwts_log_info(fw, "SLIC header length is zero, aborting dump of SLIC.");
> +                       break;
> +               }
> +
>                 switch(header->type) {
>                 case 0:
>                         __acpi_dump_table_fields(fw, ptr, slic_header_fields, ptr - data);
> --
> 1.8.1.2
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/acpi/acpidump/acpidump.c b/src/acpi/acpidump/acpidump.c
index 5f3e25e..ecb6592 100644
--- a/src/acpi/acpidump/acpidump.c
+++ b/src/acpi/acpidump/acpidump.c
@@ -1452,6 +1452,17 @@  static void acpidump_slic(fwts_framework *fw, fwts_acpi_table_info *table)
 		fwts_acpi_table_slic_header *header =
 			(fwts_acpi_table_slic_header *)ptr;
 
+		/*
+		 *  Some machines such as the Acer Veritas have a SLIC header that
+		 *  declares it's length as zero.  So to avoid spinning forever
+		 *  break out of the loop.
+		 */
+		if ((ptr + sizeof(fwts_acpi_table_slic_header) < data + length) &&
+		    (header->length == 0)) {
+			fwts_log_info(fw, "SLIC header length is zero, aborting dump of SLIC.");
+			break;
+		}
+
 		switch(header->type) {
 		case 0:
 			__acpi_dump_table_fields(fw, ptr, slic_header_fields, ptr - data);