aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-09 23:02:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-09 23:02:25 -0400
commit42859eea96ba6beabfb0369a1eeffa3c7d2bd9cb (patch)
treefa38aeda0d6e7a4c48a882b166b8643594a1ad50 /arch/um
parentf59b51fe3d3092c08d7d554ecb40db24011b2ebc (diff)
parentf322220d6159455da2b5a8a596d802c8695fed30 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
Pull generic execve() changes from Al Viro: "This introduces the generic kernel_thread() and kernel_execve() functions, and switches x86, arm, alpha, um and s390 over to them." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal: (26 commits) s390: convert to generic kernel_execve() s390: switch to generic kernel_thread() s390: fold kernel_thread_helper() into ret_from_fork() s390: fold execve_tail() into start_thread(), convert to generic sys_execve() um: switch to generic kernel_thread() x86, um/x86: switch to generic sys_execve and kernel_execve x86: split ret_from_fork alpha: introduce ret_from_kernel_execve(), switch to generic kernel_execve() alpha: switch to generic kernel_thread() alpha: switch to generic sys_execve() arm: get rid of execve wrapper, switch to generic execve() implementation arm: optimized current_pt_regs() arm: introduce ret_from_kernel_execve(), switch to generic kernel_execve() arm: split ret_from_fork, simplify kernel_thread() [based on patch by rmk] generic sys_execve() generic kernel_execve() new helper: current_pt_regs() preparation for generic kernel_thread() um: kill thread->forking um: let signal_delivered() do SIGTRAP on singlestepping into handler ...
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/include/asm/processor-generic.h2
-rw-r--r--arch/um/kernel/exec.c25
-rw-r--r--arch/um/kernel/internal.h1
-rw-r--r--arch/um/kernel/process.c17
-rw-r--r--arch/um/kernel/syscall.c17
5 files changed, 5 insertions, 57 deletions
diff --git a/arch/um/include/asm/processor-generic.h b/arch/um/include/asm/processor-generic.h
index 24e97be814bc..1e82e954e978 100644
--- a/arch/um/include/asm/processor-generic.h
+++ b/arch/um/include/asm/processor-generic.h
@@ -63,8 +63,6 @@ static inline void release_thread(struct task_struct *task)
63{ 63{
64} 64}
65 65
66extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
67
68extern unsigned long thread_saved_pc(struct task_struct *t); 66extern unsigned long thread_saved_pc(struct task_struct *t);
69 67
70static inline void mm_copy_segments(struct mm_struct *from_mm, 68static inline void mm_copy_segments(struct mm_struct *from_mm,
diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c
index de66c421ae9d..ab019c7f0b57 100644
--- a/arch/um/kernel/exec.c
+++ b/arch/um/kernel/exec.c
@@ -16,7 +16,6 @@
16#include <mem_user.h> 16#include <mem_user.h>
17#include <skas.h> 17#include <skas.h>
18#include <os.h> 18#include <os.h>
19#include "internal.h"
20 19
21void flush_thread(void) 20void flush_thread(void)
22{ 21{
@@ -49,27 +48,7 @@ void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
49} 48}
50EXPORT_SYMBOL(start_thread); 49EXPORT_SYMBOL(start_thread);
51 50
52long um_execve(const char *file, const char __user *const __user *argv, const char __user *const __user *env) 51void __noreturn ret_from_kernel_execve(struct pt_regs *unused)
53{ 52{
54 long err; 53 UML_LONGJMP(current->thread.exec_buf, 1);
55
56 err = do_execve(file, argv, env, &current->thread.regs);
57 if (!err)
58 UML_LONGJMP(current->thread.exec_buf, 1);
59 return err;
60}
61
62long sys_execve(const char __user *file, const char __user *const __user *argv,
63 const char __user *const __user *env)
64{
65 long error;
66 char *filename;
67
68 filename = getname(file);
69 error = PTR_ERR(filename);
70 if (IS_ERR(filename)) goto out;
71 error = do_execve(filename, argv, env, &current->thread.regs);
72 putname(filename);
73 out:
74 return error;
75} 54}
diff --git a/arch/um/kernel/internal.h b/arch/um/kernel/internal.h
deleted file mode 100644
index 5bf97db24a04..000000000000
--- a/arch/um/kernel/internal.h
+++ /dev/null
@@ -1 +0,0 @@
1extern long um_execve(const char *file, const char __user *const __user *argv, const char __user *const __user *env);
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index 41f53240e794..30629783b3e0 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -69,18 +69,6 @@ unsigned long alloc_stack(int order, int atomic)
69 return page; 69 return page;
70} 70}
71 71
72int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
73{
74 int pid;
75
76 current->thread.request.u.thread.proc = fn;
77 current->thread.request.u.thread.arg = arg;
78 pid = do_fork(CLONE_VM | CLONE_UNTRACED | flags, 0,
79 &current->thread.regs, 0, NULL, NULL);
80 return pid;
81}
82EXPORT_SYMBOL(kernel_thread);
83
84static inline void set_current(struct task_struct *task) 72static inline void set_current(struct task_struct *task)
85{ 73{
86 cpu_tasks[task_thread_info(task)->cpu] = ((struct cpu_task) 74 cpu_tasks[task_thread_info(task)->cpu] = ((struct cpu_task)
@@ -177,7 +165,7 @@ void fork_handler(void)
177} 165}
178 166
179int copy_thread(unsigned long clone_flags, unsigned long sp, 167int copy_thread(unsigned long clone_flags, unsigned long sp,
180 unsigned long stack_top, struct task_struct * p, 168 unsigned long arg, struct task_struct * p,
181 struct pt_regs *regs) 169 struct pt_regs *regs)
182{ 170{
183 void (*handler)(void); 171 void (*handler)(void);
@@ -198,7 +186,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
198 arch_copy_thread(&current->thread.arch, &p->thread.arch); 186 arch_copy_thread(&current->thread.arch, &p->thread.arch);
199 } else { 187 } else {
200 get_safe_registers(p->thread.regs.regs.gp, p->thread.regs.regs.fp); 188 get_safe_registers(p->thread.regs.regs.gp, p->thread.regs.regs.fp);
201 p->thread.request.u.thread = current->thread.request.u.thread; 189 p->thread.request.u.thread.proc = (int (*)(void *))sp;
190 p->thread.request.u.thread.arg = (void *)arg;
202 handler = new_thread_handler; 191 handler = new_thread_handler;
203 } 192 }
204 193
diff --git a/arch/um/kernel/syscall.c b/arch/um/kernel/syscall.c
index 10808bda3671..a81f3705e90f 100644
--- a/arch/um/kernel/syscall.c
+++ b/arch/um/kernel/syscall.c
@@ -13,7 +13,6 @@
13#include <asm/mman.h> 13#include <asm/mman.h>
14#include <asm/uaccess.h> 14#include <asm/uaccess.h>
15#include <asm/unistd.h> 15#include <asm/unistd.h>
16#include "internal.h"
17 16
18long sys_fork(void) 17long sys_fork(void)
19{ 18{
@@ -50,19 +49,3 @@ long old_mmap(unsigned long addr, unsigned long len,
50 out: 49 out:
51 return err; 50 return err;
52} 51}
53
54int kernel_execve(const char *filename,
55 const char *const argv[],
56 const char *const envp[])
57{
58 mm_segment_t fs;
59 int ret;
60
61 fs = get_fs();
62 set_fs(KERNEL_DS);
63 ret = um_execve(filename, (const char __user *const __user *)argv,
64 (const char __user *const __user *) envp);
65 set_fs(fs);
66
67 return ret;
68}