aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-10-21 15:57:32 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-11-28 22:36:45 -0500
commit584271bcb45b50027c8d87b51634750780c92437 (patch)
treeae0fa71904cfc2d3e7b876f4be03240556cd381a /arch/avr32
parent9ac08002130b591d0f2ee035aa9062f84f2f15cb (diff)
avr32: sanitize copy_thread(), switch to generic fork/vfork/clone, kill wrappers
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/avr32')
-rw-r--r--arch/avr32/include/asm/unistd.h3
-rw-r--r--arch/avr32/kernel/process.c31
-rw-r--r--arch/avr32/kernel/syscall-stubs.S18
-rw-r--r--arch/avr32/kernel/syscall_table.S6
4 files changed, 11 insertions, 47 deletions
diff --git a/arch/avr32/include/asm/unistd.h b/arch/avr32/include/asm/unistd.h
index 641023d1bcb5..f05a9804e8e2 100644
--- a/arch/avr32/include/asm/unistd.h
+++ b/arch/avr32/include/asm/unistd.h
@@ -40,6 +40,9 @@
40#define __ARCH_WANT_SYS_RT_SIGACTION 40#define __ARCH_WANT_SYS_RT_SIGACTION
41#define __ARCH_WANT_SYS_RT_SIGSUSPEND 41#define __ARCH_WANT_SYS_RT_SIGSUSPEND
42#define __ARCH_WANT_SYS_EXECVE 42#define __ARCH_WANT_SYS_EXECVE
43#define __ARCH_WANT_SYS_FORK
44#define __ARCH_WANT_SYS_VFORK
45#define __ARCH_WANT_SYS_CLONE
43 46
44/* 47/*
45 * "Conditional" syscalls 48 * "Conditional" syscalls
diff --git a/arch/avr32/kernel/process.c b/arch/avr32/kernel/process.c
index 09b894d96d6e..03d7aa4a4bc9 100644
--- a/arch/avr32/kernel/process.c
+++ b/arch/avr32/kernel/process.c
@@ -299,11 +299,11 @@ asmlinkage void syscall_return(void);
299 299
300int copy_thread(unsigned long clone_flags, unsigned long usp, 300int copy_thread(unsigned long clone_flags, unsigned long usp,
301 unsigned long arg, 301 unsigned long arg,
302 struct task_struct *p, struct pt_regs *regs) 302 struct task_struct *p, struct pt_regs *unused)
303{ 303{
304 struct pt_regs *childregs = task_pt_regs(p); 304 struct pt_regs *childregs = task_pt_regs(p);
305 305
306 if (unlikely(!regs)) { 306 if (unlikely(p->flags & PF_KTHREAD)) {
307 memset(childregs, 0, sizeof(struct pt_regs)); 307 memset(childregs, 0, sizeof(struct pt_regs));
308 p->thread.cpu_context.r0 = arg; 308 p->thread.cpu_context.r0 = arg;
309 p->thread.cpu_context.r1 = usp; /* fn */ 309 p->thread.cpu_context.r1 = usp; /* fn */
@@ -311,8 +311,9 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
311 p->thread.cpu_context.pc = (unsigned long)ret_from_kernel_thread; 311 p->thread.cpu_context.pc = (unsigned long)ret_from_kernel_thread;
312 childregs->sr = MODE_SUPERVISOR; 312 childregs->sr = MODE_SUPERVISOR;
313 } else { 313 } else {
314 *childregs = *regs; 314 *childregs = *current_pt_regs();
315 childregs->sp = usp; 315 if (usp)
316 childregs->sp = usp;
316 childregs->r12 = 0; /* Set return value for child */ 317 childregs->r12 = 0; /* Set return value for child */
317 p->thread.cpu_context.pc = (unsigned long)ret_from_fork; 318 p->thread.cpu_context.pc = (unsigned long)ret_from_fork;
318 } 319 }
@@ -327,28 +328,6 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
327 return 0; 328 return 0;
328} 329}
329 330
330/* r12-r8 are dummy parameters to force the compiler to use the stack */
331asmlinkage int sys_fork(struct pt_regs *regs)
332{
333 return do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL);
334}
335
336asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
337 void __user *parent_tidptr, void __user *child_tidptr,
338 struct pt_regs *regs)
339{
340 if (!newsp)
341 newsp = regs->sp;
342 return do_fork(clone_flags, newsp, regs, 0, parent_tidptr,
343 child_tidptr);
344}
345
346asmlinkage int sys_vfork(struct pt_regs *regs)
347{
348 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, regs,
349 0, NULL, NULL);
350}
351
352/* 331/*
353 * This function is supposed to answer the question "who called 332 * This function is supposed to answer the question "who called
354 * schedule()?" 333 * schedule()?"
diff --git a/arch/avr32/kernel/syscall-stubs.S b/arch/avr32/kernel/syscall-stubs.S
index 285a61b9194e..275aab9731fd 100644
--- a/arch/avr32/kernel/syscall-stubs.S
+++ b/arch/avr32/kernel/syscall-stubs.S
@@ -32,24 +32,6 @@ __sys_rt_sigreturn:
32 mov r12, sp 32 mov r12, sp
33 rjmp sys_rt_sigreturn 33 rjmp sys_rt_sigreturn
34 34
35 .global __sys_fork
36 .type __sys_fork,@function
37__sys_fork:
38 mov r12, sp
39 rjmp sys_fork
40
41 .global __sys_clone
42 .type __sys_clone,@function
43__sys_clone:
44 mov r8, sp
45 rjmp sys_clone
46
47 .global __sys_vfork
48 .type __sys_vfork,@function
49__sys_vfork:
50 mov r12, sp
51 rjmp sys_vfork
52
53 .global __sys_mmap2 35 .global __sys_mmap2
54 .type __sys_mmap2,@function 36 .type __sys_mmap2,@function
55__sys_mmap2: 37__sys_mmap2:
diff --git a/arch/avr32/kernel/syscall_table.S b/arch/avr32/kernel/syscall_table.S
index fc6497706819..f27bb878da6b 100644
--- a/arch/avr32/kernel/syscall_table.S
+++ b/arch/avr32/kernel/syscall_table.S
@@ -15,7 +15,7 @@
15sys_call_table: 15sys_call_table:
16 .long sys_restart_syscall 16 .long sys_restart_syscall
17 .long sys_exit 17 .long sys_exit
18 .long __sys_fork 18 .long sys_fork
19 .long sys_read 19 .long sys_read
20 .long sys_write 20 .long sys_write
21 .long sys_open /* 5 */ 21 .long sys_open /* 5 */
@@ -57,7 +57,7 @@ sys_call_table:
57 .long sys_dup 57 .long sys_dup
58 .long sys_pipe 58 .long sys_pipe
59 .long sys_times 59 .long sys_times
60 .long __sys_clone 60 .long sys_clone
61 .long sys_brk /* 45 */ 61 .long sys_brk /* 45 */
62 .long sys_setgid 62 .long sys_setgid
63 .long sys_getgid 63 .long sys_getgid
@@ -127,7 +127,7 @@ sys_call_table:
127 .long sys_newuname 127 .long sys_newuname
128 .long sys_adjtimex 128 .long sys_adjtimex
129 .long sys_mprotect 129 .long sys_mprotect
130 .long __sys_vfork 130 .long sys_vfork
131 .long sys_init_module /* 115 */ 131 .long sys_init_module /* 115 */
132 .long sys_delete_module 132 .long sys_delete_module
133 .long sys_quotactl 133 .long sys_quotactl