Skip to contentSkip to conversation

device types

PATCH Russell Coker 2 participants 2 messages Aug 10, 2004 – Aug 12, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

/u?dev/irlpt[0-9]+ -c system_u:object_r:tty_device_t

Wouldn't it be more appropriate to have irlpt be printer_device_t?

/u?dev/md.* -c system_u:object_r:fixed_disk_device_t

In what situation will a /dev/md* device node be a character device? The block devices are already labelled. The only device nodes of class chr_file labelled with fixed_disk_device_t are for raw devices and a flash device, probably neither of which will work properly due to lack of policy.

I have attached a patch which fixes these problems and a couple of other minor issues (including making the /dev/*nrft* entries only take one line) and adding an entry for /dev/dm-* (which LVM on Fedora seems to create).

Finally I've added a solution to the BSD pty issue. I've labelled all the device nodes as bsdpty_device_t and made domains that don't use such nodes have dontaudit rules for them. This stops programs like sshd from trying all of the BSD pty's first and filling the audit logs for no good cause.

I've also filed a bugzilla requesting that the BSD pty nodes be moved to a separate package so that SE Linux users can easily remove them.

Signature · 2 lines
http://apac.redhat.com/disclaimer
See above URL for disclaimer.
file_contexts/types.fc renamed from usr/src/se/policy/file_contexts/types.fc +8 -11
diff -ru /usr/src/se/policy/file_contexts/types.fc ./file_contexts/types.fc
@@ -127,16 +127,17 @@
 /u?dev/urandom		-c	system_u:object_r:urandom_device_t
 /u?dev/capi.*		-c	system_u:object_r:tty_device_t
 /u?dev/dcbri[0-9]+	-c	system_u:object_r:tty_device_t
-/u?dev/irlpt[0-9]+	-c	system_u:object_r:tty_device_t
+/u?dev/irlpt[0-9]+	-c	system_u:object_r:printer_device_t
 /u?dev/ircomm[0-9]+	-c	system_u:object_r:tty_device_t
 /u?dev/isdn.*		-c	system_u:object_r:tty_device_t
 /u?dev/.*tty[^/]*	-c	system_u:object_r:tty_device_t
+/u?dev/[pt]ty[abcdepqrstuvwxyz][0-9a-f]	-c system_u:object_r:bsdpty_device_t
 /u?dev/cu.*		-c	system_u:object_r:tty_device_t
 /u?dev/vcs[^/]*		-c	system_u:object_r:tty_device_t
 /u?dev/ip2[^/]*		-c	system_u:object_r:tty_device_t
-/u?dev/pty.*		-c	system_u:object_r:tty_device_t
 /u?dev/tty		-c	system_u:object_r:devtty_t
 /u?dev/[shmx]d[^/]*	-b	system_u:object_r:fixed_disk_device_t
+/u?dev/dm-[0-9]+	-b	system_u:object_r:fixed_disk_device_t
 /u?dev/sg[0-9]+		-c	system_u:object_r:scsi_generic_device_t
 /u?dev/rd.*		-b	system_u:object_r:fixed_disk_device_t
 /u?dev/i2o/hd[^/]*	-b	system_u:object_r:fixed_disk_device_t
@@ -145,7 +146,6 @@
 /u?dev/ida/[^/]*	-b	system_u:object_r:fixed_disk_device_t
 /u?dev/dasd[^/]*	-b	system_u:object_r:fixed_disk_device_t
 /u?dev/flash[^/]*	-b	system_u:object_r:fixed_disk_device_t
-/u?dev/md.*		-c	system_u:object_r:fixed_disk_device_t
 /u?dev/nb[^/]+		-b	system_u:object_r:fixed_disk_device_t
 /u?dev/ataraid/.*	-b	system_u:object_r:fixed_disk_device_t
 /u?dev/loop.*		-b	system_u:object_r:fixed_disk_device_t
@@ -212,17 +212,13 @@
 /u?dev/amidi.*		-c	system_u:object_r:sound_device_t
 /u?dev/amixer.*		-c	system_u:object_r:sound_device_t
 /u?dev/snd/.*		-c	system_u:object_r:sound_device_t
-/u?dev/rawrft[0-9]	-c	system_u:object_r:tape_device_t
-/u?dev/rft[0-9]		-c	system_u:object_r:tape_device_t
-/u?dev/rmt[0-9].*	-c	system_u:object_r:tape_device_t
 /u?dev/n?[hs]t[0-9].*	-c	system_u:object_r:tape_device_t
-/u?dev/(n?raw)?qft[0-3]	-c	system_u:object_r:tape_device_t
+/u?dev/(n?raw)?[qr]ft[0-3] -c	system_u:object_r:tape_device_t
 /u?dev/n?z?qft[0-3]	-c	system_u:object_r:tape_device_t
 /u?dev/n?tpqic[12].*	-c	system_u:object_r:tape_device_t
 /u?dev/ht[0-1]		-b	system_u:object_r:tape_device_t
 /u?dev/n?osst[0-3].*	-c	system_u:object_r:tape_device_t
 /u?dev/n?pt[0-9]+	-c	system_u:object_r:tape_device_t
-/u?dev/nrft[0-9]+	-c	system_u:object_r:tape_device_t
 /u?dev/tape.*		-c	system_u:object_r:tape_device_t
 /u?dev/usb/scanner.*	-c	system_u:object_r:scanner_device_t
 /u?dev/usb/dc2xx.*	-c	system_u:object_r:scanner_device_t
@@ -230,7 +226,7 @@
 /u?dev/usb/tty.*	-c	system_u:object_r:usbtty_device_t
 /u?dev/mmetfgrab	-c	system_u:object_r:scanner_device_t
 /u?dev/nvidia.*		-c	system_u:object_r:xserver_misc_device_t
-/u?dev/dri(/.*)?	-c	system_u:object_r:dri_device_t
+/u?dev/dri/.+		-c	system_u:object_r:dri_device_t
 /u?dev/radeon		-c	system_u:object_r:dri_device_t
 /u?dev/agpgart		-c	system_u:object_r:agp_device_t
 
@@ -254,7 +250,7 @@
 /etc/group\.lock	--	system_u:object_r:shadow_t
 /etc/shadow.*		--	system_u:object_r:shadow_t
 /etc/gshadow.*		--	system_u:object_r:shadow_t
-/etc/blkid.tab		--	system_u:object_r:etc_runtime_t
+/etc/blkid\.tab		--	system_u:object_r:etc_runtime_t
 /etc/fstab\.REVOKE	--	system_u:object_r:etc_runtime_t
 /etc/HOSTNAME		--	system_u:object_r:etc_runtime_t
 /etc/ioctl\.save	--	system_u:object_r:etc_runtime_t
@@ -318,6 +314,7 @@
 /usr/share/man(/.*)?		system_u:object_r:man_t
 /usr/share/mc/extfs/.*	--	system_u:object_r:bin_t
 /usr/share/texmf/teTeX/bin(/.*)?	system_u:object_r:bin_t
+/usr/share/selinux(/.*)?	system_u:object_r:policy_src_t
 
 #
 # /usr/bin
@@ -495,4 +492,4 @@
 #  The krb5.conf file is always being tested for writability, so
 #  we defined a type to dontautit
 #
-/etc/krb5.conf		--	system_u:object_r:krb5_conf_t
+/etc/krb5\.conf		--	system_u:object_r:krb5_conf_t
macros/core_macros.te renamed from usr/src/se/policy/macros/core_macros.te +3 -0
diff -ru /usr/src/se/policy/macros/core_macros.te ./macros/core_macros.te
@@ -556,6 +556,9 @@
 
 # allow searching /dev/pts
 allow $1_t devpts_t:dir { getattr read search };
+
+# ignore old BSD pty devices
+dontaudit $1_t bsdpty_device_t:chr_file { getattr read write };
 ')
 
 
types/device.te renamed from usr/src/se/policy/types/device.te +4 -0
diff -ru /usr/src/se/policy/types/device.te ./types/device.te
@@ -51,6 +51,10 @@
 type tty_device_t, serial_device, device_type;
 
 #
+# bsdpty_device_t is the type of /dev/[tp]ty[abcdepqrstuvwxyz][0-9a-f]
+type bsdpty_device_t, device_type;
+
+#
 # usbtty_device_t is the type of /dev/usr/tty*
 #
 type usbtty_device_t, serial_device, device_type;
#1 lore raw
Quoted 12 lines · Russell Coker

/u?dev/irlpt[0-9]+ -c system_u:object_r:tty_device_t

Wouldn't it be more appropriate to have irlpt be printer_device_t?

/u?dev/md.* -c system_u:object_r:fixed_disk_device_t

In what situation will a /dev/md* device node be a character device? The block devices are already labelled. The only device nodes of class chr_file labelled with fixed_disk_device_t are for raw devices and a flash device, probably neither of which will work properly due to lack of policy.

Quoted 8 lines

I have attached a patch which fixes these problems and a couple of other minor issues (including making the /dev/*nrft* entries only take one line) and adding an entry for /dev/dm-* (which LVM on Fedora seems to create).

Finally I've added a solution to the BSD pty issue. I've labelled all the device nodes as bsdpty_device_t and made domains that don't use such nodes have dontaudit rules for them. This stops programs like sshd from trying all of the BSD pty's first and filling the audit logs for no good cause.

Thanks, merged.

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.