diff options
author | Oleg Nesterov <oleg@tv-sign.ru> | 2006-12-08 02:38:02 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-08 08:28:52 -0800 |
commit | f020bc468fe4a91d32046d448511978c7b611315 (patch) | |
tree | 30fb5d6f149425c7d30fa9a8540a517f1cb911c4 | |
parent | 84d737866e2babdeab0c6b18ea155c6a649663b8 (diff) |
[PATCH] sys_setpgid: eliminate unnecessary do_each_task_pid(PIDTYPE_PGID)
All tasks in the process group have the same sid, we don't need to iterate
them all to check that the caller of sys_setpgid() doesn't change its
session.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | kernel/sys.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index 4f9d23a3095..c7675c1bfdf 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1397,16 +1397,13 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid) goto out; if (pgid != pid) { - struct task_struct *p; + struct task_struct *g = + find_task_by_pid_type(PIDTYPE_PGID, pgid); - do_each_task_pid(pgid, PIDTYPE_PGID, p) { - if (process_session(p) == process_session(group_leader)) - goto ok_pgid; - } while_each_task_pid(pgid, PIDTYPE_PGID, p); - goto out; + if (!g || process_session(g) != process_session(group_leader)) + goto out; } -ok_pgid: err = security_task_setpgid(p, pgid); if (err) goto out; |