--- linux-2.6.16-rc4/arch/alpha/kernel/ptrace.c 2006-02-18 14:39:40 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/arch/alpha/kernel/ptrace.c 2006-02-17 23:26:32 +0100 @@ -15,6 +15,7 @@ #include #include #include +#include #include #include --- linux-2.6.16-rc4/mm/mempolicy.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/mempolicy.c 2006-02-18 15:33:58 +0100 @@ -86,6 +86,7 @@ #include #include #include +#include #include #include --- linux-2.6.16-rc4/arch/ia64/kernel/ptrace.c 2006-02-18 14:39:43 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/arch/ia64/kernel/ptrace.c 2006-02-17 23:26:32 +0100 @@ -18,6 +18,7 @@ #include #include #include +#include #include #include --- linux-2.6.16-rc4/arch/sparc/kernel/ptrace.c 2006-02-18 14:39:49 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/arch/sparc/kernel/ptrace.c 2006-02-17 23:26:32 +0100 @@ -19,6 +19,7 @@ #include #include #include +#include #include #include --- linux-2.6.16-rc4/arch/sparc64/kernel/ptrace.c 2006-02-18 14:39:49 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/arch/sparc64/kernel/ptrace.c 2006-02-17 23:26:32 +0100 @@ -22,6 +22,7 @@ #include #include #include +#include #include #include --- linux-2.6.16-rc4/kernel/signal.c 2006-02-18 14:40:37 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/signal.c 2006-02-20 22:02:55 +0100 @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include --- linux-2.6.16-rc4/kernel/ptrace.c 2006-02-18 14:40:37 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/ptrace.c 2006-02-18 15:33:58 +0100 @@ -18,6 +18,7 @@ #include #include #include +#include #include #include --- linux-2.6.16-rc4/arch/alpha/kernel/entry.S 2006-02-18 14:39:40 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/arch/alpha/kernel/entry.S 2006-02-17 23:26:32 +0100 @@ -874,24 +874,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.16-rc4/arch/sh/kernel/kgdb_stub.c 2004-08-14 12:54:51 +0200 +++ linux-2.6.16-rc4-vs2.1.1-rc8/arch/sh/kernel/kgdb_stub.c 2006-02-17 23:26:32 +0100 @@ -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.16-rc4/drivers/char/tty_io.c 2006-02-18 14:39:54 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/drivers/char/tty_io.c 2006-02-18 15:33:51 +0100 @@ -2381,6 +2382,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.16-rc4/drivers/char/tty_io.c 2006-02-18 14:39:54 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/drivers/char/tty_io.c 2006-02-18 15:33:51 +0100 @@ -2387,7 +2389,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); } static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) --- linux-2.6.16-rc4/drivers/char/tty_io.c 2006-02-18 14:39:54 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/drivers/char/tty_io.c 2006-02-18 15:33:51 +0100 @@ -2405,6 +2409,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.16-rc4/fs/fcntl.c 2006-02-18 14:40:22 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/fcntl.c 2006-02-17 23:26:32 +0100 @@ -481,7 +488,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.16-rc4/fs/fcntl.c 2006-02-18 14:40:22 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/fcntl.c 2006-02-17 23:26:32 +0100 @@ -516,7 +523,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.16-rc4/fs/proc/array.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/proc/array.c 2006-02-17 23:26:32 +0100 @@ -161,8 +167,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.16-rc4/fs/proc/array.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/proc/array.c 2006-02-17 23:26:32 +0100 @@ -174,9 +185,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.16-rc4/fs/proc/array.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/proc/array.c 2006-02-17 23:26:32 +0100 @@ -322,7 +378,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.16-rc4/fs/proc/array.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/proc/array.c 2006-02-17 23:26:32 +0100 @@ -388,7 +444,11 @@ static int do_task_stat(struct task_stru } it_real_value = task->signal->real_timer.expires; } - 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.16-rc4/fs/proc/array.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/proc/array.c 2006-02-17 23:26:32 +0100 @@ -415,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 %ld %llu %lu %ld %lu %lu %lu %lu %lu \ %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu\n", - task->pid, + pid, tcomm, state, ppid, --- linux-2.6.16-rc4/fs/proc/base.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/proc/base.c 2006-02-17 23:26:32 +0100 @@ -2035,6 +2106,8 @@ static struct dentry *proc_task_lookup(s tid = name_to_int(dentry); if (tid == ~0U) goto out; + if (vx_current_initpid(tid)) + goto out; read_lock(&tasklist_lock); task = find_task_by_pid(tid); --- linux-2.6.16-rc4/fs/proc/base.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/proc/base.c 2006-02-17 23:26:32 +0100 @@ -2090,7 +2166,7 @@ static int get_tgid_list(int index, unsi read_lock(&tasklist_lock); p = NULL; if (version) { - p = find_task_by_pid(version); + p = find_task_by_real_pid(version); if (p && !thread_group_leader(p)) p = NULL; } --- linux-2.6.16-rc4/fs/proc/base.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/proc/base.c 2006-02-17 23:26:32 +0100 @@ -2102,11 +2178,15 @@ static int get_tgid_list(int index, unsi for ( ; p != &init_task; p = next_task(p)) { int tgid = p->pid; + if (!pid_alive(p)) continue; + /* check for context visibility */ + if (!proc_pid_visible(p, tgid)) + continue; if (--index >= 0) continue; - tgids[nr_tgids] = tgid; + tgids[nr_tgids] = vx_map_tgid(tgid); nr_tgids++; if (nr_tgids >= PROC_MAXPIDS) break; --- linux-2.6.16-rc4/fs/proc/base.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/proc/base.c 2006-02-17 23:26:32 +0100 @@ -2136,6 +2216,9 @@ static int get_tid_list(int index, unsig if (pid_alive(task)) do { int tid = task->pid; + /* check for context visibility */ + if (!proc_pid_visible(task, tid)) + continue; if (--index >= 0) continue; if (tids != NULL) --- linux-2.6.16-rc4/fs/proc/base.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/proc/base.c 2006-02-17 23:26:32 +0100 @@ -2139,7 +2222,7 @@ ***** if (--index >= 0) continue; if (tids != NULL) - tids[nr_tids] = tid; + tids[nr_tids] = vx_map_pid(tid); nr_tids++; if (nr_tids >= PROC_MAXPIDS) break; --- linux-2.6.16-rc4/include/linux/sched.h 2006-02-18 14:40:35 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/include/linux/sched.h 2006-02-18 15:33:57 +0100 @@ -1020,7 +1036,13 @@ 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_PID, nr) +#define find_task_by_pid(nr) \ + find_task_by_pid_type(PIDTYPE_PID, \ + vx_rmap_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.16-rc4/kernel/kthread.c 2006-01-03 17:30:12 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/kthread.c 2006-02-17 23:26:33 +0100 @@ -114,7 +114,7 @@ static void keventd_create_kthread(void create->result = ERR_PTR(pid); } else { wait_for_completion(&create->started); - create->result = find_task_by_pid(pid); + create->result = find_task_by_real_pid(pid); } complete(&create->done); } --- linux-2.6.16-rc4/kernel/posix-timers.c 2006-02-18 14:40:37 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/posix-timers.c 2006-02-17 23:26:33 +0100 @@ -365,7 +375,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.16-rc4/kernel/sys.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/sys.c 2006-02-17 23:26:33 +0100 @@ -1099,6 +1115,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.16-rc4/kernel/sys.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/sys.c 2006-02-17 23:26:33 +0100 @@ -1108,6 +1125,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.16-rc4/kernel/sys.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/sys.c 2006-02-17 23:26:33 +0100 @@ -1142,10 +1161,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.16-rc4/kernel/sys.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/sys.c 2006-02-17 23:26:33 +0100 @@ -1150,7 +1169,7 @@ ***** } ok_pgid: - err = security_task_setpgid(p, pgid); + err = security_task_setpgid(p, rpgid); if (err) goto out; --- linux-2.6.16-rc4/kernel/sys.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/sys.c 2006-02-17 23:26:33 +0100 @@ -1154,10 +1173,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.16-rc4/kernel/sys.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/sys.c 2006-02-17 23:26:33 +0100 @@ -1170,7 +1189,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.16-rc4/kernel/sys.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/sys.c 2006-02-17 23:26:33 +0100 @@ -1182,7 +1201,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.16-rc4/kernel/timer.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/timer.c 2006-02-18 15:33:58 +0100 @@ -954,12 +957,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.16-rc4/kernel/timer.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/timer.c 2006-02-18 15:33:58 +0100 @@ -972,7 +969,7 @@ asmlinkage unsigned long sys_alarm(unsig */ asmlinkage long sys_getpid(void) { - return current->tgid; + return vx_map_tgid(current->tgid); } /* --- linux-2.6.16-rc4/kernel/timer.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/timer.c 2006-02-18 15:33:58 +0100 @@ -1016,9 +1013,23 @@ asmlinkage long sys_getppid(void) #endif break; } - return pid; + return vx_map_pid(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 */ --- linux-2.6.16-rc4/mm/vmscan.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/vmscan.c 2006-02-17 23:26:33 +0100 @@ -1826,7 +1826,7 @@ static int __init kswapd_init(void) swap_setup(); for_each_pgdat(pgdat) pgdat->kswapd - = find_task_by_pid(kernel_thread(kswapd, pgdat, CLONE_KERNEL)); + = find_task_by_real_pid(kernel_thread(kswapd, pgdat, CLONE_KERNEL)); total_memory = nr_free_pagecache_pages(); hotcpu_notifier(cpu_callback, 0); return 0; --- linux-2.6.16-rc4/kernel/exit.c 2006-02-18 14:40:37 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/exit.c 2006-02-20 23:19:58 +0100 @@ -237,6 +241,7 @@ static void reparent_to_init(void) ptrace_unlink(current); /* Reparent to init */ REMOVE_LINKS(current); + /* FIXME: handle vchild_reaper/initpid */ current->parent = child_reaper; current->real_parent = child_reaper; SET_LINKS(current); --- linux-2.6.16-rc4/kernel/exit.c 2006-02-18 14:40:37 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/exit.c 2006-02-20 23:19:58 +0100 @@ -601,6 +610,30 @@ static void reparent_thread(task_t *p, t } } +static inline +struct task_struct *vchild_reaper(struct task_struct *father) +{ + struct vx_info *vxi; + struct task_struct *reaper, *init; + + reaper = child_reaper; + vxi = task_get_vx_info(father); + if (!vxi) + goto out; + + if (!vxi->vx_initpid) + goto out_put; + + init = find_task_by_real_pid(vxi->vx_initpid); + if (init && (init != father)) + reaper = init; + +out_put: + put_vx_info(vxi); +out: + return reaper; +} + /* * When we die, we re-parent all our children. * Try to give them to another thread in our thread --- linux-2.6.16-rc4/kernel/exit.c 2006-02-18 14:40:37 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/exit.c 2006-02-20 23:19:58 +0100 @@ -613,6 +646,7 @@ static void forget_original_parent(struc struct task_struct *p, *reaper = father; struct list_head *_p, *_n; + /* FIXME: handle vchild_reaper/initpid */ do { reaper = next_thread(reaper); if (reaper == father) { --- linux-2.6.16-rc4/kernel/exit.c 2006-02-18 14:40:37 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/exit.c 2006-02-20 23:19:58 +0100 @@ -616,7 +650,7 @@ ***** do { reaper = next_thread(reaper); if (reaper == father) { - reaper = child_reaper; + reaper = vchild_reaper(father); break; } } while (reaper->exit_state); --- linux-2.6.16-rc4/kernel/signal.c 2006-02-18 14:40:37 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/kernel/signal.c 2006-02-20 22:02:55 +0100 @@ -1991,6 +2001,11 @@ relock: if (current->pid == 1) 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