diff options
author | Kirill Korotaev <dev@openvz.org> | 2007-10-19 02:40:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-19 14:53:48 -0400 |
commit | 3ac88a41ff747b8c2f290f86b5243b2f8fce2cc0 (patch) | |
tree | a0a87ebb1b5cac9da1a2cee05475139b16a8dbc6 /ipc | |
parent | c530c6ac7eb1d4ae1ff6b382d9211be446ee82c6 (diff) |
virtualization of sysv msg queues is incomplete
Virtualization of sysv msg queues is incomplete: msg_hdrs and msg_bytes
variables visible from userspace are global. Let's make them
per-namespace.
Signed-off-by: Alexey Kuznetsov <alexey@openvz.org>
Signed-off-by: Kirill Korotaev <dev@openvz.org>
Cc: Pierre Peiffer <pierre.peiffer@bull.net>
Cc: Nadia Derbey <Nadia.Derbey@bull.net>
Cc: Serge Hallyn <serue@us.ibm.com>
Acked-by: "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/msg.c | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -66,9 +66,6 @@ struct msg_sender { | |||
66 | #define SEARCH_NOTEQUAL 3 | 66 | #define SEARCH_NOTEQUAL 3 |
67 | #define SEARCH_LESSEQUAL 4 | 67 | #define SEARCH_LESSEQUAL 4 |
68 | 68 | ||
69 | static atomic_t msg_bytes = ATOMIC_INIT(0); | ||
70 | static atomic_t msg_hdrs = ATOMIC_INIT(0); | ||
71 | |||
72 | static struct ipc_ids init_msg_ids; | 69 | static struct ipc_ids init_msg_ids; |
73 | 70 | ||
74 | #define msg_ids(ns) (*((ns)->ids[IPC_MSG_IDS])) | 71 | #define msg_ids(ns) (*((ns)->ids[IPC_MSG_IDS])) |
@@ -88,6 +85,8 @@ static void __msg_init_ns(struct ipc_namespace *ns, struct ipc_ids *ids) | |||
88 | ns->msg_ctlmax = MSGMAX; | 85 | ns->msg_ctlmax = MSGMAX; |
89 | ns->msg_ctlmnb = MSGMNB; | 86 | ns->msg_ctlmnb = MSGMNB; |
90 | ns->msg_ctlmni = MSGMNI; | 87 | ns->msg_ctlmni = MSGMNI; |
88 | atomic_set(&ns->msg_bytes, 0); | ||
89 | atomic_set(&ns->msg_hdrs, 0); | ||
91 | ipc_init_ids(ids); | 90 | ipc_init_ids(ids); |
92 | } | 91 | } |
93 | 92 | ||
@@ -293,10 +292,10 @@ static void freeque(struct ipc_namespace *ns, struct msg_queue *msq) | |||
293 | struct msg_msg *msg = list_entry(tmp, struct msg_msg, m_list); | 292 | struct msg_msg *msg = list_entry(tmp, struct msg_msg, m_list); |
294 | 293 | ||
295 | tmp = tmp->next; | 294 | tmp = tmp->next; |
296 | atomic_dec(&msg_hdrs); | 295 | atomic_dec(&ns->msg_hdrs); |
297 | free_msg(msg); | 296 | free_msg(msg); |
298 | } | 297 | } |
299 | atomic_sub(msq->q_cbytes, &msg_bytes); | 298 | atomic_sub(msq->q_cbytes, &ns->msg_bytes); |
300 | security_msg_queue_free(msq); | 299 | security_msg_queue_free(msq); |
301 | ipc_rcu_putref(msq); | 300 | ipc_rcu_putref(msq); |
302 | } | 301 | } |
@@ -463,8 +462,8 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf) | |||
463 | down_read(&msg_ids(ns).rw_mutex); | 462 | down_read(&msg_ids(ns).rw_mutex); |
464 | if (cmd == MSG_INFO) { | 463 | if (cmd == MSG_INFO) { |
465 | msginfo.msgpool = msg_ids(ns).in_use; | 464 | msginfo.msgpool = msg_ids(ns).in_use; |
466 | msginfo.msgmap = atomic_read(&msg_hdrs); | 465 | msginfo.msgmap = atomic_read(&ns->msg_hdrs); |
467 | msginfo.msgtql = atomic_read(&msg_bytes); | 466 | msginfo.msgtql = atomic_read(&ns->msg_bytes); |
468 | } else { | 467 | } else { |
469 | msginfo.msgmap = MSGMAP; | 468 | msginfo.msgmap = MSGMAP; |
470 | msginfo.msgpool = MSGPOOL; | 469 | msginfo.msgpool = MSGPOOL; |
@@ -735,8 +734,8 @@ long do_msgsnd(int msqid, long mtype, void __user *mtext, | |||
735 | list_add_tail(&msg->m_list, &msq->q_messages); | 734 | list_add_tail(&msg->m_list, &msq->q_messages); |
736 | msq->q_cbytes += msgsz; | 735 | msq->q_cbytes += msgsz; |
737 | msq->q_qnum++; | 736 | msq->q_qnum++; |
738 | atomic_add(msgsz, &msg_bytes); | 737 | atomic_add(msgsz, &ns->msg_bytes); |
739 | atomic_inc(&msg_hdrs); | 738 | atomic_inc(&ns->msg_hdrs); |
740 | } | 739 | } |
741 | 740 | ||
742 | err = 0; | 741 | err = 0; |
@@ -840,8 +839,8 @@ long do_msgrcv(int msqid, long *pmtype, void __user *mtext, | |||
840 | msq->q_rtime = get_seconds(); | 839 | msq->q_rtime = get_seconds(); |
841 | msq->q_lrpid = task_tgid_vnr(current); | 840 | msq->q_lrpid = task_tgid_vnr(current); |
842 | msq->q_cbytes -= msg->m_ts; | 841 | msq->q_cbytes -= msg->m_ts; |
843 | atomic_sub(msg->m_ts, &msg_bytes); | 842 | atomic_sub(msg->m_ts, &ns->msg_bytes); |
844 | atomic_dec(&msg_hdrs); | 843 | atomic_dec(&ns->msg_hdrs); |
845 | ss_wakeup(&msq->q_senders, 0); | 844 | ss_wakeup(&msq->q_senders, 0); |
846 | msg_unlock(msq); | 845 | msg_unlock(msq); |
847 | break; | 846 | break; |