Skip to contentSkip to conversation

more security hooks for System V IPC

RFC New Greg KH 1 participant 1 message Dec 18, 2002 1 message not in the archive Security (LSM)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Greg KH

author
#1 lore raw

RFC 1/1 more security hooks for System V IPC

Hi all,

Here's a patch against 2.5.52 that adds the remaining needed LSM hooks for the System V IPC code. This patch was split out of the LSM tree by Stephen Smalley, and he writes:

Quoted 11 lines · Stephen D. Smalley

[This patch] proceeds to add the remaining System V IPC hooks, including the inline documentation for them in security.h. This includes a restored sem_semop hook, as it does seem to be necessary to support fine-grained access.

All of these System V IPC hooks are used by SELinux. The SELinux System V IPC access controls were originally described in the technical report available from
http://www.nsa.gov/selinux/slinux-abs.html, and the LSM-based implementation is described in the technical report available from
http://www.nsa.gov/selinux/module-abs.html.

If anyone has any objections to these hooks being added please let me know, otherwise I'll send this patch off to Linus in a few days.

thanks,

greg k-h

 include/linux/msg.h      |    1 
 include/linux/security.h |  244 +++++++++++++++++++++++++++++++++++++++++++++++
 ipc/msg.c                |   41 +++++++
 ipc/sem.c                |   32 +++++-
 ipc/shm.c                |   41 +++++++
 security/dummy.c         |   77 ++++++++++++++
 6 files changed, 428 insertions(+), 8 deletions(-)
include/linux/msg.h +1 -0
diff -X /home/sds/dontdiff -ru 2.5.52-lsm-dummy/include/linux/msg.h 2.5.52-lsm-ipc/include/linux/msg.h
@@ -69,6 +69,7 @@
 	long  m_type;          
 	int m_ts;           /* message text size */
 	struct msg_msgseg* next;
+	void *security;
 	/* the actual message follows immediately */
 };
 
include/linux/security.h +244 -0

330 lines not on this page · raw message

ipc/msg.c +37 -4

106 lines not on this page · raw message

ipc/sem.c +30 -2
diff -X /home/sds/dontdiff -ru 2.5.52-lsm-dummy/ipc/sem.c 2.5.52-lsm-ipc/ipc/sem.c
@@ -188,8 +188,12 @@
 			err = -EINVAL;
 		else if (ipcperms(&sma->sem_perm, semflg))
 			err = -EACCES;
-		else
-			err = sem_buildid(id, sma->sem_perm.seq);
+		else {
+			int semid = sem_buildid(id, sma->sem_perm.seq);
+			err = security_sem_associate(sma, semflg);
+			if (!err)
+				err = semid;
+		}
 		sem_unlock(sma);
 	}
 
@@ -466,6 +470,10 @@
 		struct seminfo seminfo;
 		int max_id;
 
+		err = security_sem_semctl(NULL, cmd);
+		if (err)
+			return err;
+		
 		memset(&seminfo,0,sizeof(seminfo));
 		seminfo.semmni = sc_semmni;
 		seminfo.semmns = sc_semmns;
@@ -506,6 +514,11 @@
 		err = -EACCES;
 		if (ipcperms (&sma->sem_perm, S_IRUGO))
 			goto out_unlock;
+
+		err = security_sem_semctl(sma, cmd);
+		if (err)
+			goto out_unlock;
+
 		id = sem_buildid(semid, sma->sem_perm.seq);
 
 		kernel_to_ipc64_perm(&sma->sem_perm, &tbuf.sem_perm);
@@ -549,6 +562,11 @@
 	if (ipcperms (&sma->sem_perm, (cmd==SETVAL||cmd==SETALL)?S_IWUGO:S_IRUGO))
 		goto out_unlock;
 
+	err = security_sem_semctl(sma, cmd);
+	if (err)
+		goto out_unlock;
+
+	err = -EACCES;
 	switch (cmd) {
 	case GETALL:
 	{
@@ -740,6 +758,10 @@
 		goto out_unlock;
 	}
 
+	err = security_sem_semctl(sma, cmd);
+	if (err)
+		goto out_unlock;
+
 	switch(cmd){
 	case IPC_RMID:
 		freeary(semid);
@@ -1035,6 +1057,12 @@
 	error = -EACCES;
 	if (ipcperms(&sma->sem_perm, alter ? S_IWUGO : S_IRUGO))
 		goto out_unlock_semundo_free;
+
+	error = security_sem_semop(sma, sops, nsops, alter);
+	if (error)
+		goto out_unlock_semundo_free;
+
+	error = -EACCES;		
 	if (undos) {
 		/* Make sure we have an undo structure
 		 * for this process and this semaphore set.
ipc/shm.c +39 -2

95 lines not on this page · raw message

security/dummy.c +77 -0

113 lines not on this page · raw message