diff options
Diffstat (limited to 'arch/arm64/kernel/sys.c')
-rw-r--r-- | arch/arm64/kernel/sys.c | 76 |
1 files changed, 3 insertions, 73 deletions
diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c index b120df37de35..4364df85050e 100644 --- a/arch/arm64/kernel/sys.c +++ b/arch/arm64/kernel/sys.c | |||
@@ -31,79 +31,11 @@ | |||
31 | */ | 31 | */ |
32 | asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp, | 32 | asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp, |
33 | int __user *parent_tidptr, unsigned long tls_val, | 33 | int __user *parent_tidptr, unsigned long tls_val, |
34 | int __user *child_tidptr, struct pt_regs *regs) | 34 | int __user *child_tidptr) |
35 | { | 35 | { |
36 | if (!newsp) | 36 | return do_fork(clone_flags, newsp, current_pt_regs(), 0, |
37 | newsp = regs->sp; | 37 | parent_tidptr, child_tidptr); |
38 | /* 16-byte aligned stack mandatory on AArch64 */ | ||
39 | if (newsp & 15) | ||
40 | return -EINVAL; | ||
41 | return do_fork(clone_flags, newsp, regs, 0, parent_tidptr, child_tidptr); | ||
42 | } | ||
43 | |||
44 | /* | ||
45 | * sys_execve() executes a new program. | ||
46 | */ | ||
47 | asmlinkage long sys_execve(const char __user *filenamei, | ||
48 | const char __user *const __user *argv, | ||
49 | const char __user *const __user *envp, | ||
50 | struct pt_regs *regs) | ||
51 | { | ||
52 | long error; | ||
53 | struct filename *filename; | ||
54 | |||
55 | filename = getname(filenamei); | ||
56 | error = PTR_ERR(filename); | ||
57 | if (IS_ERR(filename)) | ||
58 | goto out; | ||
59 | error = do_execve(filename->name, argv, envp, regs); | ||
60 | putname(filename); | ||
61 | out: | ||
62 | return error; | ||
63 | } | ||
64 | |||
65 | int kernel_execve(const char *filename, | ||
66 | const char *const argv[], | ||
67 | const char *const envp[]) | ||
68 | { | ||
69 | struct pt_regs regs; | ||
70 | int ret; | ||
71 | |||
72 | memset(®s, 0, sizeof(struct pt_regs)); | ||
73 | ret = do_execve(filename, | ||
74 | (const char __user *const __user *)argv, | ||
75 | (const char __user *const __user *)envp, ®s); | ||
76 | if (ret < 0) | ||
77 | goto out; | ||
78 | |||
79 | /* | ||
80 | * Save argc to the register structure for userspace. | ||
81 | */ | ||
82 | regs.regs[0] = ret; | ||
83 | |||
84 | /* | ||
85 | * We were successful. We won't be returning to our caller, but | ||
86 | * instead to user space by manipulating the kernel stack. | ||
87 | */ | ||
88 | asm( "add x0, %0, %1\n\t" | ||
89 | "mov x1, %2\n\t" | ||
90 | "mov x2, %3\n\t" | ||
91 | "bl memmove\n\t" /* copy regs to top of stack */ | ||
92 | "mov x27, #0\n\t" /* not a syscall */ | ||
93 | "mov x28, %0\n\t" /* thread structure */ | ||
94 | "mov sp, x0\n\t" /* reposition stack pointer */ | ||
95 | "b ret_to_user" | ||
96 | : | ||
97 | : "r" (current_thread_info()), | ||
98 | "Ir" (THREAD_START_SP - sizeof(regs)), | ||
99 | "r" (®s), | ||
100 | "Ir" (sizeof(regs)) | ||
101 | : "x0", "x1", "x2", "x27", "x28", "x30", "memory"); | ||
102 | |||
103 | out: | ||
104 | return ret; | ||
105 | } | 38 | } |
106 | EXPORT_SYMBOL(kernel_execve); | ||
107 | 39 | ||
108 | asmlinkage long sys_mmap(unsigned long addr, unsigned long len, | 40 | asmlinkage long sys_mmap(unsigned long addr, unsigned long len, |
109 | unsigned long prot, unsigned long flags, | 41 | unsigned long prot, unsigned long flags, |
@@ -118,8 +50,6 @@ asmlinkage long sys_mmap(unsigned long addr, unsigned long len, | |||
118 | /* | 50 | /* |
119 | * Wrappers to pass the pt_regs argument. | 51 | * Wrappers to pass the pt_regs argument. |
120 | */ | 52 | */ |
121 | #define sys_execve sys_execve_wrapper | ||
122 | #define sys_clone sys_clone_wrapper | ||
123 | #define sys_rt_sigreturn sys_rt_sigreturn_wrapper | 53 | #define sys_rt_sigreturn sys_rt_sigreturn_wrapper |
124 | #define sys_sigaltstack sys_sigaltstack_wrapper | 54 | #define sys_sigaltstack sys_sigaltstack_wrapper |
125 | 55 | ||