exec.c (77bf4400319db9d2a8af6b00c2be6faa0f3d07cb) exec.c (ba180fd437156f7fd8cfb2fdd021d949eeef08d6)
1/*
1/*
2 * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
4 */
5
3 * Licensed under the GPL
4 */
5
6#include "linux/slab.h"
6#include "linux/stddef.h"
7#include "linux/fs.h"
7#include "linux/smp_lock.h"
8#include "linux/ptrace.h"
8#include "linux/smp_lock.h"
9#include "linux/ptrace.h"
9#include "linux/fs.h"
10#include "asm/ptrace.h"
11#include "asm/pgtable.h"
12#include "asm/tlbflush.h"
10#include "linux/sched.h"
11#include "asm/current.h"
12#include "asm/processor.h"
13#include "asm/uaccess.h"
13#include "asm/uaccess.h"
14#include "kern_util.h"
15#include "as-layout.h"
16#include "mem_user.h"
14#include "mem_user.h"
17#include "kern.h"
18#include "irq_user.h"
19#include "tlb.h"
15#include "skas.h"
20#include "os.h"
16#include "os.h"
21#include "skas/skas.h"
22
23void flush_thread(void)
24{
25 void *data = NULL;
26 unsigned long end = proc_mm ? task_size : CONFIG_STUB_START;
27 int ret;
28
29 arch_flush_thread(&current->thread.arch);
30
31 ret = unmap(&current->mm->context.skas.id, 0, end, 1, &data);
17
18void flush_thread(void)
19{
20 void *data = NULL;
21 unsigned long end = proc_mm ? task_size : CONFIG_STUB_START;
22 int ret;
23
24 arch_flush_thread(&current->thread.arch);
25
26 ret = unmap(&current->mm->context.skas.id, 0, end, 1, &data);
32 if(ret){
33 printk("flush_thread - clearing address space failed, "
27 if (ret) {
28 printk(KERN_ERR "flush_thread - clearing address space failed, "
34 "err = %d\n", ret);
35 force_sig(SIGKILL, current);
36 }
37
38 __switch_mm(&current->mm->context.skas.id);
39}
40
41void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)

--- 5 unchanged lines hidden (view full) ---

47
48#ifdef CONFIG_TTY_LOG
49extern void log_exec(char **argv, void *tty);
50#endif
51
52static long execve1(char *file, char __user * __user *argv,
53 char __user *__user *env)
54{
29 "err = %d\n", ret);
30 force_sig(SIGKILL, current);
31 }
32
33 __switch_mm(&current->mm->context.skas.id);
34}
35
36void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)

--- 5 unchanged lines hidden (view full) ---

42
43#ifdef CONFIG_TTY_LOG
44extern void log_exec(char **argv, void *tty);
45#endif
46
47static long execve1(char *file, char __user * __user *argv,
48 char __user *__user *env)
49{
55 long error;
50 long error;
56#ifdef CONFIG_TTY_LOG
57 struct tty_struct *tty;
58
59 mutex_lock(&tty_mutex);
60 tty = get_current_tty();
61 if (tty)
62 log_exec(argv, tty);
63 mutex_unlock(&tty_mutex);
64#endif
51#ifdef CONFIG_TTY_LOG
52 struct tty_struct *tty;
53
54 mutex_lock(&tty_mutex);
55 tty = get_current_tty();
56 if (tty)
57 log_exec(argv, tty);
58 mutex_unlock(&tty_mutex);
59#endif
65 error = do_execve(file, argv, env, &current->thread.regs);
66 if (error == 0){
60 error = do_execve(file, argv, env, &current->thread.regs);
61 if (error == 0) {
67 task_lock(current);
62 task_lock(current);
68 current->ptrace &= ~PT_DTRACE;
63 current->ptrace &= ~PT_DTRACE;
69#ifdef SUBARCH_EXECVE1
70 SUBARCH_EXECVE1(&current->thread.regs.regs);
71#endif
72 task_unlock(current);
64#ifdef SUBARCH_EXECVE1
65 SUBARCH_EXECVE1(&current->thread.regs.regs);
66#endif
67 task_unlock(current);
73 }
74 return(error);
68 }
69 return error;
75}
76
77long um_execve(char *file, char __user *__user *argv, char __user *__user *env)
78{
79 long err;
80
81 err = execve1(file, argv, env);
70}
71
72long um_execve(char *file, char __user *__user *argv, char __user *__user *env)
73{
74 long err;
75
76 err = execve1(file, argv, env);
82 if(!err)
77 if (!err)
83 do_longjmp(current->thread.exec_buf, 1);
78 do_longjmp(current->thread.exec_buf, 1);
84 return(err);
79 return err;
85}
86
87long sys_execve(char __user *file, char __user *__user *argv,
88 char __user *__user *env)
89{
90 long error;
91 char *filename;
92
93 lock_kernel();
94 filename = getname(file);
95 error = PTR_ERR(filename);
96 if (IS_ERR(filename)) goto out;
97 error = execve1(filename, argv, env);
98 putname(filename);
99 out:
100 unlock_kernel();
80}
81
82long sys_execve(char __user *file, char __user *__user *argv,
83 char __user *__user *env)
84{
85 long error;
86 char *filename;
87
88 lock_kernel();
89 filename = getname(file);
90 error = PTR_ERR(filename);
91 if (IS_ERR(filename)) goto out;
92 error = execve1(filename, argv, env);
93 putname(filename);
94 out:
95 unlock_kernel();
101 return(error);
96 return error;
102}
97}