forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
ce29b68
commit 073115d
Showing
6 changed files
with
98 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,9 @@ | |
* mostly rewritten, threaded and wake-one semantics added | ||
* MSGMAX limit removed, sysctl's added | ||
* (c) 1999 Manfred Spraul <[email protected]> | ||
* | ||
* support for audit of ipc object properties and permission changes | ||
* Dustin Kirkland <[email protected]> | ||
*/ | ||
|
||
#include <linux/capability.h> | ||
|
@@ -447,6 +450,11 @@ asmlinkage long sys_msgctl (int msqid, int cmd, struct msqid_ds __user *buf) | |
if (msg_checkid(msq,msqid)) | ||
goto out_unlock_up; | ||
ipcp = &msq->q_perm; | ||
|
||
err = audit_ipc_obj(ipcp); | ||
if (err) | ||
goto out_unlock_up; | ||
|
||
err = -EPERM; | ||
if (current->euid != ipcp->cuid && | ||
current->euid != ipcp->uid && !capable(CAP_SYS_ADMIN)) | ||
|
@@ -460,7 +468,8 @@ asmlinkage long sys_msgctl (int msqid, int cmd, struct msqid_ds __user *buf) | |
switch (cmd) { | ||
case IPC_SET: | ||
{ | ||
if ((err = audit_ipc_perms(setbuf.qbytes, setbuf.uid, setbuf.gid, setbuf.mode, ipcp))) | ||
err = audit_ipc_set_perm(setbuf.qbytes, setbuf.uid, setbuf.gid, setbuf.mode, ipcp); | ||
if (err) | ||
goto out_unlock_up; | ||
|
||
err = -EPERM; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,9 @@ | |
* (c) 2001 Red Hat Inc <[email protected]> | ||
* Lockless wakeup | ||
* (c) 2003 Manfred Spraul <[email protected]> | ||
* | ||
* support for audit of ipc object properties and permission changes | ||
* Dustin Kirkland <[email protected]> | ||
*/ | ||
|
||
#include <linux/config.h> | ||
|
@@ -820,6 +823,11 @@ static int semctl_down(int semid, int semnum, int cmd, int version, union semun | |
goto out_unlock; | ||
} | ||
ipcp = &sma->sem_perm; | ||
|
||
err = audit_ipc_obj(ipcp); | ||
if (err) | ||
goto out_unlock; | ||
|
||
if (current->euid != ipcp->cuid && | ||
current->euid != ipcp->uid && !capable(CAP_SYS_ADMIN)) { | ||
err=-EPERM; | ||
|
@@ -836,7 +844,8 @@ static int semctl_down(int semid, int semnum, int cmd, int version, union semun | |
err = 0; | ||
break; | ||
case IPC_SET: | ||
if ((err = audit_ipc_perms(0, setbuf.uid, setbuf.gid, setbuf.mode, ipcp))) | ||
err = audit_ipc_set_perm(0, setbuf.uid, setbuf.gid, setbuf.mode, ipcp); | ||
if (err) | ||
goto out_unlock; | ||
ipcp->uid = setbuf.uid; | ||
ipcp->gid = setbuf.gid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
* Shared /dev/zero support, Kanoj Sarcar <[email protected]> | ||
* Move the mm functionality over to mm/shmem.c, Christoph Rohland <[email protected]> | ||
* | ||
* support for audit of ipc object properties and permission changes | ||
* Dustin Kirkland <[email protected]> | ||
*/ | ||
|
||
#include <linux/config.h> | ||
|
@@ -542,6 +544,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 +600,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 +637,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, &(shp->shm_perm)); | ||
if (err) | ||
goto out_unlock_up; | ||
err=-EPERM; | ||
if (current->euid != shp->shm_perm.uid && | ||
current->euid != shp->shm_perm.cuid && | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
* Manfred Spraul <[email protected]> | ||
* Oct 2002 - One lock per IPC id. RCU ipc_free for lock-free grow_ary(). | ||
* Mingming Cao <[email protected]> | ||
* Mar 2006 - support for audit of ipc object properties | ||
* Dustin Kirkland <[email protected]> | ||
*/ | ||
|
||
#include <linux/config.h> | ||
|
@@ -27,6 +29,7 @@ | |
#include <linux/workqueue.h> | ||
#include <linux/seq_file.h> | ||
#include <linux/proc_fs.h> | ||
#include <linux/audit.h> | ||
|
||
#include <asm/unistd.h> | ||
|
||
|
@@ -464,8 +467,10 @@ void ipc_rcu_putref(void *ptr) | |
|
||
int ipcperms (struct kern_ipc_perm *ipcp, short flag) | ||
{ /* flag will most probably be 0 or S_...UGO from <linux/stat.h> */ | ||
int requested_mode, granted_mode; | ||
int requested_mode, granted_mode, err; | ||
|
||
if (unlikely((err = audit_ipc_obj(ipcp)))) | ||
return err; | ||
requested_mode = (flag >> 6) | (flag >> 3) | flag; | ||
granted_mode = ipcp->mode; | ||
if (current->euid == ipcp->cuid || current->euid == ipcp->uid) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters