projects/linux·commit 42859eea

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal

42859eea · Linus Torvalds <[email protected]> · 2012-10-10 12:02:25 +09:00

Pull generic execve() changes from Al Viro:
 "This introduces the generic kernel_thread() and kernel_execve()
  functions, and switches x86, arm, alpha, um and s390 over to them."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal: (26 commits)
  s390: convert to generic kernel_execve()
  s390: switch to generic kernel_thread()
  s390: fold kernel_thread_helper() into ret_from_fork()
  s390: fold execve_tail() into start_thread(), convert to generic sys_execve()
  um: switch to generic kernel_thread()
  x86, um/x86: switch to generic sys_execve and kernel_execve
  x86: split ret_from_fork
  alpha: introduce ret_from_kernel_execve(), switch to generic kernel_execve()
  alpha: switch to generic kernel_thread()
  alpha: switch to generic sys_execve()
  arm: get rid of execve wrapper, switch to generic execve() implementation
  arm: optimized current_pt_regs()
  arm: introduce ret_from_kernel_execve(), switch to generic kernel_execve()
  arm: split ret_from_fork, simplify kernel_thread() [based on patch by rmk]
  generic sys_execve()
  generic kernel_execve()
  new helper: current_pt_regs()
  preparation for generic kernel_thread()
  um: kill thread->forking
  um: let signal_delivered() do SIGTRAP on singlestepping into handler
  ...
Commit
42859eea96ba6beabfb0369a1eeffa3c7d2bd9cb
Parents
f59b51fe · f322220d

Merge commit. Changes below are compared with the first parent: f59b51fe.

Changes

96 files changed · +390 −899

