diff options
author | Brian Gerst <brgerst@gmail.com> | 2009-12-09 19:01:53 -0500 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-12-09 19:28:34 -0500 |
commit | 11cf88bd0b8165b65aaabaee0977e9a3ad474ab7 (patch) | |
tree | 33e74a88baf24ee971282ded562b78db40749bb9 | |
parent | 27f59559d63375a4d59e7c720a439d9f0b47edad (diff) |
x86: Merge sys_execve
Change 32-bit sys_execve to PTREGSCALL3, and merge with 64-bit.
Signed-off-by: Brian Gerst <brgerst@gmail.com>
LKML-Reference: <1260403316-5679-4-git-send-email-brgerst@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | arch/x86/include/asm/syscalls.h | 6 | ||||
-rw-r--r-- | arch/x86/kernel/entry_32.S | 2 | ||||
-rw-r--r-- | arch/x86/kernel/process.c | 26 | ||||
-rw-r--r-- | arch/x86/kernel/process_32.c | 25 | ||||
-rw-r--r-- | arch/x86/kernel/process_64.c | 19 |
5 files changed, 29 insertions, 49 deletions
diff --git a/arch/x86/include/asm/syscalls.h b/arch/x86/include/asm/syscalls.h index 4b694cd904c4..48c48e508b9f 100644 --- a/arch/x86/include/asm/syscalls.h +++ b/arch/x86/include/asm/syscalls.h | |||
@@ -23,6 +23,8 @@ long sys_iopl(unsigned int, struct pt_regs *); | |||
23 | /* kernel/process.c */ | 23 | /* kernel/process.c */ |
24 | int sys_fork(struct pt_regs *); | 24 | int sys_fork(struct pt_regs *); |
25 | int sys_vfork(struct pt_regs *); | 25 | int sys_vfork(struct pt_regs *); |
26 | long sys_execve(char __user *, char __user * __user *, | ||
27 | char __user * __user *, struct pt_regs *); | ||
26 | 28 | ||
27 | /* kernel/ldt.c */ | 29 | /* kernel/ldt.c */ |
28 | asmlinkage int sys_modify_ldt(int, void __user *, unsigned long); | 30 | asmlinkage int sys_modify_ldt(int, void __user *, unsigned long); |
@@ -39,7 +41,6 @@ asmlinkage int sys_get_thread_area(struct user_desc __user *); | |||
39 | 41 | ||
40 | /* kernel/process_32.c */ | 42 | /* kernel/process_32.c */ |
41 | int sys_clone(struct pt_regs *); | 43 | int sys_clone(struct pt_regs *); |
42 | int sys_execve(struct pt_regs *); | ||
43 | 44 | ||
44 | /* kernel/signal.c */ | 45 | /* kernel/signal.c */ |
45 | asmlinkage int sys_sigsuspend(int, int, old_sigset_t); | 46 | asmlinkage int sys_sigsuspend(int, int, old_sigset_t); |
@@ -73,9 +74,6 @@ int sys_vm86(struct pt_regs *); | |||
73 | asmlinkage long sys_clone(unsigned long, unsigned long, | 74 | asmlinkage long sys_clone(unsigned long, unsigned long, |
74 | void __user *, void __user *, | 75 | void __user *, void __user *, |
75 | struct pt_regs *); | 76 | struct pt_regs *); |
76 | asmlinkage long sys_execve(char __user *, char __user * __user *, | ||
77 | char __user * __user *, | ||
78 | struct pt_regs *); | ||
79 | long sys_arch_prctl(int, unsigned long); | 77 | long sys_arch_prctl(int, unsigned long); |
80 | 78 | ||
81 | /* kernel/signal.c */ | 79 | /* kernel/signal.c */ |
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S index ab7fcef37453..a96a0d8a0fdb 100644 --- a/arch/x86/kernel/entry_32.S +++ b/arch/x86/kernel/entry_32.S | |||
@@ -762,7 +762,7 @@ PTREGSCALL1(iopl) | |||
762 | PTREGSCALL0(fork) | 762 | PTREGSCALL0(fork) |
763 | PTREGSCALL0(clone) | 763 | PTREGSCALL0(clone) |
764 | PTREGSCALL0(vfork) | 764 | PTREGSCALL0(vfork) |
765 | PTREGSCALL0(execve) | 765 | PTREGSCALL3(execve) |
766 | PTREGSCALL0(sigaltstack) | 766 | PTREGSCALL0(sigaltstack) |
767 | PTREGSCALL0(sigreturn) | 767 | PTREGSCALL0(sigreturn) |
768 | PTREGSCALL0(rt_sigreturn) | 768 | PTREGSCALL0(rt_sigreturn) |
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 5e2ba634ea15..bb17bd9334fb 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c | |||
@@ -236,6 +236,32 @@ int sys_vfork(struct pt_regs *regs) | |||
236 | 236 | ||
237 | 237 | ||
238 | /* | 238 | /* |
239 | * sys_execve() executes a new program. | ||
240 | */ | ||
241 | long sys_execve(char __user *name, char __user * __user *argv, | ||
242 | char __user * __user *envp, struct pt_regs *regs) | ||
243 | { | ||
244 | long error; | ||
245 | char *filename; | ||
246 | |||
247 | filename = getname(name); | ||
248 | error = PTR_ERR(filename); | ||
249 | if (IS_ERR(filename)) | ||
250 | return error; | ||
251 | error = do_execve(filename, argv, envp, regs); | ||
252 | |||
253 | #ifdef CONFIG_X86_32 | ||
254 | if (error == 0) { | ||
255 | /* Make sure we don't return using sysenter.. */ | ||
256 | set_thread_flag(TIF_IRET); | ||
257 | } | ||
258 | #endif | ||
259 | |||
260 | putname(filename); | ||
261 | return error; | ||
262 | } | ||
263 | |||
264 | /* | ||
239 | * Idle related variables and functions | 265 | * Idle related variables and functions |
240 | */ | 266 | */ |
241 | unsigned long boot_option_idle_override = 0; | 267 | unsigned long boot_option_idle_override = 0; |
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index 075580b35682..486e38e2900b 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c | |||
@@ -451,31 +451,6 @@ int sys_clone(struct pt_regs *regs) | |||
451 | return do_fork(clone_flags, newsp, regs, 0, parent_tidptr, child_tidptr); | 451 | return do_fork(clone_flags, newsp, regs, 0, parent_tidptr, child_tidptr); |
452 | } | 452 | } |
453 | 453 | ||
454 | /* | ||
455 | * sys_execve() executes a new program. | ||
456 | */ | ||
457 | int sys_execve(struct pt_regs *regs) | ||
458 | { | ||
459 | int error; | ||
460 | char *filename; | ||
461 | |||
462 | filename = getname((char __user *) regs->bx); | ||
463 | error = PTR_ERR(filename); | ||
464 | if (IS_ERR(filename)) | ||
465 | goto out; | ||
466 | error = do_execve(filename, | ||
467 | (char __user * __user *) regs->cx, | ||
468 | (char __user * __user *) regs->dx, | ||
469 | regs); | ||
470 | if (error == 0) { | ||
471 | /* Make sure we don't return using sysenter.. */ | ||
472 | set_thread_flag(TIF_IRET); | ||
473 | } | ||
474 | putname(filename); | ||
475 | out: | ||
476 | return error; | ||
477 | } | ||
478 | |||
479 | #define top_esp (THREAD_SIZE - sizeof(unsigned long)) | 454 | #define top_esp (THREAD_SIZE - sizeof(unsigned long)) |
480 | #define top_ebp (THREAD_SIZE - 2*sizeof(unsigned long)) | 455 | #define top_ebp (THREAD_SIZE - 2*sizeof(unsigned long)) |
481 | 456 | ||
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index c95c8f4e790a..671960d82587 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c | |||
@@ -520,25 +520,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) | |||
520 | return prev_p; | 520 | return prev_p; |
521 | } | 521 | } |
522 | 522 | ||
523 | /* | ||
524 | * sys_execve() executes a new program. | ||
525 | */ | ||
526 | asmlinkage | ||
527 | long sys_execve(char __user *name, char __user * __user *argv, | ||
528 | char __user * __user *envp, struct pt_regs *regs) | ||
529 | { | ||
530 | long error; | ||
531 | char *filename; | ||
532 | |||
533 | filename = getname(name); | ||
534 | error = PTR_ERR(filename); | ||
535 | if (IS_ERR(filename)) | ||
536 | return error; | ||
537 | error = do_execve(filename, argv, envp, regs); | ||
538 | putname(filename); | ||
539 | return error; | ||
540 | } | ||
541 | |||
542 | void set_personality_64bit(void) | 523 | void set_personality_64bit(void) |
543 | { | 524 | { |
544 | /* inherit personality from parent */ | 525 | /* inherit personality from parent */ |