Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 84658
b: refs/heads/master
c: 4e02130
h: refs/heads/master
v: v3
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Feb 8, 2008
1 parent 9c3dc16 commit 2d63c4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c543f1ee08ea6c2176dbdc47df0d0f6357c88713
refs/heads/master: 4e021306cff4277764a42065214fc73f2d26be4b
23 changes: 10 additions & 13 deletions trunk/kernel/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,8 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
{
struct task_struct *p;
struct task_struct *group_leader = current->group_leader;
int err = -EINVAL;
struct pid_namespace *ns;
struct pid *pgrp;
int err;

if (!pid)
pid = task_pid_vnr(group_leader);
Expand All @@ -929,20 +929,18 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
/* From this point forward we keep holding onto the tasklist lock
* so that our parent does not change from under us. -DaveM
*/
ns = current->nsproxy->pid_ns;

write_lock_irq(&tasklist_lock);

err = -ESRCH;
p = find_task_by_pid_ns(pid, ns);
p = find_task_by_vpid(pid);
if (!p)
goto out;

err = -EINVAL;
if (!thread_group_leader(p))
goto out;

if (p->real_parent->tgid == group_leader->tgid) {
if (same_thread_group(p->real_parent, group_leader)) {
err = -EPERM;
if (task_session(p) != task_session(group_leader))
goto out;
Expand All @@ -959,10 +957,12 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
if (p->signal->leader)
goto out;

pgrp = task_pid(p);
if (pgid != pid) {
struct task_struct *g;

g = find_task_by_pid_type_ns(PIDTYPE_PGID, pgid, ns);
pgrp = find_vpid(pgid);
g = pid_task(pgrp, PIDTYPE_PGID);
if (!g || task_session(g) != task_session(group_leader))
goto out;
}
Expand All @@ -971,13 +971,10 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
if (err)
goto out;

if (task_pgrp_nr_ns(p, ns) != pgid) {
struct pid *pid;

if (task_pgrp(p) != pgrp) {
detach_pid(p, PIDTYPE_PGID);
pid = find_vpid(pgid);
attach_pid(p, PIDTYPE_PGID, pid);
set_task_pgrp(p, pid_nr(pid));
attach_pid(p, PIDTYPE_PGID, pgrp);
set_task_pgrp(p, pid_nr(pgrp));
}

err = 0;
Expand Down

0 comments on commit 2d63c4d

Please sign in to comment.