FileStatusAddDelContent
arch/Kconfigmodified+3−0View file
arch/alpha/Kconfigmodified+1−0View file
arch/alpha/include/asm/Kbuildmodified+1−0View file
arch/alpha/include/asm/exec.hdeleted+0−6View before deletion
arch/alpha/include/asm/processor.hmodified+0−3View file
arch/alpha/include/asm/unistd.hmodified+2−0View file
arch/alpha/kernel/alpha_ksyms.cmodified+0−3View file
arch/alpha/kernel/entry.Smodified+18−51View file
arch/alpha/kernel/process.cmodified+20−59View file
arch/arm/Kconfigmodified+1−0View file
arch/arm/include/asm/processor.hmodified+0−5View file
arch/arm/include/asm/ptrace.hmodified+5−0View file
arch/arm/include/asm/system.hmodified+0−1View file
arch/arm/include/asm/unistd.hmodified+2−0View file
arch/arm/kernel/calls.Smodified+1−1View file
arch/arm/kernel/entry-common.Smodified+24−5View file
arch/arm/kernel/process.cmodified+13−62View file
arch/arm/kernel/sys_arm.cmodified+0−63View file
arch/avr32/include/asm/Kbuildmodified+1−0View file
arch/avr32/include/asm/exec.hdeleted+0−13View before deletion
arch/c6x/include/asm/Kbuildmodified+1−0View file
arch/c6x/include/asm/exec.hdeleted+0−6View before deletion
arch/cris/include/asm/Kbuildmodified+1−0View file
arch/cris/include/asm/exec.hdeleted+0−6View before deletion
arch/frv/include/asm/Kbuildmodified+1−0View file
arch/frv/include/asm/exec.hdeleted+0−17View before deletion
arch/h8300/include/asm/Kbuildmodified+2−1View file
arch/h8300/include/asm/exec.hdeleted+0−6View before deletion
arch/hexagon/kernel/syscall.cmodified+0−1View file
arch/ia64/include/asm/Kbuildmodified+1−0View file
arch/ia64/include/asm/exec.hdeleted+0−14View before deletion
arch/m32r/include/asm/Kbuildmodified+2−1View file
arch/m32r/include/asm/exec.hdeleted+0−14View before deletion
arch/m68k/include/asm/Kbuildmodified+1−0View file
arch/m68k/include/asm/exec.hdeleted+0−6View before deletion
arch/microblaze/include/asm/Kbuildmodified+1−0View file
arch/microblaze/include/asm/exec.hdeleted+0−14View before deletion
arch/mn10300/include/asm/Kbuildmodified+1−0View file
arch/mn10300/include/asm/exec.hdeleted+0−16View before deletion
arch/parisc/include/asm/Kbuildmodified+1−0View file
arch/parisc/include/asm/exec.hdeleted+0−6View before deletion
arch/s390/Kconfigmodified+1−0View file
arch/s390/include/asm/processor.hmodified+3−1View file
arch/s390/include/asm/unistd.hmodified+2−0View file
arch/s390/kernel/compat_linux.cmodified+0−26View file
arch/s390/kernel/compat_linux.hmodified+0−2View file
arch/s390/kernel/compat_wrapper.Smodified+1−1View file
arch/s390/kernel/entry.Smodified+21−30View file
arch/s390/kernel/entry.hmodified+0−3View file
arch/s390/kernel/entry64.Smodified+20−30View file
arch/s390/kernel/process.cmodified+33−74View file
arch/sh/include/asm/Kbuildmodified+1−0View file
arch/sh/include/asm/exec.hdeleted+0−10View before deletion
arch/sparc/include/asm/Kbuildmodified+1−0View file
arch/sparc/include/asm/exec.hdeleted+0−6View before deletion
arch/tile/include/asm/Kbuildmodified+1−0View file
arch/tile/include/asm/exec.hdeleted+0−20View before deletion
arch/um/include/asm/processor-generic.hmodified+0−2View file
arch/um/kernel/exec.cmodified+2−23View file
arch/um/kernel/internal.hdeleted+0−1View before deletion
arch/um/kernel/process.cmodified+3−14View file
arch/um/kernel/syscall.cmodified+0−17View file
arch/unicore32/include/asm/Kbuildmodified+1−0View file
arch/unicore32/include/asm/exec.hdeleted+0−15View before deletion
arch/unicore32/kernel/sys.cmodified+0−1View file
arch/x86/Kconfigmodified+1−0View file
arch/x86/ia32/ia32entry.Smodified+1−1View file
arch/x86/ia32/sys_ia32.cmodified+0−15View file
arch/x86/include/asm/processor.hmodified+0−5View file
arch/x86/include/asm/sys_ia32.hmodified+0−2View file
arch/x86/include/asm/syscalls.hmodified+1−1View file
arch/x86/include/asm/thread_info.hmodified+0−2View file
arch/x86/include/asm/unistd.hmodified+2−0View file
arch/x86/kernel/Makefilemodified+1−1View file
arch/x86/kernel/asm-offsets.cmodified+3−0View file
arch/x86/kernel/entry_32.Smodified+18−8View file
arch/x86/kernel/entry_64.Smodified+25−49View file
arch/x86/kernel/process.cmodified+0−65View file
arch/x86/kernel/process_32.cmodified+30−7View file
arch/x86/kernel/process_64.cmodified+21−14View file
arch/x86/kernel/signal.cmodified+0−4View file
arch/x86/kernel/sys_i386_32.cdeleted+0−40View before deletion
arch/x86/kernel/vm86_32.cmodified+3−3View file
arch/x86/syscalls/syscall_32.tblmodified+1−1View file
arch/x86/um/Kconfigmodified+1−0View file
arch/x86/um/sys_call_table_32.cmodified+0−1View file
arch/xtensa/include/asm/Kbuildmodified+1−0View file
arch/xtensa/include/asm/exec.hdeleted+0−14View before deletion
fs/binfmt_elf.cmodified+0−1View file
fs/binfmt_elf_fdpic.cmodified+0−1View file
fs/exec.cmodified+56−5View file
include/linux/binfmts.hmodified+6−0View file
include/linux/compat.hmodified+6−2View file
include/linux/ptrace.hmodified+4−0View file
include/linux/sched.hmodified+3−0View file
kernel/fork.cmodified+12−1View file

Only the first 600 diff lines are shown. Download the complete patch.

arch/Kconfig

View file
diff --git a/arch/Kconfig b/arch/Kconfig
index 550cce4..26a2841 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -271,6 +271,9 @@ config ARCH_WANT_OLD_COMPAT_IPC
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
bool
+config GENERIC_KERNEL_THREAD
+ bool
+
config HAVE_ARCH_SECCOMP_FILTER
bool
help

