diff options
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index fb8572a42297..72e3252c6763 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -743,6 +743,14 @@ int unshare_files(void) | |||
743 | 743 | ||
744 | EXPORT_SYMBOL(unshare_files); | 744 | EXPORT_SYMBOL(unshare_files); |
745 | 745 | ||
746 | void sighand_free_cb(struct rcu_head *rhp) | ||
747 | { | ||
748 | struct sighand_struct *sp; | ||
749 | |||
750 | sp = container_of(rhp, struct sighand_struct, rcu); | ||
751 | kmem_cache_free(sighand_cachep, sp); | ||
752 | } | ||
753 | |||
746 | static inline int copy_sighand(unsigned long clone_flags, struct task_struct * tsk) | 754 | static inline int copy_sighand(unsigned long clone_flags, struct task_struct * tsk) |
747 | { | 755 | { |
748 | struct sighand_struct *sig; | 756 | struct sighand_struct *sig; |
@@ -752,7 +760,7 @@ static inline int copy_sighand(unsigned long clone_flags, struct task_struct * t | |||
752 | return 0; | 760 | return 0; |
753 | } | 761 | } |
754 | sig = kmem_cache_alloc(sighand_cachep, GFP_KERNEL); | 762 | sig = kmem_cache_alloc(sighand_cachep, GFP_KERNEL); |
755 | tsk->sighand = sig; | 763 | rcu_assign_pointer(tsk->sighand, sig); |
756 | if (!sig) | 764 | if (!sig) |
757 | return -ENOMEM; | 765 | return -ENOMEM; |
758 | spin_lock_init(&sig->siglock); | 766 | spin_lock_init(&sig->siglock); |
@@ -803,9 +811,6 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts | |||
803 | sig->it_prof_expires = cputime_zero; | 811 | sig->it_prof_expires = cputime_zero; |
804 | sig->it_prof_incr = cputime_zero; | 812 | sig->it_prof_incr = cputime_zero; |
805 | 813 | ||
806 | sig->tty = current->signal->tty; | ||
807 | sig->pgrp = process_group(current); | ||
808 | sig->session = current->signal->session; | ||
809 | sig->leader = 0; /* session leadership doesn't inherit */ | 814 | sig->leader = 0; /* session leadership doesn't inherit */ |
810 | sig->tty_old_pgrp = 0; | 815 | sig->tty_old_pgrp = 0; |
811 | 816 | ||
@@ -964,12 +969,13 @@ static task_t *copy_process(unsigned long clone_flags, | |||
964 | p->io_context = NULL; | 969 | p->io_context = NULL; |
965 | p->io_wait = NULL; | 970 | p->io_wait = NULL; |
966 | p->audit_context = NULL; | 971 | p->audit_context = NULL; |
972 | cpuset_fork(p); | ||
967 | #ifdef CONFIG_NUMA | 973 | #ifdef CONFIG_NUMA |
968 | p->mempolicy = mpol_copy(p->mempolicy); | 974 | p->mempolicy = mpol_copy(p->mempolicy); |
969 | if (IS_ERR(p->mempolicy)) { | 975 | if (IS_ERR(p->mempolicy)) { |
970 | retval = PTR_ERR(p->mempolicy); | 976 | retval = PTR_ERR(p->mempolicy); |
971 | p->mempolicy = NULL; | 977 | p->mempolicy = NULL; |
972 | goto bad_fork_cleanup; | 978 | goto bad_fork_cleanup_cpuset; |
973 | } | 979 | } |
974 | #endif | 980 | #endif |
975 | 981 | ||
@@ -1127,25 +1133,19 @@ static task_t *copy_process(unsigned long clone_flags, | |||
1127 | attach_pid(p, PIDTYPE_PID, p->pid); | 1133 | attach_pid(p, PIDTYPE_PID, p->pid); |
1128 | attach_pid(p, PIDTYPE_TGID, p->tgid); | 1134 | attach_pid(p, PIDTYPE_TGID, p->tgid); |
1129 | if (thread_group_leader(p)) { | 1135 | if (thread_group_leader(p)) { |
1136 | p->signal->tty = current->signal->tty; | ||
1137 | p->signal->pgrp = process_group(current); | ||
1138 | p->signal->session = current->signal->session; | ||
1130 | attach_pid(p, PIDTYPE_PGID, process_group(p)); | 1139 | attach_pid(p, PIDTYPE_PGID, process_group(p)); |
1131 | attach_pid(p, PIDTYPE_SID, p->signal->session); | 1140 | attach_pid(p, PIDTYPE_SID, p->signal->session); |
1132 | if (p->pid) | 1141 | if (p->pid) |
1133 | __get_cpu_var(process_counts)++; | 1142 | __get_cpu_var(process_counts)++; |
1134 | } | 1143 | } |
1135 | 1144 | ||
1136 | if (!current->signal->tty && p->signal->tty) | ||
1137 | p->signal->tty = NULL; | ||
1138 | |||
1139 | nr_threads++; | 1145 | nr_threads++; |
1140 | total_forks++; | 1146 | total_forks++; |
1141 | write_unlock_irq(&tasklist_lock); | 1147 | write_unlock_irq(&tasklist_lock); |
1142 | proc_fork_connector(p); | 1148 | proc_fork_connector(p); |
1143 | cpuset_fork(p); | ||
1144 | retval = 0; | ||
1145 | |||
1146 | fork_out: | ||
1147 | if (retval) | ||
1148 | return ERR_PTR(retval); | ||
1149 | return p; | 1149 | return p; |
1150 | 1150 | ||
1151 | bad_fork_cleanup_namespace: | 1151 | bad_fork_cleanup_namespace: |
@@ -1172,7 +1172,9 @@ bad_fork_cleanup_security: | |||
1172 | bad_fork_cleanup_policy: | 1172 | bad_fork_cleanup_policy: |
1173 | #ifdef CONFIG_NUMA | 1173 | #ifdef CONFIG_NUMA |
1174 | mpol_free(p->mempolicy); | 1174 | mpol_free(p->mempolicy); |
1175 | bad_fork_cleanup_cpuset: | ||
1175 | #endif | 1176 | #endif |
1177 | cpuset_exit(p); | ||
1176 | bad_fork_cleanup: | 1178 | bad_fork_cleanup: |
1177 | if (p->binfmt) | 1179 | if (p->binfmt) |
1178 | module_put(p->binfmt->module); | 1180 | module_put(p->binfmt->module); |
@@ -1184,7 +1186,8 @@ bad_fork_cleanup_count: | |||
1184 | free_uid(p->user); | 1186 | free_uid(p->user); |
1185 | bad_fork_free: | 1187 | bad_fork_free: |
1186 | free_task(p); | 1188 | free_task(p); |
1187 | goto fork_out; | 1189 | fork_out: |
1190 | return ERR_PTR(retval); | ||
1188 | } | 1191 | } |
1189 | 1192 | ||
1190 | struct pt_regs * __devinit __attribute__((weak)) idle_regs(struct pt_regs *regs) | 1193 | struct pt_regs * __devinit __attribute__((weak)) idle_regs(struct pt_regs *regs) |