1 /* 2 * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) 3 * Licensed under the GPL 4 */ 5 6 #include "linux/slab.h" 7 #include "linux/smp_lock.h" 8 #include "linux/ptrace.h" 9 #include "linux/fs.h" 10 #include "asm/ptrace.h" 11 #include "asm/pgtable.h" 12 #include "asm/tlbflush.h" 13 #include "asm/uaccess.h" 14 #include "kern_util.h" 15 #include "as-layout.h" 16 #include "mem_user.h" 17 #include "kern.h" 18 #include "irq_user.h" 19 #include "tlb.h" 20 #include "os.h" 21 #include "choose-mode.h" 22 #include "mode_kern.h" 23 24 void flush_thread(void) 25 { 26 arch_flush_thread(¤t->thread.arch); 27 CHOOSE_MODE(flush_thread_tt(), flush_thread_skas()); 28 } 29 30 void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp) 31 { 32 CHOOSE_MODE_PROC(start_thread_tt, start_thread_skas, regs, eip, esp); 33 } 34 35 #ifdef CONFIG_TTY_LOG 36 extern void log_exec(char **argv, void *tty); 37 #endif 38 39 static long execve1(char *file, char __user * __user *argv, 40 char __user *__user *env) 41 { 42 long error; 43 #ifdef CONFIG_TTY_LOG 44 struct tty_struct *tty; 45 46 mutex_lock(&tty_mutex); 47 tty = get_current_tty(); 48 if (tty) 49 log_exec(argv, tty); 50 mutex_unlock(&tty_mutex); 51 #endif 52 error = do_execve(file, argv, env, ¤t->thread.regs); 53 if (error == 0){ 54 task_lock(current); 55 current->ptrace &= ~PT_DTRACE; 56 #ifdef SUBARCH_EXECVE1 57 SUBARCH_EXECVE1(¤t->thread.regs.regs); 58 #endif 59 task_unlock(current); 60 } 61 return(error); 62 } 63 64 long um_execve(char *file, char __user *__user *argv, char __user *__user *env) 65 { 66 long err; 67 68 err = execve1(file, argv, env); 69 if(!err) 70 do_longjmp(current->thread.exec_buf, 1); 71 return(err); 72 } 73 74 long sys_execve(char __user *file, char __user *__user *argv, 75 char __user *__user *env) 76 { 77 long error; 78 char *filename; 79 80 lock_kernel(); 81 filename = getname(file); 82 error = PTR_ERR(filename); 83 if (IS_ERR(filename)) goto out; 84 error = execve1(filename, argv, env); 85 putname(filename); 86 out: 87 unlock_kernel(); 88 return(error); 89 } 90