arch/alpha/Kconfig

View file
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 9944ded..7da9124 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -20,6 +20,7 @@ config ALPHA
select GENERIC_CMOS_UPDATE
select GENERIC_STRNCPY_FROM_USER
select GENERIC_STRNLEN_USER
+ select GENERIC_KERNEL_THREAD
help
The Alpha is a 64-bit general-purpose processor designed and
marketed by the Digital Equipment Corporation of blessed memory,

arch/alpha/include/asm/Kbuild

View file
diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild
index d97d663..64ffc9e 100644
--- a/arch/alpha/include/asm/Kbuild
+++ b/arch/alpha/include/asm/Kbuild
@@ -10,3 +10,4 @@ header-y += pal.h
header-y += reg.h
header-y += regdef.h
header-y += sysinfo.h
+generic-y += exec.h

arch/alpha/include/asm/exec.h

View before deletion
diff --git a/arch/alpha/include/asm/exec.h b/arch/alpha/include/asm/exec.h
deleted file mode 100644
index 4a5a41f..0000000
--- a/arch/alpha/include/asm/exec.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __ALPHA_EXEC_H
-#define __ALPHA_EXEC_H
-
-#define arch_align_stack(x) (x)
-
-#endif /* __ALPHA_EXEC_H */

arch/alpha/include/asm/processor.h

View file
diff --git a/arch/alpha/include/asm/processor.h b/arch/alpha/include/asm/processor.h
index e37b887..6cb7fe8 100644
--- a/arch/alpha/include/asm/processor.h
+++ b/arch/alpha/include/asm/processor.h
@@ -49,9 +49,6 @@ extern void start_thread(struct pt_regs *, unsigned long, unsigned long);
/* Free all resources held by a thread. */
extern void release_thread(struct task_struct *);
-/* Create a kernel thread without removing it from tasklists. */
-extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
-
unsigned long get_wchan(struct task_struct *p);
#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)

arch/alpha/include/asm/unistd.h

View file
diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h
index a31a78e..3cb6c11 100644
--- a/arch/alpha/include/asm/unistd.h
+++ b/arch/alpha/include/asm/unistd.h
@@ -481,6 +481,8 @@
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_RT_SIGSUSPEND
+#define __ARCH_WANT_SYS_EXECVE
+#define __ARCH_WANT_KERNEL_EXECVE
/* "Conditional" syscalls. What we want is

arch/alpha/kernel/alpha_ksyms.c

View file
diff --git a/arch/alpha/kernel/alpha_ksyms.c b/arch/alpha/kernel/alpha_ksyms.c
index 15fa821..89566b3 100644
--- a/arch/alpha/kernel/alpha_ksyms.c
+++ b/arch/alpha/kernel/alpha_ksyms.c
@@ -50,9 +50,6 @@ EXPORT_SYMBOL(alpha_read_fp_reg_s);
EXPORT_SYMBOL(alpha_write_fp_reg);
EXPORT_SYMBOL(alpha_write_fp_reg_s);
-/* entry.S */
-EXPORT_SYMBOL(kernel_thread);
-
/* Networking helper routines. */
EXPORT_SYMBOL(csum_tcpudp_magic);
EXPORT_SYMBOL(ip_compute_csum);

arch/alpha/kernel/entry.S

