linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] tools/x86/kcpuid: Check last token too
@ 2021-03-15 12:59 Borislav Petkov
  2021-03-15 12:59 ` [PATCH 2/2] tools/x86/kcpuid: Add AMD leaf 0x8000001E Borislav Petkov
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Borislav Petkov @ 2021-03-15 12:59 UTC (permalink / raw)
  To: Feng Tang; +Cc: X86 ML, LKML

From: Borislav Petkov <bp@suse.de>

Input lines like

  0x8000001E,     0, EAX,   31:0, Extended APIC ID

where the short name is missing lead to a segfault because the loop
takes the long name for the short name and tokens[5] becomes NULL which
explodes later in strcpy().

Check its value too before further processing.

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 tools/arch/x86/kcpuid/kcpuid.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c
index 6048da34fcc6..dae75511fef7 100644
--- a/tools/arch/x86/kcpuid/kcpuid.c
+++ b/tools/arch/x86/kcpuid/kcpuid.c
@@ -324,6 +324,8 @@ static int parse_line(char *line)
 		str = NULL;
 	}
 	tokens[5] = strtok(str, "\n");
+	if (!tokens[5])
+		goto err_exit;
 
 	/* index/main-leaf */
 	index = strtoull(tokens[0], NULL, 0);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-03-18 10:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 12:59 [PATCH 1/2] tools/x86/kcpuid: Check last token too Borislav Petkov
2021-03-15 12:59 ` [PATCH 2/2] tools/x86/kcpuid: Add AMD leaf 0x8000001E Borislav Petkov
2021-03-16  7:42   ` Feng Tang
2021-03-16 14:28     ` Borislav Petkov
2021-03-16 17:04       ` Sean Christopherson
2021-03-17  0:30         ` Feng Tang
2021-03-18 10:38   ` [tip: x86/misc] " tip-bot2 for Borislav Petkov
2021-03-16  7:34 ` [PATCH 1/2] tools/x86/kcpuid: Check last token too Feng Tang
2021-03-18 10:38 ` [tip: x86/misc] " tip-bot2 for Borislav Petkov

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).