* [PATCH] x86/boot: Handle malformed SRAT tables during early ACPI parsing
@ 2020-01-31 0:48 Steven Clarkson
2020-01-31 18:55 ` Borislav Petkov
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Steven Clarkson @ 2020-01-31 0:48 UTC (permalink / raw)
To: linux-kernel, Borislav Petkov; +Cc: Steven Clarkson
Break an infinite loop when early parsing SRAT caused by a subtable with
zero length. Known to affect the ASUS WS X299 SAGE motherboard with
firmware version 1201, which has a large block of zeros in its SRAT table.
The kernel could boot successfully on this board/firmware prior to the
introduction of early parsing this table.
Fixes: 02a3e3cdb7f1 ("x86/boot: Parse SRAT table and count immovable
memory regions")
Signed-off-by: Steven Clarkson <sc@lambdal.com>
---
arch/x86/boot/compressed/acpi.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c
index 25019d42ae93..1a4479c5edfc 100644
--- a/arch/x86/boot/compressed/acpi.c
+++ b/arch/x86/boot/compressed/acpi.c
@@ -394,6 +394,12 @@ int count_immovable_mem_regions(void)
while (table + sizeof(struct acpi_subtable_header) < table_end) {
sub_table = (struct acpi_subtable_header *)table;
+
+ if (!sub_table->length) {
+ debug_putstr("Invalid zero length SRAT subtable.\n");
+ break;
+ }
+
if (sub_table->type == ACPI_SRAT_TYPE_MEMORY_AFFINITY) {
struct acpi_srat_mem_affinity *ma;
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] x86/boot: Handle malformed SRAT tables during early ACPI parsing
2020-01-31 0:48 [PATCH] x86/boot: Handle malformed SRAT tables during early ACPI parsing Steven Clarkson
@ 2020-01-31 18:55 ` Borislav Petkov
2020-01-31 23:00 ` Steven Clarkson
2020-01-31 18:58 ` [tip: x86/urgent] " tip-bot2 for Steven Clarkson
2020-01-31 19:10 ` tip-bot2 for Steven Clarkson
2 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2020-01-31 18:55 UTC (permalink / raw)
To: Steven Clarkson; +Cc: linux-kernel
On Thu, Jan 30, 2020 at 04:48:16PM -0800, Steven Clarkson wrote:
> Break an infinite loop when early parsing SRAT caused by a subtable with
> zero length. Known to affect the ASUS WS X299 SAGE motherboard with
> firmware version 1201, which has a large block of zeros in its SRAT table.
> The kernel could boot successfully on this board/firmware prior to the
> introduction of early parsing this table.
>
> Fixes: 02a3e3cdb7f1 ("x86/boot: Parse SRAT table and count immovable
> memory regions")
> Signed-off-by: Steven Clarkson <sc@lambdal.com>
> ---
> arch/x86/boot/compressed/acpi.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c
> index 25019d42ae93..1a4479c5edfc 100644
> --- a/arch/x86/boot/compressed/acpi.c
> +++ b/arch/x86/boot/compressed/acpi.c
> @@ -394,6 +394,12 @@ int count_immovable_mem_regions(void)
>
> while (table + sizeof(struct acpi_subtable_header) < table_end) {
> sub_table = (struct acpi_subtable_header *)table;
> +
> + if (!sub_table->length) {
> + debug_putstr("Invalid zero length SRAT subtable.\n");
> + break;
> + }
> +
> if (sub_table->type == ACPI_SRAT_TYPE_MEMORY_AFFINITY) {
> struct acpi_srat_mem_affinity *ma;
>
> --
Only in case you want to send patches in the future, see below.
scripts/checkpatch.pl can do that checking for you before you send. I'll
fix it up now.
ERROR: code indent should use tabs where possible
#37: FILE: arch/x86/boot/compressed/acpi.c:398:
+ if (!sub_table->length) {$
WARNING: please, no spaces at the start of a line
#37: FILE: arch/x86/boot/compressed/acpi.c:398:
+ if (!sub_table->length) {$
WARNING: suspect code indent for conditional statements (15, 23)
#37: FILE: arch/x86/boot/compressed/acpi.c:398:
+ if (!sub_table->length) {
+ debug_putstr("Invalid zero length SRAT subtable.\n");
ERROR: code indent should use tabs where possible
#38: FILE: arch/x86/boot/compressed/acpi.c:399:
+ debug_putstr("Invalid zero length SRAT subtable.\n");$
WARNING: please, no spaces at the start of a line
#38: FILE: arch/x86/boot/compressed/acpi.c:399:
+ debug_putstr("Invalid zero length SRAT subtable.\n");$
ERROR: code indent should use tabs where possible
#39: FILE: arch/x86/boot/compressed/acpi.c:400:
+ break;$
WARNING: please, no spaces at the start of a line
#39: FILE: arch/x86/boot/compressed/acpi.c:400:
+ break;$
ERROR: code indent should use tabs where possible
#40: FILE: arch/x86/boot/compressed/acpi.c:401:
+ }$
WARNING: please, no spaces at the start of a line
#40: FILE: arch/x86/boot/compressed/acpi.c:401:
+ }$
total: 4 errors, 5 warnings, 12 lines checked
--
Regards/Gruss,
Boris.
SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip: x86/urgent] x86/boot: Handle malformed SRAT tables during early ACPI parsing
2020-01-31 0:48 [PATCH] x86/boot: Handle malformed SRAT tables during early ACPI parsing Steven Clarkson
2020-01-31 18:55 ` Borislav Petkov
@ 2020-01-31 18:58 ` tip-bot2 for Steven Clarkson
2020-01-31 19:10 ` tip-bot2 for Steven Clarkson
2 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Steven Clarkson @ 2020-01-31 18:58 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Steven Clarkson, Borislav Petkov, linux-acpi, x86, LKML
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 32ea5bc7ab8344600e87acf68cd6981c845d6edc
Gitweb: https://git.kernel.org/tip/32ea5bc7ab8344600e87acf68cd6981c845d6edc
Author: Steven Clarkson <sc@lambdal.com>
AuthorDate: Thu, 30 Jan 2020 16:48:16 -08:00
Committer: Borislav Petkov <bp@suse.de>
CommitterDate: Fri, 31 Jan 2020 19:54:35 +01:00
x86/boot: Handle malformed SRAT tables during early ACPI parsing
Break an infinite loop when early parsing of the SRAT table is caused
by a subtable with zero length. Known to affect the ASUS WS X299 SAGE
motherboard with firmware version 1201 which has a large block of
zeros in its SRAT table. The kernel could boot successfully on this
board/firmware prior to the introduction of early parsing this table or
after a BIOS update.
[ bp: Fixup whitespace damage and commit message. ]
Fixes: 02a3e3cdb7f1 ("x86/boot: Parse SRAT table and count immovable memory regions")
Signed-off-by: Steven Clarkson <sc@lambdal.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: linux-acpi@vger.kernel.org
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206343
Link: https://lkml.kernel.org/r/CAHKq8taGzj0u1E_i=poHUam60Bko5BpiJ9jn0fAupFUYexvdUQ@mail.gmail.com
---
arch/x86/boot/compressed/acpi.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c
index 25019d4..ef2ad72 100644
--- a/arch/x86/boot/compressed/acpi.c
+++ b/arch/x86/boot/compressed/acpi.c
@@ -393,7 +393,13 @@ int count_immovable_mem_regions(void)
table = table_addr + sizeof(struct acpi_table_srat);
while (table + sizeof(struct acpi_subtable_header) < table_end) {
+
sub_table = (struct acpi_subtable_header *)table;
+ if (!sub_table->length) {
+ debug_putstr("Invalid zero length SRAT subtable.\n");
+ return 0;
+ }
+
if (sub_table->type == ACPI_SRAT_TYPE_MEMORY_AFFINITY) {
struct acpi_srat_mem_affinity *ma;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [tip: x86/urgent] x86/boot: Handle malformed SRAT tables during early ACPI parsing
2020-01-31 0:48 [PATCH] x86/boot: Handle malformed SRAT tables during early ACPI parsing Steven Clarkson
2020-01-31 18:55 ` Borislav Petkov
2020-01-31 18:58 ` [tip: x86/urgent] " tip-bot2 for Steven Clarkson
@ 2020-01-31 19:10 ` tip-bot2 for Steven Clarkson
2 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Steven Clarkson @ 2020-01-31 19:10 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Steven Clarkson, Borislav Petkov, linux-acpi, x86, LKML
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 2b73ea3796242608b4ccf019ff217156c92e92fe
Gitweb: https://git.kernel.org/tip/2b73ea3796242608b4ccf019ff217156c92e92fe
Author: Steven Clarkson <sc@lambdal.com>
AuthorDate: Thu, 30 Jan 2020 16:48:16 -08:00
Committer: Borislav Petkov <bp@suse.de>
CommitterDate: Fri, 31 Jan 2020 20:03:23 +01:00
x86/boot: Handle malformed SRAT tables during early ACPI parsing
Break an infinite loop when early parsing of the SRAT table is caused
by a subtable with zero length. Known to affect the ASUS WS X299 SAGE
motherboard with firmware version 1201 which has a large block of
zeros in its SRAT table. The kernel could boot successfully on this
board/firmware prior to the introduction of early parsing this table or
after a BIOS update.
[ bp: Fixup whitespace damage and commit message. Make it return 0 to
denote that there are no immovable regions because who knows what
else is broken in this BIOS. ]
Fixes: 02a3e3cdb7f1 ("x86/boot: Parse SRAT table and count immovable memory regions")
Signed-off-by: Steven Clarkson <sc@lambdal.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: linux-acpi@vger.kernel.org
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206343
Link: https://lkml.kernel.org/r/CAHKq8taGzj0u1E_i=poHUam60Bko5BpiJ9jn0fAupFUYexvdUQ@mail.gmail.com
---
arch/x86/boot/compressed/acpi.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c
index 25019d4..ef2ad72 100644
--- a/arch/x86/boot/compressed/acpi.c
+++ b/arch/x86/boot/compressed/acpi.c
@@ -393,7 +393,13 @@ int count_immovable_mem_regions(void)
table = table_addr + sizeof(struct acpi_table_srat);
while (table + sizeof(struct acpi_subtable_header) < table_end) {
+
sub_table = (struct acpi_subtable_header *)table;
+ if (!sub_table->length) {
+ debug_putstr("Invalid zero length SRAT subtable.\n");
+ return 0;
+ }
+
if (sub_table->type == ACPI_SRAT_TYPE_MEMORY_AFFINITY) {
struct acpi_srat_mem_affinity *ma;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] x86/boot: Handle malformed SRAT tables during early ACPI parsing
2020-01-31 18:55 ` Borislav Petkov
@ 2020-01-31 23:00 ` Steven Clarkson
2020-01-31 23:02 ` Borislav Petkov
0 siblings, 1 reply; 6+ messages in thread
From: Steven Clarkson @ 2020-01-31 23:00 UTC (permalink / raw)
To: Borislav Petkov; +Cc: linux-kernel
On Fri, Jan 31, 2020 at 10:55 AM Borislav Petkov <bp@suse.de> wrote:
> Only in case you want to send patches in the future, see below.
> scripts/checkpatch.pl can do that checking for you before you send. I'll
> fix it up now.
>
> ERROR: code indent should use tabs where possible
> #37: FILE: arch/x86/boot/compressed/acpi.c:398:
> + if (!sub_table->length) {$
I did that, but my mail client ate my tabs. Lesson learned. Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86/boot: Handle malformed SRAT tables during early ACPI parsing
2020-01-31 23:00 ` Steven Clarkson
@ 2020-01-31 23:02 ` Borislav Petkov
0 siblings, 0 replies; 6+ messages in thread
From: Borislav Petkov @ 2020-01-31 23:02 UTC (permalink / raw)
To: Steven Clarkson; +Cc: linux-kernel
On Fri, Jan 31, 2020 at 03:00:49PM -0800, Steven Clarkson wrote:
> I did that, but my mail client ate my tabs. Lesson learned. Thanks.
We have some info for mail clients too:
https://www.kernel.org/doc/html/latest/process/email-clients.html
HTH.
--
Regards/Gruss,
Boris.
SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-01-31 23:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-31 0:48 [PATCH] x86/boot: Handle malformed SRAT tables during early ACPI parsing Steven Clarkson
2020-01-31 18:55 ` Borislav Petkov
2020-01-31 23:00 ` Steven Clarkson
2020-01-31 23:02 ` Borislav Petkov
2020-01-31 18:58 ` [tip: x86/urgent] " tip-bot2 for Steven Clarkson
2020-01-31 19:10 ` tip-bot2 for Steven Clarkson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).