View file
diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
index ec0da05..7e43e11 100644
--- a/arch/alpha/kernel/entry.S
+++ b/arch/alpha/kernel/entry.S
@@ -609,59 +609,35 @@ ret_from_fork:
.end ret_from_fork
/*
- * kernel_thread(fn, arg, clone_flags)
+ * ... and new kernel threads - here
*/
.align 4
- .globl kernel_thread
- .ent kernel_thread
-kernel_thread:
- /* We can be called from a module. */
- ldgp $gp, 0($27)
- .prologue 1
- subq $sp, SP_OFF+6*8, $sp
- br $1, 2f /* load start address */
-
- /* We've now "returned" from a fake system call. */
- unop
- blt $0, 1f /* error? */
- ldi $1, 0x3fff
- beq $20, 1f /* parent or child? */
-
- bic $sp, $1, $8 /* in child. */
- jsr $26, ($27)
+ .globl ret_from_kernel_thread
+ .ent ret_from_kernel_thread
+ret_from_kernel_thread:
+ mov $17, $16
+ jsr $26, schedule_tail
+ mov $9, $27
+ mov $10, $16
+ jsr $26, ($9)
ldgp $gp, 0($26)
mov $0, $16
mov $31, $26
jmp $31, sys_exit
+.end ret_from_kernel_thread
-1: ret /* in parent. */
-
- .align 4
-2: /* Fake a system call stack frame, as we can't do system calls
- from kernel space. Note that we store FN and ARG as they
- need to be set up in the child for the call. Also store $8
- and $26 for use in the parent. */
- stq $31, SP_OFF($sp) /* ps */
- stq $1, SP_OFF+8($sp) /* pc */
- stq $gp, SP_OFF+16($sp) /* gp */
- stq $16, 136($sp) /* $27; FN for child */
- stq $17, SP_OFF+24($sp) /* $16; ARG for child */
- stq $8, 64($sp) /* $8 */
- stq $26, 128($sp) /* $26 */
+ .globl ret_from_kernel_execve
+ .align 4
+ .ent ret_from_kernel_execve
+ret_from_kernel_execve:
+ mov $16, $sp
/* Avoid the HAE being gratuitously wrong, to avoid restoring it. */
ldq $2, alpha_mv+HAE_CACHE
stq $2, 152($sp) /* HAE */
+ mov $31, $19 /* to disable syscall restarts */
+ br $31, ret_to_user
- /* Shuffle FLAGS to the front; add CLONE_VM. */
- ldi $1, CLONE_VM|CLONE_UNTRACED
- or $18, $1, $16
- bsr $26, sys_clone
-
- /* We don't actually care for a3 success widgetry in the kernel.
- Not for positive errno values. */
- stq $0, 0($sp) /* $0 */
- br ret_to_kernel
-.end kernel_thread
+.end ret_from_kernel_execve
/*
@@ -745,15 +721,6 @@ sys_rt_sigreturn:
.end sys_rt_sigreturn
.align 4
- .globl sys_execve
- .ent sys_execve
-sys_execve:
- .prologue 0
- mov $sp, $19
- jmp $31, do_sys_execve
-.end sys_execve
-
- .align 4
.globl alpha_ni_syscall
.ent alpha_ni_syscall
alpha_ni_syscall:

arch/alpha/kernel/process.c

View file
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index 83638aa..4054e0f 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -263,33 +263,35 @@ alpha_vfork(struct pt_regs *regs)
/*
* Copy an alpha thread..
- *
- * Note the "stack_offset" stuff: when returning to kernel mode, we need
- * to have some extra stack-space for the kernel stack that still exists
- * after the "ret_from_fork". When returning to user mode, we only want
- * the space needed by the syscall stack frame (ie "struct pt_regs").
- * Use the passed "regs" pointer to determine how much space we need
- * for a kernel fork().
*/
int
copy_thread(unsigned long clone_flags, unsigned long usp,
- unsigned long unused,
+ unsigned long arg,
struct task_struct * p, struct pt_regs * regs)
{
extern void ret_from_fork(void);
+ extern void ret_from_kernel_thread(void);
struct thread_info *childti = task_thread_info(p);
- struct pt_regs * childregs;
- struct switch_stack * childstack, *stack;
- unsigned long stack_offset, settls;
-
- stack_offset = PAGE_SIZE - sizeof(struct pt_regs);
- if (!(regs->ps & 8))
- stack_offset = (PAGE_SIZE-1) & (unsigned long) regs;
- childregs = (struct pt_regs *)
- (stack_offset + PAGE_SIZE + task_stack_page(p));
-
+ struct pt_regs *childregs = task_pt_regs(p);
+ struct switch_stack *childstack, *stack;
+ unsigned long settls;
+
+ childstack = ((struct switch_stack *) childregs) - 1;
+ if (unlikely(!regs)) {
+ /* kernel thread */
+ memset(childstack, 0,
+ sizeof(struct switch_stack) + sizeof(struct pt_regs));
+ childstack->r26 = (unsigned long) ret_from_kernel_thread;
+ childstack->r9 = usp; /* function */
+ childstack->r10 = arg;
+ childregs->hae = alpha_mv.hae_cache,
+ childti->pcb.usp = 0;
+ childti->pcb.ksp = (unsigned long) childstack;
+ childti->pcb.flags = 1; /* set FEN, clear everything else */
+ return 0;
+ }
*childregs = *regs;
settls = regs->r20;
childregs->r0 = 0;
@@ -297,7 +299,6 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
childregs->r20 = 1; /* OSF/1 has some strange fork() semantics. */
regs->r20 = 0;
stack = ((struct switch_stack *) regs) - 1;
- childstack = ((struct switch_stack *) childregs) - 1;
*childstack = *stack;
childstack->r26 = (unsigned long) ret_from_fork;
childti->pcb.usp = usp;
@@ -386,27 +387,6 @@ dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task)
EXPORT_SYMBOL(dump_elf_task_fp);
/*
- * sys_execve() executes a new program.
- */
-asmlinkage int
-do_sys_execve(const char __user *ufilename,
- const char __user *const __user *argv,
- const char __user *const __user *envp, struct pt_regs *regs)
-{
- int error;
- char *filename;
-
- filename = getname(ufilename);
- error = PTR_ERR(filename);
- if (IS_ERR(filename))
- goto out;
- error = do_execve(filename, argv, envp, regs);
- putname(filename);
-out:
- return error;
-}
-
-/*
* Return saved PC of a blocked thread. This assumes the frame
* pointer is the 6th saved long on the kernel stack and that the
* saved return address is the first long in the frame. This all
@@ -459,22 +439,3 @@ get_wchan(struct task_struct *p)
}
return pc;
}
-
-int kernel_execve(const char *path, const char *const argv[], const char *const envp[])
-{
- /* Avoid the HAE being gratuitously wrong, which would cause us
- to do the whole turn off interrupts thing and restore it. */
- struct pt_regs regs = {.hae = alpha_mv.hae_cache};
- int err = do_execve(path, argv, envp, &regs);
- if (!err) {
- struct pt_regs *p = current_pt_regs();
- /* copy regs to normal position and off to userland we go... */
- *p = regs;
- __asm__ __volatile__ (
- "mov %0, $sp;"
- "br $31, ret_from_sys_call"
- : : "r"(p));
- }
- return err;
-}
-EXPORT_SYMBOL(kernel_execve);

