Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'x86-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into master

Pull x86 fixes from Ingo Molnar:
"Misc fixes:

- Fix a section end page alignment assumption that was causing
crashes

- Fix ORC unwinding on freshly forked tasks which haven't executed
yet and which have empty user task stacks

- Fix the debug.exception-trace=1 sysctl dumping of user stacks,
which was broken by recent maccess changes"

* tag 'x86-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/dumpstack: Dump user space code correctly again
x86/stacktrace: Fix reliable check for empty user task stacks
x86/unwind/orc: Fix ORC for newly forked tasks
x86, vmlinux.lds: Page-align end of ..page_aligned sections

+28 -18
+17 -10
arch/x86/kernel/dumpstack.c
··· 71 71 printk("%s %s%pB\n", log_lvl, reliable ? "" : "? ", (void *)address); 72 72 } 73 73 74 + static int copy_code(struct pt_regs *regs, u8 *buf, unsigned long src, 75 + unsigned int nbytes) 76 + { 77 + if (!user_mode(regs)) 78 + return copy_from_kernel_nofault(buf, (u8 *)src, nbytes); 79 + 80 + /* 81 + * Make sure userspace isn't trying to trick us into dumping kernel 82 + * memory by pointing the userspace instruction pointer at it. 83 + */ 84 + if (__chk_range_not_ok(src, nbytes, TASK_SIZE_MAX)) 85 + return -EINVAL; 86 + 87 + return copy_from_user_nmi(buf, (void __user *)src, nbytes); 88 + } 89 + 74 90 /* 75 91 * There are a couple of reasons for the 2/3rd prologue, courtesy of Linus: 76 92 * ··· 113 97 #define OPCODE_BUFSIZE (PROLOGUE_SIZE + 1 + EPILOGUE_SIZE) 114 98 u8 opcodes[OPCODE_BUFSIZE]; 115 99 unsigned long prologue = regs->ip - PROLOGUE_SIZE; 116 - bool bad_ip; 117 100 118 - /* 119 - * Make sure userspace isn't trying to trick us into dumping kernel 120 - * memory by pointing the userspace instruction pointer at it. 121 - */ 122 - bad_ip = user_mode(regs) && 123 - __chk_range_not_ok(prologue, OPCODE_BUFSIZE, TASK_SIZE_MAX); 124 - 125 - if (bad_ip || copy_from_kernel_nofault(opcodes, (u8 *)prologue, 126 - OPCODE_BUFSIZE)) { 101 + if (copy_code(regs, opcodes, prologue, sizeof(opcodes))) { 127 102 printk("%sCode: Bad RIP value.\n", loglvl); 128 103 } else { 129 104 printk("%sCode: %" __stringify(PROLOGUE_SIZE) "ph <%02x> %"
-5
arch/x86/kernel/stacktrace.c
··· 58 58 * or a page fault), which can make frame pointers 59 59 * unreliable. 60 60 */ 61 - 62 61 if (IS_ENABLED(CONFIG_FRAME_POINTER)) 63 62 return -EINVAL; 64 63 } ··· 78 79 79 80 /* Check for stack corruption */ 80 81 if (unwind_error(&state)) 81 - return -EINVAL; 82 - 83 - /* Success path for non-user tasks, i.e. kthreads and idle tasks */ 84 - if (!(task->flags & (PF_KTHREAD | PF_IDLE))) 85 82 return -EINVAL; 86 83 87 84 return 0;
+6 -2
arch/x86/kernel/unwind_orc.c
··· 440 440 /* 441 441 * Find the orc_entry associated with the text address. 442 442 * 443 - * Decrement call return addresses by one so they work for sibling 444 - * calls and calls to noreturn functions. 443 + * For a call frame (as opposed to a signal frame), state->ip points to 444 + * the instruction after the call. That instruction's stack layout 445 + * could be different from the call instruction's layout, for example 446 + * if the call was to a noreturn function. So get the ORC data for the 447 + * call instruction itself. 445 448 */ 446 449 orc = orc_find(state->signal ? state->ip : state->ip - 1); 447 450 if (!orc) { ··· 665 662 state->sp = task->thread.sp; 666 663 state->bp = READ_ONCE_NOCHECK(frame->bp); 667 664 state->ip = READ_ONCE_NOCHECK(frame->ret_addr); 665 + state->signal = (void *)state->ip == ret_from_fork; 668 666 } 669 667 670 668 if (get_stack_info((unsigned long *)state->sp, state->task,
+1
arch/x86/kernel/vmlinux.lds.S
··· 358 358 .bss : AT(ADDR(.bss) - LOAD_OFFSET) { 359 359 __bss_start = .; 360 360 *(.bss..page_aligned) 361 + . = ALIGN(PAGE_SIZE); 361 362 *(BSS_MAIN) 362 363 BSS_DECRYPTED 363 364 . = ALIGN(PAGE_SIZE);
+4 -1
include/asm-generic/vmlinux.lds.h
··· 341 341 342 342 #define PAGE_ALIGNED_DATA(page_align) \ 343 343 . = ALIGN(page_align); \ 344 - *(.data..page_aligned) 344 + *(.data..page_aligned) \ 345 + . = ALIGN(page_align); 345 346 346 347 #define READ_MOSTLY_DATA(align) \ 347 348 . = ALIGN(align); \ ··· 738 737 . = ALIGN(bss_align); \ 739 738 .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \ 740 739 BSS_FIRST_SECTIONS \ 740 + . = ALIGN(PAGE_SIZE); \ 741 741 *(.bss..page_aligned) \ 742 + . = ALIGN(PAGE_SIZE); \ 742 743 *(.dynbss) \ 743 744 *(BSS_MAIN) \ 744 745 *(COMMON) \