NetLabel policy additions for the reference policy
cover NetLabel policy additions for the reference policy
This patch is an updated version of the RFC patches I sent out to the list yesterday for comments. Since yesterday I have made changes based on Chris' comments as well as changes for problems found during testing today.
Please review and if it is acceptable please merge this into the reference policy.
Thanks.
--
paul moore
linux security @ hp
--
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.
PATCH 2/2 Reference policy: Restrict NetLabel to same MLS label connections by default
This patch adjusts the {tcp,udp}_socket recvfrom permissions to only allow same MLS label connections.
--- refpolicy/policy/mls | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletion(-)
refpolicy/policy/mls +7 -1
@@ -165,7 +165,7 @@ mlsconstrain { socket tcp_socket udp_soc ( h1 dom h2 ); # the socket "read" ops (note the check is dominance of the low level) -mlsconstrain { socket tcp_socket udp_socket rawip_socket netlink_socket packet_socket key_socket unix_stream_socket unix_dgram_socket netlink_route_socket netlink_firewall_socket netlink_tcpdiag_socket netlink_nflog_socket netlink_xfrm_socket netlink_selinux_socket netlink_audit_socket netlink_ip6fw_socket netlink_dnrt_socket } { read getattr listen accept getopt recvfrom recv_msg } +mlsconstrain { socket tcp_socket udp_socket rawip_socket netlink_socket packet_socket key_socket unix_stream_socket unix_dgram_socket netlink_route_socket netlink_firewall_socket netlink_tcpdiag_socket netlink_nflog_socket netlink_xfrm_socket netlink_selinux_socket netlink_audit_socket netlink_ip6fw_socket netlink_dnrt_socket } { read getattr listen accept getopt recv_msg } (( l1 dom l2 ) or (( t1 == mlsnetreadtoclr ) and ( h1 dom l2 )) or ( t1 == mlsnetread ));
@@ -181,6 +181,12 @@ mlsconstrain { socket tcp_socket udp_soc (( t1 == mlsnetwritetoclr ) and ( h1 dom l2 ) and ( l1 domby l2 )) or ( t1 == mlsnetwrite )); +# used by netlabel to restrict normal domains to same level connections +mlsconstrain { tcp_socket udp_socket } recvfrom + (( l1 eq l2 ) or + (( t1 == mlsnetreadtoclr ) and ( h1 dom l2 )) or + ( t1 == mlsnetread )); + # these access vectors have no MLS restrictions # { socket tcp_socket udp_socket rawip_socket netlink_socket packet_socket key_socket unix_stream_socket unix_dgram_socket netlink_route_socket netlink_firewall_socket netlink_tcpdiag_socket netlink_nflog_socket netlink_xfrm_socket netlink_selinux_socket netlink_audit_socket netlink_ip6fw_socket netlink_dnrt_socket } { ioctl create lock append bind sendto send_msg name_bind } #
--
paul moore
linux security @ hp
--
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.
PATCH 1/2 Reference policy: NetLabel policy additions
In reply to [email protected]This patch adds basic NetLabel support to the reference policy.
--- refpolicy/policy/modules/kernel/corenetwork.if.in | 58 ++++++++++++ refpolicy/policy/modules/kernel/kernel.if | 102 ++++++++++++++++++++++ refpolicy/policy/modules/system/netlabel.fc | 7 + refpolicy/policy/modules/system/netlabel.if | 58 ++++++++++++ refpolicy/policy/modules/system/netlabel.te | 34 +++++++ refpolicy/policy/modules/system/userdomain.if | 2 refpolicy/policy/modules/system/userdomain.te | 2 7 files changed, 263 insertions(+)
refpolicy/policy/modules/kernel/corenetwork.if.in +58 -0
@@ -1436,6 +1436,64 @@ interface(`corenet_dontaudit_non_ipsec_s ######################################## ## <summary> +## Receive TCP packets from a NetLabel connection. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`corenet_tcp_recv_netlabel',` + kernel_tcp_recv_netlabel($1) +') + +######################################## +## <summary> +## Do not audit attempts to receive TCP packets from a NetLabel +## connection. +## </summary> +## <param name="domain"> +## <summary> +## Domain to not audit. +## </summary> +## </param> +# +interface(`corenet_dontaudit_tcp_recv_netlabel',` + kernel_dontaudit_tcp_recv_netlabel($1) +') + +######################################## +## <summary> +## Receive UDP packets from a NetLabel connection. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`corenet_udp_recv_netlabel',` + kernel_udp_recv_netlabel($1) +') + +######################################## +## <summary> +## Do not audit attempts to receive UDP packets from a NetLabel +## connection. +## </summary> +## <param name="domain"> +## <summary> +## Domain to not audit. +## </summary> +## </param> +# +interface(`corenet_dontaudit_udp_recv_netlabel',` + kernel_dontaudit_udp_recv_netlabel($1) +') + +######################################## +## <summary> ## Send generic client packets. ## </summary> ## <param name="domain">
refpolicy/policy/modules/kernel/kernel.if +102 -0
108 lines not on this page · raw message
refpolicy/policy/modules/system/netlabel.fc new file +7 -0
@@ -0,0 +1,7 @@ + +######################################## +# +# netlabel file contexts +# + +/sbin/netlabelctl -- gen_context(system_u:object_r:netlabel_mgmt_exec_t,s0)
refpolicy/policy/modules/system/netlabel.if new file +58 -0
58 lines not on this page · raw message
refpolicy/policy/modules/system/netlabel.te new file +34 -0
@@ -0,0 +1,34 @@ + +policy_module(netlabel,1.0.0) + +######################################## +# +# Declarations +# + +type netlabel_mgmt_t; +type netlabel_mgmt_exec_t; + +domain_type(netlabel_mgmt_t) +domain_entry_file(netlabel_mgmt_t,netlabel_mgmt_exec_t) + +######################################## +# +# NetLabel Management Tools Local policy +# + +# allow access to newrole fds +seutil_use_newrole_fds(netlabel_mgmt_t) + +# allow access to shared libraries +libs_use_ld_so(netlabel_mgmt_t) +libs_use_shared_libs(netlabel_mgmt_t) + +# allow read access to network state +kernel_read_network_state(netlabel_mgmt_t) + +# allow communication with kernel subsystem +allow netlabel_mgmt_t self:netlink_socket create_socket_perms; + +# allow CAP_NET_ADMIN to modify the kernel subsystem configuration +allow netlabel_mgmt_t self:capability net_admin;
refpolicy/policy/modules/system/userdomain.if +2 -0
@@ -512,6 +512,8 @@ template(`userdom_basic_networking_templ corenet_udp_sendrecv_all_nodes($1_t) corenet_tcp_sendrecv_all_ports($1_t) corenet_udp_sendrecv_all_ports($1_t) + corenet_tcp_recv_netlabel($1_t) + corenet_udp_recv_netlabel($1_t) corenet_tcp_connect_all_ports($1_t) corenet_sendrecv_all_client_packets($1_t) ')
refpolicy/policy/modules/system/userdomain.te +2 -0
@@ -155,10 +155,12 @@ ifdef(`strict_policy',` logging_read_generic_logs(secadm_t) userdom_dontaudit_append_staff_home_content_files(secadm_t) userdom_dontaudit_read_sysadm_home_content_files(secadm_t) + netlabel_run_mgmt(secadm_t,secadm_r, { secadm_tty_device_t secadm_devpts_t }) ',` logging_manage_audit_log(sysadm_t) logging_manage_audit_config(sysadm_t) logging_run_auditctl(sysadm_t,sysadm_r,admin_terminal) + netlabel_run_mgmt(sysadm_t,sysadm_r,admin_terminal) ') tunable_policy(`allow_ptrace',`
--
paul moore
linux security @ hp
--
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.
Christopher J. PeBenito
AppliedRe: [PATCH 1/2] Reference policy: NetLabel policy additions
Quoted 1 line · On Wed, 2006-10-11 at 17:29 -0400, [email protected] wrote:
This patch adds basic NetLabel support to the reference policy.
Merged to the labeled networking branch. A couple notes, mostly nitpicking that I skipped on your RFC email:
Quoted 5 lines
refpolicy/policy/modules/kernel/kernel.if +5
-0+interface(`kernel_dontaudit_tcp_recv_netlabel',` + gen_require(` + type unlabeled_t; + ') +
refpolicy/policy/modules/kernel/kernel.if interface(`kernel_dontaudit_sendrecv_unl · line 2255
Quoted 10 lines
refpolicy/policy/modules/kernel/kernel.if +9
-0+ allow $1 unlabeled_t:tcp_socket recvfrom; +') +interface(`kernel_tcp_recv_netlabel',` + gen_require(` + type unlabeled_t; + ') + + dontaudit $1 unlabeled_t:tcp_socket recvfrom; +')
Fixed the above interfaces, you had the allow interface dontaudit and vice versa, I didn't notice these the first time around. I also tweaked the names a little.
refpolicy/policy/modules/system/netlabel.te line 31
Quoted 2 lines
refpolicy/policy/modules/system/netlabel.te new file +2
-0+# allow communication with kernel subsystem +allow netlabel_mgmt_t self:netlink_socket create_socket_perms;
I'm guessing we don't have time to fix the kernel to make this a specified netlink socket, rather than using the fallback generic netlink socket?
I also removed some of the comments, since they seemed obvious because they were almost the same as the interface names.
refpolicy/policy/modules/system/userdomain.if template(`userdom_basic_networking_templ · line 519
Quoted 9 lines
refpolicy/policy/modules/system/userdomain.if +2
-0@@ -512,6 +512,8 @@ template(`userdom_basic_networking_templ corenet_udp_sendrecv_all_nodes($1_t) corenet_tcp_sendrecv_all_ports($1_t) corenet_udp_sendrecv_all_ports($1_t) + corenet_tcp_recv_netlabel($1_t) + corenet_udp_recv_netlabel($1_t) corenet_tcp_connect_all_ports($1_t) corenet_sendrecv_all_client_packets($1_t) ')
I put this in ifdef enable_mls. It doesn't hurt non-mls, but might as well keep things clean.
refpolicy/policy/modules/system/userdomain.te ifdef(`enable_mls',` · line 164
Quoted 11 lines
refpolicy/policy/modules/system/userdomain.te +2
-0@@ -155,10 +155,12 @@ ifdef(`enable_mls',` logging_read_generic_logs(secadm_t) userdom_dontaudit_append_staff_home_content_files(secadm_t) userdom_dontaudit_read_sysadm_home_content_files(secadm_t) + netlabel_run_mgmt(secadm_t,secadm_r, { secadm_tty_device_t secadm_devpts_t }) ',` logging_manage_audit_log(sysadm_t) logging_manage_audit_config(sysadm_t) logging_run_auditctl(sysadm_t,sysadm_r,admin_terminal) + netlabel_run_mgmt(sysadm_t,sysadm_r,admin_terminal) ')
I thought that netlabel just had the mls level. Wouldn't that make it useless on a non mls policy (the second addition is for non mls)?
Signature · 9 lines
Chris PeBenito Tresys Technology, LLC (410) 290-1411 x150 -- 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.
Re: [PATCH 1/2] Reference policy: NetLabel policy additions
Quoted 6 lines · Christopher J. PeBenito
Quoted 1 line · On Wed, 2006-10-11 at 17:29 -0400, [email protected] wrote:
This patch adds basic NetLabel support to the reference policy.
Merged to the labeled networking branch. A couple notes, mostly nitpicking that I skipped on your RFC email:
Thanks! I'll grab the version you checked in and give it a quick test just to make sure.
Quoted 6 lines
refpolicy/policy/modules/system/netlabel.te line 31
Quoted 2 lines
refpolicy/policy/modules/system/netlabel.te new file +2
-0+# allow communication with kernel subsystem +allow netlabel_mgmt_t self:netlink_socket create_socket_perms;I'm guessing we don't have time to fix the kernel to make this a specified netlink socket, rather than using the fallback generic netlink socket?
No, the problem is that it is a much larger problem than just NetLabel, it's the genetlink mechanism in general. I heard a rumor that someone was working on adding proper SELinux genetlink support but I haven't seen anything posted. If nothing appears in the next month or two I'll start working on something for genetlink (I also owe Jamal some comments for his genetlink document).
Quoted 7 lines
Quoted 7 lines
refpolicy/policy/modules/system/userdomain.te +1
-0@@ -155,10 +155,12 @@ ifdef(`enable_mls',` logging_read_generic_logs(secadm_t) userdom_dontaudit_append_staff_home_content_files(secadm_t) userdom_dontaudit_read_sysadm_home_content_files(secadm_t) + netlabel_run_mgmt(secadm_t,secadm_r, { secadm_tty_device_t secadm_devpts_t }) ',` logging_manage_audit_log(sysadm_t)
Quoted 8 lines
refpolicy/policy/modules/system/userdomain.te ifdef(`strict_policy',` · line 164
Quoted 4 lines
refpolicy/policy/modules/system/userdomain.te +1
-0logging_manage_audit_config(sysadm_t) logging_run_auditctl(sysadm_t,sysadm_r,admin_terminal) + netlabel_run_mgmt(sysadm_t,sysadm_r,admin_terminal) ')I thought that netlabel just had the mls level. Wouldn't that make it useless on a non mls policy (the second addition is for non mls)?
There is an argument that it would still apply for the mcs case as well, although the quality of that argument is debatable.
Signature · 7 lines
paul moore linux security @ hp -- 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.