Bug 198427 - KASAN: bad failure mode on OOM during bootstrap
Summary: KASAN: bad failure mode on OOM during bootstrap
Status: RESOLVED CODE_FIX
Alias: None
Product: Memory Management
Classification: Unclassified
Component: Sanitizers (show other bugs)
Hardware: All Linux
: P2 normal
Assignee: Dmitry Vyukov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-10 09:35 UTC by Dmitry Vyukov
Modified: 2018-01-14 12:13 UTC (History)
0 users

See Also:
Kernel Version: ALL
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Dmitry Vyukov 2018-01-10 09:35:49 UTC
For context see:
https://groups.google.com/d/msg/kasan-dev/bwl5y0EaBeg/8FQS8X8VDQAJ

In short, a machine has small amount of memory (for KASAN), as the result early_alloc() in kasan_init() fails, but is not properly handled. A bit later kernel crashes with a cryptic panic (see below). We need to properly handle errors in early_alloc().

From Andrey Ryabinin:

> We probably should panic only if PAGE_SIZE allocation failed.
> PUD_SIZE,PMD_SIZE allocations have
> failure fallback. I would suggest add 'bool panic' param  to early_alloc()
> and call
> memblock_virt_alloc_try_nid() if it's true.


[    0.000000] kernel BUG at arch/x86/mm/physaddr.c:27!
PANIC: early exception 0x06 IP 10:ffffffff8115586f error 0 cr2 0xffff88000e468000
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.14.0-00160-g10043e02 #1
[    0.000000] task: ffffffff8a4683c0 task.stack: ffffffff8a400000
[    0.000000] RIP: 0010:__phys_addr+0x268/0x276
[    0.000000] RSP: 0000:ffffffff8a407bd8 EFLAGS: 00010002 ORIG_RAX: 0000000000000000
[    0.000000] RAX: 0000000000000000 RBX: 0000780000000000 RCX: 1ffffffff17a9a01
[    0.000000] RDX: dffffc0000000000 RSI: 0000000000000003 RDI: ffffffff8bd4d340
[    0.000000] RBP: ffffffff8a407bf8 R08: 0000000000000001 R09: ffffffff8a407a48
[    0.000000] R10: ffff880000010000 R11: ffff880000010fff R12: 0000000000000001
[    0.000000] R13: 0000000000000001 R14: 0000000000000000 R15: fffffbd00c401000
[    0.000000] FS:  0000000000000000(0000) GS:ffffffff8cb4d000(0000) knlGS:0000000000000000
[    0.000000] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    0.000000] CR2: ffff88000e468000 CR3: 000000000cde8000 CR4: 00000000000406b0
[    0.000000] Call Trace:
[    0.000000]  kasan_populate_shadow+0x3f2/0x497
[    0.000000]  ? 0xffffffff81000000
[    0.000000]  kasan_init+0x12e/0x2b2
[    0.000000]  setup_arch+0x2825/0x2a2c
[    0.000000]  ? reserve_standard_io_resources+0x36/0x36
[    0.000000]  ? vprintk_func+0x1ed/0x1f6
[    0.000000]  ? printk+0x94/0xb0
[    0.000000]  ? show_regs_print_info+0x60/0x60
[    0.000000]  start_kernel+0xc8/0x15f4
[    0.000000]  ? mem_encrypt_init+0xb/0xb
[    0.000000]  ? early_idt_handler_common+0x3b/0x52
[    0.000000]  x86_64_start_reservations+0x2a/0x2c
[    0.000000]  x86_64_start_kernel+0x72/0x75
[    0.000000]  secondary_startup_64+0xa5/0xb0
[    0.000000] Code: e0 07 38 c2 0f 9e c1 84 d2 0f 95 c0 84 c1 74 0a be 08 00 00 00 e8 0a f5 77 00 49 8d 75 02 48 ff 04 f5 28 d3 d4 8b 45 84 e4 74 02 <0f> 0b 48 89 d8 5b 41 5c 41 5d 41 5e 5d c3 e8 9e c1 0a 07 55 b8
Comment 1 Dmitry Vyukov 2018-01-10 15:41:28 UTC
FTR, Andrey mailed "x86/kasan: panic if there is not enough memory to boot." to fix this.
Comment 2 Dmitry Vyukov 2018-01-14 12:13:02 UTC
Now in tip tree, so let's consider this fixed.

Note You need to log in before you can comment on or make changes to this bug.