arch/arm/Kconfig

View file
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 2867a77..e40eefb 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -52,6 +52,7 @@ config ARM
select GENERIC_STRNCPY_FROM_USER
select GENERIC_STRNLEN_USER
select DCACHE_WORD_ACCESS if (CPU_V6 || CPU_V6K || CPU_V7) && !CPU_BIG_ENDIAN
+ select GENERIC_KERNEL_THREAD
help
The ARM series is a line of low-power-consumption RISC chip designs
licensed by ARM Ltd and targeted at embedded applications and

arch/arm/include/asm/processor.h

View file
diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
index 99afa74..06e7d50 100644
--- a/arch/arm/include/asm/processor.h
+++ b/arch/arm/include/asm/processor.h
@@ -85,11 +85,6 @@ unsigned long get_wchan(struct task_struct *p);
#define cpu_relax() barrier()
#endif
-/*
- * Create a new kernel thread
- */
-extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
-
#define task_pt_regs(p) \
((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)

arch/arm/include/asm/ptrace.h

View file
diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h
index 355ece5..44fe998 100644
--- a/arch/arm/include/asm/ptrace.h
+++ b/arch/arm/include/asm/ptrace.h
@@ -254,6 +254,11 @@ static inline unsigned long user_stack_pointer(struct pt_regs *regs)
return regs->ARM_sp;
}
+#define current_pt_regs(void) ({ \
+ register unsigned long sp asm ("sp"); \
+ (struct pt_regs *)((sp | (THREAD_SIZE - 1)) - 7) - 1; \
+})
+
#endif /* __KERNEL__ */
#endif /* __ASSEMBLY__ */

