Skip to content

Commit 6783eaa

Browse files
author
Al Viro
committed
x86, um/x86: switch to generic sys_execve and kernel_execve
32bit wrapper is lost on that; 64bit one is *not*, since we need to arrange for full pt_regs on stack when we call sys_execve() and we need to load callee-saved ones from there afterwards. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 7076aad commit 6783eaa

File tree

17 files changed

+34
-158
lines changed

17 files changed

+34
-158
lines changed

arch/um/kernel/exec.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "mem_user.h"
1717
#include "skas.h"
1818
#include "os.h"
19-
#include "internal.h"
2019

2120
void flush_thread(void)
2221
{
@@ -49,27 +48,7 @@ void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
4948
}
5049
EXPORT_SYMBOL(start_thread);
5150

52-
long um_execve(const char *file, const char __user *const __user *argv, const char __user *const __user *env)
51+
void __noreturn ret_from_kernel_execve(struct pt_regs *unused)
5352
{
54-
long err;
55-
56-
err = do_execve(file, argv, env, &current->thread.regs);
57-
if (!err)
58-
UML_LONGJMP(current->thread.exec_buf, 1);
59-
return err;
60-
}
61-
62-
long sys_execve(const char __user *file, const char __user *const __user *argv,
63-
const char __user *const __user *env)
64-
{
65-
long error;
66-
char *filename;
67-
68-
filename = getname(file);
69-
error = PTR_ERR(filename);
70-
if (IS_ERR(filename)) goto out;
71-
error = do_execve(filename, argv, env, &current->thread.regs);
72-
putname(filename);
73-
out:
74-
return error;
53+
UML_LONGJMP(current->thread.exec_buf, 1);
7554
}

arch/um/kernel/internal.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

arch/um/kernel/syscall.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "asm/mman.h"
1414
#include "asm/uaccess.h"
1515
#include "asm/unistd.h"
16-
#include "internal.h"
1716

1817
long sys_fork(void)
1918
{
@@ -50,19 +49,3 @@ long old_mmap(unsigned long addr, unsigned long len,
5049
out:
5150
return err;
5251
}
53-
54-
int kernel_execve(const char *filename,
55-
const char *const argv[],
56-
const char *const envp[])
57-
{
58-
mm_segment_t fs;
59-
int ret;
60-
61-
fs = get_fs();
62-
set_fs(KERNEL_DS);
63-
ret = um_execve(filename, (const char __user *const __user *)argv,
64-
(const char __user *const __user *) envp);
65-
set_fs(fs);
66-
67-
return ret;
68-
}

arch/x86/ia32/ia32entry.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ GLOBAL(\label)
459459
PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
460460
PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
461461
PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
462-
PTREGSCALL stub32_execve, sys32_execve, %rcx
462+
PTREGSCALL stub32_execve, compat_sys_execve, %rcx
463463
PTREGSCALL stub32_fork, sys_fork, %rdi
464464
PTREGSCALL stub32_clone, sys32_clone, %rdx
465465
PTREGSCALL stub32_vfork, sys_vfork, %rdi

arch/x86/ia32/sys_ia32.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -385,21 +385,6 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
385385
return ret;
386386
}
387387

388-
asmlinkage long sys32_execve(const char __user *name, compat_uptr_t __user *argv,
389-
compat_uptr_t __user *envp, struct pt_regs *regs)
390-
{
391-
long error;
392-
char *filename;
393-
394-
filename = getname(name);
395-
error = PTR_ERR(filename);
396-
if (IS_ERR(filename))
397-
return error;
398-
error = compat_do_execve(filename, argv, envp, regs);
399-
putname(filename);
400-
return error;
401-
}
402-
403388
asmlinkage long sys32_clone(unsigned int clone_flags, unsigned int newsp,
404389
struct pt_regs *regs)
405390
{

arch/x86/include/asm/sys_ia32.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ asmlinkage long sys32_pwrite(unsigned int, const char __user *, u32, u32, u32);
5454
asmlinkage long sys32_personality(unsigned long);
5555
asmlinkage long sys32_sendfile(int, int, compat_off_t __user *, s32);
5656

57-
asmlinkage long sys32_execve(const char __user *, compat_uptr_t __user *,
58-
compat_uptr_t __user *, struct pt_regs *);
5957
asmlinkage long sys32_clone(unsigned int, unsigned int, struct pt_regs *);
6058

6159
long sys32_lseek(unsigned int, int, unsigned int);

arch/x86/include/asm/syscalls.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int sys_fork(struct pt_regs *);
2525
int sys_vfork(struct pt_regs *);
2626
long sys_execve(const char __user *,
2727
const char __user *const __user *,
28-
const char __user *const __user *, struct pt_regs *);
28+
const char __user *const __user *);
2929
long sys_clone(unsigned long, unsigned long, void __user *,
3030
void __user *, struct pt_regs *);
3131

arch/x86/include/asm/unistd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
# define __ARCH_WANT_SYS_TIME
5151
# define __ARCH_WANT_SYS_UTIME
5252
# define __ARCH_WANT_SYS_WAITPID
53+
# define __ARCH_WANT_SYS_EXECVE
54+
# define __ARCH_WANT_KERNEL_EXECVE
5355

5456
/*
5557
* "Conditional" syscalls

arch/x86/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
2323
obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
2424
obj-$(CONFIG_IRQ_WORK) += irq_work.o
2525
obj-y += probe_roms.o
26-
obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
26+
obj-$(CONFIG_X86_32) += i386_ksyms_32.o
2727
obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
2828
obj-y += syscall_$(BITS).o
2929
obj-$(CONFIG_X86_64) += vsyscall_64.o

arch/x86/kernel/asm-offsets.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,7 @@ void common(void) {
6969
OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment);
7070
OFFSET(BP_pref_address, boot_params, hdr.pref_address);
7171
OFFSET(BP_code32_start, boot_params, hdr.code32_start);
72+
73+
BLANK();
74+
DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
7275
}

0 commit comments

Comments
 (0)