Skip to contentSkip to conversation

what is "null" access?

DISCUSSION Russell Coker 3 participants 5 messages Aug 5, 2002 – Aug 16, 2002 SELinux security module

lore
Share & tools
lore
#0 lore raw

Aug ?5 10:58:57 ns kernel: avc: ?denied ?null for ?pid=30897 exe=/usr/sbin/apache IPCID=0 scontext=system_u:system_r:httpd_t tcontext=system_u:system_r:httpd_t tclass=shm
Aug ?5 10:58:57 ns kernel: avc: ?denied ?null for ?pid=30897 exe=/usr/sbin/apache IPCID=0 scontext=system_u:system_r:httpd_t tcontext=system_u:system_r:httpd_t tclass=shm

The above messages are appearing on a system running a version of SE Linux that's not the latest (running the original 2002.07.03 release).

Bug?

Signature · 3 lines
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 9 lines · Russell Coker

Aug ?5 10:58:57 ns kernel: avc: ?denied ?null for ?pid=30897 exe=/usr/sbin/apache IPCID=0 scontext=system_u:system_r:httpd_t tcontext=system_u:system_r:httpd_t tclass=shm
Aug ?5 10:58:57 ns kernel: avc: ?denied ?null for ?pid=30897 exe=/usr/sbin/apache IPCID=0 scontext=system_u:system_r:httpd_t tcontext=system_u:system_r:httpd_t tclass=shm

The above messages are appearing on a system running a version of SE Linux that's not the latest (running the original 2002.07.03 release).

The above message indicates that the requested permission is null. In this particular case, it looks like apache is calling shmget() with a requested permission that does not include read or write access. This can be a permission of '0000', '0111' or similar. In May of this year a change to the AVC causes this access request to be explicitly denied.

The kernel code path accepts this, and subsequently the ipc_permission() hook is called. The SELinux implementation currently applies masks for read and write permissions, and not finding these checks for no (null) permission. We are looking at the logic here and will likely make a change, as this denial is not the expected behaviour.

chris.

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#2 lore raw
Quoted 17 lines · Chris Vance
Quoted 9 lines · Russell Coker

Aug ?5 10:58:57 ns kernel: avc: ?denied ?null for ?pid=30897 exe=/usr/sbin/apache IPCID=0 scontext=system_u:system_r:httpd_t tcontext=system_u:system_r:httpd_t tclass=shm
Aug ?5 10:58:57 ns kernel: avc: ?denied ?null for ?pid=30897 exe=/usr/sbin/apache IPCID=0 scontext=system_u:system_r:httpd_t tcontext=system_u:system_r:httpd_t tclass=shm

The above messages are appearing on a system running a version of SE Linux that's not the latest (running the original 2002.07.03 release).

The above message indicates that the requested permission is null. In this particular case, it looks like apache is calling shmget() with a requested permission that does not include read or write access. This can be a permission of '0000', '0111' or similar. In May of this year a change to the AVC causes this access request to be explicitly denied.

Quoted 5 lines

The kernel code path accepts this, and subsequently the ipc_permission() hook is called. The SELinux implementation currently applies masks for read and write permissions, and not finding these checks for no (null) permission. We are looking at the logic here and will likely make a change, as this denial is not the expected behaviour.

So you are saying that this is a bug in Apache which causes an unexpected parameter to a system call, and that parameter is not handled correctly due to a bug in SE Linux?

Russell Coker

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#3 lore raw
Quoted 24 lines · Russell Coker
Quoted 17 lines · Chris Vance
Quoted 9 lines · Russell Coker

Aug ?5 10:58:57 ns kernel: avc: ?denied ?null for ?pid=30897 exe=/usr/sbin/apache IPCID=0 scontext=system_u:system_r:httpd_t tcontext=system_u:system_r:httpd_t tclass=shm
Aug ?5 10:58:57 ns kernel: avc: ?denied ?null for ?pid=30897 exe=/usr/sbin/apache IPCID=0 scontext=system_u:system_r:httpd_t tcontext=system_u:system_r:httpd_t tclass=shm

The above messages are appearing on a system running a version of SE Linux that's not the latest (running the original 2002.07.03 release).

The above message indicates that the requested permission is null. In this particular case, it looks like apache is calling shmget() with a requested permission that does not include read or write access. This can be a permission of '0000', '0111' or similar. In May of this year a change to the AVC causes this access request to be explicitly denied.

Quoted 5 lines

The kernel code path accepts this, and subsequently the ipc_permission() hook is called. The SELinux implementation currently applies masks for read and write permissions, and not finding these checks for no (null) permission. We are looking at the logic here and will likely make a change, as this denial is not the expected behaviour.

Quoted 3 lines

So you are saying that this is a bug in Apache which causes an unexpected parameter to a system call, and that parameter is not handled correctly due to a bug in SE Linux?

More along the lines of it being a case that is silently ignored by the kernel, but for which SELinux decided was odd enough to complain about. SELinux is worried primarily about read and write access to IPC resources (including shared memory), so when asked about execute permission the default is to fail closed (hence permission denied).

I didn't have the time to look at the apache sources, so it's hard to say whether it's broken. I'm also not a master of SYSV, so I'm not certain whether it's normal for a process to associate with a pre-existing IPC region using shmget with a requested permission of '0000'. This seems to work perfectly, the kernel just adopts a default behaviour that differs from SELinux.

I think it would be appropriate for SELinux to default to permitting this, since the kernel also choses to ignore it. We just want to think about it a bit more, since it is something that won't be controlled via the policy.

chris.

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#4 lore raw
In reply to Russell Coker
Quoted 11 lines · Russell Coker

Aug ?5 10:58:57 ns kernel: avc: ?denied ?null for ?pid=30897 exe=/usr/sbin/apache IPCID=0 scontext=system_u:system_r:httpd_t tcontext=system_u:system_r:httpd_t tclass=shm
Aug ?5 10:58:57 ns kernel: avc: ?denied ?null for ?pid=30897 exe=/usr/sbin/apache IPCID=0 scontext=system_u:system_r:httpd_t tcontext=system_u:system_r:httpd_t tclass=shm

The above messages are appearing on a system running a version of SE Linux that's not the latest (running the original 2002.07.03 release).

Bug?

The attached patch (also committed to sourceforge CVS) should fix this bug. To apply, save to ~/ipc.patch, cd lsm-2.4 && patch -p1 < ~/ipc.patch.

--
Stephen D. Smalley, NAI Labs
[email protected]

Index: lsm-2.4/security/selinux/hooks.c
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.4/security/selinux/hooks.c,v retrieving revision 1.15
retrieving revision 1.16

security/selinux/hooks.c +3 -0
diff -u -r1.15 -r1.16
@@ -4487,6 +4487,9 @@
 	if (flag & S_IWUGO)
 		av |= IPC__UNIX_WRITE;
 
+	if (av == 0)
+		return 0;
+
 	return ipc_has_perm(ipcp, 0 /* XXX */, sclass, av);
 }