arch/arm/include/asm/system.h

View file
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 74542c5..368165e 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -2,7 +2,6 @@
#include <asm/barrier.h>
#include <asm/compiler.h>
#include <asm/cmpxchg.h>
-#include <asm/exec.h>
#include <asm/switch_to.h>
#include <asm/system_info.h>
#include <asm/system_misc.h>

arch/arm/include/asm/unistd.h

View file
diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h
index d9ff5cc..f259921 100644
--- a/arch/arm/include/asm/unistd.h
+++ b/arch/arm/include/asm/unistd.h
@@ -478,6 +478,8 @@
#define __ARCH_WANT_OLD_READDIR
#define __ARCH_WANT_SYS_SOCKETCALL
#endif
+#define __ARCH_WANT_SYS_EXECVE
+#define __ARCH_WANT_KERNEL_EXECVE
/*
* "Conditional" syscalls

arch/arm/kernel/calls.S

View file
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S
index e337879..831cd38 100644
--- a/arch/arm/kernel/calls.S
+++ b/arch/arm/kernel/calls.S
@@ -20,7 +20,7 @@
CALL(sys_creat)
CALL(sys_link)
/* 10 */ CALL(sys_unlink)
- CALL(sys_execve_wrapper)
+ CALL(sys_execve)
CALL(sys_chdir)
CALL(OBSOLETE(sys_time)) /* used by libc4 */
CALL(sys_mknod)

arch/arm/kernel/entry-common.S

