patches to debian 1.12 policy (including new "discover" policy)
Subsystems (2)
i been playing to get a working policy for a workstation system. i don't recommend to anyone to install all of these.
however, there's definitely a need for a policy for the discover package.
main comments / things out of this patch:
- for cupsys-bsd compatability in debian.
- Allow hotplug to copy /etc/network/ifstate.hotplug to ifstate
- allow kdm's kde_greet and krootimage to access /var/lib/defoma.
- ssh-agent must be granted sigchild to xdm_t in order for kdm to be able to spawn a kde user session (!!)
there are other things in here which i have been playing
with: in my desperate attempts to get a kde user session started, i even created something to allow access to /etc/qt3 and i notice that somehow, (in unmodified vanilla debian 1.12 policy!) permission is granted to kdm to _create_ /etc/qt3/.qtrc.lock, but that user sessions are not then allowed to create file locks on it.
discover
--------
well, like a silly person i wrote a policy for discover and _then_ went to look if someone else had already done it:
http://www.cip.ifi.lmu.de/%7ebleher/cgi-bin/archzoom.cgi/[email protected]/policy--devo--0--patch-9/domains/program/unused/discover.te
the difference between that one and this one is that 1) i don't understand how i am supposed to correctly grant fd { use } in a sufficiently generic way to cope with discover being run by sysadm_r to newrole_t, sysadm_t and getty ttys. i don't get it.
and 2) i specifically separated /sbin/discover-modprobe which is run from /etc/init.d/discover from /bin/discover.
the execute stuff (allow discover_mod_t discover_exec_t:file { execute execute_no_trans getattr read };) is because /sbin/discover-modprobe wants to exec /bin/discover, and the allow discover_mod_t bin_t:file { execute execute_no_trans getattr ioctl read } is to allow /sbin/discover-modprobe to run /sbin/discover-config (whatever that's for).
cupsys
------
i install cupsys-bsd because openoffice.org needs that for compatibility printing (lpd). therefore i needed to add a thingy to inetd.te to allow cupsd to run its compatibility-mode lpd thing.
kdm
---
lots of weird stuff, here. x server isn't granted permission to access /tmp/.font-unix (?). kde_greet and krootimage need to access defoma.
Signature · 9 lines
-- expecting email to be received and understood is a bit like picking up the telephone and immediately dialing without checking for a dial-tone; speaking immediately without listening for either an answer or ring-tone; hanging up immediately and believing that you have actually started a conversation. -- <a href="http://lkcl.net"> lkcl.net </a> <br /> <a href="mailto:[email protected]"> [email protected] </a> <br />
etc/selinux/domains/program/discover.te renamed from usr/share/selinux/policy/default/domains/program/discover.te +80 -0
@@ -0,0 +1,80 @@ +#DESC discover - discover hardware (and load modules if required) +# +# Authors: Luke Kenneth Casson Leighton <[email protected]> +# X-Debian-Packages: discover +# + +################################# +# +# Rules for the discover_t domain. +# +# discover_t is the domain for the discover program. +# discover_exec_t is the type of the corresponding program. +# +type discover_t, domain, privlog, privmodule; +type discover_mod_t, domain, privlog, privmodule; +type discover_exec_t, file_type, sysadmfile, exec_type; +type discover_mod_exec_t, file_type, sysadmfile, exec_type; + +role system_r types discover_t; +role sysadm_r types discover_t; + +type discover_etc_t, file_type, sysadmfile; +type discover_lib_t, file_type, sysadmfile; +type discover_share_t, file_type, sysadmfile; + +file_type_auto_trans(discover_t, usr_t, discover_share_t, file) +file_type_auto_trans(discover_t, etc_t, discover_etc_t, file) +#file_type_auto_trans(discover_t, lib_t, discover_lib_t, file) + +uses_shlib(discover_t) +general_domain_access(discover_t) + +uses_shlib(discover_mod_t) +general_domain_access(discover_mod_t) + +domain_auto_trans(initrc_t, discover_mod_exec_t, discover_mod_t) +domain_auto_trans(sysadm_t, discover_exec_t, discover_t) + +# Use capabilities. +allow discover_t self:capability sys_admin; + +# ############################### +# for interactive use by sysadmin + +# NB: this one i am not sure about, i'm logging in over ssh +# and doing a newrole -r sysadm_r. console login and +# running discover required getty_t:fd { use }; + +allow discover_t newrole_t:fd { use }; +allow discover_t sysadm_devpts_t:chr_file { getattr read write }; + +allow discover_t discover_lib_t:dir { search }; +allow discover_t discover_lib_t:file { getattr read }; +allow discover_t proc_t:dir { search }; +allow discover_t proc_t:file { getattr read }; +allow discover_t sysadm_tty_device_t:chr_file { getattr ioctl read write }; +allow discover_t usbfs_t:dir { search }; +allow discover_t usbfs_t:file { getattr read }; + + +####################################### +# for startup from /etc/init.d/discover + +allow discover_mod_t bin_t:dir { search }; +allow discover_mod_t bin_t:file { execute execute_no_trans getattr ioctl read }; +allow discover_mod_t bin_t:lnk_file { read }; +allow discover_mod_t devtty_t:chr_file { read write }; +allow discover_mod_t discover_etc_t:file { getattr read }; +allow discover_mod_t discover_exec_t:file { execute execute_no_trans getattr read }; +allow discover_mod_t discover_lib_t:dir { search }; +allow discover_mod_t discover_lib_t:file { getattr read }; +allow discover_mod_t etc_runtime_t:file { getattr read }; +allow discover_mod_t etc_t:file { getattr read }; +allow discover_mod_t proc_t:dir { search }; +allow discover_mod_t proc_t:file { getattr read }; +allow discover_mod_t sbin_t:dir { search }; +allow discover_mod_t shell_exec_t:file { execute read }; +allow discover_mod_t var_run_t:dir { search }; +allow discover_mod_t var_t:dir { add_name getattr remove_name search write }; +allow discover_mod_t var_t:file { create unlink write };
etc/selinux/domains/program/hotplug.te renamed from usr/share/selinux/policy/default/domains/program/hotplug.te +5 -1
@@ -24,7 +24,7 @@ allow hotplug_t self:unix_stream_socket create_socket_perms; allow hotplug_t self:udp_socket create_socket_perms; -allow hotplug_t sysctl_net_t:dir search; +allow hotplug_t sysctl_net_t:dir { search read }; allow hotplug_t sysctl_net_t:file { getattr read }; # get info from /proc
@@ -144,3 +144,7 @@ unconfined_domain(hotplug_t) ') +# Allow hotplug to copy /etc/network/ifstate.hotplug to ifstate +allow hotplug_t etc_runtime_t:file { relabelfrom relabelto }; + +
etc/selinux/domains/program/hwclock.te renamed from usr/share/selinux/policy/default/domains/program/hwclock.te +3 -0
@@ -43,4 +43,7 @@ allow hwclock_t ptyfile:chr_file rw_file_perms; ifdef(`gnome-pty-helper.te', `allow hwclock_t sysadm_gph_t:fd use;') +# lkcl: no idea what this is +allow hwclock_t file_t:dir { search }; + read_locale(hwclock_t)
etc/selinux/domains/program/inetd.te renamed from usr/share/selinux/policy/default/domains/program/inetd.te +3 -0
@@ -64,6 +64,9 @@ allow inetd_t ntalk_port_t:tcp_socket name_bind; ') +# for cupsys-bsd compatibility in debian. +ifdef(`cups.te', `allow inetd_t printer_port_t:tcp_socket name_bind;') + # allow to bind to chargen, echo, etc allow inetd_t inetd_port_t:{ tcp_socket udp_socket } name_bind;
etc/selinux/domains/program/ldconfig.te renamed from usr/share/selinux/policy/default/domains/program/ldconfig.te +5 -0
@@ -31,3 +31,8 @@ allow ldconfig_t fs_t:filesystem getattr; allow ldconfig_t tmp_t:dir { search }; + +allow ldconfig_t lib_t:file { getattr read }; +allow ldconfig_t usr_t:file { read }; +allow ldconfig_t usr_t:lnk_file { read unlink }; +
etc/selinux/domains/program/ssh.te renamed from usr/share/selinux/policy/default/domains/program/ssh.te +9 -0
@@ -231,3 +231,12 @@ allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms; allow ssh_keygen_t sysadm_tty_device_t:chr_file { read write }; allow ssh_keygen_t urandom_device_t:chr_file { getattr read }; + +# provide means for /sbin/unix_chkpwd to do some "stuff" with sshd, hey +# i don't pretend to understand... +allow system_chkpwd_t sshd_t:tcp_socket { read write }; +allow system_chkpwd_t sshd_t:unix_stream_socket { read write }; + +# users can't ssh in! or they _can_, they just can't run a shell (!) +# allow user_t sshd_devpts_t:chr_file { ioctl read write }; +
etc/selinux/domains/program/xdm.te renamed from usr/share/selinux/policy/default/domains/program/xdm.te +23 -0
@@ -317,3 +317,26 @@ ifdef(`crack.te', ` allow xdm_t crack_db_t:file r_file_perms; ') + +# allow kdm's kde_greet and krootimage to access /var/lib/defoma. +allow xdm_t readable_t:dir { getattr read search }; +allow xdm_t readable_t:file { getattr read }; + + +# allow x server in setup phase to connect to /tmp/.font-unix +allow xdm_xserver_t initrc_tmp_t:dir { search }; + +# nuts. allow creation of "stuff" in /etc/qt3 by kde. yuk. +type etc_qt3_t, file_type, sysadmfile; +file_type_auto_trans(xdm_t, etc_t, etc_qt3_t, file) +allow xdm_t etc_qt3_t:dir rw_dir_perms; +allow xdm_t etc_qt3_t:dir setattr; +allow xdm_t etc_qt3_t:dir { write }; +allow xdm_t etc_t:dir { write }; + +allow unpriv_userdomain etc_qt3_t:dir { search }; +allow unpriv_userdomain etc_qt3_t:file { read getattr }; + +# pam_selinux used by kdm... +allow system_chkpwd_t xserver_log_t:file { append }; +
etc/selinux/file_contexts/misc/qt3.fc renamed from usr/share/selinux/policy/default/file_contexts/misc/qt3.fc +1 -0
@@ -0,0 +1 @@ +/etc/qt3(/.*)? system_u:object_r:etc_qt3_t
etc/selinux/file_contexts/program/discover.fc renamed from usr/share/selinux/policy/default/file_contexts/program/discover.fc +7 -0
@@ -0,0 +1,7 @@ +# discover +/bin/discover -- system_u:object_r:discover_exec_t +/sbin/discover-modprobe -- system_u:object_r:discover_mod_exec_t +/usr/share/discover(/.*)? system_u:object_r:discover_share_t +/etc/discover.conf -- system_u:object_r:discover_etc_t +/etc/discover-modprobe.conf -- system_u:object_r:discover_etc_t +/lib/discover(/.*)? system_u:object_r:discover_lib_t
etc/selinux/file_contexts/program/netutils.fc renamed from usr/share/selinux/policy/default/file_contexts/program/netutils.fc +1 -0
@@ -2,3 +2,4 @@ /sbin/arping -- system_u:object_r:netutils_exec_t /usr/sbin/tcpdump -- system_u:object_r:netutils_exec_t /etc/network/ifstate -- system_u:object_r:etc_runtime_t +/etc/network/ifstate.hotplug -- system_u:object_r:etc_runtime_t
etc/selinux/macros/program/ssh_agent_macros.te renamed from usr/share/selinux/policy/default/macros/program/ssh_agent_macros.te +2 -1
@@ -85,7 +85,8 @@ ifdef(`xdm.te', ` allow $1_ssh_agent_t xdm_t:fd { use }; -allow $1_ssh_agent_t xdm_t:fifo_file { write }; +allow $1_ssh_agent_t xdm_t:process { sigchld }; +allow $1_ssh_agent_t xdm_t:fifo_file { read write }; ') #
Quoted 2 lines · Luke Kenneth Casson Leighton
however, there's definitely a need for a policy for the discover package.
How does discover differ from the "kudzu" program in Fedora? They appear to do very similar things, maybe the kudzu policy will do the job?
Review
Quoted 5 lines
main comments / things out of this patch:
(quoted diff) +0
-2- for cupsys-bsd compatability in debian. - Allow hotplug to copy /etc/network/ifstate.hotplug to ifstate
file_type_auto_trans(hotplug_t, etc_t, etc_runtime_t, file)
The above rule should do it.
Quoted 14 lines
(quoted diff) +0
-2- allow kdm's kde_greet and krootimage to access /var/lib/defoma. - ssh-agent must be granted sigchild to xdm_t in order for kdm to be able to spawn a kde user session (!!)there are other things in here which i have been playing
with: in my desperate attempts to get a kde user session started, i even created something to allow access to/etc/qt3and i notice that somehow, (in unmodified vanilla debian 1.12 policy!) permission is granted to kdm to _create_/etc/qt3/.qtrc.lock, but that user sessions are not then allowed to create file locks on it.
Quoted 4 lines
the difference between that one and this one is that 1) i don't understand how i am supposed to correctly grant fd { use } in a sufficiently generic way to cope with discover being run by
sysadm_rtonewrole_t,sysadm_tand getty ttys. i don't get it.
allow discover_t privfd:fd use;
Quoted 3 lines
i install cupsys-bsd because openoffice.org needs that for compatibility printing (lpd). therefore i needed to add a thingy to inetd.te to allow cupsd to run its compatibility-mode lpd thing.
It appears that you haven't put in enough policy to allow cups to be run from inetd, so allowing the port bind isn't going to do much good.
Quoted 2 lines
lots of weird stuff, here. x server isn't granted permission to access
/tmp/.font-unix(?).kde_greetand krootimage need to access defoma.
+allow hwclock_t file_t:dir { search };
+allow ldconfig_t lib_t:file { getattr read };
+allow ldconfig_t usr_t:file { read };
+allow ldconfig_t usr_t:lnk_file { read unlink };
Those are not desired.
+allow system_chkpwd_t sshd_t:tcp_socket { read write }; +allow system_chkpwd_t sshd_t:unix_stream_socket { read write };
When Debian's pam has the same features as that in Fedora those won't happen.
+# allow kdm's kde_greet and krootimage to access /var/lib/defoma. +allow xdm_t readable_t:dir { getattr read search }; +allow xdm_t readable_t:file { getattr read };
I've changed my policy to have the defoma directory labelled as fonts_t.
What is /tmp/.fonts-unix? What creates it?
Maybe /etc/qt3 should be labelled as xdm_rw_etc_t?
+/etc/network/ifstate.hotplug -- system_u:object_r:etc_runtime_t
I've changed this rule and also moved it to dpkg.fc as it's Debian specific.
PS I've just uploaded a new policy package to Debian with these changes. If you want to look at the kudzu policy then note that I've removed it from the Debian package (it currently doesn't work in Debian) so you'll have to see the source of the policy package.
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.
Quoted 6 lines · Russell Coker
Quoted 2 lines · Luke Kenneth Casson Leighton
however, there's definitely a need for a policy for the discover package.
How does discover differ from the "kudzu" program in Fedora? They appear to do very similar things, maybe the kudzu policy will do the job?
discover is much more passive than kudzu.
discover-modprobe is used to load kernel modules, and that's about the end of its active capabilities.
the discover program simply "reads" information from the kernel and tells you the pretty names.
it can then be used by other programs such as x-configuration programs to find out the name of video card in use, etc.
i believe that hotplug uses it.
kudzu is quite a pain: i did investigate using it on debian but it has so many hard-coded redhat-specificisms in it that i gave up and raised a wish-list bug request about it.
it would actually be very good if kudzu could be rewritten in two ways:
1) it used discover (or libdiscover if nothing else).
2) it called out to scripts rather than to hard-coded programs.
but anyway.
yes, basically, discover is primarily passive whilst kudzu is most definitely active.
therefore, discover doesn't need half of the things that kudzu does.
Quoted 9 lines
Review
Quoted 5 lines
main comments / things out of this patch:
(quoted diff) +0
-2- for cupsys-bsd compatability in debian. - Allow hotplug to copy /etc/network/ifstate.hotplug to ifstate
file_type_auto_trans(hotplug_t, etc_t, etc_runtime_t, file)The above rule should do it.
ha, cool.
Quoted 14 lines
Quoted 14 lines
(quoted diff) +0
-2- allow kdm's kde_greet and krootimage to access /var/lib/defoma. - ssh-agent must be granted sigchild to xdm_t in order for kdm to be able to spawn a kde user session (!!)there are other things in here which i have been playing
with: in my desperate attempts to get a kde user session started, i even created something to allow access to/etc/qt3and i notice that somehow, (in unmodified vanilla debian 1.12 policy!) permission is granted to kdm to _create_/etc/qt3/.qtrc.lock, but that user sessions are not then allowed to create file locks on it.
Quoted 6 lines
Quoted 4 lines
the difference between that one and this one is that 1) i don't understand how i am supposed to correctly grant fd { use } in a sufficiently generic way to cope with discover being run by
sysadm_rtonewrole_t,sysadm_tand getty ttys. i don't get it.allow
discover_tprivfd:fd use;
ace! v. helpful. a new incantation i can now plug into my brain in other circumstances :)
Quoted 6 lines
Quoted 3 lines
i install cupsys-bsd because openoffice.org needs that for compatibility printing (lpd). therefore i needed to add a thingy to inetd.te to allow cupsd to run its compatibility-mode lpd thing.
It appears that you haven't put in enough policy to allow cups to be run from inetd, so allowing the port bind isn't going to do much good.
:) oops.
Quoted 9 lines
Quoted 2 lines
lots of weird stuff, here. x server isn't granted permission to access
/tmp/.font-unix(?).kde_greetand krootimage need to access defoma.etc/selinux/domains/program/ldconfig.te renamed from usr/share/selinux/policy/default/domains/program/ldconfig.te +4
-0+allow hwclock_t file_t:dir { search }; +allow ldconfig_t lib_t:file { getattr read }; +allow ldconfig_t usr_t:file { read }; +allow ldconfig_t usr_t:lnk_file { read unlink };Those are not desired.
oh. i think i understand about the ldconfig_t ones. i don't
grok the hwclock_t one, though.
Quoted 4 lines
etc/selinux/domains/program/ssh.te renamed from usr/share/selinux/policy/default/domains/program/ssh.te +2
-0+allow system_chkpwd_t sshd_t:tcp_socket { read write }; +allow system_chkpwd_t sshd_t:unix_stream_socket { read write };When Debian's pam has the same features as that in Fedora those won't happen.
:)
*sigh*.
Quoted 5 lines
etc/selinux/domains/program/xdm.te renamed from usr/share/selinux/policy/default/domains/program/xdm.te +3
-0+# allow kdm's kde_greet and krootimage to access /var/lib/defoma. +allow xdm_t readable_t:dir { getattr read search }; +allow xdm_t readable_t:file { getattr read };I've changed my policy to have the defoma directory labelled as
fonts_t.
great.
Quoted 1 line
What is
/tmp/.fonts-unix? What creates it?
mmmm.... xfs i think.
Quoted 1 line
Maybe
/etc/qt3should be labelled asxdm_rw_etc_t?
i'm not so sure.
it's ... well - piss-poor practice to allow writing to /etc on non-configuration stuff.
these are _lock_ files that are being created there!
but hey, given that somehow, xdm manages to create these lock files, and then in a user-context, kde programs attempt to also create them, i'm inclined to say that if you think it would help, yes, /etc/qt3 should be writeable.
Quoted 2 lines
+/etc/network/ifstate.hotplug -- system_u:object_r:etc_runtime_t
I've changed this rule and also moved it to dpkg.fc as it's Debian specific.
ooooo. okay :)
Quoted 5 lines
PS I've just uploaded a new policy package to Debian with these changes. If you want to look at the kudzu policy then note that I've removed it from the Debian package (it currently doesn't work in Debian) so you'll have to see the source of the policy package.
had a quick look: yes it does _way_ more than discover possibly needs.
the reason why discover.te is big is because i deliberately split out discover from discover-modprobe.
/sbin/discover-modprobe is only run from /etc/init.d/discover (and it then runs /bin/discover) whilst /bin/discover can be run from other locations.
l.
--
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.