diff options
Diffstat (limited to 'arch/um/kernel')
-rw-r--r-- | arch/um/kernel/exitcode.c | 2 | ||||
-rw-r--r-- | arch/um/kernel/process.c | 48 | ||||
-rw-r--r-- | arch/um/kernel/process_kern.c | 2 | ||||
-rw-r--r-- | arch/um/kernel/skas/process.c | 2 | ||||
-rw-r--r-- | arch/um/kernel/skas/trap_user.c | 1 | ||||
-rw-r--r-- | arch/um/kernel/time_kern.c | 5 |
6 files changed, 36 insertions, 24 deletions
diff --git a/arch/um/kernel/exitcode.c b/arch/um/kernel/exitcode.c index 0ea87f24b36f..d21ebad666b4 100644 --- a/arch/um/kernel/exitcode.c +++ b/arch/um/kernel/exitcode.c | |||
@@ -48,7 +48,7 @@ static int make_proc_exitcode(void) | |||
48 | 48 | ||
49 | ent = create_proc_entry("exitcode", 0600, &proc_root); | 49 | ent = create_proc_entry("exitcode", 0600, &proc_root); |
50 | if(ent == NULL){ | 50 | if(ent == NULL){ |
51 | printk("make_proc_exitcode : Failed to register " | 51 | printk(KERN_WARNING "make_proc_exitcode : Failed to register " |
52 | "/proc/exitcode\n"); | 52 | "/proc/exitcode\n"); |
53 | return(0); | 53 | return(0); |
54 | } | 54 | } |
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index 8b01a5584e80..67acd92c5322 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c | |||
@@ -131,7 +131,7 @@ int start_fork_tramp(void *thread_arg, unsigned long temp_stack, | |||
131 | return(arg.pid); | 131 | return(arg.pid); |
132 | } | 132 | } |
133 | 133 | ||
134 | static int ptrace_child(void) | 134 | static int ptrace_child(void *arg) |
135 | { | 135 | { |
136 | int ret; | 136 | int ret; |
137 | int pid = os_getpid(), ppid = getppid(); | 137 | int pid = os_getpid(), ppid = getppid(); |
@@ -160,16 +160,20 @@ static int ptrace_child(void) | |||
160 | _exit(ret); | 160 | _exit(ret); |
161 | } | 161 | } |
162 | 162 | ||
163 | static int start_ptraced_child(void) | 163 | static int start_ptraced_child(void **stack_out) |
164 | { | 164 | { |
165 | void *stack; | ||
166 | unsigned long sp; | ||
165 | int pid, n, status; | 167 | int pid, n, status; |
166 | 168 | ||
167 | pid = fork(); | 169 | stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, |
168 | if(pid == 0) | 170 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
169 | ptrace_child(); | 171 | if(stack == MAP_FAILED) |
170 | 172 | panic("check_ptrace : mmap failed, errno = %d", errno); | |
173 | sp = (unsigned long) stack + PAGE_SIZE - sizeof(void *); | ||
174 | pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL); | ||
171 | if(pid < 0) | 175 | if(pid < 0) |
172 | panic("check_ptrace : fork failed, errno = %d", errno); | 176 | panic("check_ptrace : clone failed, errno = %d", errno); |
173 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); | 177 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); |
174 | if(n < 0) | 178 | if(n < 0) |
175 | panic("check_ptrace : wait failed, errno = %d", errno); | 179 | panic("check_ptrace : wait failed, errno = %d", errno); |
@@ -177,6 +181,7 @@ static int start_ptraced_child(void) | |||
177 | panic("check_ptrace : expected SIGSTOP, got status = %d", | 181 | panic("check_ptrace : expected SIGSTOP, got status = %d", |
178 | status); | 182 | status); |
179 | 183 | ||
184 | *stack_out = stack; | ||
180 | return(pid); | 185 | return(pid); |
181 | } | 186 | } |
182 | 187 | ||
@@ -184,12 +189,12 @@ static int start_ptraced_child(void) | |||
184 | * just avoid using sysemu, not panic, but only if SYSEMU features are broken. | 189 | * just avoid using sysemu, not panic, but only if SYSEMU features are broken. |
185 | * So only for SYSEMU features we test mustpanic, while normal host features | 190 | * So only for SYSEMU features we test mustpanic, while normal host features |
186 | * must work anyway!*/ | 191 | * must work anyway!*/ |
187 | static int stop_ptraced_child(int pid, int exitcode, int mustexit) | 192 | static int stop_ptraced_child(int pid, void *stack, int exitcode, int mustpanic) |
188 | { | 193 | { |
189 | int status, n, ret = 0; | 194 | int status, n, ret = 0; |
190 | 195 | ||
191 | if(ptrace(PTRACE_CONT, pid, 0, 0) < 0) | 196 | if(ptrace(PTRACE_CONT, pid, 0, 0) < 0) |
192 | panic("stop_ptraced_child : ptrace failed, errno = %d", errno); | 197 | panic("check_ptrace : ptrace failed, errno = %d", errno); |
193 | CATCH_EINTR(n = waitpid(pid, &status, 0)); | 198 | CATCH_EINTR(n = waitpid(pid, &status, 0)); |
194 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) { | 199 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) { |
195 | int exit_with = WEXITSTATUS(status); | 200 | int exit_with = WEXITSTATUS(status); |
@@ -200,13 +205,15 @@ static int stop_ptraced_child(int pid, int exitcode, int mustexit) | |||
200 | printk("check_ptrace : child exited with exitcode %d, while " | 205 | printk("check_ptrace : child exited with exitcode %d, while " |
201 | "expecting %d; status 0x%x", exit_with, | 206 | "expecting %d; status 0x%x", exit_with, |
202 | exitcode, status); | 207 | exitcode, status); |
203 | if (mustexit) | 208 | if (mustpanic) |
204 | panic("\n"); | 209 | panic("\n"); |
205 | else | 210 | else |
206 | printk("\n"); | 211 | printk("\n"); |
207 | ret = -1; | 212 | ret = -1; |
208 | } | 213 | } |
209 | 214 | ||
215 | if(munmap(stack, PAGE_SIZE) < 0) | ||
216 | panic("check_ptrace : munmap failed, errno = %d", errno); | ||
210 | return ret; | 217 | return ret; |
211 | } | 218 | } |
212 | 219 | ||
@@ -242,11 +249,12 @@ __uml_setup("nosysemu", nosysemu_cmd_param, | |||
242 | 249 | ||
243 | static void __init check_sysemu(void) | 250 | static void __init check_sysemu(void) |
244 | { | 251 | { |
252 | void *stack; | ||
245 | int pid, syscall, n, status, count=0; | 253 | int pid, syscall, n, status, count=0; |
246 | 254 | ||
247 | printk("Checking syscall emulation patch for ptrace..."); | 255 | printk("Checking syscall emulation patch for ptrace..."); |
248 | sysemu_supported = 0; | 256 | sysemu_supported = 0; |
249 | pid = start_ptraced_child(); | 257 | pid = start_ptraced_child(&stack); |
250 | 258 | ||
251 | if(ptrace(PTRACE_SYSEMU, pid, 0, 0) < 0) | 259 | if(ptrace(PTRACE_SYSEMU, pid, 0, 0) < 0) |
252 | goto fail; | 260 | goto fail; |
@@ -264,7 +272,7 @@ static void __init check_sysemu(void) | |||
264 | panic("check_sysemu : failed to modify system " | 272 | panic("check_sysemu : failed to modify system " |
265 | "call return, errno = %d", errno); | 273 | "call return, errno = %d", errno); |
266 | 274 | ||
267 | if (stop_ptraced_child(pid, 0, 0) < 0) | 275 | if (stop_ptraced_child(pid, stack, 0, 0) < 0) |
268 | goto fail_stopped; | 276 | goto fail_stopped; |
269 | 277 | ||
270 | sysemu_supported = 1; | 278 | sysemu_supported = 1; |
@@ -272,7 +280,7 @@ static void __init check_sysemu(void) | |||
272 | set_using_sysemu(!force_sysemu_disabled); | 280 | set_using_sysemu(!force_sysemu_disabled); |
273 | 281 | ||
274 | printk("Checking advanced syscall emulation patch for ptrace..."); | 282 | printk("Checking advanced syscall emulation patch for ptrace..."); |
275 | pid = start_ptraced_child(); | 283 | pid = start_ptraced_child(&stack); |
276 | while(1){ | 284 | while(1){ |
277 | count++; | 285 | count++; |
278 | if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0) | 286 | if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0) |
@@ -297,7 +305,7 @@ static void __init check_sysemu(void) | |||
297 | break; | 305 | break; |
298 | } | 306 | } |
299 | } | 307 | } |
300 | if (stop_ptraced_child(pid, 0, 0) < 0) | 308 | if (stop_ptraced_child(pid, stack, 0, 0) < 0) |
301 | goto fail_stopped; | 309 | goto fail_stopped; |
302 | 310 | ||
303 | sysemu_supported = 2; | 311 | sysemu_supported = 2; |
@@ -308,17 +316,18 @@ static void __init check_sysemu(void) | |||
308 | return; | 316 | return; |
309 | 317 | ||
310 | fail: | 318 | fail: |
311 | stop_ptraced_child(pid, 1, 0); | 319 | stop_ptraced_child(pid, stack, 1, 0); |
312 | fail_stopped: | 320 | fail_stopped: |
313 | printk("missing\n"); | 321 | printk("missing\n"); |
314 | } | 322 | } |
315 | 323 | ||
316 | void __init check_ptrace(void) | 324 | void __init check_ptrace(void) |
317 | { | 325 | { |
326 | void *stack; | ||
318 | int pid, syscall, n, status; | 327 | int pid, syscall, n, status; |
319 | 328 | ||
320 | printk("Checking that ptrace can change system call numbers..."); | 329 | printk("Checking that ptrace can change system call numbers..."); |
321 | pid = start_ptraced_child(); | 330 | pid = start_ptraced_child(&stack); |
322 | 331 | ||
323 | if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) | 332 | if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) |
324 | panic("check_ptrace: PTRACE_SETOPTIONS failed, errno = %d", errno); | 333 | panic("check_ptrace: PTRACE_SETOPTIONS failed, errno = %d", errno); |
@@ -345,7 +354,7 @@ void __init check_ptrace(void) | |||
345 | break; | 354 | break; |
346 | } | 355 | } |
347 | } | 356 | } |
348 | stop_ptraced_child(pid, 0, 1); | 357 | stop_ptraced_child(pid, stack, 0, 1); |
349 | printk("OK\n"); | 358 | printk("OK\n"); |
350 | check_sysemu(); | 359 | check_sysemu(); |
351 | } | 360 | } |
@@ -380,10 +389,11 @@ extern void *__syscall_stub_start, __syscall_stub_end; | |||
380 | static inline void check_skas3_ptrace_support(void) | 389 | static inline void check_skas3_ptrace_support(void) |
381 | { | 390 | { |
382 | struct ptrace_faultinfo fi; | 391 | struct ptrace_faultinfo fi; |
392 | void *stack; | ||
383 | int pid, n; | 393 | int pid, n; |
384 | 394 | ||
385 | printf("Checking for the skas3 patch in the host..."); | 395 | printf("Checking for the skas3 patch in the host..."); |
386 | pid = start_ptraced_child(); | 396 | pid = start_ptraced_child(&stack); |
387 | 397 | ||
388 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); | 398 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); |
389 | if (n < 0) { | 399 | if (n < 0) { |
@@ -402,7 +412,7 @@ static inline void check_skas3_ptrace_support(void) | |||
402 | } | 412 | } |
403 | 413 | ||
404 | init_registers(pid); | 414 | init_registers(pid); |
405 | stop_ptraced_child(pid, 1, 1); | 415 | stop_ptraced_child(pid, stack, 1, 1); |
406 | } | 416 | } |
407 | 417 | ||
408 | int can_do_skas(void) | 418 | int can_do_skas(void) |
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c index d4036ed680bc..c23d8a08d0ff 100644 --- a/arch/um/kernel/process_kern.c +++ b/arch/um/kernel/process_kern.c | |||
@@ -412,7 +412,7 @@ int __init make_proc_sysemu(void) | |||
412 | 412 | ||
413 | if (ent == NULL) | 413 | if (ent == NULL) |
414 | { | 414 | { |
415 | printk("Failed to register /proc/sysemu\n"); | 415 | printk(KERN_WARNING "Failed to register /proc/sysemu\n"); |
416 | return(0); | 416 | return(0); |
417 | } | 417 | } |
418 | 418 | ||
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c index ba671dab8878..6dd9e5bf18ed 100644 --- a/arch/um/kernel/skas/process.c +++ b/arch/um/kernel/skas/process.c | |||
@@ -64,7 +64,7 @@ void wait_stub_done(int pid, int sig, char * fname) | |||
64 | (WSTOPSIG(status) == SIGVTALRM)); | 64 | (WSTOPSIG(status) == SIGVTALRM)); |
65 | 65 | ||
66 | if((n < 0) || !WIFSTOPPED(status) || | 66 | if((n < 0) || !WIFSTOPPED(status) || |
67 | (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status != SIGTRAP))){ | 67 | (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){ |
68 | panic("%s : failed to wait for SIGUSR1/SIGTRAP, " | 68 | panic("%s : failed to wait for SIGUSR1/SIGTRAP, " |
69 | "pid = %d, n = %d, errno = %d, status = 0x%x\n", | 69 | "pid = %d, n = %d, errno = %d, status = 0x%x\n", |
70 | fname, pid, n, errno, status); | 70 | fname, pid, n, errno, status); |
diff --git a/arch/um/kernel/skas/trap_user.c b/arch/um/kernel/skas/trap_user.c index 0dee1d95c806..9950a6716fe5 100644 --- a/arch/um/kernel/skas/trap_user.c +++ b/arch/um/kernel/skas/trap_user.c | |||
@@ -58,7 +58,6 @@ void user_signal(int sig, union uml_pt_regs *regs, int pid) | |||
58 | int segv = ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) || | 58 | int segv = ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) || |
59 | (sig == SIGILL) || (sig == SIGTRAP)); | 59 | (sig == SIGILL) || (sig == SIGTRAP)); |
60 | 60 | ||
61 | regs->skas.is_user = 1; | ||
62 | if (segv) | 61 | if (segv) |
63 | get_skas_faultinfo(pid, ®s->skas.faultinfo); | 62 | get_skas_faultinfo(pid, ®s->skas.faultinfo); |
64 | info = &sig_info[sig]; | 63 | info = &sig_info[sig]; |
diff --git a/arch/um/kernel/time_kern.c b/arch/um/kernel/time_kern.c index a8b4ef601f59..4e08f7545d63 100644 --- a/arch/um/kernel/time_kern.c +++ b/arch/um/kernel/time_kern.c | |||
@@ -137,7 +137,10 @@ long um_stime(int __user *tptr) | |||
137 | void timer_handler(int sig, union uml_pt_regs *regs) | 137 | void timer_handler(int sig, union uml_pt_regs *regs) |
138 | { | 138 | { |
139 | local_irq_disable(); | 139 | local_irq_disable(); |
140 | update_process_times(CHOOSE_MODE(user_context(UPT_SP(regs)), (regs)->skas.is_user)); | 140 | irq_enter(); |
141 | update_process_times(CHOOSE_MODE(user_context(UPT_SP(regs)), | ||
142 | (regs)->skas.is_user)); | ||
143 | irq_exit(); | ||
141 | local_irq_enable(); | 144 | local_irq_enable(); |
142 | if(current_thread->cpu == 0) | 145 | if(current_thread->cpu == 0) |
143 | timer_irq(regs); | 146 | timer_irq(regs); |