View file
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index f459870..e340fa1 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -91,6 +91,30 @@ ENTRY(ret_from_fork)
b ret_slow_syscall
ENDPROC(ret_from_fork)
+ENTRY(ret_from_kernel_thread)
+ UNWIND(.fnstart)
+ UNWIND(.cantunwind)
+ bl schedule_tail
+ mov r0, r4
+ adr lr, BSYM(1f) @ kernel threads should not exit
+ mov pc, r5
+1: bl do_exit
+ nop
+ UNWIND(.fnend)
+ENDPROC(ret_from_kernel_thread)
+
+/*
+ * turn a kernel thread into userland process
+ * use: ret_from_kernel_execve(struct pt_regs *normal)
+ */
+ENTRY(ret_from_kernel_execve)
+ mov why, #0 @ not a syscall
+ str why, [r0, #S_R0] @ ... and we want 0 in ->ARM_r0 as well
+ get_thread_info tsk @ thread structure
+ mov sp, r0 @ stack pointer just under pt_regs
+ b ret_slow_syscall
+ENDPROC(ret_from_kernel_execve)
+
.equ NR_syscalls,0
#define CALL(x) .equ NR_syscalls,NR_syscalls+1
#include "calls.S"
@@ -517,11 +541,6 @@ sys_vfork_wrapper:
b sys_vfork
ENDPROC(sys_vfork_wrapper)
-sys_execve_wrapper:
- add r3, sp, #S_OFF
- b sys_execve
-ENDPROC(sys_execve_wrapper)
-
sys_clone_wrapper:
add ip, sp, #S_OFF
str ip, [sp, #4]

arch/arm/kernel/process.c

View file
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 04eea22..f98c17f 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -373,6 +373,7 @@ void release_thread(struct task_struct *dead_task)
}
asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
+asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
int
copy_thread(unsigned long clone_flags, unsigned long stack_start,
@@ -381,13 +382,20 @@ copy_thread(unsigned long clone_flags, unsigned long stack_start,
struct thread_info *thread = task_thread_info(p);
struct pt_regs *childregs = task_pt_regs(p);
- *childregs = *regs;
- childregs->ARM_r0 = 0;
- childregs->ARM_sp = stack_start;
-
memset(&thread->cpu_context, 0, sizeof(struct cpu_context_save));
+
+ if (likely(regs)) {
+ *childregs = *regs;
+ childregs->ARM_r0 = 0;
+ childregs->ARM_sp = stack_start;
+ thread->cpu_context.pc = (unsigned long)ret_from_fork;
+ } else {
+ thread->cpu_context.r4 = stk_sz;
+ thread->cpu_context.r5 = stack_start;
+ thread->cpu_context.pc = (unsigned long)ret_from_kernel_thread;
+ childregs->ARM_cpsr = SVC_MODE;
+ }
thread->cpu_context.sp = (unsigned long)childregs;
- thread->cpu_context.pc = (unsigned long)ret_from_fork;
clear_ptrace_hw_breakpoint(p);
@@ -423,63 +431,6 @@ int dump_fpu (struct pt_regs *regs, struct user_fp *fp)
}
EXPORT_SYMBOL(dump_fpu);
-/*
- * Shuffle the argument into the correct register before calling the
- * thread function. r4 is the thread argument, r5 is the pointer to
- * the thread function, and r6 points to the exit function.
- */
-extern void kernel_thread_helper(void);
-asm( ".pushsection .text\n"
-" .align\n"
-" .type kernel_thread_helper, #function\n"
-"kernel_thread_helper:\n"
-#ifdef CONFIG_TRACE_IRQFLAGS
-" bl trace_hardirqs_on\n"
-#endif
-" msr cpsr_c, r7\n"
-" mov r0, r4\n"
-" mov lr, r6\n"
-" mov pc, r5\n"
-" .size kernel_thread_helper, . - kernel_thread_helper\n"
-" .popsection");
-
-#ifdef CONFIG_ARM_UNWIND
-extern void kernel_thread_exit(long code);
-asm( ".pushsection .text\n"
-" .align\n"
-" .type kernel_thread_exit, #function\n"
-"kernel_thread_exit:\n"
-" .fnstart\n"
-" .cantunwind\n"
-" bl do_exit\n"
-" nop\n"
-" .fnend\n"
-" .size kernel_thread_exit, . - kernel_thread_exit\n"
-" .popsection");
-#else
-#define kernel_thread_exit do_exit
-#endif
-
-/*
- * Create a kernel thread.
- */
-pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
-{
- struct pt_regs regs;
-
- memset(&regs, 0, sizeof(regs));
-
- regs.ARM_r4 = (unsigned long)arg;
- regs.ARM_r5 = (unsigned long)fn;
- regs.ARM_r6 = (unsigned long)kernel_thread_exit;
- regs.ARM_r7 = SVC_MODE | PSR_ENDSTATE | PSR_ISETSTATE;
- regs.ARM_pc = (unsigned long)kernel_thread_helper;
- regs.ARM_cpsr = regs.ARM_r7 | PSR_I_BIT;
-
- return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
-}
-EXPORT_SYMBOL(kernel_thread);
-
unsigned long get_wchan(struct task_struct *p)
{
struct stackframe frame;

arch/arm/kernel/sys_arm.c

View file
diff --git a/arch/arm/kernel/sys_arm.c b/arch/arm/kernel/sys_arm.c
index 76cbb05..c2a898a 100644
--- a/arch/arm/kernel/sys_arm.c
+++ b/arch/arm/kernel/sys_arm.c
@@ -59,69 +59,6 @@ asmlinkage int sys_vfork(struct pt_regs *regs)
return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->ARM_sp, regs, 0, NULL, NULL);
}
-/* sys_execve() executes a new program.
- * This is called indirectly via a small wrapper
- */
-asmlinkage int sys_execve(const char __user *filenamei,
- const char __user *const __user *argv,
- const char __user *const __user *envp, struct pt_regs *regs)
-{
- int error;
- char * filename;
-
- filename = getname(filenamei);
- error = PTR_ERR(filename);
- if (IS_ERR(filename))
- goto out;
- error = do_execve(filename, argv, envp, regs);
- putname(filename);
-out:
- return error;
-}
-
-int kernel_execve(const char *filename,
- const char *const argv[],
- const char *const envp[])
-{
- struct pt_regs regs;
- int ret;
-
- memset(&regs, 0, sizeof(struct pt_regs));
- ret = do_execve(filename,
- (const char __user *const __user *)argv,
- (const char __user *const __user *)envp, &regs);
- if (ret < 0)
- goto out;
-
- /*
- * Save argc to the register structure for userspace.
- */
- regs.ARM_r0 = ret;
-
- /*
- * We were successful. We won't be returning to our caller, but
- * instead to user space by manipulating the kernel stack.
- */
- asm( "add r0, %0, %1\n\t"
- "mov r1, %2\n\t"
- "mov r2, %3\n\t"
- "bl memmove\n\t" /* copy regs to top of stack */
- "mov r8, #0\n\t" /* not a syscall */
- "mov r9, %0\n\t" /* thread structure */
- "mov sp, r0\n\t" /* reposition stack pointer */
- "b ret_to_user"
- :
- : "r" (current_thread_info()),
- "Ir" (THREAD_START_SP - sizeof(regs)),
- "r" (&regs),
- "Ir" (sizeof(regs))
- : "r0", "r1", "r2", "r3", "r8", "r9", "ip", "lr", "memory");
-

This diff is incomplete. Download the complete patch.

arch/avr32/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/avr32/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/c6x/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/c6x/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/cris/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/cris/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/frv/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/frv/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/h8300/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/h8300/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/hexagon/kernel/syscall.c

View file

This diff is incomplete. Download the complete patch.

arch/ia64/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/ia64/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/m32r/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/m32r/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/m68k/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/m68k/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/microblaze/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/microblaze/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/mn10300/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/mn10300/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/parisc/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/parisc/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/s390/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/s390/include/asm/processor.h

View file

This diff is incomplete. Download the complete patch.

arch/s390/include/asm/unistd.h

View file

This diff is incomplete. Download the complete patch.

arch/s390/kernel/compat_linux.c

View file

This diff is incomplete. Download the complete patch.

arch/s390/kernel/compat_linux.h

View file

This diff is incomplete. Download the complete patch.

arch/s390/kernel/compat_wrapper.S

View file

This diff is incomplete. Download the complete patch.

arch/s390/kernel/entry.S

View file

This diff is incomplete. Download the complete patch.

arch/s390/kernel/entry.h

View file

This diff is incomplete. Download the complete patch.

arch/s390/kernel/entry64.S

View file

This diff is incomplete. Download the complete patch.

arch/s390/kernel/process.c

View file

This diff is incomplete. Download the complete patch.

arch/sh/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/sh/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/sparc/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/sparc/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/tile/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/tile/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/um/include/asm/processor-generic.h

View file

This diff is incomplete. Download the complete patch.

arch/um/kernel/exec.c

View file

This diff is incomplete. Download the complete patch.

arch/um/kernel/internal.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/um/kernel/process.c

View file

This diff is incomplete. Download the complete patch.

arch/um/kernel/syscall.c

View file

This diff is incomplete. Download the complete patch.

arch/unicore32/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/unicore32/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/unicore32/kernel/sys.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/x86/ia32/ia32entry.S

View file

This diff is incomplete. Download the complete patch.

arch/x86/ia32/sys_ia32.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/asm/processor.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/asm/sys_ia32.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/asm/syscalls.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/asm/thread_info.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/asm/unistd.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/Makefile

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/asm-offsets.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/entry_32.S

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/entry_64.S

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/process.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/process_32.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/process_64.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/signal.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/sys_i386_32.c

View before deletion

This diff is incomplete. Download the complete patch.

arch/x86/kernel/vm86_32.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/syscalls/syscall_32.tbl

View file

This diff is incomplete. Download the complete patch.

arch/x86/um/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/x86/um/sys_call_table_32.c

View file

This diff is incomplete. Download the complete patch.

arch/xtensa/include/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/xtensa/include/asm/exec.h

View before deletion

This diff is incomplete. Download the complete patch.

fs/binfmt_elf.c

View file

This diff is incomplete. Download the complete patch.

fs/binfmt_elf_fdpic.c

View file

This diff is incomplete. Download the complete patch.

fs/exec.c

View file

This diff is incomplete. Download the complete patch.

include/linux/binfmts.h

View file

This diff is incomplete. Download the complete patch.

include/linux/compat.h

View file

This diff is incomplete. Download the complete patch.

include/linux/ptrace.h

View file

This diff is incomplete. Download the complete patch.

include/linux/sched.h

View file

This diff is incomplete. Download the complete patch.

kernel/fork.c

View file

This diff is incomplete. Download the complete patch.