mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
[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 <[email protected]>
This commit is contained in:
parent
ce29b682e2
commit
073115d6b2
6 changed files with 98 additions and 11 deletions
11
ipc/sem.c
11
ipc/sem.c
|
|
@ -61,6 +61,9 @@
|
|||
* (c) 2001 Red Hat Inc <alan@redhat.com>
|
||||
* Lockless wakeup
|
||||
* (c) 2003 Manfred Spraul <manfred@colorfullife.com>
|
||||
*
|
||||
* support for audit of ipc object properties and permission changes
|
||||
* Dustin Kirkland <dustin.kirkland@us.ibm.com>
|
||||
*/
|
||||
|
||||
#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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue