[Bluetooth] Enable SCO support for Broadcom HID proxy dongle
[pandora-kernel.git] / ipc / shm.c
index 1c2faf6..940b0c9 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
  * Shared /dev/zero support, Kanoj Sarcar <kanoj@sgi.com>
  * Move the mm functionality over to mm/shmem.c, Christoph Rohland <cr@sap.com>
  *
+ * support for audit of ipc object properties and permission changes
+ * Dustin Kirkland <dustin.kirkland@us.ibm.com>
  */
 
-#include <linux/config.h>
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
@@ -542,6 +543,10 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
                if(err)
                        goto out_unlock;
 
+               err = audit_ipc_obj(&(shp->shm_perm));
+               if (err)
+                       goto out_unlock;
+
                if (!capable(CAP_IPC_LOCK)) {
                        err = -EPERM;
                        if (current->euid != shp->shm_perm.uid &&
@@ -594,6 +599,10 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
                if(err)
                        goto out_unlock_up;
 
+               err = audit_ipc_obj(&(shp->shm_perm));
+               if (err)
+                       goto out_unlock_up;
+
                if (current->euid != shp->shm_perm.uid &&
                    current->euid != shp->shm_perm.cuid && 
                    !capable(CAP_SYS_ADMIN)) {
@@ -627,12 +636,15 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
                err=-EINVAL;
                if(shp==NULL)
                        goto out_up;
-               if ((err = audit_ipc_perms(0, setbuf.uid, setbuf.gid,
-                                       setbuf.mode, &(shp->shm_perm))))
-                       goto out_unlock_up;
                err = shm_checkid(shp,shmid);
                if(err)
                        goto out_unlock_up;
+               err = audit_ipc_obj(&(shp->shm_perm));
+               if (err)
+                       goto out_unlock_up;
+               err = audit_ipc_set_perm(0, setbuf.uid, setbuf.gid, setbuf.mode);
+               if (err)
+                       goto out_unlock_up;
                err=-EPERM;
                if (current->euid != shp->shm_perm.uid &&
                    current->euid != shp->shm_perm.cuid && 
@@ -685,7 +697,6 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
        int    err;
        unsigned long flags;
        unsigned long prot;
-       unsigned long o_flags;
        int acc_mode;
        void *user_addr;
 
@@ -712,11 +723,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
 
        if (shmflg & SHM_RDONLY) {
                prot = PROT_READ;
-               o_flags = O_RDONLY;
                acc_mode = S_IRUGO;
        } else {
                prot = PROT_READ | PROT_WRITE;
-               o_flags = O_RDWR;
                acc_mode = S_IRUGO | S_IWUGO;
        }
        if (shmflg & SHM_EXEC) {