aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/shm.c
diff options
context:
space:
mode:
authorSteve Grubb <sgrubb@redhat.com>2006-04-02 17:07:33 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2006-05-01 06:10:04 -0400
commit073115d6b29c7910feaa08241c6484637f5ca958 (patch)
tree5fd32da9f54b3c12b65d3c0142fb9bdf87dc01c3 /ipc/shm.c
parentce29b682e228c70cdc91a1b2935c5adb2087bab8 (diff)
[PATCH] Rework of IPC auditing
1) The audit_ipc_perms() function has been split into two different functions: - audit_ipc_obj() - audit_ipc_set_perm() There's a key shift here... The audit_ipc_obj() collects the uid, gid, mode, and SElinux context label of the current ipc object. This audit_ipc_obj() hook is now found in several places. Most notably, it is hooked in ipcperms(), which is called in various places around the ipc code permforming a MAC check. Additionally there are several places where *checkid() is used to validate that an operation is being performed on a valid object while not necessarily having a nearby ipcperms() call. In these locations, audit_ipc_obj() is called to ensure that the information is captured by the audit system. The audit_set_new_perm() function is called any time the permissions on the ipc object changes. In this case, the NEW permissions are recorded (and note that an audit_ipc_obj() call exists just a few lines before each instance). 2) Support for an AUDIT_IPC_SET_PERM audit message type. This allows for separate auxiliary audit records for normal operations on an IPC object and permissions changes. Note that the same struct audit_aux_data_ipcctl is used and populated, however there are separate audit_log_format statements based on the type of the message. Finally, the AUDIT_IPC block of code in audit_free_aux() was extended to handle aux messages of this new type. No more mem leaks I hope ;-) Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'ipc/shm.c')
-rw-r--r--ipc/shm.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 1c2faf62bc73..809896851902 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -13,6 +13,8 @@
13 * Shared /dev/zero support, Kanoj Sarcar <kanoj@sgi.com> 13 * Shared /dev/zero support, Kanoj Sarcar <kanoj@sgi.com>
14 * Move the mm functionality over to mm/shmem.c, Christoph Rohland <cr@sap.com> 14 * Move the mm functionality over to mm/shmem.c, Christoph Rohland <cr@sap.com>
15 * 15 *
16 * support for audit of ipc object properties and permission changes
17 * Dustin Kirkland <dustin.kirkland@us.ibm.com>
16 */ 18 */
17 19
18#include <linux/config.h> 20#include <linux/config.h>
@@ -542,6 +544,10 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
542 if(err) 544 if(err)
543 goto out_unlock; 545 goto out_unlock;
544 546
547 err = audit_ipc_obj(&(shp->shm_perm));
548 if (err)
549 goto out_unlock;
550
545 if (!capable(CAP_IPC_LOCK)) { 551 if (!capable(CAP_IPC_LOCK)) {
546 err = -EPERM; 552 err = -EPERM;
547 if (current->euid != shp->shm_perm.uid && 553 if (current->euid != shp->shm_perm.uid &&
@@ -594,6 +600,10 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
594 if(err) 600 if(err)
595 goto out_unlock_up; 601 goto out_unlock_up;
596 602
603 err = audit_ipc_obj(&(shp->shm_perm));
604 if (err)
605 goto out_unlock_up;
606
597 if (current->euid != shp->shm_perm.uid && 607 if (current->euid != shp->shm_perm.uid &&
598 current->euid != shp->shm_perm.cuid && 608 current->euid != shp->shm_perm.cuid &&
599 !capable(CAP_SYS_ADMIN)) { 609 !capable(CAP_SYS_ADMIN)) {
@@ -627,12 +637,15 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
627 err=-EINVAL; 637 err=-EINVAL;
628 if(shp==NULL) 638 if(shp==NULL)
629 goto out_up; 639 goto out_up;
630 if ((err = audit_ipc_perms(0, setbuf.uid, setbuf.gid,
631 setbuf.mode, &(shp->shm_perm))))
632 goto out_unlock_up;
633 err = shm_checkid(shp,shmid); 640 err = shm_checkid(shp,shmid);
634 if(err) 641 if(err)
635 goto out_unlock_up; 642 goto out_unlock_up;
643 err = audit_ipc_obj(&(shp->shm_perm));
644 if (err)
645 goto out_unlock_up;
646 err = audit_ipc_set_perm(0, setbuf.uid, setbuf.gid, setbuf.mode, &(shp->shm_perm));
647 if (err)
648 goto out_unlock_up;
636 err=-EPERM; 649 err=-EPERM;
637 if (current->euid != shp->shm_perm.uid && 650 if (current->euid != shp->shm_perm.uid &&
638 current->euid != shp->shm_perm.cuid && 651 current->euid != shp->shm_perm.cuid &&