diff options
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 266c6af6ef1b..5b2959b3ffc2 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -64,6 +64,7 @@ | |||
64 | #include <linux/magic.h> | 64 | #include <linux/magic.h> |
65 | #include <linux/perf_event.h> | 65 | #include <linux/perf_event.h> |
66 | #include <linux/posix-timers.h> | 66 | #include <linux/posix-timers.h> |
67 | #include <linux/user-return-notifier.h> | ||
67 | 68 | ||
68 | #include <asm/pgtable.h> | 69 | #include <asm/pgtable.h> |
69 | #include <asm/pgalloc.h> | 70 | #include <asm/pgalloc.h> |
@@ -91,7 +92,7 @@ int nr_processes(void) | |||
91 | int cpu; | 92 | int cpu; |
92 | int total = 0; | 93 | int total = 0; |
93 | 94 | ||
94 | for_each_online_cpu(cpu) | 95 | for_each_possible_cpu(cpu) |
95 | total += per_cpu(process_counts, cpu); | 96 | total += per_cpu(process_counts, cpu); |
96 | 97 | ||
97 | return total; | 98 | return total; |
@@ -249,6 +250,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) | |||
249 | goto out; | 250 | goto out; |
250 | 251 | ||
251 | setup_thread_stack(tsk, orig); | 252 | setup_thread_stack(tsk, orig); |
253 | clear_user_return_notifier(tsk); | ||
252 | stackend = end_of_stack(tsk); | 254 | stackend = end_of_stack(tsk); |
253 | *stackend = STACK_END_MAGIC; /* for overflow detection */ | 255 | *stackend = STACK_END_MAGIC; /* for overflow detection */ |
254 | 256 | ||
@@ -570,12 +572,18 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm) | |||
570 | 572 | ||
571 | /* Get rid of any futexes when releasing the mm */ | 573 | /* Get rid of any futexes when releasing the mm */ |
572 | #ifdef CONFIG_FUTEX | 574 | #ifdef CONFIG_FUTEX |
573 | if (unlikely(tsk->robust_list)) | 575 | if (unlikely(tsk->robust_list)) { |
574 | exit_robust_list(tsk); | 576 | exit_robust_list(tsk); |
577 | tsk->robust_list = NULL; | ||
578 | } | ||
575 | #ifdef CONFIG_COMPAT | 579 | #ifdef CONFIG_COMPAT |
576 | if (unlikely(tsk->compat_robust_list)) | 580 | if (unlikely(tsk->compat_robust_list)) { |
577 | compat_exit_robust_list(tsk); | 581 | compat_exit_robust_list(tsk); |
582 | tsk->compat_robust_list = NULL; | ||
583 | } | ||
578 | #endif | 584 | #endif |
585 | if (unlikely(!list_empty(&tsk->pi_state_list))) | ||
586 | exit_pi_state_list(tsk); | ||
579 | #endif | 587 | #endif |
580 | 588 | ||
581 | /* Get rid of any cached register state */ | 589 | /* Get rid of any cached register state */ |
@@ -878,6 +886,9 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) | |||
878 | sig->utime = sig->stime = sig->cutime = sig->cstime = cputime_zero; | 886 | sig->utime = sig->stime = sig->cutime = sig->cstime = cputime_zero; |
879 | sig->gtime = cputime_zero; | 887 | sig->gtime = cputime_zero; |
880 | sig->cgtime = cputime_zero; | 888 | sig->cgtime = cputime_zero; |
889 | #ifndef CONFIG_VIRT_CPU_ACCOUNTING | ||
890 | sig->prev_utime = sig->prev_stime = cputime_zero; | ||
891 | #endif | ||
881 | sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0; | 892 | sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0; |
882 | sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0; | 893 | sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0; |
883 | sig->inblock = sig->oublock = sig->cinblock = sig->coublock = 0; | 894 | sig->inblock = sig->oublock = sig->cinblock = sig->coublock = 0; |
@@ -928,9 +939,9 @@ SYSCALL_DEFINE1(set_tid_address, int __user *, tidptr) | |||
928 | 939 | ||
929 | static void rt_mutex_init_task(struct task_struct *p) | 940 | static void rt_mutex_init_task(struct task_struct *p) |
930 | { | 941 | { |
931 | spin_lock_init(&p->pi_lock); | 942 | raw_spin_lock_init(&p->pi_lock); |
932 | #ifdef CONFIG_RT_MUTEXES | 943 | #ifdef CONFIG_RT_MUTEXES |
933 | plist_head_init(&p->pi_waiters, &p->pi_lock); | 944 | plist_head_init_raw(&p->pi_waiters, &p->pi_lock); |
934 | p->pi_blocked_on = NULL; | 945 | p->pi_blocked_on = NULL; |
935 | #endif | 946 | #endif |
936 | } | 947 | } |
@@ -1060,8 +1071,10 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1060 | p->gtime = cputime_zero; | 1071 | p->gtime = cputime_zero; |
1061 | p->utimescaled = cputime_zero; | 1072 | p->utimescaled = cputime_zero; |
1062 | p->stimescaled = cputime_zero; | 1073 | p->stimescaled = cputime_zero; |
1074 | #ifndef CONFIG_VIRT_CPU_ACCOUNTING | ||
1063 | p->prev_utime = cputime_zero; | 1075 | p->prev_utime = cputime_zero; |
1064 | p->prev_stime = cputime_zero; | 1076 | p->prev_stime = cputime_zero; |
1077 | #endif | ||
1065 | 1078 | ||
1066 | p->default_timer_slack_ns = current->timer_slack_ns; | 1079 | p->default_timer_slack_ns = current->timer_slack_ns; |
1067 | 1080 | ||
@@ -1114,6 +1127,10 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1114 | #ifdef CONFIG_DEBUG_MUTEXES | 1127 | #ifdef CONFIG_DEBUG_MUTEXES |
1115 | p->blocked_on = NULL; /* not blocked yet */ | 1128 | p->blocked_on = NULL; /* not blocked yet */ |
1116 | #endif | 1129 | #endif |
1130 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR | ||
1131 | p->memcg_batch.do_batch = 0; | ||
1132 | p->memcg_batch.memcg = NULL; | ||
1133 | #endif | ||
1117 | 1134 | ||
1118 | p->bts = NULL; | 1135 | p->bts = NULL; |
1119 | 1136 | ||
@@ -1193,9 +1210,10 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1193 | p->sas_ss_sp = p->sas_ss_size = 0; | 1210 | p->sas_ss_sp = p->sas_ss_size = 0; |
1194 | 1211 | ||
1195 | /* | 1212 | /* |
1196 | * Syscall tracing should be turned off in the child regardless | 1213 | * Syscall tracing and stepping should be turned off in the |
1197 | * of CLONE_PTRACE. | 1214 | * child regardless of CLONE_PTRACE. |
1198 | */ | 1215 | */ |
1216 | user_disable_single_step(p); | ||
1199 | clear_tsk_thread_flag(p, TIF_SYSCALL_TRACE); | 1217 | clear_tsk_thread_flag(p, TIF_SYSCALL_TRACE); |
1200 | #ifdef TIF_SYSCALL_EMU | 1218 | #ifdef TIF_SYSCALL_EMU |
1201 | clear_tsk_thread_flag(p, TIF_SYSCALL_EMU); | 1219 | clear_tsk_thread_flag(p, TIF_SYSCALL_EMU); |
@@ -1273,7 +1291,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1273 | } | 1291 | } |
1274 | 1292 | ||
1275 | if (likely(p->pid)) { | 1293 | if (likely(p->pid)) { |
1276 | list_add_tail(&p->sibling, &p->real_parent->children); | ||
1277 | tracehook_finish_clone(p, clone_flags, trace); | 1294 | tracehook_finish_clone(p, clone_flags, trace); |
1278 | 1295 | ||
1279 | if (thread_group_leader(p)) { | 1296 | if (thread_group_leader(p)) { |
@@ -1285,6 +1302,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1285 | p->signal->tty = tty_kref_get(current->signal->tty); | 1302 | p->signal->tty = tty_kref_get(current->signal->tty); |
1286 | attach_pid(p, PIDTYPE_PGID, task_pgrp(current)); | 1303 | attach_pid(p, PIDTYPE_PGID, task_pgrp(current)); |
1287 | attach_pid(p, PIDTYPE_SID, task_session(current)); | 1304 | attach_pid(p, PIDTYPE_SID, task_session(current)); |
1305 | list_add_tail(&p->sibling, &p->real_parent->children); | ||
1288 | list_add_tail_rcu(&p->tasks, &init_task.tasks); | 1306 | list_add_tail_rcu(&p->tasks, &init_task.tasks); |
1289 | __get_cpu_var(process_counts)++; | 1307 | __get_cpu_var(process_counts)++; |
1290 | } | 1308 | } |
@@ -1304,7 +1322,8 @@ bad_fork_free_pid: | |||
1304 | if (pid != &init_struct_pid) | 1322 | if (pid != &init_struct_pid) |
1305 | free_pid(pid); | 1323 | free_pid(pid); |
1306 | bad_fork_cleanup_io: | 1324 | bad_fork_cleanup_io: |
1307 | put_io_context(p->io_context); | 1325 | if (p->io_context) |
1326 | exit_io_context(p); | ||
1308 | bad_fork_cleanup_namespaces: | 1327 | bad_fork_cleanup_namespaces: |
1309 | exit_task_namespaces(p); | 1328 | exit_task_namespaces(p); |
1310 | bad_fork_cleanup_mm: | 1329 | bad_fork_cleanup_mm: |