Skip to contentSkip to conversation

r_file_perms and ioctl

DISCUSSION Russell Coker 2 participants 3 messages Jun 28, 2004 SELinux security module

lore
Share & tools
lore
#0 lore raw

It seems to me that including ioctl in the r_file_perms macro is a bad idea. ioctl is often (usually?) used for writing, so therefore the macro is not doing what it's name suggests.

Signature · 9 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page

--
This message was distributed to subscribers of the selinux mailing 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 3 lines · Russell Coker

It seems to me that including ioctl in the r_file_perms macro is a bad idea. ioctl is often (usually?) used for writing, so therefore the macro is not doing what it's name suggests.

Sorry my last message was not complete.

I was thinking of the case of using r_file_perms for access to device nodes. ioctl on a file is usually harmless.

Of course there's probably some policy which uses r_file_perms when it really wants to do ioctl's as well, access to sound devices and SCSI generic devices comes to mind.

Signature · 9 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page

--
This message was distributed to subscribers of the selinux mailing 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 5 lines · Russell Coker
Quoted 3 lines · Russell Coker

It seems to me that including ioctl in the r_file_perms macro is a bad idea. ioctl is often (usually?) used for writing, so therefore the macro is not doing what it's name suggests.

Quoted 8 lines

Sorry my last message was not complete.

I was thinking of the case of using r_file_perms for access to device nodes. ioctl on a file is usually harmless.

Of course there's probably some policy which uses r_file_perms when it really wants to do ioctl's as well, access to sound devices and SCSI generic devices comes to mind.

IIRC, ioctl permission was added to r_file_perms and similar macros because library routines were using ioctl frequently to probe the type of file, and because certain ioctls are indeed read flows (e.g. ext[23] getflags and getversion ioctls, although we did try to map those ioctls to other permissions in the ioctl hook). If you remove ioctl from those macros, then you'll likely encounter a number of denials due to such probes.

With regard to read vs. write on devices, note that you have to obtain a descriptor in order to perform the ioctl, and we already mediate read and write permissions on the open or exec or local IPC. Further, any capability checks performed by the driver code for the ioctl will require corresponding SELinux capability permissions.

The ioctl permission check is really just a placeholder; a reminder that we ultimately need fine-grained permissions on individual ioctl operations implemented in the driver code if we want to effectively control ioctls.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.