diff options
-rw-r--r-- | arch/ia64/kernel/signal.c | 4 | ||||
-rw-r--r-- | arch/parisc/kernel/signal.c | 2 | ||||
-rw-r--r-- | arch/sparc/kernel/sys_sunos.c | 2 | ||||
-rw-r--r-- | arch/sparc64/kernel/sys_sunos32.c | 2 | ||||
-rw-r--r-- | drivers/char/tty_io.c | 7 | ||||
-rw-r--r-- | fs/binfmt_elf.c | 16 | ||||
-rw-r--r-- | fs/binfmt_elf_fdpic.c | 16 | ||||
-rw-r--r-- | fs/exec.c | 4 | ||||
-rw-r--r-- | fs/fcntl.c | 5 | ||||
-rw-r--r-- | fs/ioprio.c | 11 | ||||
-rw-r--r-- | fs/proc/array.c | 27 | ||||
-rw-r--r-- | fs/proc/base.c | 37 | ||||
-rw-r--r-- | include/net/scm.h | 4 | ||||
-rw-r--r-- | ipc/mqueue.c | 7 | ||||
-rw-r--r-- | ipc/msg.c | 6 | ||||
-rw-r--r-- | ipc/sem.c | 8 | ||||
-rw-r--r-- | ipc/shm.c | 6 | ||||
-rw-r--r-- | kernel/capability.c | 14 | ||||
-rw-r--r-- | kernel/exit.c | 31 | ||||
-rw-r--r-- | kernel/fork.c | 2 | ||||
-rw-r--r-- | kernel/futex.c | 27 | ||||
-rw-r--r-- | kernel/futex_compat.c | 4 | ||||
-rw-r--r-- | kernel/ptrace.c | 4 | ||||
-rw-r--r-- | kernel/sched.c | 6 | ||||
-rw-r--r-- | kernel/signal.c | 52 | ||||
-rw-r--r-- | kernel/sys.c | 54 | ||||
-rw-r--r-- | kernel/sysctl.c | 2 | ||||
-rw-r--r-- | kernel/timer.c | 7 | ||||
-rw-r--r-- | mm/mempolicy.c | 4 | ||||
-rw-r--r-- | mm/migrate.c | 4 | ||||
-rw-r--r-- | net/core/scm.c | 4 | ||||
-rw-r--r-- | net/unix/af_unix.c | 6 |
32 files changed, 241 insertions, 144 deletions
diff --git a/arch/ia64/kernel/signal.c b/arch/ia64/kernel/signal.c index aeec8184e862..cdb64cc4d9c8 100644 --- a/arch/ia64/kernel/signal.c +++ b/arch/ia64/kernel/signal.c | |||
@@ -227,7 +227,7 @@ ia64_rt_sigreturn (struct sigscratch *scr) | |||
227 | si.si_signo = SIGSEGV; | 227 | si.si_signo = SIGSEGV; |
228 | si.si_errno = 0; | 228 | si.si_errno = 0; |
229 | si.si_code = SI_KERNEL; | 229 | si.si_code = SI_KERNEL; |
230 | si.si_pid = current->pid; | 230 | si.si_pid = task_pid_vnr(current); |
231 | si.si_uid = current->uid; | 231 | si.si_uid = current->uid; |
232 | si.si_addr = sc; | 232 | si.si_addr = sc; |
233 | force_sig_info(SIGSEGV, &si, current); | 233 | force_sig_info(SIGSEGV, &si, current); |
@@ -332,7 +332,7 @@ force_sigsegv_info (int sig, void __user *addr) | |||
332 | si.si_signo = SIGSEGV; | 332 | si.si_signo = SIGSEGV; |
333 | si.si_errno = 0; | 333 | si.si_errno = 0; |
334 | si.si_code = SI_KERNEL; | 334 | si.si_code = SI_KERNEL; |
335 | si.si_pid = current->pid; | 335 | si.si_pid = task_pid_vnr(current); |
336 | si.si_uid = current->uid; | 336 | si.si_uid = current->uid; |
337 | si.si_addr = addr; | 337 | si.si_addr = addr; |
338 | force_sig_info(SIGSEGV, &si, current); | 338 | force_sig_info(SIGSEGV, &si, current); |
diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c index fb35ebc0c4da..2ce3806f02e1 100644 --- a/arch/parisc/kernel/signal.c +++ b/arch/parisc/kernel/signal.c | |||
@@ -181,7 +181,7 @@ give_sigsegv: | |||
181 | si.si_signo = SIGSEGV; | 181 | si.si_signo = SIGSEGV; |
182 | si.si_errno = 0; | 182 | si.si_errno = 0; |
183 | si.si_code = SI_KERNEL; | 183 | si.si_code = SI_KERNEL; |
184 | si.si_pid = current->pid; | 184 | si.si_pid = task_pid_vnr(current); |
185 | si.si_uid = current->uid; | 185 | si.si_uid = current->uid; |
186 | si.si_addr = &frame->uc; | 186 | si.si_addr = &frame->uc; |
187 | force_sig_info(SIGSEGV, &si, current); | 187 | force_sig_info(SIGSEGV, &si, current); |
diff --git a/arch/sparc/kernel/sys_sunos.c b/arch/sparc/kernel/sys_sunos.c index f807172cab0e..28c187c5d9fd 100644 --- a/arch/sparc/kernel/sys_sunos.c +++ b/arch/sparc/kernel/sys_sunos.c | |||
@@ -866,7 +866,7 @@ asmlinkage int sunos_killpg(int pgrp, int sig) | |||
866 | rcu_read_lock(); | 866 | rcu_read_lock(); |
867 | ret = -EINVAL; | 867 | ret = -EINVAL; |
868 | if (pgrp > 0) | 868 | if (pgrp > 0) |
869 | ret = kill_pgrp(find_pid(pgrp), sig, 0); | 869 | ret = kill_pgrp(find_vpid(pgrp), sig, 0); |
870 | rcu_read_unlock(); | 870 | rcu_read_unlock(); |
871 | 871 | ||
872 | return ret; | 872 | return ret; |
diff --git a/arch/sparc64/kernel/sys_sunos32.c b/arch/sparc64/kernel/sys_sunos32.c index 8f7a06e2c7e7..170d6ca8de6f 100644 --- a/arch/sparc64/kernel/sys_sunos32.c +++ b/arch/sparc64/kernel/sys_sunos32.c | |||
@@ -831,7 +831,7 @@ asmlinkage int sunos_killpg(int pgrp, int sig) | |||
831 | rcu_read_lock(); | 831 | rcu_read_lock(); |
832 | ret = -EINVAL; | 832 | ret = -EINVAL; |
833 | if (pgrp > 0) | 833 | if (pgrp > 0) |
834 | ret = kill_pgrp(find_pid(pgrp), sig, 0); | 834 | ret = kill_pgrp(find_vpid(pgrp), sig, 0); |
835 | rcu_read_unlock(); | 835 | rcu_read_unlock(); |
836 | 836 | ||
837 | return ret; | 837 | return ret; |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 9820f86831ee..e40544947135 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -103,6 +103,7 @@ | |||
103 | #include <linux/selection.h> | 103 | #include <linux/selection.h> |
104 | 104 | ||
105 | #include <linux/kmod.h> | 105 | #include <linux/kmod.h> |
106 | #include <linux/nsproxy.h> | ||
106 | 107 | ||
107 | #undef TTY_DEBUG_HANGUP | 108 | #undef TTY_DEBUG_HANGUP |
108 | 109 | ||
@@ -3107,7 +3108,7 @@ static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t | |||
3107 | */ | 3108 | */ |
3108 | if (tty == real_tty && current->signal->tty != real_tty) | 3109 | if (tty == real_tty && current->signal->tty != real_tty) |
3109 | return -ENOTTY; | 3110 | return -ENOTTY; |
3110 | return put_user(pid_nr(real_tty->pgrp), p); | 3111 | return put_user(pid_vnr(real_tty->pgrp), p); |
3111 | } | 3112 | } |
3112 | 3113 | ||
3113 | /** | 3114 | /** |
@@ -3141,7 +3142,7 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t | |||
3141 | if (pgrp_nr < 0) | 3142 | if (pgrp_nr < 0) |
3142 | return -EINVAL; | 3143 | return -EINVAL; |
3143 | rcu_read_lock(); | 3144 | rcu_read_lock(); |
3144 | pgrp = find_pid(pgrp_nr); | 3145 | pgrp = find_vpid(pgrp_nr); |
3145 | retval = -ESRCH; | 3146 | retval = -ESRCH; |
3146 | if (!pgrp) | 3147 | if (!pgrp) |
3147 | goto out_unlock; | 3148 | goto out_unlock; |
@@ -3178,7 +3179,7 @@ static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t _ | |||
3178 | return -ENOTTY; | 3179 | return -ENOTTY; |
3179 | if (!real_tty->session) | 3180 | if (!real_tty->session) |
3180 | return -ENOTTY; | 3181 | return -ENOTTY; |
3181 | return put_user(pid_nr(real_tty->session), p); | 3182 | return put_user(pid_vnr(real_tty->session), p); |
3182 | } | 3183 | } |
3183 | 3184 | ||
3184 | /** | 3185 | /** |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 9ea2b99dc31a..ba8de7ca260b 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -1383,10 +1383,10 @@ static void fill_prstatus(struct elf_prstatus *prstatus, | |||
1383 | prstatus->pr_info.si_signo = prstatus->pr_cursig = signr; | 1383 | prstatus->pr_info.si_signo = prstatus->pr_cursig = signr; |
1384 | prstatus->pr_sigpend = p->pending.signal.sig[0]; | 1384 | prstatus->pr_sigpend = p->pending.signal.sig[0]; |
1385 | prstatus->pr_sighold = p->blocked.sig[0]; | 1385 | prstatus->pr_sighold = p->blocked.sig[0]; |
1386 | prstatus->pr_pid = p->pid; | 1386 | prstatus->pr_pid = task_pid_vnr(p); |
1387 | prstatus->pr_ppid = p->parent->pid; | 1387 | prstatus->pr_ppid = task_pid_vnr(p->parent); |
1388 | prstatus->pr_pgrp = task_pgrp_nr(p); | 1388 | prstatus->pr_pgrp = task_pgrp_vnr(p); |
1389 | prstatus->pr_sid = task_session_nr(p); | 1389 | prstatus->pr_sid = task_session_vnr(p); |
1390 | if (thread_group_leader(p)) { | 1390 | if (thread_group_leader(p)) { |
1391 | /* | 1391 | /* |
1392 | * This is the record for the group leader. Add in the | 1392 | * This is the record for the group leader. Add in the |
@@ -1429,10 +1429,10 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p, | |||
1429 | psinfo->pr_psargs[i] = ' '; | 1429 | psinfo->pr_psargs[i] = ' '; |
1430 | psinfo->pr_psargs[len] = 0; | 1430 | psinfo->pr_psargs[len] = 0; |
1431 | 1431 | ||
1432 | psinfo->pr_pid = p->pid; | 1432 | psinfo->pr_pid = task_pid_vnr(p); |
1433 | psinfo->pr_ppid = p->parent->pid; | 1433 | psinfo->pr_ppid = task_pid_vnr(p->parent); |
1434 | psinfo->pr_pgrp = task_pgrp_nr(p); | 1434 | psinfo->pr_pgrp = task_pgrp_vnr(p); |
1435 | psinfo->pr_sid = task_session_nr(p); | 1435 | psinfo->pr_sid = task_session_vnr(p); |
1436 | 1436 | ||
1437 | i = p->state ? ffz(~p->state) + 1 : 0; | 1437 | i = p->state ? ffz(~p->state) + 1 : 0; |
1438 | psinfo->pr_state = i; | 1438 | psinfo->pr_state = i; |
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index b8b4e93f6f62..32649f2a1654 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
@@ -1342,10 +1342,10 @@ static void fill_prstatus(struct elf_prstatus *prstatus, | |||
1342 | prstatus->pr_info.si_signo = prstatus->pr_cursig = signr; | 1342 | prstatus->pr_info.si_signo = prstatus->pr_cursig = signr; |
1343 | prstatus->pr_sigpend = p->pending.signal.sig[0]; | 1343 | prstatus->pr_sigpend = p->pending.signal.sig[0]; |
1344 | prstatus->pr_sighold = p->blocked.sig[0]; | 1344 | prstatus->pr_sighold = p->blocked.sig[0]; |
1345 | prstatus->pr_pid = p->pid; | 1345 | prstatus->pr_pid = task_pid_vnr(p); |
1346 | prstatus->pr_ppid = p->parent->pid; | 1346 | prstatus->pr_ppid = task_pid_vnr(p->parent); |
1347 | prstatus->pr_pgrp = task_pgrp_nr(p); | 1347 | prstatus->pr_pgrp = task_pgrp_vnr(p); |
1348 | prstatus->pr_sid = task_session_nr(p); | 1348 | prstatus->pr_sid = task_session_vnr(p); |
1349 | if (thread_group_leader(p)) { | 1349 | if (thread_group_leader(p)) { |
1350 | /* | 1350 | /* |
1351 | * This is the record for the group leader. Add in the | 1351 | * This is the record for the group leader. Add in the |
@@ -1391,10 +1391,10 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p, | |||
1391 | psinfo->pr_psargs[i] = ' '; | 1391 | psinfo->pr_psargs[i] = ' '; |
1392 | psinfo->pr_psargs[len] = 0; | 1392 | psinfo->pr_psargs[len] = 0; |
1393 | 1393 | ||
1394 | psinfo->pr_pid = p->pid; | 1394 | psinfo->pr_pid = task_pid_vnr(p); |
1395 | psinfo->pr_ppid = p->parent->pid; | 1395 | psinfo->pr_ppid = task_pid_vnr(p->parent); |
1396 | psinfo->pr_pgrp = task_pgrp_nr(p); | 1396 | psinfo->pr_pgrp = task_pgrp_vnr(p); |
1397 | psinfo->pr_sid = task_session_nr(p); | 1397 | psinfo->pr_sid = task_session_vnr(p); |
1398 | 1398 | ||
1399 | i = p->state ? ffz(~p->state) + 1 : 0; | 1399 | i = p->state ? ffz(~p->state) + 1 : 0; |
1400 | psinfo->pr_state = i; | 1400 | psinfo->pr_state = i; |
@@ -1433,7 +1433,7 @@ static int format_corename(char *corename, const char *pattern, long signr) | |||
1433 | case 'p': | 1433 | case 'p': |
1434 | pid_in_pattern = 1; | 1434 | pid_in_pattern = 1; |
1435 | rc = snprintf(out_ptr, out_end - out_ptr, | 1435 | rc = snprintf(out_ptr, out_end - out_ptr, |
1436 | "%d", current->tgid); | 1436 | "%d", task_tgid_vnr(current)); |
1437 | if (rc > out_end - out_ptr) | 1437 | if (rc > out_end - out_ptr) |
1438 | goto out; | 1438 | goto out; |
1439 | out_ptr += rc; | 1439 | out_ptr += rc; |
@@ -1513,7 +1513,7 @@ static int format_corename(char *corename, const char *pattern, long signr) | |||
1513 | if (!ispipe && !pid_in_pattern | 1513 | if (!ispipe && !pid_in_pattern |
1514 | && (core_uses_pid || atomic_read(¤t->mm->mm_users) != 1)) { | 1514 | && (core_uses_pid || atomic_read(¤t->mm->mm_users) != 1)) { |
1515 | rc = snprintf(out_ptr, out_end - out_ptr, | 1515 | rc = snprintf(out_ptr, out_end - out_ptr, |
1516 | ".%d", current->tgid); | 1516 | ".%d", task_tgid_vnr(current)); |
1517 | if (rc > out_end - out_ptr) | 1517 | if (rc > out_end - out_ptr) |
1518 | goto out; | 1518 | goto out; |
1519 | out_ptr += rc; | 1519 | out_ptr += rc; |
diff --git a/fs/fcntl.c b/fs/fcntl.c index c9db73fc5e3d..8685263ccc4a 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/ptrace.h> | 18 | #include <linux/ptrace.h> |
19 | #include <linux/signal.h> | 19 | #include <linux/signal.h> |
20 | #include <linux/rcupdate.h> | 20 | #include <linux/rcupdate.h> |
21 | #include <linux/pid_namespace.h> | ||
21 | 22 | ||
22 | #include <asm/poll.h> | 23 | #include <asm/poll.h> |
23 | #include <asm/siginfo.h> | 24 | #include <asm/siginfo.h> |
@@ -292,7 +293,7 @@ int f_setown(struct file *filp, unsigned long arg, int force) | |||
292 | who = -who; | 293 | who = -who; |
293 | } | 294 | } |
294 | rcu_read_lock(); | 295 | rcu_read_lock(); |
295 | pid = find_pid(who); | 296 | pid = find_vpid(who); |
296 | result = __f_setown(filp, pid, type, force); | 297 | result = __f_setown(filp, pid, type, force); |
297 | rcu_read_unlock(); | 298 | rcu_read_unlock(); |
298 | return result; | 299 | return result; |
@@ -308,7 +309,7 @@ pid_t f_getown(struct file *filp) | |||
308 | { | 309 | { |
309 | pid_t pid; | 310 | pid_t pid; |
310 | read_lock(&filp->f_owner.lock); | 311 | read_lock(&filp->f_owner.lock); |
311 | pid = pid_nr(filp->f_owner.pid); | 312 | pid = pid_nr_ns(filp->f_owner.pid, current->nsproxy->pid_ns); |
312 | if (filp->f_owner.pid_type == PIDTYPE_PGID) | 313 | if (filp->f_owner.pid_type == PIDTYPE_PGID) |
313 | pid = -pid; | 314 | pid = -pid; |
314 | read_unlock(&filp->f_owner.lock); | 315 | read_unlock(&filp->f_owner.lock); |
diff --git a/fs/ioprio.c b/fs/ioprio.c index 10d2c211d18b..0a615f87142e 100644 --- a/fs/ioprio.c +++ b/fs/ioprio.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/capability.h> | 25 | #include <linux/capability.h> |
26 | #include <linux/syscalls.h> | 26 | #include <linux/syscalls.h> |
27 | #include <linux/security.h> | 27 | #include <linux/security.h> |
28 | #include <linux/pid_namespace.h> | ||
28 | 29 | ||
29 | static int set_task_ioprio(struct task_struct *task, int ioprio) | 30 | static int set_task_ioprio(struct task_struct *task, int ioprio) |
30 | { | 31 | { |
@@ -93,7 +94,8 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio) | |||
93 | if (!who) | 94 | if (!who) |
94 | p = current; | 95 | p = current; |
95 | else | 96 | else |
96 | p = find_task_by_pid(who); | 97 | p = find_task_by_pid_ns(who, |
98 | current->nsproxy->pid_ns); | ||
97 | if (p) | 99 | if (p) |
98 | ret = set_task_ioprio(p, ioprio); | 100 | ret = set_task_ioprio(p, ioprio); |
99 | break; | 101 | break; |
@@ -101,7 +103,7 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio) | |||
101 | if (!who) | 103 | if (!who) |
102 | pgrp = task_pgrp(current); | 104 | pgrp = task_pgrp(current); |
103 | else | 105 | else |
104 | pgrp = find_pid(who); | 106 | pgrp = find_vpid(who); |
105 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { | 107 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { |
106 | ret = set_task_ioprio(p, ioprio); | 108 | ret = set_task_ioprio(p, ioprio); |
107 | if (ret) | 109 | if (ret) |
@@ -180,7 +182,8 @@ asmlinkage long sys_ioprio_get(int which, int who) | |||
180 | if (!who) | 182 | if (!who) |
181 | p = current; | 183 | p = current; |
182 | else | 184 | else |
183 | p = find_task_by_pid(who); | 185 | p = find_task_by_pid_ns(who, |
186 | current->nsproxy->pid_ns); | ||
184 | if (p) | 187 | if (p) |
185 | ret = get_task_ioprio(p); | 188 | ret = get_task_ioprio(p); |
186 | break; | 189 | break; |
@@ -188,7 +191,7 @@ asmlinkage long sys_ioprio_get(int which, int who) | |||
188 | if (!who) | 191 | if (!who) |
189 | pgrp = task_pgrp(current); | 192 | pgrp = task_pgrp(current); |
190 | else | 193 | else |
191 | pgrp = find_pid(who); | 194 | pgrp = find_vpid(who); |
192 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { | 195 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { |
193 | tmpio = get_task_ioprio(p); | 196 | tmpio = get_task_ioprio(p); |
194 | if (tmpio < 0) | 197 | if (tmpio < 0) |
diff --git a/fs/proc/array.c b/fs/proc/array.c index 24f7f9f6684d..04b689f3288f 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -77,6 +77,7 @@ | |||
77 | #include <linux/cpuset.h> | 77 | #include <linux/cpuset.h> |
78 | #include <linux/rcupdate.h> | 78 | #include <linux/rcupdate.h> |
79 | #include <linux/delayacct.h> | 79 | #include <linux/delayacct.h> |
80 | #include <linux/pid_namespace.h> | ||
80 | 81 | ||
81 | #include <asm/pgtable.h> | 82 | #include <asm/pgtable.h> |
82 | #include <asm/processor.h> | 83 | #include <asm/processor.h> |
@@ -161,8 +162,15 @@ static inline char *task_state(struct task_struct *p, char *buffer) | |||
161 | struct group_info *group_info; | 162 | struct group_info *group_info; |
162 | int g; | 163 | int g; |
163 | struct fdtable *fdt = NULL; | 164 | struct fdtable *fdt = NULL; |
165 | struct pid_namespace *ns; | ||
166 | pid_t ppid, tpid; | ||
164 | 167 | ||
168 | ns = current->nsproxy->pid_ns; | ||
165 | rcu_read_lock(); | 169 | rcu_read_lock(); |
170 | ppid = pid_alive(p) ? | ||
171 | task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; | ||
172 | tpid = pid_alive(p) && p->ptrace ? | ||
173 | task_ppid_nr_ns(rcu_dereference(p->parent), ns) : 0; | ||
166 | buffer += sprintf(buffer, | 174 | buffer += sprintf(buffer, |
167 | "State:\t%s\n" | 175 | "State:\t%s\n" |
168 | "Tgid:\t%d\n" | 176 | "Tgid:\t%d\n" |
@@ -172,9 +180,9 @@ static inline char *task_state(struct task_struct *p, char *buffer) | |||
172 | "Uid:\t%d\t%d\t%d\t%d\n" | 180 | "Uid:\t%d\t%d\t%d\t%d\n" |
173 | "Gid:\t%d\t%d\t%d\t%d\n", | 181 | "Gid:\t%d\t%d\t%d\t%d\n", |
174 | get_task_state(p), | 182 | get_task_state(p), |
175 | p->tgid, p->pid, | 183 | task_tgid_nr_ns(p, ns), |
176 | pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0, | 184 | task_pid_nr_ns(p, ns), |
177 | pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0, | 185 | ppid, tpid, |
178 | p->uid, p->euid, p->suid, p->fsuid, | 186 | p->uid, p->euid, p->suid, p->fsuid, |
179 | p->gid, p->egid, p->sgid, p->fsgid); | 187 | p->gid, p->egid, p->sgid, p->fsgid); |
180 | 188 | ||
@@ -394,6 +402,9 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole) | |||
394 | unsigned long rsslim = 0; | 402 | unsigned long rsslim = 0; |
395 | char tcomm[sizeof(task->comm)]; | 403 | char tcomm[sizeof(task->comm)]; |
396 | unsigned long flags; | 404 | unsigned long flags; |
405 | struct pid_namespace *ns; | ||
406 | |||
407 | ns = current->nsproxy->pid_ns; | ||
397 | 408 | ||
398 | state = *get_task_state(task); | 409 | state = *get_task_state(task); |
399 | vsize = eip = esp = 0; | 410 | vsize = eip = esp = 0; |
@@ -416,7 +427,7 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole) | |||
416 | struct signal_struct *sig = task->signal; | 427 | struct signal_struct *sig = task->signal; |
417 | 428 | ||
418 | if (sig->tty) { | 429 | if (sig->tty) { |
419 | tty_pgrp = pid_nr(sig->tty->pgrp); | 430 | tty_pgrp = pid_nr_ns(sig->tty->pgrp, ns); |
420 | tty_nr = new_encode_dev(tty_devnum(sig->tty)); | 431 | tty_nr = new_encode_dev(tty_devnum(sig->tty)); |
421 | } | 432 | } |
422 | 433 | ||
@@ -449,9 +460,9 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole) | |||
449 | gtime += cputime_add(gtime, sig->gtime); | 460 | gtime += cputime_add(gtime, sig->gtime); |
450 | } | 461 | } |
451 | 462 | ||
452 | sid = task_session_nr(task); | 463 | sid = task_session_nr_ns(task, ns); |
453 | pgid = task_pgrp_nr(task); | 464 | pgid = task_pgrp_nr_ns(task, ns); |
454 | ppid = rcu_dereference(task->real_parent)->tgid; | 465 | ppid = task_ppid_nr_ns(task, ns); |
455 | 466 | ||
456 | unlock_task_sighand(task, &flags); | 467 | unlock_task_sighand(task, &flags); |
457 | } | 468 | } |
@@ -483,7 +494,7 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole) | |||
483 | res = sprintf(buffer, "%d (%s) %c %d %d %d %d %d %u %lu \ | 494 | res = sprintf(buffer, "%d (%s) %c %d %d %d %d %d %u %lu \ |
484 | %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \ | 495 | %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \ |
485 | %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n", | 496 | %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n", |
486 | task->pid, | 497 | task_pid_nr_ns(task, ns), |
487 | tcomm, | 498 | tcomm, |
488 | state, | 499 | state, |
489 | ppid, | 500 | ppid, |
diff --git a/fs/proc/base.c b/fs/proc/base.c index 21510c9aa89c..db7636041c10 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -1937,14 +1937,14 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer, | |||
1937 | int buflen) | 1937 | int buflen) |
1938 | { | 1938 | { |
1939 | char tmp[PROC_NUMBUF]; | 1939 | char tmp[PROC_NUMBUF]; |
1940 | sprintf(tmp, "%d", current->tgid); | 1940 | sprintf(tmp, "%d", task_tgid_vnr(current)); |
1941 | return vfs_readlink(dentry,buffer,buflen,tmp); | 1941 | return vfs_readlink(dentry,buffer,buflen,tmp); |
1942 | } | 1942 | } |
1943 | 1943 | ||
1944 | static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd) | 1944 | static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd) |
1945 | { | 1945 | { |
1946 | char tmp[PROC_NUMBUF]; | 1946 | char tmp[PROC_NUMBUF]; |
1947 | sprintf(tmp, "%d", current->tgid); | 1947 | sprintf(tmp, "%d", task_tgid_vnr(current)); |
1948 | return ERR_PTR(vfs_follow_link(nd,tmp)); | 1948 | return ERR_PTR(vfs_follow_link(nd,tmp)); |
1949 | } | 1949 | } |
1950 | 1950 | ||
@@ -2316,6 +2316,7 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct | |||
2316 | struct dentry *result = ERR_PTR(-ENOENT); | 2316 | struct dentry *result = ERR_PTR(-ENOENT); |
2317 | struct task_struct *task; | 2317 | struct task_struct *task; |
2318 | unsigned tgid; | 2318 | unsigned tgid; |
2319 | struct pid_namespace *ns; | ||
2319 | 2320 | ||
2320 | result = proc_base_lookup(dir, dentry); | 2321 | result = proc_base_lookup(dir, dentry); |
2321 | if (!IS_ERR(result) || PTR_ERR(result) != -ENOENT) | 2322 | if (!IS_ERR(result) || PTR_ERR(result) != -ENOENT) |
@@ -2325,8 +2326,9 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct | |||
2325 | if (tgid == ~0U) | 2326 | if (tgid == ~0U) |
2326 | goto out; | 2327 | goto out; |
2327 | 2328 | ||
2329 | ns = dentry->d_sb->s_fs_info; | ||
2328 | rcu_read_lock(); | 2330 | rcu_read_lock(); |
2329 | task = find_task_by_pid(tgid); | 2331 | task = find_task_by_pid_ns(tgid, ns); |
2330 | if (task) | 2332 | if (task) |
2331 | get_task_struct(task); | 2333 | get_task_struct(task); |
2332 | rcu_read_unlock(); | 2334 | rcu_read_unlock(); |
@@ -2343,7 +2345,8 @@ out: | |||
2343 | * Find the first task with tgid >= tgid | 2345 | * Find the first task with tgid >= tgid |
2344 | * | 2346 | * |
2345 | */ | 2347 | */ |
2346 | static struct task_struct *next_tgid(unsigned int tgid) | 2348 | static struct task_struct *next_tgid(unsigned int tgid, |
2349 | struct pid_namespace *ns) | ||
2347 | { | 2350 | { |
2348 | struct task_struct *task; | 2351 | struct task_struct *task; |
2349 | struct pid *pid; | 2352 | struct pid *pid; |
@@ -2351,9 +2354,9 @@ static struct task_struct *next_tgid(unsigned int tgid) | |||
2351 | rcu_read_lock(); | 2354 | rcu_read_lock(); |
2352 | retry: | 2355 | retry: |
2353 | task = NULL; | 2356 | task = NULL; |
2354 | pid = find_ge_pid(tgid, &init_pid_ns); | 2357 | pid = find_ge_pid(tgid, ns); |
2355 | if (pid) { | 2358 | if (pid) { |
2356 | tgid = pid->nr + 1; | 2359 | tgid = pid_nr_ns(pid, ns) + 1; |
2357 | task = pid_task(pid, PIDTYPE_PID); | 2360 | task = pid_task(pid, PIDTYPE_PID); |
2358 | /* What we to know is if the pid we have find is the | 2361 | /* What we to know is if the pid we have find is the |
2359 | * pid of a thread_group_leader. Testing for task | 2362 | * pid of a thread_group_leader. Testing for task |
@@ -2393,6 +2396,7 @@ int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
2393 | struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode); | 2396 | struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode); |
2394 | struct task_struct *task; | 2397 | struct task_struct *task; |
2395 | int tgid; | 2398 | int tgid; |
2399 | struct pid_namespace *ns; | ||
2396 | 2400 | ||
2397 | if (!reaper) | 2401 | if (!reaper) |
2398 | goto out_no_task; | 2402 | goto out_no_task; |
@@ -2403,11 +2407,12 @@ int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
2403 | goto out; | 2407 | goto out; |
2404 | } | 2408 | } |
2405 | 2409 | ||
2410 | ns = filp->f_dentry->d_sb->s_fs_info; | ||
2406 | tgid = filp->f_pos - TGID_OFFSET; | 2411 | tgid = filp->f_pos - TGID_OFFSET; |
2407 | for (task = next_tgid(tgid); | 2412 | for (task = next_tgid(tgid, ns); |
2408 | task; | 2413 | task; |
2409 | put_task_struct(task), task = next_tgid(tgid + 1)) { | 2414 | put_task_struct(task), task = next_tgid(tgid + 1, ns)) { |
2410 | tgid = task->pid; | 2415 | tgid = task_pid_nr_ns(task, ns); |
2411 | filp->f_pos = tgid + TGID_OFFSET; | 2416 | filp->f_pos = tgid + TGID_OFFSET; |
2412 | if (proc_pid_fill_cache(filp, dirent, filldir, task, tgid) < 0) { | 2417 | if (proc_pid_fill_cache(filp, dirent, filldir, task, tgid) < 0) { |
2413 | put_task_struct(task); | 2418 | put_task_struct(task); |
@@ -2531,6 +2536,7 @@ static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry | |||
2531 | struct task_struct *task; | 2536 | struct task_struct *task; |
2532 | struct task_struct *leader = get_proc_task(dir); | 2537 | struct task_struct *leader = get_proc_task(dir); |
2533 | unsigned tid; | 2538 | unsigned tid; |
2539 | struct pid_namespace *ns; | ||
2534 | 2540 | ||
2535 | if (!leader) | 2541 | if (!leader) |
2536 | goto out_no_task; | 2542 | goto out_no_task; |
@@ -2539,8 +2545,9 @@ static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry | |||
2539 | if (tid == ~0U) | 2545 | if (tid == ~0U) |
2540 | goto out; | 2546 | goto out; |
2541 | 2547 | ||
2548 | ns = dentry->d_sb->s_fs_info; | ||
2542 | rcu_read_lock(); | 2549 | rcu_read_lock(); |
2543 | task = find_task_by_pid(tid); | 2550 | task = find_task_by_pid_ns(tid, ns); |
2544 | if (task) | 2551 | if (task) |
2545 | get_task_struct(task); | 2552 | get_task_struct(task); |
2546 | rcu_read_unlock(); | 2553 | rcu_read_unlock(); |
@@ -2571,14 +2578,14 @@ out_no_task: | |||
2571 | * threads past it. | 2578 | * threads past it. |
2572 | */ | 2579 | */ |
2573 | static struct task_struct *first_tid(struct task_struct *leader, | 2580 | static struct task_struct *first_tid(struct task_struct *leader, |
2574 | int tid, int nr) | 2581 | int tid, int nr, struct pid_namespace *ns) |
2575 | { | 2582 | { |
2576 | struct task_struct *pos; | 2583 | struct task_struct *pos; |
2577 | 2584 | ||
2578 | rcu_read_lock(); | 2585 | rcu_read_lock(); |
2579 | /* Attempt to start with the pid of a thread */ | 2586 | /* Attempt to start with the pid of a thread */ |
2580 | if (tid && (nr > 0)) { | 2587 | if (tid && (nr > 0)) { |
2581 | pos = find_task_by_pid(tid); | 2588 | pos = find_task_by_pid_ns(tid, ns); |
2582 | if (pos && (pos->group_leader == leader)) | 2589 | if (pos && (pos->group_leader == leader)) |
2583 | goto found; | 2590 | goto found; |
2584 | } | 2591 | } |
@@ -2647,6 +2654,7 @@ static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldi | |||
2647 | ino_t ino; | 2654 | ino_t ino; |
2648 | int tid; | 2655 | int tid; |
2649 | unsigned long pos = filp->f_pos; /* avoiding "long long" filp->f_pos */ | 2656 | unsigned long pos = filp->f_pos; /* avoiding "long long" filp->f_pos */ |
2657 | struct pid_namespace *ns; | ||
2650 | 2658 | ||
2651 | task = get_proc_task(inode); | 2659 | task = get_proc_task(inode); |
2652 | if (!task) | 2660 | if (!task) |
@@ -2680,12 +2688,13 @@ static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldi | |||
2680 | /* f_version caches the tgid value that the last readdir call couldn't | 2688 | /* f_version caches the tgid value that the last readdir call couldn't |
2681 | * return. lseek aka telldir automagically resets f_version to 0. | 2689 | * return. lseek aka telldir automagically resets f_version to 0. |
2682 | */ | 2690 | */ |
2691 | ns = filp->f_dentry->d_sb->s_fs_info; | ||
2683 | tid = (int)filp->f_version; | 2692 | tid = (int)filp->f_version; |
2684 | filp->f_version = 0; | 2693 | filp->f_version = 0; |
2685 | for (task = first_tid(leader, tid, pos - 2); | 2694 | for (task = first_tid(leader, tid, pos - 2, ns); |
2686 | task; | 2695 | task; |
2687 | task = next_tid(task), pos++) { | 2696 | task = next_tid(task), pos++) { |
2688 | tid = task->pid; | 2697 | tid = task_pid_nr_ns(task, ns); |
2689 | if (proc_task_fill_cache(filp, dirent, filldir, task, tid) < 0) { | 2698 | if (proc_task_fill_cache(filp, dirent, filldir, task, tid) < 0) { |
2690 | /* returning this tgid failed, save it as the first | 2699 | /* returning this tgid failed, save it as the first |
2691 | * pid for the next readir call */ | 2700 | * pid for the next readir call */ |
diff --git a/include/net/scm.h b/include/net/scm.h index 423cb1d5ac25..06df126103ca 100644 --- a/include/net/scm.h +++ b/include/net/scm.h | |||
@@ -4,6 +4,8 @@ | |||
4 | #include <linux/limits.h> | 4 | #include <linux/limits.h> |
5 | #include <linux/net.h> | 5 | #include <linux/net.h> |
6 | #include <linux/security.h> | 6 | #include <linux/security.h> |
7 | #include <linux/pid.h> | ||
8 | #include <linux/nsproxy.h> | ||
7 | 9 | ||
8 | /* Well, we should have at least one descriptor open | 10 | /* Well, we should have at least one descriptor open |
9 | * to accept passed FDs 8) | 11 | * to accept passed FDs 8) |
@@ -54,7 +56,7 @@ static __inline__ int scm_send(struct socket *sock, struct msghdr *msg, | |||
54 | struct task_struct *p = current; | 56 | struct task_struct *p = current; |
55 | scm->creds.uid = p->uid; | 57 | scm->creds.uid = p->uid; |
56 | scm->creds.gid = p->gid; | 58 | scm->creds.gid = p->gid; |
57 | scm->creds.pid = p->tgid; | 59 | scm->creds.pid = task_tgid_vnr(p); |
58 | scm->fp = NULL; | 60 | scm->fp = NULL; |
59 | scm->seq = 0; | 61 | scm->seq = 0; |
60 | unix_get_peersec_dgram(sock, scm); | 62 | unix_get_peersec_dgram(sock, scm); |
diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 20f1fed8fa48..c0b26dc4617b 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c | |||
@@ -29,6 +29,8 @@ | |||
29 | #include <linux/audit.h> | 29 | #include <linux/audit.h> |
30 | #include <linux/signal.h> | 30 | #include <linux/signal.h> |
31 | #include <linux/mutex.h> | 31 | #include <linux/mutex.h> |
32 | #include <linux/nsproxy.h> | ||
33 | #include <linux/pid.h> | ||
32 | 34 | ||
33 | #include <net/sock.h> | 35 | #include <net/sock.h> |
34 | #include "util.h" | 36 | #include "util.h" |
@@ -330,7 +332,8 @@ static ssize_t mqueue_read_file(struct file *filp, char __user *u_data, | |||
330 | (info->notify_owner && | 332 | (info->notify_owner && |
331 | info->notify.sigev_notify == SIGEV_SIGNAL) ? | 333 | info->notify.sigev_notify == SIGEV_SIGNAL) ? |
332 | info->notify.sigev_signo : 0, | 334 | info->notify.sigev_signo : 0, |
333 | pid_nr(info->notify_owner)); | 335 | pid_nr_ns(info->notify_owner, |
336 | current->nsproxy->pid_ns)); | ||
334 | spin_unlock(&info->lock); | 337 | spin_unlock(&info->lock); |
335 | buffer[sizeof(buffer)-1] = '\0'; | 338 | buffer[sizeof(buffer)-1] = '\0'; |
336 | slen = strlen(buffer)+1; | 339 | slen = strlen(buffer)+1; |
@@ -507,7 +510,7 @@ static void __do_notify(struct mqueue_inode_info *info) | |||
507 | sig_i.si_errno = 0; | 510 | sig_i.si_errno = 0; |
508 | sig_i.si_code = SI_MESGQ; | 511 | sig_i.si_code = SI_MESGQ; |
509 | sig_i.si_value = info->notify.sigev_value; | 512 | sig_i.si_value = info->notify.sigev_value; |
510 | sig_i.si_pid = current->tgid; | 513 | sig_i.si_pid = task_pid_vnr(current); |
511 | sig_i.si_uid = current->uid; | 514 | sig_i.si_uid = current->uid; |
512 | 515 | ||
513 | kill_pid_info(info->notify.sigev_signo, | 516 | kill_pid_info(info->notify.sigev_signo, |
@@ -611,7 +611,7 @@ static inline int pipelined_send(struct msg_queue *msq, struct msg_msg *msg) | |||
611 | msr->r_msg = ERR_PTR(-E2BIG); | 611 | msr->r_msg = ERR_PTR(-E2BIG); |
612 | } else { | 612 | } else { |
613 | msr->r_msg = NULL; | 613 | msr->r_msg = NULL; |
614 | msq->q_lrpid = msr->r_tsk->pid; | 614 | msq->q_lrpid = task_pid_vnr(msr->r_tsk); |
615 | msq->q_rtime = get_seconds(); | 615 | msq->q_rtime = get_seconds(); |
616 | wake_up_process(msr->r_tsk); | 616 | wake_up_process(msr->r_tsk); |
617 | smp_mb(); | 617 | smp_mb(); |
@@ -695,7 +695,7 @@ long do_msgsnd(int msqid, long mtype, void __user *mtext, | |||
695 | } | 695 | } |
696 | } | 696 | } |
697 | 697 | ||
698 | msq->q_lspid = current->tgid; | 698 | msq->q_lspid = task_tgid_vnr(current); |
699 | msq->q_stime = get_seconds(); | 699 | msq->q_stime = get_seconds(); |
700 | 700 | ||
701 | if (!pipelined_send(msq, msg)) { | 701 | if (!pipelined_send(msq, msg)) { |
@@ -810,7 +810,7 @@ long do_msgrcv(int msqid, long *pmtype, void __user *mtext, | |||
810 | list_del(&msg->m_list); | 810 | list_del(&msg->m_list); |
811 | msq->q_qnum--; | 811 | msq->q_qnum--; |
812 | msq->q_rtime = get_seconds(); | 812 | msq->q_rtime = get_seconds(); |
813 | msq->q_lrpid = current->tgid; | 813 | msq->q_lrpid = task_tgid_vnr(current); |
814 | msq->q_cbytes -= msg->m_ts; | 814 | msq->q_cbytes -= msg->m_ts; |
815 | atomic_sub(msg->m_ts, &msg_bytes); | 815 | atomic_sub(msg->m_ts, &msg_bytes); |
816 | atomic_dec(&msg_hdrs); | 816 | atomic_dec(&msg_hdrs); |
@@ -795,7 +795,7 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
795 | for (un = sma->undo; un; un = un->id_next) | 795 | for (un = sma->undo; un; un = un->id_next) |
796 | un->semadj[semnum] = 0; | 796 | un->semadj[semnum] = 0; |
797 | curr->semval = val; | 797 | curr->semval = val; |
798 | curr->sempid = current->tgid; | 798 | curr->sempid = task_tgid_vnr(current); |
799 | sma->sem_ctime = get_seconds(); | 799 | sma->sem_ctime = get_seconds(); |
800 | /* maybe some queued-up processes were waiting for this */ | 800 | /* maybe some queued-up processes were waiting for this */ |
801 | update_queue(sma); | 801 | update_queue(sma); |
@@ -1196,7 +1196,7 @@ retry_undos: | |||
1196 | if (error) | 1196 | if (error) |
1197 | goto out_unlock_free; | 1197 | goto out_unlock_free; |
1198 | 1198 | ||
1199 | error = try_atomic_semop (sma, sops, nsops, un, current->tgid); | 1199 | error = try_atomic_semop (sma, sops, nsops, un, task_tgid_vnr(current)); |
1200 | if (error <= 0) { | 1200 | if (error <= 0) { |
1201 | if (alter && error == 0) | 1201 | if (alter && error == 0) |
1202 | update_queue (sma); | 1202 | update_queue (sma); |
@@ -1211,7 +1211,7 @@ retry_undos: | |||
1211 | queue.sops = sops; | 1211 | queue.sops = sops; |
1212 | queue.nsops = nsops; | 1212 | queue.nsops = nsops; |
1213 | queue.undo = un; | 1213 | queue.undo = un; |
1214 | queue.pid = current->tgid; | 1214 | queue.pid = task_tgid_vnr(current); |
1215 | queue.id = semid; | 1215 | queue.id = semid; |
1216 | queue.alter = alter; | 1216 | queue.alter = alter; |
1217 | if (alter) | 1217 | if (alter) |
@@ -1382,7 +1382,7 @@ found: | |||
1382 | semaphore->semval = 0; | 1382 | semaphore->semval = 0; |
1383 | if (semaphore->semval > SEMVMX) | 1383 | if (semaphore->semval > SEMVMX) |
1384 | semaphore->semval = SEMVMX; | 1384 | semaphore->semval = SEMVMX; |
1385 | semaphore->sempid = current->tgid; | 1385 | semaphore->sempid = task_tgid_vnr(current); |
1386 | } | 1386 | } |
1387 | } | 1387 | } |
1388 | sma->sem_otime = get_seconds(); | 1388 | sma->sem_otime = get_seconds(); |
@@ -168,7 +168,7 @@ static void shm_open(struct vm_area_struct *vma) | |||
168 | shp = shm_lock(sfd->ns, sfd->id); | 168 | shp = shm_lock(sfd->ns, sfd->id); |
169 | BUG_ON(!shp); | 169 | BUG_ON(!shp); |
170 | shp->shm_atim = get_seconds(); | 170 | shp->shm_atim = get_seconds(); |
171 | shp->shm_lprid = current->tgid; | 171 | shp->shm_lprid = task_tgid_vnr(current); |
172 | shp->shm_nattch++; | 172 | shp->shm_nattch++; |
173 | shm_unlock(shp); | 173 | shm_unlock(shp); |
174 | } | 174 | } |
@@ -213,7 +213,7 @@ static void shm_close(struct vm_area_struct *vma) | |||
213 | /* remove from the list of attaches of the shm segment */ | 213 | /* remove from the list of attaches of the shm segment */ |
214 | shp = shm_lock(ns, sfd->id); | 214 | shp = shm_lock(ns, sfd->id); |
215 | BUG_ON(!shp); | 215 | BUG_ON(!shp); |
216 | shp->shm_lprid = current->tgid; | 216 | shp->shm_lprid = task_tgid_vnr(current); |
217 | shp->shm_dtim = get_seconds(); | 217 | shp->shm_dtim = get_seconds(); |
218 | shp->shm_nattch--; | 218 | shp->shm_nattch--; |
219 | if(shp->shm_nattch == 0 && | 219 | if(shp->shm_nattch == 0 && |
@@ -392,7 +392,7 @@ static int newseg (struct ipc_namespace *ns, key_t key, int shmflg, size_t size) | |||
392 | if(id == -1) | 392 | if(id == -1) |
393 | goto no_id; | 393 | goto no_id; |
394 | 394 | ||
395 | shp->shm_cprid = current->tgid; | 395 | shp->shm_cprid = task_tgid_vnr(current); |
396 | shp->shm_lprid = 0; | 396 | shp->shm_lprid = 0; |
397 | shp->shm_atim = shp->shm_dtim = 0; | 397 | shp->shm_atim = shp->shm_dtim = 0; |
398 | shp->shm_ctim = get_seconds(); | 398 | shp->shm_ctim = get_seconds(); |
diff --git a/kernel/capability.c b/kernel/capability.c index f02ad47320b9..d4377c5a36c9 100644 --- a/kernel/capability.c +++ b/kernel/capability.c | |||
@@ -62,8 +62,9 @@ asmlinkage long sys_capget(cap_user_header_t header, cap_user_data_t dataptr) | |||
62 | spin_lock(&task_capability_lock); | 62 | spin_lock(&task_capability_lock); |
63 | read_lock(&tasklist_lock); | 63 | read_lock(&tasklist_lock); |
64 | 64 | ||
65 | if (pid && pid != current->pid) { | 65 | if (pid && pid != task_pid_vnr(current)) { |
66 | target = find_task_by_pid(pid); | 66 | target = find_task_by_pid_ns(pid, |
67 | current->nsproxy->pid_ns); | ||
67 | if (!target) { | 68 | if (!target) { |
68 | ret = -ESRCH; | 69 | ret = -ESRCH; |
69 | goto out; | 70 | goto out; |
@@ -96,7 +97,7 @@ static inline int cap_set_pg(int pgrp_nr, kernel_cap_t *effective, | |||
96 | int found = 0; | 97 | int found = 0; |
97 | struct pid *pgrp; | 98 | struct pid *pgrp; |
98 | 99 | ||
99 | pgrp = find_pid(pgrp_nr); | 100 | pgrp = find_pid_ns(pgrp_nr, current->nsproxy->pid_ns); |
100 | do_each_pid_task(pgrp, PIDTYPE_PGID, g) { | 101 | do_each_pid_task(pgrp, PIDTYPE_PGID, g) { |
101 | target = g; | 102 | target = g; |
102 | while_each_thread(g, target) { | 103 | while_each_thread(g, target) { |
@@ -185,7 +186,7 @@ asmlinkage long sys_capset(cap_user_header_t header, const cap_user_data_t data) | |||
185 | if (get_user(pid, &header->pid)) | 186 | if (get_user(pid, &header->pid)) |
186 | return -EFAULT; | 187 | return -EFAULT; |
187 | 188 | ||
188 | if (pid && pid != current->pid && !capable(CAP_SETPCAP)) | 189 | if (pid && pid != task_pid_vnr(current) && !capable(CAP_SETPCAP)) |
189 | return -EPERM; | 190 | return -EPERM; |
190 | 191 | ||
191 | if (copy_from_user(&effective, &data->effective, sizeof(effective)) || | 192 | if (copy_from_user(&effective, &data->effective, sizeof(effective)) || |
@@ -196,8 +197,9 @@ asmlinkage long sys_capset(cap_user_header_t header, const cap_user_data_t data) | |||
196 | spin_lock(&task_capability_lock); | 197 | spin_lock(&task_capability_lock); |
197 | read_lock(&tasklist_lock); | 198 | read_lock(&tasklist_lock); |
198 | 199 | ||
199 | if (pid > 0 && pid != current->pid) { | 200 | if (pid > 0 && pid != task_pid_vnr(current)) { |
200 | target = find_task_by_pid(pid); | 201 | target = find_task_by_pid_ns(pid, |
202 | current->nsproxy->pid_ns); | ||
201 | if (!target) { | 203 | if (!target) { |
202 | ret = -ESRCH; | 204 | ret = -ESRCH; |
203 | goto out; | 205 | goto out; |
diff --git a/kernel/exit.c b/kernel/exit.c index 567909fd6be4..68d27039ef7d 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -1112,15 +1112,17 @@ asmlinkage void sys_exit_group(int error_code) | |||
1112 | static int eligible_child(pid_t pid, int options, struct task_struct *p) | 1112 | static int eligible_child(pid_t pid, int options, struct task_struct *p) |
1113 | { | 1113 | { |
1114 | int err; | 1114 | int err; |
1115 | struct pid_namespace *ns; | ||
1115 | 1116 | ||
1117 | ns = current->nsproxy->pid_ns; | ||
1116 | if (pid > 0) { | 1118 | if (pid > 0) { |
1117 | if (p->pid != pid) | 1119 | if (task_pid_nr_ns(p, ns) != pid) |
1118 | return 0; | 1120 | return 0; |
1119 | } else if (!pid) { | 1121 | } else if (!pid) { |
1120 | if (task_pgrp_nr(p) != task_pgrp_nr(current)) | 1122 | if (task_pgrp_nr_ns(p, ns) != task_pgrp_vnr(current)) |
1121 | return 0; | 1123 | return 0; |
1122 | } else if (pid != -1) { | 1124 | } else if (pid != -1) { |
1123 | if (task_pgrp_nr(p) != -pid) | 1125 | if (task_pgrp_nr_ns(p, ns) != -pid) |
1124 | return 0; | 1126 | return 0; |
1125 | } | 1127 | } |
1126 | 1128 | ||
@@ -1190,9 +1192,12 @@ static int wait_task_zombie(struct task_struct *p, int noreap, | |||
1190 | { | 1192 | { |
1191 | unsigned long state; | 1193 | unsigned long state; |
1192 | int retval, status, traced; | 1194 | int retval, status, traced; |
1195 | struct pid_namespace *ns; | ||
1196 | |||
1197 | ns = current->nsproxy->pid_ns; | ||
1193 | 1198 | ||
1194 | if (unlikely(noreap)) { | 1199 | if (unlikely(noreap)) { |
1195 | pid_t pid = p->pid; | 1200 | pid_t pid = task_pid_nr_ns(p, ns); |
1196 | uid_t uid = p->uid; | 1201 | uid_t uid = p->uid; |
1197 | int exit_code = p->exit_code; | 1202 | int exit_code = p->exit_code; |
1198 | int why, status; | 1203 | int why, status; |
@@ -1311,11 +1316,11 @@ static int wait_task_zombie(struct task_struct *p, int noreap, | |||
1311 | retval = put_user(status, &infop->si_status); | 1316 | retval = put_user(status, &infop->si_status); |
1312 | } | 1317 | } |
1313 | if (!retval && infop) | 1318 | if (!retval && infop) |
1314 | retval = put_user(p->pid, &infop->si_pid); | 1319 | retval = put_user(task_pid_nr_ns(p, ns), &infop->si_pid); |
1315 | if (!retval && infop) | 1320 | if (!retval && infop) |
1316 | retval = put_user(p->uid, &infop->si_uid); | 1321 | retval = put_user(p->uid, &infop->si_uid); |
1317 | if (!retval) | 1322 | if (!retval) |
1318 | retval = p->pid; | 1323 | retval = task_pid_nr_ns(p, ns); |
1319 | 1324 | ||
1320 | if (traced) { | 1325 | if (traced) { |
1321 | write_lock_irq(&tasklist_lock); | 1326 | write_lock_irq(&tasklist_lock); |
@@ -1352,6 +1357,7 @@ static int wait_task_stopped(struct task_struct *p, int delayed_group_leader, | |||
1352 | int __user *stat_addr, struct rusage __user *ru) | 1357 | int __user *stat_addr, struct rusage __user *ru) |
1353 | { | 1358 | { |
1354 | int retval, exit_code; | 1359 | int retval, exit_code; |
1360 | struct pid_namespace *ns; | ||
1355 | 1361 | ||
1356 | if (!p->exit_code) | 1362 | if (!p->exit_code) |
1357 | return 0; | 1363 | return 0; |
@@ -1370,11 +1376,12 @@ static int wait_task_stopped(struct task_struct *p, int delayed_group_leader, | |||
1370 | * keep holding onto the tasklist_lock while we call getrusage and | 1376 | * keep holding onto the tasklist_lock while we call getrusage and |
1371 | * possibly take page faults for user memory. | 1377 | * possibly take page faults for user memory. |
1372 | */ | 1378 | */ |
1379 | ns = current->nsproxy->pid_ns; | ||
1373 | get_task_struct(p); | 1380 | get_task_struct(p); |
1374 | read_unlock(&tasklist_lock); | 1381 | read_unlock(&tasklist_lock); |
1375 | 1382 | ||
1376 | if (unlikely(noreap)) { | 1383 | if (unlikely(noreap)) { |
1377 | pid_t pid = p->pid; | 1384 | pid_t pid = task_pid_nr_ns(p, ns); |
1378 | uid_t uid = p->uid; | 1385 | uid_t uid = p->uid; |
1379 | int why = (p->ptrace & PT_PTRACED) ? CLD_TRAPPED : CLD_STOPPED; | 1386 | int why = (p->ptrace & PT_PTRACED) ? CLD_TRAPPED : CLD_STOPPED; |
1380 | 1387 | ||
@@ -1445,11 +1452,11 @@ bail_ref: | |||
1445 | if (!retval && infop) | 1452 | if (!retval && infop) |
1446 | retval = put_user(exit_code, &infop->si_status); | 1453 | retval = put_user(exit_code, &infop->si_status); |
1447 | if (!retval && infop) | 1454 | if (!retval && infop) |
1448 | retval = put_user(p->pid, &infop->si_pid); | 1455 | retval = put_user(task_pid_nr_ns(p, ns), &infop->si_pid); |
1449 | if (!retval && infop) | 1456 | if (!retval && infop) |
1450 | retval = put_user(p->uid, &infop->si_uid); | 1457 | retval = put_user(p->uid, &infop->si_uid); |
1451 | if (!retval) | 1458 | if (!retval) |
1452 | retval = p->pid; | 1459 | retval = task_pid_nr_ns(p, ns); |
1453 | put_task_struct(p); | 1460 | put_task_struct(p); |
1454 | 1461 | ||
1455 | BUG_ON(!retval); | 1462 | BUG_ON(!retval); |
@@ -1469,6 +1476,7 @@ static int wait_task_continued(struct task_struct *p, int noreap, | |||
1469 | int retval; | 1476 | int retval; |
1470 | pid_t pid; | 1477 | pid_t pid; |
1471 | uid_t uid; | 1478 | uid_t uid; |
1479 | struct pid_namespace *ns; | ||
1472 | 1480 | ||
1473 | if (!(p->signal->flags & SIGNAL_STOP_CONTINUED)) | 1481 | if (!(p->signal->flags & SIGNAL_STOP_CONTINUED)) |
1474 | return 0; | 1482 | return 0; |
@@ -1483,7 +1491,8 @@ static int wait_task_continued(struct task_struct *p, int noreap, | |||
1483 | p->signal->flags &= ~SIGNAL_STOP_CONTINUED; | 1491 | p->signal->flags &= ~SIGNAL_STOP_CONTINUED; |
1484 | spin_unlock_irq(&p->sighand->siglock); | 1492 | spin_unlock_irq(&p->sighand->siglock); |
1485 | 1493 | ||
1486 | pid = p->pid; | 1494 | ns = current->nsproxy->pid_ns; |
1495 | pid = task_pid_nr_ns(p, ns); | ||
1487 | uid = p->uid; | 1496 | uid = p->uid; |
1488 | get_task_struct(p); | 1497 | get_task_struct(p); |
1489 | read_unlock(&tasklist_lock); | 1498 | read_unlock(&tasklist_lock); |
@@ -1494,7 +1503,7 @@ static int wait_task_continued(struct task_struct *p, int noreap, | |||
1494 | if (!retval && stat_addr) | 1503 | if (!retval && stat_addr) |
1495 | retval = put_user(0xffff, stat_addr); | 1504 | retval = put_user(0xffff, stat_addr); |
1496 | if (!retval) | 1505 | if (!retval) |
1497 | retval = p->pid; | 1506 | retval = task_pid_nr_ns(p, ns); |
1498 | } else { | 1507 | } else { |
1499 | retval = wait_noreap_copyout(p, pid, uid, | 1508 | retval = wait_noreap_copyout(p, pid, uid, |
1500 | CLD_CONTINUED, SIGCONT, | 1509 | CLD_CONTINUED, SIGCONT, |
diff --git a/kernel/fork.c b/kernel/fork.c index ce9297e4e7d4..a794bfcf6003 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -950,7 +950,7 @@ asmlinkage long sys_set_tid_address(int __user *tidptr) | |||
950 | { | 950 | { |
951 | current->clear_child_tid = tidptr; | 951 | current->clear_child_tid = tidptr; |
952 | 952 | ||
953 | return current->pid; | 953 | return task_pid_vnr(current); |
954 | } | 954 | } |
955 | 955 | ||
956 | static inline void rt_mutex_init_task(struct task_struct *p) | 956 | static inline void rt_mutex_init_task(struct task_struct *p) |
diff --git a/kernel/futex.c b/kernel/futex.c index e45a65e41686..86b2600381b6 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -53,6 +53,9 @@ | |||
53 | #include <linux/signal.h> | 53 | #include <linux/signal.h> |
54 | #include <linux/module.h> | 54 | #include <linux/module.h> |
55 | #include <linux/magic.h> | 55 | #include <linux/magic.h> |
56 | #include <linux/pid.h> | ||
57 | #include <linux/nsproxy.h> | ||
58 | |||
56 | #include <asm/futex.h> | 59 | #include <asm/futex.h> |
57 | 60 | ||
58 | #include "rtmutex_common.h" | 61 | #include "rtmutex_common.h" |
@@ -443,7 +446,8 @@ static struct task_struct * futex_find_get_task(pid_t pid) | |||
443 | struct task_struct *p; | 446 | struct task_struct *p; |
444 | 447 | ||
445 | rcu_read_lock(); | 448 | rcu_read_lock(); |
446 | p = find_task_by_pid(pid); | 449 | p = find_task_by_pid_ns(pid, |
450 | current->nsproxy->pid_ns); | ||
447 | 451 | ||
448 | if (!p || ((current->euid != p->euid) && (current->euid != p->uid))) | 452 | if (!p || ((current->euid != p->euid) && (current->euid != p->uid))) |
449 | p = ERR_PTR(-ESRCH); | 453 | p = ERR_PTR(-ESRCH); |
@@ -653,7 +657,7 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this) | |||
653 | if (!(uval & FUTEX_OWNER_DIED)) { | 657 | if (!(uval & FUTEX_OWNER_DIED)) { |
654 | int ret = 0; | 658 | int ret = 0; |
655 | 659 | ||
656 | newval = FUTEX_WAITERS | new_owner->pid; | 660 | newval = FUTEX_WAITERS | task_pid_vnr(new_owner); |
657 | 661 | ||
658 | curval = cmpxchg_futex_value_locked(uaddr, uval, newval); | 662 | curval = cmpxchg_futex_value_locked(uaddr, uval, newval); |
659 | 663 | ||
@@ -1106,7 +1110,7 @@ static void unqueue_me_pi(struct futex_q *q) | |||
1106 | static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, | 1110 | static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, |
1107 | struct task_struct *curr) | 1111 | struct task_struct *curr) |
1108 | { | 1112 | { |
1109 | u32 newtid = curr->pid | FUTEX_WAITERS; | 1113 | u32 newtid = task_pid_vnr(curr) | FUTEX_WAITERS; |
1110 | struct futex_pi_state *pi_state = q->pi_state; | 1114 | struct futex_pi_state *pi_state = q->pi_state; |
1111 | u32 uval, curval, newval; | 1115 | u32 uval, curval, newval; |
1112 | int ret; | 1116 | int ret; |
@@ -1368,7 +1372,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1368 | * (by doing a 0 -> TID atomic cmpxchg), while holding all | 1372 | * (by doing a 0 -> TID atomic cmpxchg), while holding all |
1369 | * the locks. It will most likely not succeed. | 1373 | * the locks. It will most likely not succeed. |
1370 | */ | 1374 | */ |
1371 | newval = current->pid; | 1375 | newval = task_pid_vnr(current); |
1372 | 1376 | ||
1373 | curval = cmpxchg_futex_value_locked(uaddr, 0, newval); | 1377 | curval = cmpxchg_futex_value_locked(uaddr, 0, newval); |
1374 | 1378 | ||
@@ -1379,7 +1383,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1379 | * Detect deadlocks. In case of REQUEUE_PI this is a valid | 1383 | * Detect deadlocks. In case of REQUEUE_PI this is a valid |
1380 | * situation and we return success to user space. | 1384 | * situation and we return success to user space. |
1381 | */ | 1385 | */ |
1382 | if (unlikely((curval & FUTEX_TID_MASK) == current->pid)) { | 1386 | if (unlikely((curval & FUTEX_TID_MASK) == task_pid_vnr(current))) { |
1383 | ret = -EDEADLK; | 1387 | ret = -EDEADLK; |
1384 | goto out_unlock_release_sem; | 1388 | goto out_unlock_release_sem; |
1385 | } | 1389 | } |
@@ -1408,7 +1412,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1408 | */ | 1412 | */ |
1409 | if (unlikely(ownerdied || !(curval & FUTEX_TID_MASK))) { | 1413 | if (unlikely(ownerdied || !(curval & FUTEX_TID_MASK))) { |
1410 | /* Keep the OWNER_DIED bit */ | 1414 | /* Keep the OWNER_DIED bit */ |
1411 | newval = (curval & ~FUTEX_TID_MASK) | current->pid; | 1415 | newval = (curval & ~FUTEX_TID_MASK) | task_pid_vnr(current); |
1412 | ownerdied = 0; | 1416 | ownerdied = 0; |
1413 | lock_taken = 1; | 1417 | lock_taken = 1; |
1414 | } | 1418 | } |
@@ -1587,7 +1591,7 @@ retry: | |||
1587 | /* | 1591 | /* |
1588 | * We release only a lock we actually own: | 1592 | * We release only a lock we actually own: |
1589 | */ | 1593 | */ |
1590 | if ((uval & FUTEX_TID_MASK) != current->pid) | 1594 | if ((uval & FUTEX_TID_MASK) != task_pid_vnr(current)) |
1591 | return -EPERM; | 1595 | return -EPERM; |
1592 | /* | 1596 | /* |
1593 | * First take all the futex related locks: | 1597 | * First take all the futex related locks: |
@@ -1608,7 +1612,7 @@ retry_unlocked: | |||
1608 | * anyone else up: | 1612 | * anyone else up: |
1609 | */ | 1613 | */ |
1610 | if (!(uval & FUTEX_OWNER_DIED)) | 1614 | if (!(uval & FUTEX_OWNER_DIED)) |
1611 | uval = cmpxchg_futex_value_locked(uaddr, current->pid, 0); | 1615 | uval = cmpxchg_futex_value_locked(uaddr, task_pid_vnr(current), 0); |
1612 | 1616 | ||
1613 | 1617 | ||
1614 | if (unlikely(uval == -EFAULT)) | 1618 | if (unlikely(uval == -EFAULT)) |
@@ -1617,7 +1621,7 @@ retry_unlocked: | |||
1617 | * Rare case: we managed to release the lock atomically, | 1621 | * Rare case: we managed to release the lock atomically, |
1618 | * no need to wake anyone else up: | 1622 | * no need to wake anyone else up: |
1619 | */ | 1623 | */ |
1620 | if (unlikely(uval == current->pid)) | 1624 | if (unlikely(uval == task_pid_vnr(current))) |
1621 | goto out_unlock; | 1625 | goto out_unlock; |
1622 | 1626 | ||
1623 | /* | 1627 | /* |
@@ -1854,7 +1858,8 @@ sys_get_robust_list(int pid, struct robust_list_head __user * __user *head_ptr, | |||
1854 | 1858 | ||
1855 | ret = -ESRCH; | 1859 | ret = -ESRCH; |
1856 | rcu_read_lock(); | 1860 | rcu_read_lock(); |
1857 | p = find_task_by_pid(pid); | 1861 | p = find_task_by_pid_ns(pid, |
1862 | current->nsproxy->pid_ns); | ||
1858 | if (!p) | 1863 | if (!p) |
1859 | goto err_unlock; | 1864 | goto err_unlock; |
1860 | ret = -EPERM; | 1865 | ret = -EPERM; |
@@ -1887,7 +1892,7 @@ retry: | |||
1887 | if (get_user(uval, uaddr)) | 1892 | if (get_user(uval, uaddr)) |
1888 | return -1; | 1893 | return -1; |
1889 | 1894 | ||
1890 | if ((uval & FUTEX_TID_MASK) == curr->pid) { | 1895 | if ((uval & FUTEX_TID_MASK) == task_pid_vnr(curr)) { |
1891 | /* | 1896 | /* |
1892 | * Ok, this dying thread is truly holding a futex | 1897 | * Ok, this dying thread is truly holding a futex |
1893 | * of interest. Set the OWNER_DIED bit atomically | 1898 | * of interest. Set the OWNER_DIED bit atomically |
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c index 2c2e2954b713..cc098e1de960 100644 --- a/kernel/futex_compat.c +++ b/kernel/futex_compat.c | |||
@@ -8,6 +8,7 @@ | |||
8 | 8 | ||
9 | #include <linux/linkage.h> | 9 | #include <linux/linkage.h> |
10 | #include <linux/compat.h> | 10 | #include <linux/compat.h> |
11 | #include <linux/nsproxy.h> | ||
11 | #include <linux/futex.h> | 12 | #include <linux/futex.h> |
12 | 13 | ||
13 | #include <asm/uaccess.h> | 14 | #include <asm/uaccess.h> |
@@ -124,7 +125,8 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, | |||
124 | 125 | ||
125 | ret = -ESRCH; | 126 | ret = -ESRCH; |
126 | read_lock(&tasklist_lock); | 127 | read_lock(&tasklist_lock); |
127 | p = find_task_by_pid(pid); | 128 | p = find_task_by_pid_ns(pid, |
129 | current->nsproxy->pid_ns); | ||
128 | if (!p) | 130 | if (!p) |
129 | goto err_unlock; | 131 | goto err_unlock; |
130 | ret = -EPERM; | 132 | ret = -EPERM; |
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index a73ebd3b9d4c..66e99eb2d8a6 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/security.h> | 19 | #include <linux/security.h> |
20 | #include <linux/signal.h> | 20 | #include <linux/signal.h> |
21 | #include <linux/audit.h> | 21 | #include <linux/audit.h> |
22 | #include <linux/pid_namespace.h> | ||
22 | 23 | ||
23 | #include <asm/pgtable.h> | 24 | #include <asm/pgtable.h> |
24 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
@@ -443,7 +444,8 @@ struct task_struct *ptrace_get_task_struct(pid_t pid) | |||
443 | return ERR_PTR(-EPERM); | 444 | return ERR_PTR(-EPERM); |
444 | 445 | ||
445 | read_lock(&tasklist_lock); | 446 | read_lock(&tasklist_lock); |
446 | child = find_task_by_pid(pid); | 447 | child = find_task_by_pid_ns(pid, |
448 | current->nsproxy->pid_ns); | ||
447 | if (child) | 449 | if (child) |
448 | get_task_struct(child); | 450 | get_task_struct(child); |
449 | 451 | ||
diff --git a/kernel/sched.c b/kernel/sched.c index 72a2a16e2214..4ac56fe3c394 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/vmalloc.h> | 44 | #include <linux/vmalloc.h> |
45 | #include <linux/blkdev.h> | 45 | #include <linux/blkdev.h> |
46 | #include <linux/delay.h> | 46 | #include <linux/delay.h> |
47 | #include <linux/pid_namespace.h> | ||
47 | #include <linux/smp.h> | 48 | #include <linux/smp.h> |
48 | #include <linux/threads.h> | 49 | #include <linux/threads.h> |
49 | #include <linux/timer.h> | 50 | #include <linux/timer.h> |
@@ -1876,7 +1877,7 @@ asmlinkage void schedule_tail(struct task_struct *prev) | |||
1876 | preempt_enable(); | 1877 | preempt_enable(); |
1877 | #endif | 1878 | #endif |
1878 | if (current->set_child_tid) | 1879 | if (current->set_child_tid) |
1879 | put_user(current->pid, current->set_child_tid); | 1880 | put_user(task_pid_vnr(current), current->set_child_tid); |
1880 | } | 1881 | } |
1881 | 1882 | ||
1882 | /* | 1883 | /* |
@@ -4167,7 +4168,8 @@ struct task_struct *idle_task(int cpu) | |||
4167 | */ | 4168 | */ |
4168 | static struct task_struct *find_process_by_pid(pid_t pid) | 4169 | static struct task_struct *find_process_by_pid(pid_t pid) |
4169 | { | 4170 | { |
4170 | return pid ? find_task_by_pid(pid) : current; | 4171 | return pid ? |
4172 | find_task_by_pid_ns(pid, current->nsproxy->pid_ns) : current; | ||
4171 | } | 4173 | } |
4172 | 4174 | ||
4173 | /* Actually do priority change: must hold rq lock. */ | 4175 | /* Actually do priority change: must hold rq lock. */ |
diff --git a/kernel/signal.c b/kernel/signal.c index 98923882ba57..d809cdd6c0f1 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -694,7 +694,7 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t, | |||
694 | q->info.si_signo = sig; | 694 | q->info.si_signo = sig; |
695 | q->info.si_errno = 0; | 695 | q->info.si_errno = 0; |
696 | q->info.si_code = SI_USER; | 696 | q->info.si_code = SI_USER; |
697 | q->info.si_pid = current->pid; | 697 | q->info.si_pid = task_pid_vnr(current); |
698 | q->info.si_uid = current->uid; | 698 | q->info.si_uid = current->uid; |
699 | break; | 699 | break; |
700 | case (unsigned long) SEND_SIG_PRIV: | 700 | case (unsigned long) SEND_SIG_PRIV: |
@@ -1089,7 +1089,7 @@ kill_proc_info(int sig, struct siginfo *info, pid_t pid) | |||
1089 | { | 1089 | { |
1090 | int error; | 1090 | int error; |
1091 | rcu_read_lock(); | 1091 | rcu_read_lock(); |
1092 | error = kill_pid_info(sig, info, find_pid(pid)); | 1092 | error = kill_pid_info(sig, info, find_vpid(pid)); |
1093 | rcu_read_unlock(); | 1093 | rcu_read_unlock(); |
1094 | return error; | 1094 | return error; |
1095 | } | 1095 | } |
@@ -1160,9 +1160,9 @@ static int kill_something_info(int sig, struct siginfo *info, int pid) | |||
1160 | read_unlock(&tasklist_lock); | 1160 | read_unlock(&tasklist_lock); |
1161 | ret = count ? retval : -ESRCH; | 1161 | ret = count ? retval : -ESRCH; |
1162 | } else if (pid < 0) { | 1162 | } else if (pid < 0) { |
1163 | ret = kill_pgrp_info(sig, info, find_pid(-pid)); | 1163 | ret = kill_pgrp_info(sig, info, find_vpid(-pid)); |
1164 | } else { | 1164 | } else { |
1165 | ret = kill_pid_info(sig, info, find_pid(pid)); | 1165 | ret = kill_pid_info(sig, info, find_vpid(pid)); |
1166 | } | 1166 | } |
1167 | rcu_read_unlock(); | 1167 | rcu_read_unlock(); |
1168 | return ret; | 1168 | return ret; |
@@ -1266,7 +1266,12 @@ EXPORT_SYMBOL(kill_pid); | |||
1266 | int | 1266 | int |
1267 | kill_proc(pid_t pid, int sig, int priv) | 1267 | kill_proc(pid_t pid, int sig, int priv) |
1268 | { | 1268 | { |
1269 | return kill_proc_info(sig, __si_special(priv), pid); | 1269 | int ret; |
1270 | |||
1271 | rcu_read_lock(); | ||
1272 | ret = kill_pid_info(sig, __si_special(priv), find_pid(pid)); | ||
1273 | rcu_read_unlock(); | ||
1274 | return ret; | ||
1270 | } | 1275 | } |
1271 | 1276 | ||
1272 | /* | 1277 | /* |
@@ -1443,7 +1448,22 @@ void do_notify_parent(struct task_struct *tsk, int sig) | |||
1443 | 1448 | ||
1444 | info.si_signo = sig; | 1449 | info.si_signo = sig; |
1445 | info.si_errno = 0; | 1450 | info.si_errno = 0; |
1446 | info.si_pid = tsk->pid; | 1451 | /* |
1452 | * we are under tasklist_lock here so our parent is tied to | ||
1453 | * us and cannot exit and release its namespace. | ||
1454 | * | ||
1455 | * the only it can is to switch its nsproxy with sys_unshare, | ||
1456 | * bu uncharing pid namespaces is not allowed, so we'll always | ||
1457 | * see relevant namespace | ||
1458 | * | ||
1459 | * write_lock() currently calls preempt_disable() which is the | ||
1460 | * same as rcu_read_lock(), but according to Oleg, this is not | ||
1461 | * correct to rely on this | ||
1462 | */ | ||
1463 | rcu_read_lock(); | ||
1464 | info.si_pid = task_pid_nr_ns(tsk, tsk->parent->nsproxy->pid_ns); | ||
1465 | rcu_read_unlock(); | ||
1466 | |||
1447 | info.si_uid = tsk->uid; | 1467 | info.si_uid = tsk->uid; |
1448 | 1468 | ||
1449 | /* FIXME: find out whether or not this is supposed to be c*time. */ | 1469 | /* FIXME: find out whether or not this is supposed to be c*time. */ |
@@ -1508,7 +1528,13 @@ static void do_notify_parent_cldstop(struct task_struct *tsk, int why) | |||
1508 | 1528 | ||
1509 | info.si_signo = SIGCHLD; | 1529 | info.si_signo = SIGCHLD; |
1510 | info.si_errno = 0; | 1530 | info.si_errno = 0; |
1511 | info.si_pid = tsk->pid; | 1531 | /* |
1532 | * see comment in do_notify_parent() abot the following 3 lines | ||
1533 | */ | ||
1534 | rcu_read_lock(); | ||
1535 | info.si_pid = task_pid_nr_ns(tsk, tsk->parent->nsproxy->pid_ns); | ||
1536 | rcu_read_unlock(); | ||
1537 | |||
1512 | info.si_uid = tsk->uid; | 1538 | info.si_uid = tsk->uid; |
1513 | 1539 | ||
1514 | /* FIXME: find out whether or not this is supposed to be c*time. */ | 1540 | /* FIXME: find out whether or not this is supposed to be c*time. */ |
@@ -1634,7 +1660,7 @@ void ptrace_notify(int exit_code) | |||
1634 | memset(&info, 0, sizeof info); | 1660 | memset(&info, 0, sizeof info); |
1635 | info.si_signo = SIGTRAP; | 1661 | info.si_signo = SIGTRAP; |
1636 | info.si_code = exit_code; | 1662 | info.si_code = exit_code; |
1637 | info.si_pid = current->pid; | 1663 | info.si_pid = task_pid_vnr(current); |
1638 | info.si_uid = current->uid; | 1664 | info.si_uid = current->uid; |
1639 | 1665 | ||
1640 | /* Let the debugger run. */ | 1666 | /* Let the debugger run. */ |
@@ -1804,7 +1830,7 @@ relock: | |||
1804 | info->si_signo = signr; | 1830 | info->si_signo = signr; |
1805 | info->si_errno = 0; | 1831 | info->si_errno = 0; |
1806 | info->si_code = SI_USER; | 1832 | info->si_code = SI_USER; |
1807 | info->si_pid = current->parent->pid; | 1833 | info->si_pid = task_pid_vnr(current->parent); |
1808 | info->si_uid = current->parent->uid; | 1834 | info->si_uid = current->parent->uid; |
1809 | } | 1835 | } |
1810 | 1836 | ||
@@ -2191,7 +2217,7 @@ sys_kill(int pid, int sig) | |||
2191 | info.si_signo = sig; | 2217 | info.si_signo = sig; |
2192 | info.si_errno = 0; | 2218 | info.si_errno = 0; |
2193 | info.si_code = SI_USER; | 2219 | info.si_code = SI_USER; |
2194 | info.si_pid = current->tgid; | 2220 | info.si_pid = task_tgid_vnr(current); |
2195 | info.si_uid = current->uid; | 2221 | info.si_uid = current->uid; |
2196 | 2222 | ||
2197 | return kill_something_info(sig, &info, pid); | 2223 | return kill_something_info(sig, &info, pid); |
@@ -2207,12 +2233,12 @@ static int do_tkill(int tgid, int pid, int sig) | |||
2207 | info.si_signo = sig; | 2233 | info.si_signo = sig; |
2208 | info.si_errno = 0; | 2234 | info.si_errno = 0; |
2209 | info.si_code = SI_TKILL; | 2235 | info.si_code = SI_TKILL; |
2210 | info.si_pid = current->tgid; | 2236 | info.si_pid = task_tgid_vnr(current); |
2211 | info.si_uid = current->uid; | 2237 | info.si_uid = current->uid; |
2212 | 2238 | ||
2213 | read_lock(&tasklist_lock); | 2239 | read_lock(&tasklist_lock); |
2214 | p = find_task_by_pid(pid); | 2240 | p = find_task_by_pid_ns(pid, current->nsproxy->pid_ns); |
2215 | if (p && (tgid <= 0 || p->tgid == tgid)) { | 2241 | if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) { |
2216 | error = check_kill_permission(sig, &info, p); | 2242 | error = check_kill_permission(sig, &info, p); |
2217 | /* | 2243 | /* |
2218 | * The null signal is a permissions and process existence | 2244 | * The null signal is a permissions and process existence |
diff --git a/kernel/sys.c b/kernel/sys.c index 4cfa213a5ac2..23620d52cf37 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -152,7 +152,8 @@ asmlinkage long sys_setpriority(int which, int who, int niceval) | |||
152 | switch (which) { | 152 | switch (which) { |
153 | case PRIO_PROCESS: | 153 | case PRIO_PROCESS: |
154 | if (who) | 154 | if (who) |
155 | p = find_task_by_pid(who); | 155 | p = find_task_by_pid_ns(who, |
156 | current->nsproxy->pid_ns); | ||
156 | else | 157 | else |
157 | p = current; | 158 | p = current; |
158 | if (p) | 159 | if (p) |
@@ -160,7 +161,7 @@ asmlinkage long sys_setpriority(int which, int who, int niceval) | |||
160 | break; | 161 | break; |
161 | case PRIO_PGRP: | 162 | case PRIO_PGRP: |
162 | if (who) | 163 | if (who) |
163 | pgrp = find_pid(who); | 164 | pgrp = find_vpid(who); |
164 | else | 165 | else |
165 | pgrp = task_pgrp(current); | 166 | pgrp = task_pgrp(current); |
166 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { | 167 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { |
@@ -209,7 +210,8 @@ asmlinkage long sys_getpriority(int which, int who) | |||
209 | switch (which) { | 210 | switch (which) { |
210 | case PRIO_PROCESS: | 211 | case PRIO_PROCESS: |
211 | if (who) | 212 | if (who) |
212 | p = find_task_by_pid(who); | 213 | p = find_task_by_pid_ns(who, |
214 | current->nsproxy->pid_ns); | ||
213 | else | 215 | else |
214 | p = current; | 216 | p = current; |
215 | if (p) { | 217 | if (p) { |
@@ -220,7 +222,7 @@ asmlinkage long sys_getpriority(int which, int who) | |||
220 | break; | 222 | break; |
221 | case PRIO_PGRP: | 223 | case PRIO_PGRP: |
222 | if (who) | 224 | if (who) |
223 | pgrp = find_pid(who); | 225 | pgrp = find_vpid(who); |
224 | else | 226 | else |
225 | pgrp = task_pgrp(current); | 227 | pgrp = task_pgrp(current); |
226 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { | 228 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { |
@@ -917,9 +919,10 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid) | |||
917 | struct task_struct *p; | 919 | struct task_struct *p; |
918 | struct task_struct *group_leader = current->group_leader; | 920 | struct task_struct *group_leader = current->group_leader; |
919 | int err = -EINVAL; | 921 | int err = -EINVAL; |
922 | struct pid_namespace *ns; | ||
920 | 923 | ||
921 | if (!pid) | 924 | if (!pid) |
922 | pid = group_leader->pid; | 925 | pid = task_pid_vnr(group_leader); |
923 | if (!pgid) | 926 | if (!pgid) |
924 | pgid = pid; | 927 | pgid = pid; |
925 | if (pgid < 0) | 928 | if (pgid < 0) |
@@ -928,10 +931,12 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid) | |||
928 | /* From this point forward we keep holding onto the tasklist lock | 931 | /* From this point forward we keep holding onto the tasklist lock |
929 | * so that our parent does not change from under us. -DaveM | 932 | * so that our parent does not change from under us. -DaveM |
930 | */ | 933 | */ |
934 | ns = current->nsproxy->pid_ns; | ||
935 | |||
931 | write_lock_irq(&tasklist_lock); | 936 | write_lock_irq(&tasklist_lock); |
932 | 937 | ||
933 | err = -ESRCH; | 938 | err = -ESRCH; |
934 | p = find_task_by_pid(pid); | 939 | p = find_task_by_pid_ns(pid, ns); |
935 | if (!p) | 940 | if (!p) |
936 | goto out; | 941 | goto out; |
937 | 942 | ||
@@ -957,9 +962,9 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid) | |||
957 | goto out; | 962 | goto out; |
958 | 963 | ||
959 | if (pgid != pid) { | 964 | if (pgid != pid) { |
960 | struct task_struct *g = | 965 | struct task_struct *g; |
961 | find_task_by_pid_type(PIDTYPE_PGID, pgid); | ||
962 | 966 | ||
967 | g = find_task_by_pid_type_ns(PIDTYPE_PGID, pgid, ns); | ||
963 | if (!g || task_session(g) != task_session(group_leader)) | 968 | if (!g || task_session(g) != task_session(group_leader)) |
964 | goto out; | 969 | goto out; |
965 | } | 970 | } |
@@ -968,10 +973,13 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid) | |||
968 | if (err) | 973 | if (err) |
969 | goto out; | 974 | goto out; |
970 | 975 | ||
971 | if (task_pgrp_nr(p) != pgid) { | 976 | if (task_pgrp_nr_ns(p, ns) != pgid) { |
977 | struct pid *pid; | ||
978 | |||
972 | detach_pid(p, PIDTYPE_PGID); | 979 | detach_pid(p, PIDTYPE_PGID); |
973 | p->signal->pgrp = pgid; | 980 | pid = find_vpid(pgid); |
974 | attach_pid(p, PIDTYPE_PGID, find_pid(pgid)); | 981 | attach_pid(p, PIDTYPE_PGID, pid); |
982 | p->signal->pgrp = pid_nr(pid); | ||
975 | } | 983 | } |
976 | 984 | ||
977 | err = 0; | 985 | err = 0; |
@@ -984,19 +992,21 @@ out: | |||
984 | asmlinkage long sys_getpgid(pid_t pid) | 992 | asmlinkage long sys_getpgid(pid_t pid) |
985 | { | 993 | { |
986 | if (!pid) | 994 | if (!pid) |
987 | return task_pgrp_nr(current); | 995 | return task_pgrp_vnr(current); |
988 | else { | 996 | else { |
989 | int retval; | 997 | int retval; |
990 | struct task_struct *p; | 998 | struct task_struct *p; |
999 | struct pid_namespace *ns; | ||
991 | 1000 | ||
992 | read_lock(&tasklist_lock); | 1001 | ns = current->nsproxy->pid_ns; |
993 | p = find_task_by_pid(pid); | ||
994 | 1002 | ||
1003 | read_lock(&tasklist_lock); | ||
1004 | p = find_task_by_pid_ns(pid, ns); | ||
995 | retval = -ESRCH; | 1005 | retval = -ESRCH; |
996 | if (p) { | 1006 | if (p) { |
997 | retval = security_task_getpgid(p); | 1007 | retval = security_task_getpgid(p); |
998 | if (!retval) | 1008 | if (!retval) |
999 | retval = task_pgrp_nr(p); | 1009 | retval = task_pgrp_nr_ns(p, ns); |
1000 | } | 1010 | } |
1001 | read_unlock(&tasklist_lock); | 1011 | read_unlock(&tasklist_lock); |
1002 | return retval; | 1012 | return retval; |
@@ -1008,7 +1018,7 @@ asmlinkage long sys_getpgid(pid_t pid) | |||
1008 | asmlinkage long sys_getpgrp(void) | 1018 | asmlinkage long sys_getpgrp(void) |
1009 | { | 1019 | { |
1010 | /* SMP - assuming writes are word atomic this is fine */ | 1020 | /* SMP - assuming writes are word atomic this is fine */ |
1011 | return task_pgrp_nr(current); | 1021 | return task_pgrp_vnr(current); |
1012 | } | 1022 | } |
1013 | 1023 | ||
1014 | #endif | 1024 | #endif |
@@ -1016,19 +1026,21 @@ asmlinkage long sys_getpgrp(void) | |||
1016 | asmlinkage long sys_getsid(pid_t pid) | 1026 | asmlinkage long sys_getsid(pid_t pid) |
1017 | { | 1027 | { |
1018 | if (!pid) | 1028 | if (!pid) |
1019 | return task_session_nr(current); | 1029 | return task_session_vnr(current); |
1020 | else { | 1030 | else { |
1021 | int retval; | 1031 | int retval; |
1022 | struct task_struct *p; | 1032 | struct task_struct *p; |
1033 | struct pid_namespace *ns; | ||
1023 | 1034 | ||
1024 | read_lock(&tasklist_lock); | 1035 | ns = current->nsproxy->pid_ns; |
1025 | p = find_task_by_pid(pid); | ||
1026 | 1036 | ||
1037 | read_lock(&tasklist_lock); | ||
1038 | p = find_task_by_pid_ns(pid, ns); | ||
1027 | retval = -ESRCH; | 1039 | retval = -ESRCH; |
1028 | if (p) { | 1040 | if (p) { |
1029 | retval = security_task_getsid(p); | 1041 | retval = security_task_getsid(p); |
1030 | if (!retval) | 1042 | if (!retval) |
1031 | retval = task_session_nr(p); | 1043 | retval = task_session_nr_ns(p, ns); |
1032 | } | 1044 | } |
1033 | read_unlock(&tasklist_lock); | 1045 | read_unlock(&tasklist_lock); |
1034 | return retval; | 1046 | return retval; |
@@ -1065,7 +1077,7 @@ asmlinkage long sys_setsid(void) | |||
1065 | group_leader->signal->tty = NULL; | 1077 | group_leader->signal->tty = NULL; |
1066 | spin_unlock(&group_leader->sighand->siglock); | 1078 | spin_unlock(&group_leader->sighand->siglock); |
1067 | 1079 | ||
1068 | err = task_pgrp_nr(group_leader); | 1080 | err = task_pgrp_vnr(group_leader); |
1069 | out: | 1081 | out: |
1070 | write_unlock_irq(&tasklist_lock); | 1082 | write_unlock_irq(&tasklist_lock); |
1071 | return err; | 1083 | return err; |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 44868e4df1d3..3b4efbe26445 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -2278,7 +2278,7 @@ static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp | |||
2278 | pid_t tmp; | 2278 | pid_t tmp; |
2279 | int r; | 2279 | int r; |
2280 | 2280 | ||
2281 | tmp = pid_nr(cad_pid); | 2281 | tmp = pid_nr_ns(cad_pid, current->nsproxy->pid_ns); |
2282 | 2282 | ||
2283 | r = __do_proc_dointvec(&tmp, table, write, filp, buffer, | 2283 | r = __do_proc_dointvec(&tmp, table, write, filp, buffer, |
2284 | lenp, ppos, NULL, NULL); | 2284 | lenp, ppos, NULL, NULL); |
diff --git a/kernel/timer.c b/kernel/timer.c index 8521d10fbb27..fb4e67d5dd60 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/mm.h> | 27 | #include <linux/mm.h> |
28 | #include <linux/swap.h> | 28 | #include <linux/swap.h> |
29 | #include <linux/pid_namespace.h> | ||
29 | #include <linux/notifier.h> | 30 | #include <linux/notifier.h> |
30 | #include <linux/thread_info.h> | 31 | #include <linux/thread_info.h> |
31 | #include <linux/time.h> | 32 | #include <linux/time.h> |
@@ -956,7 +957,7 @@ asmlinkage unsigned long sys_alarm(unsigned int seconds) | |||
956 | */ | 957 | */ |
957 | asmlinkage long sys_getpid(void) | 958 | asmlinkage long sys_getpid(void) |
958 | { | 959 | { |
959 | return current->tgid; | 960 | return task_tgid_vnr(current); |
960 | } | 961 | } |
961 | 962 | ||
962 | /* | 963 | /* |
@@ -970,7 +971,7 @@ asmlinkage long sys_getppid(void) | |||
970 | int pid; | 971 | int pid; |
971 | 972 | ||
972 | rcu_read_lock(); | 973 | rcu_read_lock(); |
973 | pid = rcu_dereference(current->real_parent)->tgid; | 974 | pid = task_ppid_nr_ns(current, current->nsproxy->pid_ns); |
974 | rcu_read_unlock(); | 975 | rcu_read_unlock(); |
975 | 976 | ||
976 | return pid; | 977 | return pid; |
@@ -1102,7 +1103,7 @@ EXPORT_SYMBOL(schedule_timeout_uninterruptible); | |||
1102 | /* Thread ID - the internal kernel "pid" */ | 1103 | /* Thread ID - the internal kernel "pid" */ |
1103 | asmlinkage long sys_gettid(void) | 1104 | asmlinkage long sys_gettid(void) |
1104 | { | 1105 | { |
1105 | return current->pid; | 1106 | return task_pid_vnr(current); |
1106 | } | 1107 | } |
1107 | 1108 | ||
1108 | /** | 1109 | /** |
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 7fef5ebfaf13..a09ca3b1cf9c 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -78,6 +78,7 @@ | |||
78 | #include <linux/slab.h> | 78 | #include <linux/slab.h> |
79 | #include <linux/string.h> | 79 | #include <linux/string.h> |
80 | #include <linux/module.h> | 80 | #include <linux/module.h> |
81 | #include <linux/nsproxy.h> | ||
81 | #include <linux/interrupt.h> | 82 | #include <linux/interrupt.h> |
82 | #include <linux/init.h> | 83 | #include <linux/init.h> |
83 | #include <linux/compat.h> | 84 | #include <linux/compat.h> |
@@ -940,7 +941,8 @@ asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode, | |||
940 | 941 | ||
941 | /* Find the mm_struct */ | 942 | /* Find the mm_struct */ |
942 | read_lock(&tasklist_lock); | 943 | read_lock(&tasklist_lock); |
943 | task = pid ? find_task_by_pid(pid) : current; | 944 | task = pid ? |
945 | find_task_by_pid_ns(pid, current->nsproxy->pid_ns) : current; | ||
944 | if (!task) { | 946 | if (!task) { |
945 | read_unlock(&tasklist_lock); | 947 | read_unlock(&tasklist_lock); |
946 | return -ESRCH; | 948 | return -ESRCH; |
diff --git a/mm/migrate.c b/mm/migrate.c index 06d0877a66ef..c479357b5480 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/pagemap.h> | 19 | #include <linux/pagemap.h> |
20 | #include <linux/buffer_head.h> | 20 | #include <linux/buffer_head.h> |
21 | #include <linux/mm_inline.h> | 21 | #include <linux/mm_inline.h> |
22 | #include <linux/nsproxy.h> | ||
22 | #include <linux/pagevec.h> | 23 | #include <linux/pagevec.h> |
23 | #include <linux/rmap.h> | 24 | #include <linux/rmap.h> |
24 | #include <linux/topology.h> | 25 | #include <linux/topology.h> |
@@ -924,7 +925,8 @@ asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages, | |||
924 | 925 | ||
925 | /* Find the mm_struct */ | 926 | /* Find the mm_struct */ |
926 | read_lock(&tasklist_lock); | 927 | read_lock(&tasklist_lock); |
927 | task = pid ? find_task_by_pid(pid) : current; | 928 | task = pid ? |
929 | find_task_by_pid_ns(pid, current->nsproxy->pid_ns) : current; | ||
928 | if (!task) { | 930 | if (!task) { |
929 | read_unlock(&tasklist_lock); | 931 | read_unlock(&tasklist_lock); |
930 | return -ESRCH; | 932 | return -ESRCH; |
diff --git a/net/core/scm.c b/net/core/scm.c index 530bee8d9ed9..100ba6d9d478 100644 --- a/net/core/scm.c +++ b/net/core/scm.c | |||
@@ -24,6 +24,8 @@ | |||
24 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/netdevice.h> | 25 | #include <linux/netdevice.h> |
26 | #include <linux/security.h> | 26 | #include <linux/security.h> |
27 | #include <linux/pid.h> | ||
28 | #include <linux/nsproxy.h> | ||
27 | 29 | ||
28 | #include <asm/system.h> | 30 | #include <asm/system.h> |
29 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
@@ -42,7 +44,7 @@ | |||
42 | 44 | ||
43 | static __inline__ int scm_check_creds(struct ucred *creds) | 45 | static __inline__ int scm_check_creds(struct ucred *creds) |
44 | { | 46 | { |
45 | if ((creds->pid == current->tgid || capable(CAP_SYS_ADMIN)) && | 47 | if ((creds->pid == task_tgid_vnr(current) || capable(CAP_SYS_ADMIN)) && |
46 | ((creds->uid == current->uid || creds->uid == current->euid || | 48 | ((creds->uid == current->uid || creds->uid == current->euid || |
47 | creds->uid == current->suid) || capable(CAP_SETUID)) && | 49 | creds->uid == current->suid) || capable(CAP_SETUID)) && |
48 | ((creds->gid == current->gid || creds->gid == current->egid || | 50 | ((creds->gid == current->gid || creds->gid == current->egid || |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 6996cba5aa96..9163ec526c2a 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -483,7 +483,7 @@ static int unix_listen(struct socket *sock, int backlog) | |||
483 | sk->sk_max_ack_backlog = backlog; | 483 | sk->sk_max_ack_backlog = backlog; |
484 | sk->sk_state = TCP_LISTEN; | 484 | sk->sk_state = TCP_LISTEN; |
485 | /* set credentials so connect can copy them */ | 485 | /* set credentials so connect can copy them */ |
486 | sk->sk_peercred.pid = current->tgid; | 486 | sk->sk_peercred.pid = task_tgid_vnr(current); |
487 | sk->sk_peercred.uid = current->euid; | 487 | sk->sk_peercred.uid = current->euid; |
488 | sk->sk_peercred.gid = current->egid; | 488 | sk->sk_peercred.gid = current->egid; |
489 | err = 0; | 489 | err = 0; |
@@ -1133,7 +1133,7 @@ restart: | |||
1133 | unix_peer(newsk) = sk; | 1133 | unix_peer(newsk) = sk; |
1134 | newsk->sk_state = TCP_ESTABLISHED; | 1134 | newsk->sk_state = TCP_ESTABLISHED; |
1135 | newsk->sk_type = sk->sk_type; | 1135 | newsk->sk_type = sk->sk_type; |
1136 | newsk->sk_peercred.pid = current->tgid; | 1136 | newsk->sk_peercred.pid = task_tgid_vnr(current); |
1137 | newsk->sk_peercred.uid = current->euid; | 1137 | newsk->sk_peercred.uid = current->euid; |
1138 | newsk->sk_peercred.gid = current->egid; | 1138 | newsk->sk_peercred.gid = current->egid; |
1139 | newu = unix_sk(newsk); | 1139 | newu = unix_sk(newsk); |
@@ -1194,7 +1194,7 @@ static int unix_socketpair(struct socket *socka, struct socket *sockb) | |||
1194 | sock_hold(skb); | 1194 | sock_hold(skb); |
1195 | unix_peer(ska)=skb; | 1195 | unix_peer(ska)=skb; |
1196 | unix_peer(skb)=ska; | 1196 | unix_peer(skb)=ska; |
1197 | ska->sk_peercred.pid = skb->sk_peercred.pid = current->tgid; | 1197 | ska->sk_peercred.pid = skb->sk_peercred.pid = task_tgid_vnr(current); |
1198 | ska->sk_peercred.uid = skb->sk_peercred.uid = current->euid; | 1198 | ska->sk_peercred.uid = skb->sk_peercred.uid = current->euid; |
1199 | ska->sk_peercred.gid = skb->sk_peercred.gid = current->egid; | 1199 | ska->sk_peercred.gid = skb->sk_peercred.gid = current->egid; |
1200 | 1200 | ||