Skip to contentSkip to conversation

xserver policy

PATCH Russell Coker 1 participant 1 message Feb 24, 2003

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

I have attached an experimental patch for the X server policy that removes /dev/*mem access and some capabilities that aren't necessary when using a frame-buffer.

Strangely the X server seems to need sys_rawio even when using the frame buffer (X will abort if it can't get that access). This may be a bug in the X server (I'm using XFree86 version 4.2.1).

Also I removed every_domain().

Finally I have been considering creating a separate domain for the SUID wrapper program, which would allow removing setuid and setgid capabilities from the main X server program (and possibly other access as well).

This is still a work in progress, the concept is good although the implementation is a bit rough.

Finally I suggest that the Frame Buffer device be the recommeded way of doing graphics on SE Linux as it allows you to really reduce the access that the X server geets to the system. With sys_rawio it should still be possible to take over the system, but with memory_device_t it's just too easy to go from finding a bug in the X server to exploiting it.

Signature · 4 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
usr/share/selinux/policy/current/macros/program/xserver_macros.te renamed from usr/share/selinux/policy/default/macros/program/xserver_macros.te +13 -4
diff -ru /usr/share/selinux/policy/default/macros/program/xserver_macros.te /usr/share/selinux/policy/current/macros/program/xserver_macros.te
@@ -37,12 +37,21 @@
 role $1_r types $1_xserver_t;
 ')dnl
 
-# This domain is granted permissions common to most domains (includes can_net)
-every_domain($1_xserver_t)
+uses_shlib($1_xserver_t)
+can_network($1_xserver_t)
+
+# for access within the domain
+general_domain_access($1_xserver_t)
+
+# for access to lots of base files
+general_file_read_access($1_xserver_t)
+
+allow $1_xserver_t proc_t:dir search;
 
 # Use capabilities.  Access /dev/mem.  
-allow $1_xserver_t self:capability { net_bind_service setuid setgid chown dac_override fsetid sys_rawio sys_admin sys_nice sys_tty_config };
-allow $1_xserver_t memory_device_t:chr_file { rw_file_perms execute };
+allow $1_xserver_t self:capability { setuid setgid sys_rawio sys_nice };
+dontaudit $1_xserver_t self:capability { dac_override dac_read_search };
+#allow $1_xserver_t memory_device_t:chr_file { rw_file_perms execute };
 
 allow $1_xserver_t mtrr_device_t:file rw_file_perms;
 allow $1_xserver_t apm_bios_t:chr_file rw_file_perms;