aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-10-19 02:40:14 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 14:53:40 -0400
commitb488893a390edfe027bae7a46e9af8083e740668 (patch)
treec469a7f99ad01005a73011c029eb5e5d15454559 /ipc
parent3eb07c8c8adb6f0572baba844ba2d9e501654316 (diff)
pid namespaces: changes to show virtual ids to user
This is the largest patch in the set. Make all (I hope) the places where the pid is shown to or get from user operate on the virtual pids. The idea is: - all in-kernel data structures must store either struct pid itself or the pid's global nr, obtained with pid_nr() call; - when seeking the task from kernel code with the stored id one should use find_task_by_pid() call that works with global pids; - when showing pid's numerical value to the user the virtual one should be used, but however when one shows task's pid outside this task's namespace the global one is to be used; - when getting the pid from userspace one need to consider this as the virtual one and use appropriate task/pid-searching functions. [akpm@linux-foundation.org: build fix] [akpm@linux-foundation.org: nuther build fix] [akpm@linux-foundation.org: yet nuther build fix] [akpm@linux-foundation.org: remove unneeded casts] Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: Alexey Dobriyan <adobriyan@openvz.org> Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com> Cc: Oleg Nesterov <oleg@tv-sign.ru> Cc: Paul Menage <menage@google.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/mqueue.c7
-rw-r--r--ipc/msg.c6
-rw-r--r--ipc/sem.c8
-rw-r--r--ipc/shm.c6
4 files changed, 15 insertions, 12 deletions
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,
diff --git a/ipc/msg.c b/ipc/msg.c
index a03fcb522fff..319468609b76 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -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);
diff --git a/ipc/sem.c b/ipc/sem.c
index b676fef6d208..64ff4261f4e2 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -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();
diff --git a/ipc/shm.c b/ipc/shm.c
index 5fc5cf50cf1b..b9d272900a1e 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -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();