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.

[PATCH] uml: fix random segfaults at bootup

Don't use printk() where "current_thread_info()" is crap.

Until when we switch to running on init_stack, current_thread_info() evaluates
to crap. Printk uses "current" at times (in detail, &current is evaluated with
CONFIG_DEBUG_SPINLOCK to check the spinlock owner task).

And this leads to random segmentation faults.

Exactly, what happens is that &current = *(current_thread_info()), i.e. round
down $esp and dereference the value. I.e. access the stack below $esp, which
causes SIGSEGV on a VM_GROWSDOWN vma (see arch/i386/mm/fault.c).

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Paolo 'Blaisorblade' Giarrusso and committed by
Linus Torvalds
51694948 3603bc8d

+12 -10
+12 -10
arch/um/os-Linux/start_up.c
··· 116 116 if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) { 117 117 int exit_with = WEXITSTATUS(status); 118 118 if (exit_with == 2) 119 - printk("check_ptrace : child exited with status 2. " 119 + printf("check_ptrace : child exited with status 2. " 120 120 "Serious trouble happening! Try updating your " 121 121 "host skas patch!\nDisabling SYSEMU support."); 122 - printk("check_ptrace : child exited with exitcode %d, while " 122 + printf("check_ptrace : child exited with exitcode %d, while " 123 123 "expecting %d; status 0x%x", exit_with, 124 124 exitcode, status); 125 125 if (mustpanic) 126 126 panic("\n"); 127 127 else 128 - printk("\n"); 128 + printf("\n"); 129 129 ret = -1; 130 130 } 131 131 ··· 183 183 void *stack; 184 184 int pid, n, status, count=0; 185 185 186 - printk("Checking syscall emulation patch for ptrace..."); 186 + printf("Checking syscall emulation patch for ptrace..."); 187 187 sysemu_supported = 0; 188 188 pid = start_ptraced_child(&stack); 189 189 ··· 207 207 goto fail_stopped; 208 208 209 209 sysemu_supported = 1; 210 - printk("OK\n"); 210 + printf("OK\n"); 211 211 set_using_sysemu(!force_sysemu_disabled); 212 212 213 - printk("Checking advanced syscall emulation patch for ptrace..."); 213 + printf("Checking advanced syscall emulation patch for ptrace..."); 214 214 pid = start_ptraced_child(&stack); 215 215 216 216 if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0, ··· 246 246 goto fail_stopped; 247 247 248 248 sysemu_supported = 2; 249 - printk("OK\n"); 249 + printf("OK\n"); 250 250 251 251 if ( !force_sysemu_disabled ) 252 252 set_using_sysemu(sysemu_supported); ··· 255 255 fail: 256 256 stop_ptraced_child(pid, stack, 1, 0); 257 257 fail_stopped: 258 - printk("missing\n"); 258 + printf("missing\n"); 259 259 } 260 260 261 261 static void __init check_ptrace(void) ··· 263 263 void *stack; 264 264 int pid, syscall, n, status; 265 265 266 - printk("Checking that ptrace can change system call numbers..."); 266 + printf("Checking that ptrace can change system call numbers..."); 267 267 pid = start_ptraced_child(&stack); 268 268 269 269 if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) ··· 292 292 } 293 293 } 294 294 stop_ptraced_child(pid, stack, 0, 1); 295 - printk("OK\n"); 295 + printf("OK\n"); 296 296 check_sysemu(); 297 297 } 298 298 ··· 471 471 #endif 472 472 473 473 int have_devanon = 0; 474 + 475 + /* Runs on boot kernel stack - already safe to use printk. */ 474 476 475 477 void check_devanon(void) 476 478 {