diff options
-rw-r--r-- | fs/exec.c | 2 | ||||
-rw-r--r-- | include/linux/pid.h | 3 | ||||
-rw-r--r-- | kernel/exit.c | 4 | ||||
-rw-r--r-- | kernel/fork.c | 11 | ||||
-rw-r--r-- | kernel/pid.c | 9 | ||||
-rw-r--r-- | kernel/sys.c | 2 |
6 files changed, 18 insertions, 13 deletions
@@ -702,7 +702,7 @@ static int de_thread(struct task_struct *tsk) | |||
702 | */ | 702 | */ |
703 | detach_pid(tsk, PIDTYPE_PID); | 703 | detach_pid(tsk, PIDTYPE_PID); |
704 | tsk->pid = leader->pid; | 704 | tsk->pid = leader->pid; |
705 | attach_pid(tsk, PIDTYPE_PID, tsk->pid); | 705 | attach_pid(tsk, PIDTYPE_PID, find_pid(tsk->pid)); |
706 | transfer_pid(leader, tsk, PIDTYPE_PGID); | 706 | transfer_pid(leader, tsk, PIDTYPE_PGID); |
707 | transfer_pid(leader, tsk, PIDTYPE_SID); | 707 | transfer_pid(leader, tsk, PIDTYPE_SID); |
708 | list_replace_rcu(&leader->tasks, &tsk->tasks); | 708 | list_replace_rcu(&leader->tasks, &tsk->tasks); |
diff --git a/include/linux/pid.h b/include/linux/pid.h index 2ac27f9997dd..33d343880d89 100644 --- a/include/linux/pid.h +++ b/include/linux/pid.h | |||
@@ -76,8 +76,7 @@ extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type); | |||
76 | * write-held. | 76 | * write-held. |
77 | */ | 77 | */ |
78 | extern int FASTCALL(attach_pid(struct task_struct *task, | 78 | extern int FASTCALL(attach_pid(struct task_struct *task, |
79 | enum pid_type type, int nr)); | 79 | enum pid_type type, struct pid *pid)); |
80 | |||
81 | extern void FASTCALL(detach_pid(struct task_struct *task, enum pid_type)); | 80 | extern void FASTCALL(detach_pid(struct task_struct *task, enum pid_type)); |
82 | extern void FASTCALL(transfer_pid(struct task_struct *old, | 81 | extern void FASTCALL(transfer_pid(struct task_struct *old, |
83 | struct task_struct *new, enum pid_type)); | 82 | struct task_struct *new, enum pid_type)); |
diff --git a/kernel/exit.c b/kernel/exit.c index 7a5fd77f8fb0..e93691e9b325 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -302,12 +302,12 @@ void __set_special_pids(pid_t session, pid_t pgrp) | |||
302 | if (process_session(curr) != session) { | 302 | if (process_session(curr) != session) { |
303 | detach_pid(curr, PIDTYPE_SID); | 303 | detach_pid(curr, PIDTYPE_SID); |
304 | set_signal_session(curr->signal, session); | 304 | set_signal_session(curr->signal, session); |
305 | attach_pid(curr, PIDTYPE_SID, session); | 305 | attach_pid(curr, PIDTYPE_SID, find_pid(session)); |
306 | } | 306 | } |
307 | if (process_group(curr) != pgrp) { | 307 | if (process_group(curr) != pgrp) { |
308 | detach_pid(curr, PIDTYPE_PGID); | 308 | detach_pid(curr, PIDTYPE_PGID); |
309 | curr->signal->pgrp = pgrp; | 309 | curr->signal->pgrp = pgrp; |
310 | attach_pid(curr, PIDTYPE_PGID, pgrp); | 310 | attach_pid(curr, PIDTYPE_PGID, find_pid(pgrp)); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
diff --git a/kernel/fork.c b/kernel/fork.c index da92e01aba6b..6031800c94cf 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1249,16 +1249,19 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1249 | __ptrace_link(p, current->parent); | 1249 | __ptrace_link(p, current->parent); |
1250 | 1250 | ||
1251 | if (thread_group_leader(p)) { | 1251 | if (thread_group_leader(p)) { |
1252 | pid_t pgid = process_group(current); | ||
1253 | pid_t sid = process_session(current); | ||
1254 | |||
1252 | p->signal->tty = current->signal->tty; | 1255 | p->signal->tty = current->signal->tty; |
1253 | p->signal->pgrp = process_group(current); | 1256 | p->signal->pgrp = pgid; |
1254 | set_signal_session(p->signal, process_session(current)); | 1257 | set_signal_session(p->signal, process_session(current)); |
1255 | attach_pid(p, PIDTYPE_PGID, process_group(p)); | 1258 | attach_pid(p, PIDTYPE_PGID, find_pid(pgid)); |
1256 | attach_pid(p, PIDTYPE_SID, process_session(p)); | 1259 | attach_pid(p, PIDTYPE_SID, find_pid(sid)); |
1257 | 1260 | ||
1258 | list_add_tail_rcu(&p->tasks, &init_task.tasks); | 1261 | list_add_tail_rcu(&p->tasks, &init_task.tasks); |
1259 | __get_cpu_var(process_counts)++; | 1262 | __get_cpu_var(process_counts)++; |
1260 | } | 1263 | } |
1261 | attach_pid(p, PIDTYPE_PID, p->pid); | 1264 | attach_pid(p, PIDTYPE_PID, find_pid(p->pid)); |
1262 | nr_threads++; | 1265 | nr_threads++; |
1263 | } | 1266 | } |
1264 | 1267 | ||
diff --git a/kernel/pid.c b/kernel/pid.c index d3ad724afa83..d76f59326bd4 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -247,13 +247,16 @@ struct pid * fastcall find_pid(int nr) | |||
247 | } | 247 | } |
248 | EXPORT_SYMBOL_GPL(find_pid); | 248 | EXPORT_SYMBOL_GPL(find_pid); |
249 | 249 | ||
250 | int fastcall attach_pid(struct task_struct *task, enum pid_type type, int nr) | 250 | /* |
251 | * attach_pid() must be called with the tasklist_lock write-held. | ||
252 | */ | ||
253 | int fastcall attach_pid(struct task_struct *task, enum pid_type type, | ||
254 | struct pid *pid) | ||
251 | { | 255 | { |
252 | struct pid_link *link; | 256 | struct pid_link *link; |
253 | struct pid *pid; | ||
254 | 257 | ||
255 | link = &task->pids[type]; | 258 | link = &task->pids[type]; |
256 | link->pid = pid = find_pid(nr); | 259 | link->pid = pid; |
257 | hlist_add_head_rcu(&link->node, &pid->tasks[type]); | 260 | hlist_add_head_rcu(&link->node, &pid->tasks[type]); |
258 | 261 | ||
259 | return 0; | 262 | return 0; |
diff --git a/kernel/sys.c b/kernel/sys.c index df4c3a8f5df9..872271ccc384 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -1488,7 +1488,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid) | |||
1488 | if (process_group(p) != pgid) { | 1488 | if (process_group(p) != pgid) { |
1489 | detach_pid(p, PIDTYPE_PGID); | 1489 | detach_pid(p, PIDTYPE_PGID); |
1490 | p->signal->pgrp = pgid; | 1490 | p->signal->pgrp = pgid; |
1491 | attach_pid(p, PIDTYPE_PGID, pgid); | 1491 | attach_pid(p, PIDTYPE_PGID, find_pid(pgid)); |
1492 | } | 1492 | } |
1493 | 1493 | ||
1494 | err = 0; | 1494 | err = 0; |