aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux
diff options
context:
space:
mode:
authorPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>2005-12-29 11:39:51 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-12-29 12:48:15 -0500
commit516949480d3700cbde4272228a102c84721d6007 (patch)
treeb7fef00010e2ad97a9fdab4f683c1516948749cb /arch/um/os-Linux
parent3603bc8dc5ab33941e6378fe52ea03b7f5561109 (diff)
[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>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r--arch/um/os-Linux/start_up.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 37517d49c4ae..29a9e3f43763 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -116,16 +116,16 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode,
116 if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) { 116 if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) {
117 int exit_with = WEXITSTATUS(status); 117 int exit_with = WEXITSTATUS(status);
118 if (exit_with == 2) 118 if (exit_with == 2)
119 printk("check_ptrace : child exited with status 2. " 119 printf("check_ptrace : child exited with status 2. "
120 "Serious trouble happening! Try updating your " 120 "Serious trouble happening! Try updating your "
121 "host skas patch!\nDisabling SYSEMU support."); 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 "expecting %d; status 0x%x", exit_with, 123 "expecting %d; status 0x%x", exit_with,
124 exitcode, status); 124 exitcode, status);
125 if (mustpanic) 125 if (mustpanic)
126 panic("\n"); 126 panic("\n");
127 else 127 else
128 printk("\n"); 128 printf("\n");
129 ret = -1; 129 ret = -1;
130 } 130 }
131 131
@@ -183,7 +183,7 @@ static void __init check_sysemu(void)
183 void *stack; 183 void *stack;
184 int pid, n, status, count=0; 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 sysemu_supported = 0; 187 sysemu_supported = 0;
188 pid = start_ptraced_child(&stack); 188 pid = start_ptraced_child(&stack);
189 189
@@ -207,10 +207,10 @@ static void __init check_sysemu(void)
207 goto fail_stopped; 207 goto fail_stopped;
208 208
209 sysemu_supported = 1; 209 sysemu_supported = 1;
210 printk("OK\n"); 210 printf("OK\n");
211 set_using_sysemu(!force_sysemu_disabled); 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 pid = start_ptraced_child(&stack); 214 pid = start_ptraced_child(&stack);
215 215
216 if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0, 216 if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0,
@@ -246,7 +246,7 @@ static void __init check_sysemu(void)
246 goto fail_stopped; 246 goto fail_stopped;
247 247
248 sysemu_supported = 2; 248 sysemu_supported = 2;
249 printk("OK\n"); 249 printf("OK\n");
250 250
251 if ( !force_sysemu_disabled ) 251 if ( !force_sysemu_disabled )
252 set_using_sysemu(sysemu_supported); 252 set_using_sysemu(sysemu_supported);
@@ -255,7 +255,7 @@ static void __init check_sysemu(void)
255fail: 255fail:
256 stop_ptraced_child(pid, stack, 1, 0); 256 stop_ptraced_child(pid, stack, 1, 0);
257fail_stopped: 257fail_stopped:
258 printk("missing\n"); 258 printf("missing\n");
259} 259}
260 260
261static void __init check_ptrace(void) 261static void __init check_ptrace(void)
@@ -263,7 +263,7 @@ static void __init check_ptrace(void)
263 void *stack; 263 void *stack;
264 int pid, syscall, n, status; 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 pid = start_ptraced_child(&stack); 267 pid = start_ptraced_child(&stack);
268 268
269 if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) 269 if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0)
@@ -292,7 +292,7 @@ static void __init check_ptrace(void)
292 } 292 }
293 } 293 }
294 stop_ptraced_child(pid, stack, 0, 1); 294 stop_ptraced_child(pid, stack, 0, 1);
295 printk("OK\n"); 295 printf("OK\n");
296 check_sysemu(); 296 check_sysemu();
297} 297}
298 298
@@ -472,6 +472,8 @@ int can_do_skas(void)
472 472
473int have_devanon = 0; 473int have_devanon = 0;
474 474
475/* Runs on boot kernel stack - already safe to use printk. */
476
475void check_devanon(void) 477void check_devanon(void)
476{ 478{
477 int fd; 479 int fd;