linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* x86/crash: fix crash_setup_memmap_entries() out-of-bounds access
@ 2021-04-15 17:56 Mike Galbraith
  2021-04-16 11:07 ` Dave Young
  0 siblings, 1 reply; 14+ messages in thread
From: Mike Galbraith @ 2021-04-15 17:56 UTC (permalink / raw)
  To: LKML; +Cc: Dave Young, Baoquan He

x86/crash: fix crash_setup_memmap_entries() KASAN vmalloc-out-of-bounds gripe

[   15.428011] BUG: KASAN: vmalloc-out-of-bounds in crash_setup_memmap_entries+0x17e/0x3a0
[   15.428018] Write of size 8 at addr ffffc90000426008 by task kexec/1187

(gdb) list *crash_setup_memmap_entries+0x17e
0xffffffff8107cafe is in crash_setup_memmap_entries (arch/x86/kernel/crash.c:322).
317                                      unsigned long long mend)
318     {
319             unsigned long start, end;
320
321             cmem->ranges[0].start = mstart;
322             cmem->ranges[0].end = mend;
323             cmem->nr_ranges = 1;
324
325             /* Exclude elf header region */
326             start = image->arch.elf_load_addr;
(gdb)

We're excluding two ranges, allocate the scratch space we need to do that.

Signed-off-by: Mike Galbraith <efault@gmx.de>
---
 arch/x86/kernel/crash.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -337,7 +337,7 @@ int crash_setup_memmap_entries(struct ki
 	struct crash_memmap_data cmd;
 	struct crash_mem *cmem;

-	cmem = vzalloc(sizeof(struct crash_mem));
+	cmem = vzalloc(sizeof(struct crash_mem)+(2*sizeof(struct crash_mem_range)));
 	if (!cmem)
 		return -ENOMEM;



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

end of thread, other threads:[~2021-04-20 18:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15 17:56 x86/crash: fix crash_setup_memmap_entries() out-of-bounds access Mike Galbraith
2021-04-16 11:07 ` Dave Young
2021-04-16 11:28   ` Mike Galbraith
2021-04-16 11:47     ` Dave Young
2021-04-16 12:02       ` [patch] " Mike Galbraith
2021-04-16 12:16         ` Borislav Petkov
2021-04-16 13:16           ` Mike Galbraith
2021-04-16 14:44             ` Borislav Petkov
2021-04-16 15:13               ` Mike Galbraith
2021-04-16 21:44                 ` Thomas Gleixner
2021-04-17  0:05                   ` Mike Galbraith
2021-04-19  8:52                     ` Borislav Petkov
2021-04-19  9:37                       ` DaveYoung
2021-04-20 18:00         ` [tip: x86/urgent] x86/crash: Fix " tip-bot2 for Mike Galbraith

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