Skip to contentSkip to conversation

/dev/null and /dev/zero

DISCUSSION Russell Coker 2 participants 2 messages Mar 24, 2002 – Mar 26, 2002 SELinux security module

lore
Share & tools
lore
#0 lore raw

In what situations would you want to deny access to /dev/null and /dev/zero?

It would make more sense to me to grant global access to these devices via:
allow domain { zero_device_t null_device_t }:chr_file rw_file_perms;

The reason for allowing /dev/null globally is that some programs will deliberately open /dev/null so that programs they run will have file handles 0, 1, and 2 open to avoid possible confusion (and the potential for data loss and/or security holes) in child processes.

As for /dev/zero, it is mmap'd by programs in some situations (dependant on program input in some cases, seems harmless, and could potentially be excluded from programs that need it.

Also this would simplify policy, which I think is always a good thing.

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
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 4 lines · Russell Coker

In what situations would you want to deny access to /dev/null and /dev/zero?

It would make more sense to me to grant global access to these devices via:
allow domain { zero_device_t null_device_t }:chr_file rw_file_perms;

I'm inclined to avoid 'allow domain' rules entirely now that we've replaced every.te with macros that can be selectively applied to individual domains. There are already rules related to /dev/null and /dev/zero in the general_file_read/write_access macros. I'm not sure you really need write permission to zero_device_t, just read access.

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

--
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.