diff options
| -rw-r--r-- | arch/sparc64/kernel/power.c | 5 | ||||
| -rw-r--r-- | init/do_mounts_initrd.c | 3 | ||||
| -rw-r--r-- | init/main.c | 4 | ||||
| -rw-r--r-- | kernel/kmod.c | 5 | ||||
| -rw-r--r-- | lib/Makefile | 2 | ||||
| -rw-r--r-- | lib/execve.c | 23 |
6 files changed, 31 insertions, 11 deletions
diff --git a/arch/sparc64/kernel/power.c b/arch/sparc64/kernel/power.c index e55466c77b61..0b9c70627ce4 100644 --- a/arch/sparc64/kernel/power.c +++ b/arch/sparc64/kernel/power.c | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | * Copyright (C) 1999 David S. Miller (davem@redhat.com) | 4 | * Copyright (C) 1999 David S. Miller (davem@redhat.com) |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #define __KERNEL_SYSCALLS__ | ||
| 8 | |||
| 9 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
| 10 | #include <linux/module.h> | 8 | #include <linux/module.h> |
| 11 | #include <linux/init.h> | 9 | #include <linux/init.h> |
| @@ -14,6 +12,7 @@ | |||
| 14 | #include <linux/delay.h> | 12 | #include <linux/delay.h> |
| 15 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
| 16 | #include <linux/pm.h> | 14 | #include <linux/pm.h> |
| 15 | #include <linux/syscalls.h> | ||
| 17 | 16 | ||
| 18 | #include <asm/system.h> | 17 | #include <asm/system.h> |
| 19 | #include <asm/auxio.h> | 18 | #include <asm/auxio.h> |
| @@ -98,7 +97,7 @@ again: | |||
| 98 | 97 | ||
| 99 | /* Ok, down we go... */ | 98 | /* Ok, down we go... */ |
| 100 | button_pressed = 0; | 99 | button_pressed = 0; |
| 101 | if (execve("/sbin/shutdown", argv, envp) < 0) { | 100 | if (kernel_execve("/sbin/shutdown", argv, envp) < 0) { |
| 102 | printk("powerd: shutdown execution failed\n"); | 101 | printk("powerd: shutdown execution failed\n"); |
| 103 | add_wait_queue(&powerd_wait, &wait); | 102 | add_wait_queue(&powerd_wait, &wait); |
| 104 | goto again; | 103 | goto again; |
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index a06f037fa000..919a80cb322e 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c | |||
| @@ -1,4 +1,3 @@ | |||
| 1 | #define __KERNEL_SYSCALLS__ | ||
| 2 | #include <linux/unistd.h> | 1 | #include <linux/unistd.h> |
| 3 | #include <linux/kernel.h> | 2 | #include <linux/kernel.h> |
| 4 | #include <linux/fs.h> | 3 | #include <linux/fs.h> |
| @@ -35,7 +34,7 @@ static int __init do_linuxrc(void * shell) | |||
| 35 | (void) sys_open("/dev/console",O_RDWR,0); | 34 | (void) sys_open("/dev/console",O_RDWR,0); |
| 36 | (void) sys_dup(0); | 35 | (void) sys_dup(0); |
| 37 | (void) sys_dup(0); | 36 | (void) sys_dup(0); |
| 38 | return execve(shell, argv, envp_init); | 37 | return kernel_execve(shell, argv, envp_init); |
| 39 | } | 38 | } |
| 40 | 39 | ||
| 41 | static void __init handle_initrd(void) | 40 | static void __init handle_initrd(void) |
diff --git a/init/main.c b/init/main.c index 0766e69712b2..a49b00235bda 100644 --- a/init/main.c +++ b/init/main.c | |||
| @@ -9,8 +9,6 @@ | |||
| 9 | * Simplified starting of init: Michael A. Griffith <grif@acm.org> | 9 | * Simplified starting of init: Michael A. Griffith <grif@acm.org> |
| 10 | */ | 10 | */ |
| 11 | 11 | ||
| 12 | #define __KERNEL_SYSCALLS__ | ||
| 13 | |||
| 14 | #include <linux/types.h> | 12 | #include <linux/types.h> |
| 15 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 16 | #include <linux/proc_fs.h> | 14 | #include <linux/proc_fs.h> |
| @@ -703,7 +701,7 @@ static void do_pre_smp_initcalls(void) | |||
| 703 | static void run_init_process(char *init_filename) | 701 | static void run_init_process(char *init_filename) |
| 704 | { | 702 | { |
| 705 | argv_init[0] = init_filename; | 703 | argv_init[0] = init_filename; |
| 706 | execve(init_filename, argv_init, envp_init); | 704 | kernel_execve(init_filename, argv_init, envp_init); |
| 707 | } | 705 | } |
| 708 | 706 | ||
| 709 | static int init(void * unused) | 707 | static int init(void * unused) |
diff --git a/kernel/kmod.c b/kernel/kmod.c index f8121b95183f..bb4e29d924e4 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
| @@ -18,8 +18,6 @@ | |||
| 18 | call_usermodehelper wait flag, and remove exec_usermodehelper. | 18 | call_usermodehelper wait flag, and remove exec_usermodehelper. |
| 19 | Rusty Russell <rusty@rustcorp.com.au> Jan 2003 | 19 | Rusty Russell <rusty@rustcorp.com.au> Jan 2003 |
| 20 | */ | 20 | */ |
| 21 | #define __KERNEL_SYSCALLS__ | ||
| 22 | |||
| 23 | #include <linux/module.h> | 21 | #include <linux/module.h> |
| 24 | #include <linux/sched.h> | 22 | #include <linux/sched.h> |
| 25 | #include <linux/syscalls.h> | 23 | #include <linux/syscalls.h> |
| @@ -169,7 +167,8 @@ static int ____call_usermodehelper(void *data) | |||
| 169 | 167 | ||
| 170 | retval = -EPERM; | 168 | retval = -EPERM; |
| 171 | if (current->fs->root) | 169 | if (current->fs->root) |
| 172 | retval = execve(sub_info->path, sub_info->argv, sub_info->envp); | 170 | retval = kernel_execve(sub_info->path, |
| 171 | sub_info->argv, sub_info->envp); | ||
| 173 | 172 | ||
| 174 | /* Exec failed? */ | 173 | /* Exec failed? */ |
| 175 | sub_info->retval = retval; | 174 | sub_info->retval = retval; |
diff --git a/lib/Makefile b/lib/Makefile index ddf3e676e1f4..4d752be0edc0 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
| @@ -35,6 +35,8 @@ ifneq ($(CONFIG_HAVE_DEC_LOCK),y) | |||
| 35 | lib-y += dec_and_lock.o | 35 | lib-y += dec_and_lock.o |
| 36 | endif | 36 | endif |
| 37 | 37 | ||
| 38 | lib-y += execve.o | ||
| 39 | |||
| 38 | obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o | 40 | obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o |
| 39 | obj-$(CONFIG_CRC16) += crc16.o | 41 | obj-$(CONFIG_CRC16) += crc16.o |
| 40 | obj-$(CONFIG_CRC32) += crc32.o | 42 | obj-$(CONFIG_CRC32) += crc32.o |
diff --git a/lib/execve.c b/lib/execve.c new file mode 100644 index 000000000000..2667ebc15045 --- /dev/null +++ b/lib/execve.c | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | #include <asm/bug.h> | ||
| 2 | #include <asm/uaccess.h> | ||
| 3 | |||
| 4 | #define __KERNEL_SYSCALLS__ | ||
| 5 | static int errno __attribute__((unused)); | ||
| 6 | #include <asm/unistd.h> | ||
| 7 | |||
| 8 | #ifdef _syscall3 | ||
| 9 | int kernel_execve (const char *filename, char *const argv[], char *const envp[]) | ||
| 10 | __attribute__((__weak__)); | ||
| 11 | int kernel_execve (const char *filename, char *const argv[], char *const envp[]) | ||
| 12 | { | ||
| 13 | mm_segment_t fs = get_fs(); | ||
| 14 | int ret; | ||
| 15 | |||
| 16 | WARN_ON(segment_eq(fs, USER_DS)); | ||
| 17 | ret = execve(filename, (char **)argv, (char **)envp); | ||
| 18 | if (ret) | ||
| 19 | ret = -errno; | ||
| 20 | |||
| 21 | return ret; | ||
| 22 | } | ||
| 23 | #endif | ||
