Merge branch 'fixes' of git://git.linaro.org/people/rmk/linux-arm
[linux-flexiantxendom0-3.2.10.git] / ipc / msg.c
index b4eee1c..7385de2 100644 (file)
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -23,7 +23,6 @@
  */
 
 #include <linux/capability.h>
-#include <linux/slab.h>
 #include <linux/msg.h>
 #include <linux/spinlock.h>
 #include <linux/init.h>
@@ -125,6 +124,7 @@ void msg_init_ns(struct ipc_namespace *ns)
 void msg_exit_ns(struct ipc_namespace *ns)
 {
        free_ipcs(ns, &msg_ids(ns), freeque);
+       idr_destroy(&ns->ids[IPC_MSG_IDS].ipcs_idr);
 }
 #endif
 
@@ -309,7 +309,7 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
        return security_msg_queue_associate(msq, msgflg);
 }
 
-asmlinkage long sys_msgget(key_t key, int msgflg)
+SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
 {
        struct ipc_namespace *ns;
        struct ipc_ops msg_ops;
@@ -345,19 +345,19 @@ copy_msqid_to_user(void __user *buf, struct msqid64_ds *in, int version)
                out.msg_rtime           = in->msg_rtime;
                out.msg_ctime           = in->msg_ctime;
 
-               if (in->msg_cbytes > USHORT_MAX)
-                       out.msg_cbytes  = USHORT_MAX;
+               if (in->msg_cbytes > USHRT_MAX)
+                       out.msg_cbytes  = USHRT_MAX;
                else
                        out.msg_cbytes  = in->msg_cbytes;
                out.msg_lcbytes         = in->msg_cbytes;
 
-               if (in->msg_qnum > USHORT_MAX)
-                       out.msg_qnum    = USHORT_MAX;
+               if (in->msg_qnum > USHRT_MAX)
+                       out.msg_qnum    = USHRT_MAX;
                else
                        out.msg_qnum    = in->msg_qnum;
 
-               if (in->msg_qbytes > USHORT_MAX)
-                       out.msg_qbytes  = USHORT_MAX;
+               if (in->msg_qbytes > USHRT_MAX)
+                       out.msg_qbytes  = USHRT_MAX;
                else
                        out.msg_qbytes  = in->msg_qbytes;
                out.msg_lqbytes         = in->msg_qbytes;
@@ -412,7 +412,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
                       struct msqid_ds __user *buf, int version)
 {
        struct kern_ipc_perm *ipcp;
-       struct msqid64_ds msqid64;
+       struct msqid64_ds uninitialized_var(msqid64);
        struct msg_queue *msq;
        int err;
 
@@ -421,7 +421,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
                        return -EFAULT;
        }
 
-       ipcp = ipcctl_pre_down(&msg_ids(ns), msqid, cmd,
+       ipcp = ipcctl_pre_down(ns, &msg_ids(ns), msqid, cmd,
                               &msqid64.msg_perm, msqid64.msg_qbytes);
        if (IS_ERR(ipcp))
                return PTR_ERR(ipcp);
@@ -466,7 +466,7 @@ out_up:
        return err;
 }
 
-asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf)
+SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf)
 {
        struct msg_queue *msq;
        int err, version;
@@ -539,7 +539,7 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf)
                        success_return = 0;
                }
                err = -EACCES;
-               if (ipcperms(&msq->q_perm, S_IRUGO))
+               if (ipcperms(ns, &msq->q_perm, S_IRUGO))
                        goto out_unlock;
 
                err = security_msg_queue_msgctl(msq, cmd);
@@ -664,7 +664,7 @@ long do_msgsnd(int msqid, long mtype, void __user *mtext,
                struct msg_sender s;
 
                err = -EACCES;
-               if (ipcperms(&msq->q_perm, S_IWUGO))
+               if (ipcperms(ns, &msq->q_perm, S_IWUGO))
                        goto out_unlock_free;
 
                err = security_msg_queue_msgsnd(msq, msg, msgflg);
@@ -704,7 +704,7 @@ long do_msgsnd(int msqid, long mtype, void __user *mtext,
        msq->q_stime = get_seconds();
 
        if (!pipelined_send(msq, msg)) {
-               /* noone is waiting for this message, enqueue it */
+               /* no one is waiting for this message, enqueue it */
                list_add_tail(&msg->m_list, &msq->q_messages);
                msq->q_cbytes += msgsz;
                msq->q_qnum++;
@@ -723,8 +723,8 @@ out_free:
        return err;
 }
 
-asmlinkage long
-sys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz, int msgflg)
+SYSCALL_DEFINE4(msgsnd, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz,
+               int, msgflg)
 {
        long mtype;
 
@@ -774,7 +774,7 @@ long do_msgrcv(int msqid, long *pmtype, void __user *mtext,
                struct list_head *tmp;
 
                msg = ERR_PTR(-EACCES);
-               if (ipcperms(&msq->q_perm, S_IRUGO))
+               if (ipcperms(ns, &msq->q_perm, S_IRUGO))
                        goto out_unlock;
 
                msg = ERR_PTR(-EAGAIN);
@@ -842,7 +842,7 @@ long do_msgrcv(int msqid, long *pmtype, void __user *mtext,
                 * Disable preemption.  We don't hold a reference to the queue
                 * and getting a reference would defeat the idea of a lockless
                 * operation, thus the code relies on rcu to guarantee the
-                * existance of msq:
+                * existence of msq:
                 * Prior to destruction, expunge_all(-EIRDM) changes r_msg.
                 * Thus if r_msg is -EAGAIN, then the queue not yet destroyed.
                 * rcu_read_lock() prevents preemption between reading r_msg
@@ -904,8 +904,8 @@ out_unlock:
        return msgsz;
 }
 
-asmlinkage long sys_msgrcv(int msqid, struct msgbuf __user *msgp, size_t msgsz,
-                          long msgtyp, int msgflg)
+SYSCALL_DEFINE5(msgrcv, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz,
+               long, msgtyp, int, msgflg)
 {
        long err, mtype;