Skip to contentSkip to conversation

Audit permission changes on IPC objects.

PATCH New David Woodhouse 1 participant 1 message Feb 28, 2005 Audit

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Audit permission changes on IPC objects.

Capture the requested permissions on IPC_SET calls. We do this with a hook in ipc/{sem,shm,msg}.c for two reasons. Firstly, it would require a lot of arch-specific knowledge about syscall numbers and sys_ipc() multiplexing to get at this information from syscall_trace_enter(). Secondly, if we did it there it could be changed by the time the IPC code does copy_from_user() to fetch it again.

===== include/linux/audit.h 1.2 vs edited =====

include/linux/audit.h +2 -0
@@ -150,6 +150,7 @@
 			    struct timespec *t, int *serial);
 extern int  audit_set_loginuid(struct audit_context *ctx, uid_t loginuid);
 extern uid_t audit_get_loginuid(struct audit_context *ctx);
+extern int audit_ipc_perms(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode);
 #else
 #define audit_alloc(t) ({ 0; })
 #define audit_free(t) do { ; } while (0)
@@ -159,6 +160,7 @@
 #define audit_putname(n) do { ; } while (0)
 #define audit_inode(n,i,d) do { ; } while (0)
 #define audit_get_loginuid(c) ({ -1; })
+#define audit_ipc_perms(q,u,g,m) ({ 0; })
 #endif
 
 #ifdef CONFIG_AUDIT

===== ipc/msg.c 1.24 vs edited =====

ipc/msg.c +3 -0
@@ -25,6 +25,7 @@
 #include <linux/security.h>
 #include <linux/sched.h>
 #include <linux/syscalls.h>
+#include <linux/audit.h>
 #include <asm/current.h>
 #include <asm/uaccess.h>
 #include "util.h"
@@ -425,6 +426,8 @@
 			return -EFAULT;
 		if (copy_msqid_from_user (&setbuf, buf, version))
 			return -EFAULT;
+		if ((err = audit_ipc_perms(setbuf.qbytes, setbuf.uid, setbuf.gid, setbuf.mode)))
+			return err;
 		break;
 	case IPC_RMID:
 		break;

===== ipc/sem.c 1.36 vs edited =====

ipc/sem.c +3 -0
@@ -72,6 +72,7 @@
 #include <linux/smp_lock.h>
 #include <linux/security.h>
 #include <linux/syscalls.h>
+#include <linux/audit.h>
 #include <asm/uaccess.h>
 #include "util.h"
 
@@ -803,6 +804,8 @@
 	if(cmd == IPC_SET) {
 		if(copy_semid_from_user (&setbuf, arg.buf, version))
 			return -EFAULT;
+		if ((err = audit_ipc_perms(0, setbuf.uid, setbuf.gid, setbuf.mode)))
+			return err;
 	}
 	sma = sem_lock(semid);
 	if(sma==NULL)

===== ipc/shm.c 1.43 vs edited =====

ipc/shm.c +3 -0
@@ -27,6 +27,7 @@
 #include <linux/shmem_fs.h>
 #include <linux/security.h>
 #include <linux/syscalls.h>
+#include <linux/audit.h>
 #include <asm/uaccess.h>
 
 #include "util.h"
@@ -600,6 +601,8 @@
 			err = -EFAULT;
 			goto out;
 		}
+		if ((err = audit_ipc_perms(0, setbuf.uid, setbuf.gid, setbuf.mode)))
+			return err;
 		down(&shm_ids.sem);
 		shp = shm_lock(shmid);
 		err=-EINVAL;

===== kernel/auditsc.c 1.6 vs edited =====

kernel/auditsc.c +79 -0

119 lines not on this page · raw message

A

6 (

x 9
z

z

	

z
raph

z

�
�

z

z

5


n
6

�

y c li�

	!

50,�
6

9

�
6
0)
z

ph

�


0,�
6�
�
6

�

6!

,�
6

z

ph�
9

z

y

�

A

	





y

ph

y c li�

y

�
50y

y c link

h

y c link

x 
�
�

!
0,�
6

y
y

ph
ph

y

y

aph

y c link

ph

�

h

h
'

aph



y c link





t


h

h




y c link

W �
)Y �
x 

x �
h
�

�n A



6

6

pc/msg.�

x c link
8�x 
s
ne !
�
6
0,�
6

05

6
�8
05

�
50,�
6

Signature · 1 line
dwmw2