--- linux-2.6.18.2/arch/alpha/kernel/entry.S 2006-09-20 16:57:57 +0200 +++ linux-2.6.18.2-vs2.1.1/arch/alpha/kernel/entry.S 2006-09-25 15:40:02 +0200 @@ -873,24 +873,15 @@ sys_getxgid: .globl sys_getxpid .ent sys_getxpid sys_getxpid: + lda $sp, -16($sp) + stq $26, 0($sp) .prologue 0 - ldq $2, TI_TASK($8) - /* See linux/kernel/timer.c sys_getppid for discussion - about this loop. */ - ldq $3, TASK_GROUP_LEADER($2) - ldq $4, TASK_REAL_PARENT($3) - ldl $0, TASK_TGID($2) -1: ldl $1, TASK_TGID($4) -#ifdef CONFIG_SMP - mov $4, $5 - mb - ldq $3, TASK_GROUP_LEADER($2) - ldq $4, TASK_REAL_PARENT($3) - cmpeq $4, $5, $5 - beq $5, 1b -#endif - stq $1, 80($sp) + lda $16, 96($sp) + jsr $26, do_getxpid + ldq $26, 0($sp) + + lda $sp, 16($sp) ret .end sys_getxpid --- linux-2.6.18.2/arch/sh/kernel/kgdb_stub.c 2004-08-14 12:54:51 +0200 +++ linux-2.6.18.2-vs2.1.1/arch/sh/kernel/kgdb_stub.c 2006-09-20 17:01:44 +0200 @@ -412,7 +412,7 @@ static struct task_struct *get_thread(in if (pid == PID_MAX) pid = 0; /* First check via PID */ - thread = find_task_by_pid(pid); + thread = find_task_by_real_pid(pid); if (thread) return thread; --- linux-2.6.18.2/drivers/char/tty_io.c 2006-09-20 16:58:13 +0200 +++ linux-2.6.18.2-vs2.1.1/drivers/char/tty_io.c 2006-09-25 17:18:30 +0200 @@ -2940,6 +2941,7 @@ static int tiocsctty(struct tty_struct * static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) { + pid_t pgrp; /* * (tty == real_tty) is a cheap way of * testing if the tty is NOT a master pty. --- linux-2.6.18.2/drivers/char/tty_io.c 2006-09-20 16:58:13 +0200 +++ linux-2.6.18.2-vs2.1.1/drivers/char/tty_io.c 2006-09-25 17:18:30 +0200 @@ -2946,7 +2948,9 @@ ***** */ if (tty == real_tty && current->signal->tty != real_tty) return -ENOTTY; - return put_user(real_tty->pgrp, p); + + pgrp = vx_map_pid(real_tty->pgrp); + return put_user(pgrp, p); } /** --- linux-2.6.18.2/drivers/char/tty_io.c 2006-09-20 16:58:13 +0200 +++ linux-2.6.18.2-vs2.1.1/drivers/char/tty_io.c 2006-09-25 17:18:30 +0200 @@ -2978,6 +2982,8 @@ static int tiocspgrp(struct tty_struct * return -ENOTTY; if (get_user(pgrp, p)) return -EFAULT; + + pgrp = vx_rmap_pid(pgrp); if (pgrp < 0) return -EINVAL; if (session_of_pgrp(pgrp) != current->signal->session) --- linux-2.6.18.2/fs/fcntl.c 2006-06-18 04:54:34 +0200 +++ linux-2.6.18.2-vs2.1.1/fs/fcntl.c 2006-09-20 17:01:44 +0200 @@ -479,7 +486,7 @@ void send_sigio(struct fown_struct *fown read_lock(&tasklist_lock); if (pid > 0) { - p = find_task_by_pid(pid); + p = find_task_by_real_pid(pid); if (p) { send_sigio_to_task(p, fown, fd, band); } --- linux-2.6.18.2/fs/fcntl.c 2006-06-18 04:54:34 +0200 +++ linux-2.6.18.2-vs2.1.1/fs/fcntl.c 2006-09-20 17:01:44 +0200 @@ -514,7 +521,7 @@ int send_sigurg(struct fown_struct *fown read_lock(&tasklist_lock); if (pid > 0) { - p = find_task_by_pid(pid); + p = find_task_by_real_pid(pid); if (p) { send_sigurg_to_task(p, fown); } --- linux-2.6.18.2/fs/proc/array.c 2006-09-20 16:58:35 +0200 +++ linux-2.6.18.2-vs2.1.1/fs/proc/array.c 2006-10-25 03:39:09 +0200 @@ -161,8 +166,13 @@ static inline char * task_state(struct t struct group_info *group_info; int g; struct fdtable *fdt = NULL; + pid_t pid, ptgid, tppid, tgid; read_lock(&tasklist_lock); + tgid = vx_map_tgid(p->tgid); + pid = vx_map_pid(p->pid); + ptgid = vx_map_pid(p->group_leader->real_parent->tgid); + tppid = vx_map_pid(p->parent->pid); buffer += sprintf(buffer, "State:\t%s\n" "SleepAVG:\t%lu%%\n" --- linux-2.6.18.2/fs/proc/array.c 2006-09-20 16:58:35 +0200 +++ linux-2.6.18.2-vs2.1.1/fs/proc/array.c 2006-10-25 03:39:09 +0200 @@ -174,9 +184,8 @@ static inline char * task_state(struct t "Gid:\t%d\t%d\t%d\t%d\n", get_task_state(p), (p->sleep_avg/1024)*100/(1020000000/1024), - p->tgid, - p->pid, pid_alive(p) ? p->group_leader->real_parent->tgid : 0, - pid_alive(p) && p->ptrace ? p->parent->pid : 0, + tgid, pid, (pid > 1) ? ptgid : 0, + pid_alive(p) && p->ptrace ? tppid : 0, p->uid, p->euid, p->suid, p->fsuid, p->gid, p->egid, p->sgid, p->fsgid); read_unlock(&tasklist_lock); --- linux-2.6.18.2/fs/proc/array.c 2006-09-20 16:58:35 +0200 +++ linux-2.6.18.2-vs2.1.1/fs/proc/array.c 2006-10-25 03:39:09 +0200 @@ -322,7 +380,7 @@ static int do_task_stat(struct task_stru sigset_t sigign, sigcatch; char state; int res; - pid_t ppid, pgid = -1, sid = -1; + pid_t pid, ppid, pgid = -1, sid = -1; int num_threads = 0; struct mm_struct *mm; unsigned long long start_time; --- linux-2.6.18.2/fs/proc/array.c 2006-09-20 16:58:35 +0200 +++ linux-2.6.18.2-vs2.1.1/fs/proc/array.c 2006-10-25 03:39:09 +0200 @@ -386,7 +444,11 @@ static int do_task_stat(struct task_stru stime = cputime_add(stime, task->signal->stime); } } - ppid = pid_alive(task) ? task->group_leader->real_parent->tgid : 0; + pid = vx_info_map_pid(task->vx_info, pid_alive(task) ? task->pid : 0); + ppid = (!(pid > 1)) ? 0 : vx_info_map_tgid(task->vx_info, + task->group_leader->real_parent->tgid); + pgid = vx_info_map_pid(task->vx_info, pgid); + read_unlock(&tasklist_lock); if (!whole || num_threads<2) --- linux-2.6.18.2/fs/proc/array.c 2006-09-20 16:58:35 +0200 +++ linux-2.6.18.2-vs2.1.1/fs/proc/array.c 2006-10-25 03:39:09 +0200 @@ -413,7 +486,7 @@ ***** res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \ %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \ %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu %llu\n", - task->pid, + pid, tcomm, state, ppid, --- linux-2.6.18.2/fs/proc/base.c 2006-09-20 16:58:35 +0200 +++ linux-2.6.18.2-vs2.1.1/fs/proc/base.c 2006-10-28 16:47:17 +0200 @@ -2050,7 +2107,7 @@ struct dentry *proc_pid_lookup(struct in goto out; rcu_read_lock(); - task = find_task_by_pid(tgid); + task = find_proc_task_by_pid(tgid); if (task) get_task_struct(task); rcu_read_unlock(); --- linux-2.6.18.2/fs/proc/base.c 2006-09-20 16:58:35 +0200 +++ linux-2.6.18.2-vs2.1.1/fs/proc/base.c 2006-10-28 16:47:17 +0200 @@ -2099,9 +2156,11 @@ static struct dentry *proc_task_lookup(s tid = name_to_int(dentry); if (tid == ~0U) goto out; + if (vx_current_initpid(tid)) + goto out; rcu_read_lock(); - task = find_task_by_pid(tid); + task = find_proc_task_by_pid(tid); if (task) get_task_struct(task); rcu_read_unlock(); --- linux-2.6.18.2/fs/proc/base.c 2006-09-20 16:58:35 +0200 +++ linux-2.6.18.2-vs2.1.1/fs/proc/base.c 2006-10-28 16:47:17 +0200 @@ -2157,7 +2216,7 @@ static struct task_struct *first_tgid(in struct task_struct *pos; rcu_read_lock(); if (tgid && nr) { - pos = find_task_by_pid(tgid); + pos = find_proc_task_by_pid(tgid); if (pos && thread_group_leader(pos)) goto found; } --- linux-2.6.18.2/fs/proc/base.c 2006-09-20 16:58:35 +0200 +++ linux-2.6.18.2-vs2.1.1/fs/proc/base.c 2006-10-28 16:47:17 +0200 @@ -2268,7 +2330,7 @@ static struct task_struct *first_tid(str rcu_read_lock(); /* Attempt to start with the pid of a thread */ if (tid && (nr > 0)) { - pos = find_task_by_pid(tid); + pos = find_proc_task_by_pid(tid); if (pos && (pos->group_leader == leader)) goto found; } --- linux-2.6.18.2/include/linux/pid.h 2006-06-18 04:55:21 +0200 +++ linux-2.6.18.2-vs2.1.1/include/linux/pid.h 2006-10-06 23:09:03 +0200 @@ -8,7 +8,8 @@ enum pid_type PIDTYPE_PID, PIDTYPE_PGID, PIDTYPE_SID, - PIDTYPE_MAX + PIDTYPE_MAX, + PIDTYPE_REALPID }; /* --- linux-2.6.18.2/include/linux/sched.h 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/include/linux/sched.h 2006-10-06 23:09:03 +0200 @@ -1162,7 +1178,12 @@ extern struct task_struct init_task; extern struct mm_struct init_mm; -#define find_task_by_pid(nr) find_task_by_pid_type(PIDTYPE_PID, nr) + +#define find_task_by_real_pid(nr) \ + find_task_by_pid_type(PIDTYPE_REALPID, nr) +#define find_task_by_pid(nr) \ + find_task_by_pid_type(PIDTYPE_PID, nr) + extern struct task_struct *find_task_by_pid_type(int type, int pid); extern void set_special_pids(pid_t session, pid_t pgrp); extern void __set_special_pids(pid_t session, pid_t pgrp); --- linux-2.6.18.2/kernel/exit.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/exit.c 2006-10-28 18:31:23 +0200 @@ -587,6 +592,11 @@ static void exit_mm(struct task_struct * static inline void choose_new_parent(struct task_struct *p, struct task_struct *reaper) { + /* check for reaper context */ + vxwprintk((p->xid != reaper->xid) && (reaper != child_reaper), + "rogue reaper: %p[%d,#%u] <> %p[%d,#%u]", + p, p->pid, p->xid, reaper, reaper->pid, reaper->xid); + /* * Make sure we're not reparenting to ourselves and that * the parent is not a zombie. --- linux-2.6.18.2/kernel/exit.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/exit.c 2006-10-28 18:31:23 +0200 @@ -669,7 +679,7 @@ forget_original_parent(struct task_struc do { reaper = next_thread(reaper); if (reaper == father) { - reaper = child_reaper; + reaper = vx_child_reaper(father); break; } } while (reaper->exit_state); --- linux-2.6.18.2/kernel/exit.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/exit.c 2006-10-28 18:31:23 +0200 @@ -693,7 +703,7 @@ forget_original_parent(struct task_struc if (father == p->real_parent) { /* reparent with a reaper, real father it's us */ - choose_new_parent(p, reaper); + choose_new_parent(p, vx_child_reaper(p)); reparent_thread(p, father, 0); } else { /* reparent ptraced task to its real parent */ --- linux-2.6.18.2/kernel/kthread.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/kthread.c 2006-09-20 17:01:45 +0200 @@ -123,7 +123,7 @@ static void keventd_create_kthread(void } else { wait_for_completion(&create->started); read_lock(&tasklist_lock); - create->result = find_task_by_pid(pid); + create->result = find_task_by_real_pid(pid); read_unlock(&tasklist_lock); } complete(&create->done); --- linux-2.6.18.2/kernel/pid.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/pid.c 2006-10-29 20:12:58 +0100 @@ -260,6 +261,14 @@ struct task_struct * fastcall pid_task(s first = rcu_dereference(pid->tasks[type].first); if (first) result = hlist_entry(first, struct task_struct, pids[(type)].node); + if (result && (pid->nr != 1) && + !vx_check(vx_task_xid(result), VX_WATCH|VX_ADMIN|VX_IDENT)) { + vxwprintk((type == PIDTYPE_PID) && (current->xid), + "pid_task(%d,%d): task %p[#%u,%u] did lookup %p[#%u,%u]", + pid->nr, type, current, vx_current_xid(), current->pid, + result, vx_task_xid(result), result->pid); + result = NULL; + } } return result; } --- linux-2.6.18.2/kernel/pid.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/pid.c 2006-10-29 20:12:58 +0100 @@ -269,6 +278,10 @@ struct task_struct * fastcall pid_task(s */ struct task_struct *find_task_by_pid_type(int type, int nr) { + if (type == PIDTYPE_PID) + nr = vx_rmap_pid(nr); + else if (type == PIDTYPE_REALPID) + type = PIDTYPE_PID; return pid_task(find_pid(nr), type); } --- linux-2.6.18.2/kernel/posix-timers.c 2006-06-18 04:55:31 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/posix-timers.c 2006-10-06 23:10:42 +0200 @@ -372,7 +381,7 @@ static struct task_struct * good_sigeven struct task_struct *rtn = current->group_leader; if ((event->sigev_notify & SIGEV_THREAD_ID ) && - (!(rtn = find_task_by_pid(event->sigev_notify_thread_id)) || + (!(rtn = find_task_by_real_pid(event->sigev_notify_thread_id)) || rtn->tgid != current->tgid || (event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL)) return NULL; --- linux-2.6.18.2/kernel/signal.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/signal.c 2006-10-25 03:39:09 +0200 @@ -1839,6 +1854,11 @@ relock: if (current == child_reaper) continue; + /* virtual init is protected against user signals */ + if ((info->si_code == SI_USER) && + vx_current_initpid(current->pid)) + continue; + if (sig_kernel_stop(signr)) { /* * The default action is to stop all threads in --- linux-2.6.18.2/kernel/sys.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/sys.c 2006-09-25 15:40:02 +0200 @@ -1251,6 +1265,7 @@ asmlinkage long sys_setpgid(pid_t pid, p { struct task_struct *p; struct task_struct *group_leader = current->group_leader; + pid_t rpgid; int err = -EINVAL; if (!pid) --- linux-2.6.18.2/kernel/sys.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/sys.c 2006-09-25 15:40:02 +0200 @@ -1254,7 +1269,7 @@ ***** int err = -EINVAL; if (!pid) - pid = group_leader->pid; + pid = vx_map_pid(group_leader->pid); if (!pgid) pgid = pid; if (pgid < 0) --- linux-2.6.18.2/kernel/sys.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/sys.c 2006-09-25 15:40:02 +0200 @@ -1260,6 +1275,8 @@ ***** if (pgid < 0) return -EINVAL; + rpgid = vx_rmap_pid(pgid); + /* From this point forward we keep holding onto the tasklist lock * so that our parent does not change from under us. -DaveM */ --- linux-2.6.18.2/kernel/sys.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/sys.c 2006-09-25 15:40:02 +0200 @@ -1294,10 +1311,10 @@ asmlinkage long sys_setpgid(pid_t pid, p if (pgid != pid) { struct task_struct *p; - do_each_task_pid(pgid, PIDTYPE_PGID, p) { + do_each_task_pid(rpgid, PIDTYPE_PGID, p) { if (p->signal->session == group_leader->signal->session) goto ok_pgid; - } while_each_task_pid(pgid, PIDTYPE_PGID, p); + } while_each_task_pid(rpgid, PIDTYPE_PGID, p); goto out; } --- linux-2.6.18.2/kernel/sys.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/sys.c 2006-09-25 15:40:02 +0200 @@ -1302,7 +1319,7 @@ ***** } ok_pgid: - err = security_task_setpgid(p, pgid); + err = security_task_setpgid(p, rpgid); if (err) goto out; --- linux-2.6.18.2/kernel/sys.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/sys.c 2006-09-25 15:40:02 +0200 @@ -1306,10 +1323,10 @@ ***** if (err) goto out; - if (process_group(p) != pgid) { + if (process_group(p) != rpgid) { detach_pid(p, PIDTYPE_PGID); - p->signal->pgrp = pgid; - attach_pid(p, PIDTYPE_PGID, pgid); + p->signal->pgrp = rpgid; + attach_pid(p, PIDTYPE_PGID, rpgid); } err = 0; --- linux-2.6.18.2/kernel/sys.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/sys.c 2006-09-25 15:40:02 +0200 @@ -1322,7 +1339,7 @@ out: asmlinkage long sys_getpgid(pid_t pid) { if (!pid) { - return process_group(current); + return vx_rmap_pid(process_group(current)); } else { int retval; struct task_struct *p; --- linux-2.6.18.2/kernel/sys.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/sys.c 2006-09-25 15:40:02 +0200 @@ -1334,7 +1351,7 @@ asmlinkage long sys_getpgid(pid_t pid) if (p) { retval = security_task_getpgid(p); if (!retval) - retval = process_group(p); + retval = vx_rmap_pid(process_group(p)); } read_unlock(&tasklist_lock); return retval; --- linux-2.6.18.2/kernel/timer.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/timer.c 2006-11-03 00:38:37 +0100 @@ -1302,12 +1305,6 @@ asmlinkage unsigned long sys_alarm(unsig #endif -#ifndef __alpha__ - -/* - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this - * should be moved into arch/i386 instead? - */ /** * sys_getpid - return the thread group id of the current process --- linux-2.6.18.2/kernel/timer.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/timer.c 2006-11-03 00:38:37 +0100 @@ -1320,7 +1317,7 @@ asmlinkage unsigned long sys_alarm(unsig */ asmlinkage long sys_getpid(void) { - return current->tgid; + return vx_map_tgid(current->tgid); } /* --- linux-2.6.18.2/kernel/timer.c 2006-09-20 16:58:44 +0200 +++ linux-2.6.18.2-vs2.1.1/kernel/timer.c 2006-11-03 00:38:37 +0100 @@ -1336,10 +1333,23 @@ asmlinkage long sys_getppid(void) rcu_read_lock(); pid = rcu_dereference(current->real_parent)->tgid; rcu_read_unlock(); + return vx_map_pid(pid); +} - return pid; +#ifdef __alpha__ + +/* + * The Alpha uses getxpid, getxuid, and getxgid instead. + */ + +asmlinkage long do_getxpid(long *ppid) +{ + *ppid = sys_getppid(); + return sys_getpid(); } +#else /* _alpha_ */ + asmlinkage long sys_getuid(void) { /* Only we change this so SMP safe */