diff options
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 42 |
1 files changed, 23 insertions, 19 deletions
@@ -59,10 +59,13 @@ | |||
59 | #include <asm/uaccess.h> | 59 | #include <asm/uaccess.h> |
60 | #include <asm/mmu_context.h> | 60 | #include <asm/mmu_context.h> |
61 | #include <asm/tlb.h> | 61 | #include <asm/tlb.h> |
62 | #include <asm/exec.h> | ||
62 | 63 | ||
63 | #include <trace/events/task.h> | 64 | #include <trace/events/task.h> |
64 | #include "internal.h" | 65 | #include "internal.h" |
65 | 66 | ||
67 | #include <trace/events/sched.h> | ||
68 | |||
66 | int core_uses_pid; | 69 | int core_uses_pid; |
67 | char core_pattern[CORENAME_MAX_SIZE] = "core"; | 70 | char core_pattern[CORENAME_MAX_SIZE] = "core"; |
68 | unsigned int core_pipe_limit; | 71 | unsigned int core_pipe_limit; |
@@ -79,15 +82,13 @@ static atomic_t call_count = ATOMIC_INIT(1); | |||
79 | static LIST_HEAD(formats); | 82 | static LIST_HEAD(formats); |
80 | static DEFINE_RWLOCK(binfmt_lock); | 83 | static DEFINE_RWLOCK(binfmt_lock); |
81 | 84 | ||
82 | int __register_binfmt(struct linux_binfmt * fmt, int insert) | 85 | void __register_binfmt(struct linux_binfmt * fmt, int insert) |
83 | { | 86 | { |
84 | if (!fmt) | 87 | BUG_ON(!fmt); |
85 | return -EINVAL; | ||
86 | write_lock(&binfmt_lock); | 88 | write_lock(&binfmt_lock); |
87 | insert ? list_add(&fmt->lh, &formats) : | 89 | insert ? list_add(&fmt->lh, &formats) : |
88 | list_add_tail(&fmt->lh, &formats); | 90 | list_add_tail(&fmt->lh, &formats); |
89 | write_unlock(&binfmt_lock); | 91 | write_unlock(&binfmt_lock); |
90 | return 0; | ||
91 | } | 92 | } |
92 | 93 | ||
93 | EXPORT_SYMBOL(__register_binfmt); | 94 | EXPORT_SYMBOL(__register_binfmt); |
@@ -822,7 +823,7 @@ static int exec_mmap(struct mm_struct *mm) | |||
822 | /* Notify parent that we're no longer interested in the old VM */ | 823 | /* Notify parent that we're no longer interested in the old VM */ |
823 | tsk = current; | 824 | tsk = current; |
824 | old_mm = current->mm; | 825 | old_mm = current->mm; |
825 | sync_mm_rss(tsk, old_mm); | 826 | sync_mm_rss(old_mm); |
826 | mm_release(tsk, old_mm); | 827 | mm_release(tsk, old_mm); |
827 | 828 | ||
828 | if (old_mm) { | 829 | if (old_mm) { |
@@ -848,6 +849,7 @@ static int exec_mmap(struct mm_struct *mm) | |||
848 | if (old_mm) { | 849 | if (old_mm) { |
849 | up_read(&old_mm->mmap_sem); | 850 | up_read(&old_mm->mmap_sem); |
850 | BUG_ON(active_mm != old_mm); | 851 | BUG_ON(active_mm != old_mm); |
852 | setmax_mm_hiwater_rss(&tsk->signal->maxrss, old_mm); | ||
851 | mm_update_next_owner(old_mm); | 853 | mm_update_next_owner(old_mm); |
852 | mmput(old_mm); | 854 | mmput(old_mm); |
853 | return 0; | 855 | return 0; |
@@ -975,8 +977,8 @@ static int de_thread(struct task_struct *tsk) | |||
975 | sig->notify_count = 0; | 977 | sig->notify_count = 0; |
976 | 978 | ||
977 | no_thread_group: | 979 | no_thread_group: |
978 | if (current->mm) | 980 | /* we have changed execution domain */ |
979 | setmax_mm_hiwater_rss(&sig->maxrss, current->mm); | 981 | tsk->exit_signal = SIGCHLD; |
980 | 982 | ||
981 | exit_itimers(sig); | 983 | exit_itimers(sig); |
982 | flush_itimer_signals(); | 984 | flush_itimer_signals(); |
@@ -1026,10 +1028,10 @@ static void flush_old_files(struct files_struct * files) | |||
1026 | fdt = files_fdtable(files); | 1028 | fdt = files_fdtable(files); |
1027 | if (i >= fdt->max_fds) | 1029 | if (i >= fdt->max_fds) |
1028 | break; | 1030 | break; |
1029 | set = fdt->close_on_exec->fds_bits[j]; | 1031 | set = fdt->close_on_exec[j]; |
1030 | if (!set) | 1032 | if (!set) |
1031 | continue; | 1033 | continue; |
1032 | fdt->close_on_exec->fds_bits[j] = 0; | 1034 | fdt->close_on_exec[j] = 0; |
1033 | spin_unlock(&files->file_lock); | 1035 | spin_unlock(&files->file_lock); |
1034 | for ( ; set ; i++,set >>= 1) { | 1036 | for ( ; set ; i++,set >>= 1) { |
1035 | if (set & 1) { | 1037 | if (set & 1) { |
@@ -1112,7 +1114,7 @@ int flush_old_exec(struct linux_binprm * bprm) | |||
1112 | bprm->mm = NULL; /* We're using it now */ | 1114 | bprm->mm = NULL; /* We're using it now */ |
1113 | 1115 | ||
1114 | set_fs(USER_DS); | 1116 | set_fs(USER_DS); |
1115 | current->flags &= ~(PF_RANDOMIZE | PF_KTHREAD); | 1117 | current->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD); |
1116 | flush_thread(); | 1118 | flush_thread(); |
1117 | current->personality &= ~bprm->per_clear; | 1119 | current->personality &= ~bprm->per_clear; |
1118 | 1120 | ||
@@ -1339,13 +1341,13 @@ int remove_arg_zero(struct linux_binprm *bprm) | |||
1339 | ret = -EFAULT; | 1341 | ret = -EFAULT; |
1340 | goto out; | 1342 | goto out; |
1341 | } | 1343 | } |
1342 | kaddr = kmap_atomic(page, KM_USER0); | 1344 | kaddr = kmap_atomic(page); |
1343 | 1345 | ||
1344 | for (; offset < PAGE_SIZE && kaddr[offset]; | 1346 | for (; offset < PAGE_SIZE && kaddr[offset]; |
1345 | offset++, bprm->p++) | 1347 | offset++, bprm->p++) |
1346 | ; | 1348 | ; |
1347 | 1349 | ||
1348 | kunmap_atomic(kaddr, KM_USER0); | 1350 | kunmap_atomic(kaddr); |
1349 | put_arg_page(page); | 1351 | put_arg_page(page); |
1350 | 1352 | ||
1351 | if (offset == PAGE_SIZE) | 1353 | if (offset == PAGE_SIZE) |
@@ -1369,7 +1371,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) | |||
1369 | unsigned int depth = bprm->recursion_depth; | 1371 | unsigned int depth = bprm->recursion_depth; |
1370 | int try,retval; | 1372 | int try,retval; |
1371 | struct linux_binfmt *fmt; | 1373 | struct linux_binfmt *fmt; |
1372 | pid_t old_pid; | 1374 | pid_t old_pid, old_vpid; |
1373 | 1375 | ||
1374 | retval = security_bprm_check(bprm); | 1376 | retval = security_bprm_check(bprm); |
1375 | if (retval) | 1377 | if (retval) |
@@ -1380,8 +1382,9 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) | |||
1380 | return retval; | 1382 | return retval; |
1381 | 1383 | ||
1382 | /* Need to fetch pid before load_binary changes it */ | 1384 | /* Need to fetch pid before load_binary changes it */ |
1385 | old_pid = current->pid; | ||
1383 | rcu_read_lock(); | 1386 | rcu_read_lock(); |
1384 | old_pid = task_pid_nr_ns(current, task_active_pid_ns(current->parent)); | 1387 | old_vpid = task_pid_nr_ns(current, task_active_pid_ns(current->parent)); |
1385 | rcu_read_unlock(); | 1388 | rcu_read_unlock(); |
1386 | 1389 | ||
1387 | retval = -ENOENT; | 1390 | retval = -ENOENT; |
@@ -1402,9 +1405,10 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) | |||
1402 | */ | 1405 | */ |
1403 | bprm->recursion_depth = depth; | 1406 | bprm->recursion_depth = depth; |
1404 | if (retval >= 0) { | 1407 | if (retval >= 0) { |
1405 | if (depth == 0) | 1408 | if (depth == 0) { |
1406 | ptrace_event(PTRACE_EVENT_EXEC, | 1409 | trace_sched_process_exec(current, old_pid, bprm); |
1407 | old_pid); | 1410 | ptrace_event(PTRACE_EVENT_EXEC, old_vpid); |
1411 | } | ||
1408 | put_binfmt(fmt); | 1412 | put_binfmt(fmt); |
1409 | allow_write_access(bprm->file); | 1413 | allow_write_access(bprm->file); |
1410 | if (bprm->file) | 1414 | if (bprm->file) |
@@ -2064,8 +2068,8 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new) | |||
2064 | fd_install(0, rp); | 2068 | fd_install(0, rp); |
2065 | spin_lock(&cf->file_lock); | 2069 | spin_lock(&cf->file_lock); |
2066 | fdt = files_fdtable(cf); | 2070 | fdt = files_fdtable(cf); |
2067 | FD_SET(0, fdt->open_fds); | 2071 | __set_open_fd(0, fdt); |
2068 | FD_CLR(0, fdt->close_on_exec); | 2072 | __clear_close_on_exec(0, fdt); |
2069 | spin_unlock(&cf->file_lock); | 2073 | spin_unlock(&cf->file_lock); |
2070 | 2074 | ||
2071 | /* and disallow core files too */ | 2075 | /* and disallow core files too */ |