Add SELinux policy capability for always checking packet class.
PATCH 1/2 Add SELinux policy capability for always checking packet class.
Currently the packet class in SELinux is not checked if there are no SECMARK rules in the security or mangle netfilter tables. Some systems prefer that packets are always checked, for example, to protect the system should the netfilter rules fail to load or if the nefilter rules were maliciously flushed.
Add the always_check_network policy capability which, when enabled, treats SECMARK as enabled, even if there are no netfilter SECMARK rules.
--- security/selinux/hooks.c | 8 ++++++-- security/selinux/include/security.h | 2 ++ security/selinux/selinuxfs.c | 3 ++- security/selinux/ss/services.c | 3 +++ 4 files changed, 13 insertions(+), 3 deletions(-)
security/selinux/hooks.c +6 -2
@@ -137,12 +137,16 @@ static struct kmem_cache *sel_inode_cache;* This function checks the SECMARK reference counter to see if any SECMARK * targets are currently configured, if the reference counter is greater than * zero SECMARK is considered to be enabled. Returns true (1) if SECMARK is -* enabled, false (0) if SECMARK is disabled. +* enabled, false (0) if SECMARK is disabled. If the always_check_network +* policy capability is enabled, SECMARK is always considered enabled. * */ static int selinux_secmark_enabled (void ) { -return (atomic_read (&selinux_secmark_refcount) >0 ); +if (selinux_policycap_alwaysnetwork) +return 1 ; +else +return (atomic_read (&selinux_secmark_refcount) >0 ); }/*
security/selinux/include/security.h +2 -0
@@ -68,12 +68,14 @@ extern int selinux_enabled;enum {POLICYDB_CAPABILITY_NETPEER ,POLICYDB_CAPABILITY_OPENPERM , +POLICYDB_CAPABILITY_ALWAYSNETWORK , __POLICYDB_CAPABILITY_MAX };#define POLICYDB_CAPABILITY_MAX (__POLICYDB_CAPABILITY_MAX - 1)extern int selinux_policycap_netpeer;extern int selinux_policycap_openperm; +extern int selinux_policycap_alwaysnetwork;/* * type_datum properties
security/selinux/selinuxfs.c +2 -1
@@ -44,7 +44,8 @@/* Policy capability filenames */ static char *policycap_names[] = {"network_peer_controls" , -"open_perms" +"open_perms" , +"always_check_network" };unsigned int selinux_checkreqprot =CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE ;
security/selinux/ss/services.c +3 -0
@@ -72,6 +72,7 @@int selinux_policycap_netpeer;int selinux_policycap_openperm; +int selinux_policycap_alwaysnetwork;static DEFINE_RWLOCK (policy_rwlock);
@@ -1812,6 +1813,8 @@ static void security_load_policycaps(void) POLICYDB_CAPABILITY_NETPEER); selinux_policycap_openperm =ebitmap_get_bit (&policydb.policycaps,POLICYDB_CAPABILITY_OPENPERM ); + selinux_policycap_alwaysnetwork =ebitmap_get_bit (&policydb.policycaps, +POLICYDB_CAPABILITY_ALWAYSNETWORK ); }static int security_preserve_bools (struct policydb *p);
Signature · 7 lines
1.7.8.6 -- 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 Update SELinux policy capability to always check peer class.
Update the always_check_network policy capability which, when enabled, treats peer labeling as enabled, even if there is no Netlabel or labeled IPSEC configuration.
--- security/selinux/hooks.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-)
security/selinux/hooks.c +19 -1
@@ -149,6 +149,24 @@ static int selinux_secmark_enabled(void)return (atomic_read (&selinux_secmark_refcount) >0 ); } +/** +* selinux_peerlbl_enabled - Check to see if peer labeling is currently enabled +* +* Description: +* This function checks if NetLabel or labeled IPSEC is enabled. Returns true +* (1) if any are enabled or false (0) if neither are enabled. If the +* always_check_network policy capability is enabled, peer labeling +* is always considered enabled. +* +*/ +static int selinux_peerlbl_enabled (void ) +{ +if (selinux_policycap_alwaysnetwork) +return 1 ; +else +return (netlbl_enabled () ||selinux_xfrm_enabled ()); +} +/* * initialise the security for the init task */
@@ -4188,7 +4206,7 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)return selinux_sock_rcv_skb_compat (sk, skb, family); secmark_active =selinux_secmark_enabled (); - peerlbl_active =netlbl_enabled () ||selinux_xfrm_enabled (); + peerlbl_active =selinux_peerlbl_enabled ();if (!secmark_active && !peerlbl_active)return 0 ;
Signature · 7 lines
1.7.8.6 -- 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.
Paul Moore
maintainerRe: [PATCH 2/2] Update SELinux policy capability to always check peer class.
Quoted 5 lines · Chris PeBenito
Update the
always_check_networkpolicy capability which, when enabled, treats peer labeling as enabled, even if there is no Netlabel or labeled IPSEC configuration.Signed-off-by Chris PeBenito <[email protected]>
I still object to this patchset for all the same old reasons, but I feel obligated to point out that this patchset is still incomplete/incorrect in that it only deals with the socket_sock_rcv_skb hook.
Signature · 8 lines
paul moore www.paul-moore.com -- 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 2/2] Update SELinux policy capability to always check peer class.
Quoted 10 lines · Paul Moore
Quoted 5 lines · Chris PeBenito
Update the
always_check_networkpolicy capability which, when enabled, treats peer labeling as enabled, even if there is no Netlabel or labeled IPSEC configuration.Signed-off-by Chris PeBenito <[email protected]>I still object to this patchset for all the same old reasons, but I feel obligated to point out that this patchset is still incomplete/incorrect in that it only deals with the
socket_sock_rcv_skbhook.
I found the missing hooks, but does this need to affect selinux_ip_output()? It seems like the answer is no, as it looks like its just applying the NetLabel on outgoing packets.
Signature · 8 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com -- 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.
Paul Moore
maintainerRe: [PATCH 2/2] Update SELinux policy capability to always check peer class.
Quoted 6 lines · Christopher J. PeBenito
Quoted 5 lines · Paul Moore
Quoted 4 lines · Chris PeBenito
Update the
always_check_networkpolicy capability which, when enabled, treats peer labeling as enabled, even if there is no Netlabel or labeled IPSEC configuration.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Chris PeBenito <[email protected]>I still object to this patchset for all the same old reasons, but I feel obligated to point out that this patchset is still incomplete/incorrect in that it only deals with the
socket_sock_rcv_skbhook.I found the missing hooks, but does this need to affect
selinux_ip_output()?
Nope.
Quoted 2 lines
It seems like the answer is no, as it looks like its just applying the NetLabel on outgoing packets.
Signature · 8 lines
paul moore www.paul-moore.com -- 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 2/2] Update SELinux policy capability to always check peer class.
Quoted 9 lines · Paul Moore
Quoted 8 lines · Christopher J. PeBenito
Quoted 7 lines · Paul Moore
Quoted 5 lines · Chris PeBenito
Update the
always_check_networkpolicy capability which, when enabled, treats peer labeling as enabled, even if there is no Netlabel or labeled IPSEC configuration.Signed-off-by Chris PeBenito <[email protected]>
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
I still object to this patchset for all the same old reasons, but I feel obligated to point out that this patchset is still incomplete/incorrect in that it only deals with the
socket_sock_rcv_skbhook.I found the missing hooks, but does this need to affect
selinux_ip_output()?Nope.
Is there anything I'm missing other than selinux_ip_forward() and selinux_ip_postroute()?
Signature · 8 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com -- 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.
Paul Moore
maintainerRe: [PATCH 2/2] Update SELinux policy capability to always check peer class.
Quoted 15 lines · Christopher J. PeBenito
Quoted 14 lines · Paul Moore
Quoted 13 lines · Christopher J. PeBenito
Quoted 11 lines · Paul Moore
Quoted 5 lines · Chris PeBenito
Update the
always_check_networkpolicy capability which, when enabled, treats peer labeling as enabled, even if there is no Netlabel or labeled IPSEC configuration.Signed-off-by Chris PeBenito <[email protected]>I still object to this patchset for all the same old reasons, but I feel obligated to point out that this patchset is still incomplete/incorrect in
that it only deals with thesocket_sock_rcv_skbhook.
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
I found the missing hooks, but does this need to affect
selinux_ip_output()?>Nope.
Is there anything I'm missing other than
selinux_ip_forward()andselinux_ip_postroute()?
It is probably best just to post the patches so that they can be (re)reviewed.
I'm also curious if you are going to do anything about incorporating the secmark configuration into the greater SELinux policy. As far as I'm concerned, that is the only way I would consider ack'ing these patches (I did mention this in the original thread).
Signature · 8 lines
paul moore www.paul-moore.com -- 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 2/2] Update SELinux policy capability to always check peer class.
Quoted 6 lines · Paul Moore
On Thursday, June 07, 2012 12:08:31 PM Christopher J. PeBenito wrote:
I'm also curious if you are going to do anything about incorporating the secmark configuration into the greater SELinux policy. As far as I'm concerned, that is the only way I would consider ack'ing these patches (I did mention this in the original thread).
As soon as this series covers all paths I am willing to take it, even over Paul's larger objection. I don't think what Paul wants makes enough sense to warrant not allowing enforcement in the face of a mislabeled system. Sorry Paul. That doesn't mean I wouldn't be happy to see something along those lines, but I think allowing people to use and control the system the way we have it today trumps some potential work tomorrow.
-Eric
--
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.