Version:
~ [ 0.6-2.3.46 ] ~
Architecture:
~ [ um ] ~
** Warning: Cannot open xref database.
1 #include "linux/malloc.h"
2 #include "linux/smp_lock.h"
3 #include "asm/ptrace.h"
4 #include "asm/pgtable.h"
5 #include "asm/pgalloc.h"
6 #include "user_util.h"
7 #include "kern_util.h"
8 #include "kern.h"
9
10 extern struct mm_struct kernel_maps;
11
12 static void add_kernel_vma(struct task_struct *task)
13 {
14 struct vm_area_struct *vma, *new;
15
16 if(task->mm != init_task.mm){
17 for(vma = kernel_maps.mmap;vma != NULL;vma = vma->vm_next){
18 new = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
19 if(!new) panic("No memory in add_kernel_vma");
20 *new = *vma;
21 new->vm_next = NULL;
22 new->vm_flags |= VM_LOCKED;
23 new->vm_avl_height = 0;
24 new->vm_avl_left = NULL;
25 new->vm_avl_right = NULL;
26 new->vm_next_share = NULL;
27 new->vm_pprev_share = NULL;
28 if(new->vm_file != NULL) atomic_inc(&new->vm_file->f_count);
29 insert_vm_struct(task->mm, new);
30 }
31 }
32 }
33
34 static void check_vma(unsigned long addr)
35 {
36 struct vm_area_struct *vma;
37
38 vma = find_vma(current->mm, addr);
39 if((vma == NULL) || (vma->vm_start > addr)) force_sigbus();
40 }
41
42 void start_thread(struct pt_regs * regs, unsigned long eip, unsigned long esp)
43 {
44 check_vma(current->mm->brk - 1);
45 check_vma(eip);
46 current->addr_limit.seg = STACK_TOP;
47 current->thread.starting_exec = 0;
48 add_kernel_vma(current);
49 flush_tlb_mm(current->mm);
50 set_signal_handler(SIGSEGV, user_segv_handler);
51 set_sigstack(NULL, SIGUSR2, syscall_handler, 0, 1, -1);
52 memset((void *) (esp & PAGE_MASK), 0, (esp & ~PAGE_MASK) - sizeof(void *));
53 current->thread.request.op = OP_EXEC;
54 current->thread.request.u.exec.ip = eip;
55 current->thread.request.u.exec.sp = esp;
56 }
57
58 void kern_finish_exec(void *task, unsigned long ip, unsigned long sp, int pid)
59 {
60 set_tracing(task, 1);
61 finish_exec(pid, ip, sp);
62 }
63
64 static int execve1(char *file, char **argv, char **env)
65 {
66 int pid, error;
67
68 pid = current->thread.extern_pid;
69 error = do_execve(file, argv, env, NULL);
70 if (error == 0){
71 current->flags &= ~PF_DTRACE;
72 set_cmdline(current_cmd());
73 }
74 return(error);
75 }
76
77 int um_execve(char *file, char **argv, char **env)
78 {
79 if(execve1(file, argv, env) == 0)
80 usr1_pid(getpid());
81 return(-1);
82 }
83
84 int sys_execve(char *file, char **argv, char **env)
85 {
86 int error;
87 char *filename;
88
89 lock_kernel();
90 filename = getname((char *) file);
91 error = PTR_ERR(filename);
92 if (IS_ERR(filename)) goto out;
93 error = execve1(filename, argv, env);
94 putname(filename);
95 out:
96 unlock_kernel();
97 if(error == 0) usr1_pid(getpid());
98 return(error);
99 }
100
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.