diff options
-rw-r--r-- | fs/exec.c | 22 | ||||
-rw-r--r-- | include/linux/binfmts.h | 5 |
2 files changed, 27 insertions, 0 deletions
@@ -2318,3 +2318,25 @@ int dump_seek(struct file *file, loff_t off) | |||
2318 | return ret; | 2318 | return ret; |
2319 | } | 2319 | } |
2320 | EXPORT_SYMBOL(dump_seek); | 2320 | EXPORT_SYMBOL(dump_seek); |
2321 | |||
2322 | #ifdef __ARCH_WANT_KERNEL_EXECVE | ||
2323 | int kernel_execve(const char *filename, | ||
2324 | const char *const argv[], | ||
2325 | const char *const envp[]) | ||
2326 | { | ||
2327 | struct pt_regs *p = current_pt_regs(); | ||
2328 | int ret; | ||
2329 | |||
2330 | ret = do_execve(filename, | ||
2331 | (const char __user *const __user *)argv, | ||
2332 | (const char __user *const __user *)envp, p); | ||
2333 | if (ret < 0) | ||
2334 | return ret; | ||
2335 | |||
2336 | /* | ||
2337 | * We were successful. We won't be returning to our caller, but | ||
2338 | * instead to user space by manipulating the kernel stack. | ||
2339 | */ | ||
2340 | ret_from_kernel_execve(p); | ||
2341 | } | ||
2342 | #endif | ||
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index 8938beabad7a..f9c9d08f4f7c 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h | |||
@@ -19,6 +19,7 @@ struct pt_regs; | |||
19 | 19 | ||
20 | #ifdef __KERNEL__ | 20 | #ifdef __KERNEL__ |
21 | #include <linux/sched.h> | 21 | #include <linux/sched.h> |
22 | #include <linux/unistd.h> | ||
22 | #include <asm/exec.h> | 23 | #include <asm/exec.h> |
23 | 24 | ||
24 | #define CORENAME_MAX_SIZE 128 | 25 | #define CORENAME_MAX_SIZE 128 |
@@ -137,5 +138,9 @@ extern void do_coredump(long signr, int exit_code, struct pt_regs *regs); | |||
137 | extern void set_binfmt(struct linux_binfmt *new); | 138 | extern void set_binfmt(struct linux_binfmt *new); |
138 | extern void free_bprm(struct linux_binprm *); | 139 | extern void free_bprm(struct linux_binprm *); |
139 | 140 | ||
141 | #ifdef __ARCH_WANT_KERNEL_EXECVE | ||
142 | extern void ret_from_kernel_execve(struct pt_regs *normal) __noreturn; | ||
143 | #endif | ||
144 | |||
140 | #endif /* __KERNEL__ */ | 145 | #endif /* __KERNEL__ */ |
141 | #endif /* _LINUX_BINFMTS_H */ | 146 | #endif /* _LINUX_BINFMTS_H */ |