aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorCedric Le Goater <clg@fr.ibm.com>2006-12-08 05:37:54 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:28:51 -0500
commit937949d9edbf4049bd41af6c9f92c26280584564 (patch)
treed0a28f503b082f890cfa1f7fe952fda8fc771752 /kernel
parentef55d53caa055aedee13e77da82740987dd64f2d (diff)
[PATCH] add process_session() helper routine
Replace occurences of task->signal->session by a new process_session() helper routine. It will be useful for pid namespaces to abstract the session pid number. Signed-off-by: Cedric Le Goater <clg@fr.ibm.com> Cc: Kirill Korotaev <dev@openvz.org> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/exit.c19
-rw-r--r--kernel/fork.c4
-rw-r--r--kernel/signal.c2
-rw-r--r--kernel/sys.c8
4 files changed, 17 insertions, 16 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index fa0495e167e9..8d289bfc13d1 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -193,14 +193,14 @@ int session_of_pgrp(int pgrp)
193 193
194 read_lock(&tasklist_lock); 194 read_lock(&tasklist_lock);
195 do_each_task_pid(pgrp, PIDTYPE_PGID, p) { 195 do_each_task_pid(pgrp, PIDTYPE_PGID, p) {
196 if (p->signal->session > 0) { 196 if (process_session(p) > 0) {
197 sid = p->signal->session; 197 sid = process_session(p);
198 goto out; 198 goto out;
199 } 199 }
200 } while_each_task_pid(pgrp, PIDTYPE_PGID, p); 200 } while_each_task_pid(pgrp, PIDTYPE_PGID, p);
201 p = find_task_by_pid(pgrp); 201 p = find_task_by_pid(pgrp);
202 if (p) 202 if (p)
203 sid = p->signal->session; 203 sid = process_session(p);
204out: 204out:
205 read_unlock(&tasklist_lock); 205 read_unlock(&tasklist_lock);
206 206
@@ -225,8 +225,8 @@ static int will_become_orphaned_pgrp(int pgrp, struct task_struct *ignored_task)
225 || p->exit_state 225 || p->exit_state
226 || is_init(p->real_parent)) 226 || is_init(p->real_parent))
227 continue; 227 continue;
228 if (process_group(p->real_parent) != pgrp 228 if (process_group(p->real_parent) != pgrp &&
229 && p->real_parent->signal->session == p->signal->session) { 229 process_session(p->real_parent) == process_session(p)) {
230 ret = 0; 230 ret = 0;
231 break; 231 break;
232 } 232 }
@@ -302,7 +302,7 @@ void __set_special_pids(pid_t session, pid_t pgrp)
302{ 302{
303 struct task_struct *curr = current->group_leader; 303 struct task_struct *curr = current->group_leader;
304 304
305 if (curr->signal->session != session) { 305 if (process_session(curr) != session) {
306 detach_pid(curr, PIDTYPE_SID); 306 detach_pid(curr, PIDTYPE_SID);
307 curr->signal->session = session; 307 curr->signal->session = session;
308 attach_pid(curr, PIDTYPE_SID, session); 308 attach_pid(curr, PIDTYPE_SID, session);
@@ -647,10 +647,11 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
647 * outside, so the child pgrp is now orphaned. 647 * outside, so the child pgrp is now orphaned.
648 */ 648 */
649 if ((process_group(p) != process_group(father)) && 649 if ((process_group(p) != process_group(father)) &&
650 (p->signal->session == father->signal->session)) { 650 (process_session(p) == process_session(father))) {
651 int pgrp = process_group(p); 651 int pgrp = process_group(p);
652 652
653 if (will_become_orphaned_pgrp(pgrp, NULL) && has_stopped_jobs(pgrp)) { 653 if (will_become_orphaned_pgrp(pgrp, NULL) &&
654 has_stopped_jobs(pgrp)) {
654 __kill_pg_info(SIGHUP, SEND_SIG_PRIV, pgrp); 655 __kill_pg_info(SIGHUP, SEND_SIG_PRIV, pgrp);
655 __kill_pg_info(SIGCONT, SEND_SIG_PRIV, pgrp); 656 __kill_pg_info(SIGCONT, SEND_SIG_PRIV, pgrp);
656 } 657 }
@@ -784,7 +785,7 @@ static void exit_notify(struct task_struct *tsk)
784 t = tsk->real_parent; 785 t = tsk->real_parent;
785 786
786 if ((process_group(t) != process_group(tsk)) && 787 if ((process_group(t) != process_group(tsk)) &&
787 (t->signal->session == tsk->signal->session) && 788 (process_session(t) == process_session(tsk)) &&
788 will_become_orphaned_pgrp(process_group(tsk), tsk) && 789 will_become_orphaned_pgrp(process_group(tsk), tsk) &&
789 has_stopped_jobs(process_group(tsk))) { 790 has_stopped_jobs(process_group(tsk))) {
790 __kill_pg_info(SIGHUP, SEND_SIG_PRIV, process_group(tsk)); 791 __kill_pg_info(SIGHUP, SEND_SIG_PRIV, process_group(tsk));
diff --git a/kernel/fork.c b/kernel/fork.c
index 597707819327..298c4d6ab512 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1259,9 +1259,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1259 if (thread_group_leader(p)) { 1259 if (thread_group_leader(p)) {
1260 p->signal->tty = current->signal->tty; 1260 p->signal->tty = current->signal->tty;
1261 p->signal->pgrp = process_group(current); 1261 p->signal->pgrp = process_group(current);
1262 p->signal->session = current->signal->session; 1262 p->signal->session = process_session(current);
1263 attach_pid(p, PIDTYPE_PGID, process_group(p)); 1263 attach_pid(p, PIDTYPE_PGID, process_group(p));
1264 attach_pid(p, PIDTYPE_SID, p->signal->session); 1264 attach_pid(p, PIDTYPE_SID, process_session(p));
1265 1265
1266 list_add_tail_rcu(&p->tasks, &init_task.tasks); 1266 list_add_tail_rcu(&p->tasks, &init_task.tasks);
1267 __get_cpu_var(process_counts)++; 1267 __get_cpu_var(process_counts)++;
diff --git a/kernel/signal.c b/kernel/signal.c
index ec81defde339..9eac4db60eda 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -583,7 +583,7 @@ static int check_kill_permission(int sig, struct siginfo *info,
583 error = -EPERM; 583 error = -EPERM;
584 if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info))) 584 if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info)))
585 && ((sig != SIGCONT) || 585 && ((sig != SIGCONT) ||
586 (current->signal->session != t->signal->session)) 586 (process_session(current) != process_session(t)))
587 && (current->euid ^ t->suid) && (current->euid ^ t->uid) 587 && (current->euid ^ t->suid) && (current->euid ^ t->uid)
588 && (current->uid ^ t->suid) && (current->uid ^ t->uid) 588 && (current->uid ^ t->suid) && (current->uid ^ t->uid)
589 && !capable(CAP_KILL)) 589 && !capable(CAP_KILL))
diff --git a/kernel/sys.c b/kernel/sys.c
index 1ac2d1c5d84e..4f9d23a3095f 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1381,7 +1381,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
1381 1381
1382 if (p->real_parent == group_leader) { 1382 if (p->real_parent == group_leader) {
1383 err = -EPERM; 1383 err = -EPERM;
1384 if (p->signal->session != group_leader->signal->session) 1384 if (process_session(p) != process_session(group_leader))
1385 goto out; 1385 goto out;
1386 err = -EACCES; 1386 err = -EACCES;
1387 if (p->did_exec) 1387 if (p->did_exec)
@@ -1400,7 +1400,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
1400 struct task_struct *p; 1400 struct task_struct *p;
1401 1401
1402 do_each_task_pid(pgid, PIDTYPE_PGID, p) { 1402 do_each_task_pid(pgid, PIDTYPE_PGID, p) {
1403 if (p->signal->session == group_leader->signal->session) 1403 if (process_session(p) == process_session(group_leader))
1404 goto ok_pgid; 1404 goto ok_pgid;
1405 } while_each_task_pid(pgid, PIDTYPE_PGID, p); 1405 } while_each_task_pid(pgid, PIDTYPE_PGID, p);
1406 goto out; 1406 goto out;
@@ -1459,7 +1459,7 @@ asmlinkage long sys_getpgrp(void)
1459asmlinkage long sys_getsid(pid_t pid) 1459asmlinkage long sys_getsid(pid_t pid)
1460{ 1460{
1461 if (!pid) 1461 if (!pid)
1462 return current->signal->session; 1462 return process_session(current);
1463 else { 1463 else {
1464 int retval; 1464 int retval;
1465 struct task_struct *p; 1465 struct task_struct *p;
@@ -1471,7 +1471,7 @@ asmlinkage long sys_getsid(pid_t pid)
1471 if (p) { 1471 if (p) {
1472 retval = security_task_getsid(p); 1472 retval = security_task_getsid(p);
1473 if (!retval) 1473 if (!retval)
1474 retval = p->signal->session; 1474 retval = process_session(p);
1475 } 1475 }
1476 read_unlock(&tasklist_lock); 1476 read_unlock(&tasklist_lock);
1477 return retval; 1477 return retval;