Skip to content

Commit d878d6d

Browse files
author
Al Viro
committed
m68k: switch to generic sys_execve()/kernel_execve()
The tricky part here is that task_pt_regs() on m68k works *only* for process inside do_signal(). However, we need something much simpler - pt_regs of a process inside do_signal() may be at different offsets from the stack bottom, depending on the way we'd entered the kernel, but for a task inside sys_execve() it *is* at constant offset. Moreover, for a kernel thread about to become a userland process the same location is also fine - setting sp to that will leave the kernel stack pointer at the very bottom of the kernel stack when we finally switch to userland. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 533e690 commit d878d6d

5 files changed

Lines changed: 9 additions & 37 deletions

File tree

‎arch/m68k/include/asm/ptrace.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ struct switch_stack {
8585
#define user_mode(regs) (!((regs)->sr & PS_S))
8686
#define instruction_pointer(regs) ((regs)->pc)
8787
#define profile_pc(regs) instruction_pointer(regs)
88+
#define current_pt_regs() \
89+
(struct pt_regs *)((char *)current_thread_info() + THREAD_SIZE) - 1
8890

8991
#define arch_has_single_step() (1)
9092

‎arch/m68k/include/asm/unistd.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@
382382
#define __ARCH_WANT_SYS_SIGPROCMASK
383383
#define __ARCH_WANT_SYS_RT_SIGACTION
384384
#define __ARCH_WANT_SYS_RT_SIGSUSPEND
385+
#define __ARCH_WANT_SYS_EXECVE
386+
#define __ARCH_WANT_KERNEL_EXECVE
385387

386388
/*
387389
* "Conditional" syscalls

‎arch/m68k/kernel/entry.S‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ ENTRY(ret_from_kernel_thread)
122122
movel %d0,(%sp)
123123
jra sys_exit
124124

125+
ENTRY(ret_from_kernel_execve)
126+
movel 4(%sp), %sp
127+
GET_CURRENT(%d0)
128+
jra ret_from_exception
129+
125130
#if defined(CONFIG_COLDFIRE) || !defined(CONFIG_MMU)
126131

127132
#ifdef TRAP_DBG_INTERRUPT

‎arch/m68k/kernel/process.c‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -298,26 +298,6 @@ int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu)
298298
EXPORT_SYMBOL(dump_fpu);
299299
#endif /* CONFIG_FPU */
300300

301-
/*
302-
* sys_execve() executes a new program.
303-
*/
304-
asmlinkage int sys_execve(const char __user *name,
305-
const char __user *const __user *argv,
306-
const char __user *const __user *envp)
307-
{
308-
int error;
309-
char * filename;
310-
struct pt_regs *regs = (struct pt_regs *) &name;
311-
312-
filename = getname(name);
313-
error = PTR_ERR(filename);
314-
if (IS_ERR(filename))
315-
return error;
316-
error = do_execve(filename, argv, envp, regs);
317-
putname(filename);
318-
return error;
319-
}
320-
321301
unsigned long get_wchan(struct task_struct *p)
322302
{
323303
unsigned long fp, pc;

‎arch/m68k/kernel/sys_m68k.c‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -549,23 +549,6 @@ asmlinkage int sys_getpagesize(void)
549549
return PAGE_SIZE;
550550
}
551551

552-
/*
553-
* Do a system call from kernel instead of calling sys_execve so we
554-
* end up with proper pt_regs.
555-
*/
556-
int kernel_execve(const char *filename,
557-
const char *const argv[],
558-
const char *const envp[])
559-
{
560-
register long __res asm ("%d0") = __NR_execve;
561-
register long __a asm ("%d1") = (long)(filename);
562-
register long __b asm ("%d2") = (long)(argv);
563-
register long __c asm ("%d3") = (long)(envp);
564-
asm volatile ("trap #0" : "+d" (__res)
565-
: "d" (__a), "d" (__b), "d" (__c));
566-
return __res;
567-
}
568-
569552
asmlinkage unsigned long sys_get_thread_area(void)
570553
{
571554
return current_thread_info()->tp_value;

0 commit comments

Comments
 (0)