]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/sysv_msg.c
xnu-4570.41.2.tar.gz
[apple/xnu.git] / bsd / kern / sysv_msg.c
index 7ed083eb969ff897feb8fe4330949b40a1f80da3..fad2cfbf766c6eb35febf096c2472150f81ae866 100644 (file)
 #include <sys/sysproto.h>
 #include <sys/ipcs.h>
 
+#if CONFIG_MACF
+#include <security/mac_framework.h>
+#endif
+
 #if SYSV_MSG
 
 static int msginit(void *);
@@ -216,7 +220,7 @@ static int
 msginit(__unused void *dummy)
 {
        static int initted = 0;
-       register int i;
+       int i;
 
        /* Lazy initialization on first system call; we don't have SYSINIT(). */
        if (initted)
@@ -268,7 +272,7 @@ msginit(__unused void *dummy)
        }
 
        MALLOC(msqids, struct msqid_kernel *,
-                       sizeof(struct user_msqid_ds) * msginfo.msgmni, 
+                       sizeof(struct msqid_kernel) * msginfo.msgmni,
                        M_SHM, M_WAITOK);
        if (msqids == NULL) {
                printf("msginit: can't allocate msqids");
@@ -558,11 +562,11 @@ msgctl(struct proc *p, struct msgctl_args *uap, int32_t *retval)
 
                SYSV_MSG_SUBSYS_UNLOCK();
                if (IS_64BIT_PROCESS(p)) {
-                       struct user64_msqid_ds msqid_ds64;
+                       struct user64_msqid_ds msqid_ds64 = {};
                        msqid_ds_kerneltouser64(&msqptr->u, &msqid_ds64);
                        eval = copyout(&msqid_ds64, uap->buf, sizeof(msqid_ds64));
                } else {
-                       struct user32_msqid_ds msqid_ds32;
+                       struct user32_msqid_ds msqid_ds32 = {};
                        msqid_ds_kerneltouser32(&msqptr->u, &msqid_ds32);
                        eval = copyout(&msqid_ds32, uap->buf, sizeof(msqid_ds32));
                }
@@ -667,8 +671,8 @@ msgget(__unused struct proc *p, struct msgget_args *uap, int32_t *retval)
                msqptr->u.msg_perm._key = key;
                msqptr->u.msg_perm.cuid = kauth_cred_getuid(cred);
                msqptr->u.msg_perm.uid = kauth_cred_getuid(cred);
-               msqptr->u.msg_perm.cgid = cred->cr_gid;
-               msqptr->u.msg_perm.gid = cred->cr_gid;
+               msqptr->u.msg_perm.cgid = kauth_cred_getgid(cred);
+               msqptr->u.msg_perm.gid = kauth_cred_getgid(cred);
                msqptr->u.msg_perm.mode = (msgflg & 0777);
                /* Make sure that the returned msqid is unique */
                msqptr->u.msg_perm._seq++;
@@ -1468,8 +1472,8 @@ IPCS_msg_sysctl(__unused struct sysctl_oid *oidp, __unused void *arg1,
                struct user32_IPCS_command u32;
                struct user_IPCS_command u64;
        } ipcs;
-       struct user32_msqid_ds msqid_ds32;      /* post conversion, 32 bit version */
-       struct user64_msqid_ds msqid_ds64;      /* post conversion, 64 bit version */
+       struct user32_msqid_ds msqid_ds32 = {}; /* post conversion, 32 bit version */
+       struct user64_msqid_ds msqid_ds64 = {}; /* post conversion, 64 bit version */
        void *msqid_dsp;
        size_t ipcs_sz;
        size_t msqid_ds_sz;
@@ -1576,7 +1580,7 @@ IPCS_msg_sysctl(__unused struct sysctl_oid *oidp, __unused void *arg1,
 }
 
 SYSCTL_DECL(_kern_sysv_ipcs);
-SYSCTL_PROC(_kern_sysv_ipcs, OID_AUTO, msg, CTLFLAG_RW|CTLFLAG_ANYBODY,
+SYSCTL_PROC(_kern_sysv_ipcs, OID_AUTO, msg, CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_LOCKED,
        0, 0, IPCS_msg_sysctl,
        "S,IPCS_msg_command",
        "ipcs msg command interface");