From 6760856791c6e527da678021ee6a67896549d4da Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 2 Oct 2006 02:18:26 -0700 Subject: [PATCH] introduce kernel_execve The use of execve() in the kernel is dubious, since it relies on the __KERNEL_SYSCALLS__ mechanism that stores the result in a global errno variable. As a first step of getting rid of this, change all users to a global kernel_execve function that returns a proper error code. This function is a terrible hack, and a later patch removes it again after the kernel syscalls are gone. Signed-off-by: Arnd Bergmann Cc: Andi Kleen Cc: Paul Mackerras Cc: Benjamin Herrenschmidt Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Russell King Cc: Ian Molton Cc: Mikael Starvik Cc: David Howells Cc: Yoshinori Sato Cc: Hirokazu Takata Cc: Ralf Baechle Cc: Kyle McMartin Cc: Heiko Carstens Cc: Martin Schwidefsky Cc: Paul Mundt Cc: Kazumoto Kojima Cc: Richard Curnow Cc: William Lee Irwin III Cc: "David S. Miller" Cc: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Cc: Miles Bader Cc: Chris Zankel Cc: "Luck, Tony" Cc: Geert Uytterhoeven Cc: Roman Zippel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- lib/Makefile | 2 ++ lib/execve.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 lib/execve.c (limited to 'lib') diff --git a/lib/Makefile b/lib/Makefile index ddf3e676e1f..4d752be0edc 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -35,6 +35,8 @@ ifneq ($(CONFIG_HAVE_DEC_LOCK),y) lib-y += dec_and_lock.o endif +lib-y += execve.o + obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o obj-$(CONFIG_CRC16) += crc16.o obj-$(CONFIG_CRC32) += crc32.o diff --git a/lib/execve.c b/lib/execve.c new file mode 100644 index 00000000000..2667ebc1504 --- /dev/null +++ b/lib/execve.c @@ -0,0 +1,23 @@ +#include +#include + +#define __KERNEL_SYSCALLS__ +static int errno __attribute__((unused)); +#include + +#ifdef _syscall3 +int kernel_execve (const char *filename, char *const argv[], char *const envp[]) + __attribute__((__weak__)); +int kernel_execve (const char *filename, char *const argv[], char *const envp[]) +{ + mm_segment_t fs = get_fs(); + int ret; + + WARN_ON(segment_eq(fs, USER_DS)); + ret = execve(filename, (char **)argv, (char **)envp); + if (ret) + ret = -errno; + + return ret; +} +#endif -- cgit v1.2.3