selinux: drop remapping of netlink classes
PATCH 1/1 selinux: drop remapping of netlink classes
Drop remapping of netlink classes and bypass of permission checking based on netlink message type for policy version < 18. This removes compatibility code introduced when the original single netlink security class used for all netlink sockets was split into finer-grained netlink classes based on netlink protocol and when permission checking was added based on netlink message type in Linux 2.6.8. The only known distribution that shipped with SELinux and policy < 18 was Fedora Core 2, which was EOL'd on 2005-04-11.
Given that the remapping code was never updated to address the addition of newer netlink classes, that the corresponding userland support was dropped in 2005, and that the assumptions made by the remapping code about the fixed ordering among netlink classes in the policy may be violated in the future due to the dynamic class/perm discovery support, we should drop this compatibility code now.
---
This patch is relative to the v5 patches for dynamic class/perm discovery and generating flask headers during kernel build.
security/selinux/hooks.c | 6 +----- security/selinux/ss/services.c | 25 ------------------------- 2 files changed, 1 insertions(+), 30 deletions(-)
security/selinux/hooks.c +1 -5
@@ -91,7 +91,6 @@#define NUM_SEL_MNT_OPTS 5 -extern unsigned int policydb_loaded_version;extern int selinux_nlmsg_lookup (u16 sclass,u16 nlmsg_type,u32 *perm);extern struct security_operations *security_ops;
@@ -4714,10 +4713,7 @@ static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb)if (err)return err; -if (policydb_loaded_version >=POLICYDB_VERSION_NLCLASS ) - err =selinux_nlmsg_perm (sk, skb); - -return err; +return selinux_nlmsg_perm (sk, skb); }static int selinux_netlink_recv (struct sk_buff *skb,int capability)
security/selinux/ss/services.c +0 -25
@@ -65,7 +65,6 @@#include "audit.h" extern void selnl_notify_policyload (u32 seqno); -unsigned int policydb_loaded_version;int selinux_policycap_netpeer;int selinux_policycap_openperm;
@@ -617,17 +616,6 @@ static int context_struct_compute_av(struct context *scontext,unsigned int i, j;/* -* Remap extended Netlink classes for old policy versions. -* Do this here rather than socket_type_to_security_class() -* in case a newer policy version is loaded, allowing sockets -* to remain in the correct class. -*/ -if (policydb_loaded_version <POLICYDB_VERSION_NLCLASS ) -if (tclass >=unmap_class (SECCLASS_NETLINK_ROUTE_SOCKET ) && - tclass <=unmap_class (SECCLASS_NETLINK_DNRT_SOCKET )) - tclass =unmap_class (SECCLASS_NETLINK_SOCKET ); - -/* * Initialize the access vectors to the default values. */ avd->allowed =0 ;
@@ -761,17 +749,6 @@ int security_validate_transition(u32 oldsid, u32 newsid, u32 tasksid, tclass =unmap_class (orig_tclass); -/* -* Remap extended Netlink classes for old policy versions. -* Do this here rather than socket_type_to_security_class() -* in case a newer policy version is loaded, allowing sockets -* to remain in the correct class. -*/ -if (policydb_loaded_version <POLICYDB_VERSION_NLCLASS ) -if (tclass >=unmap_class (SECCLASS_NETLINK_ROUTE_SOCKET ) && - tclass <=unmap_class (SECCLASS_NETLINK_DNRT_SOCKET )) - tclass =unmap_class (SECCLASS_NETLINK_SOCKET ); -if (!tclass || tclass > policydb.p_classes.nprim) {printk (KERN_ERR "SELinux: %s: unrecognized class %d\n" , __func__, tclass);
@@ -1766,7 +1743,6 @@ int security_load_policy(void *data, size_t len)return -EINVAL ; }security_load_policycaps (); - policydb_loaded_version = policydb.policyvers; ss_initialized =1 ; seqno = ++latest_granting;selinux_complete_init ();
@@ -1829,7 +1805,6 @@ int security_load_policy(void *data, size_t len) current_mapping = map; current_mapping_size = map_size; seqno = ++latest_granting; - policydb_loaded_version = policydb.policyvers;write_unlock_irq (&policy_rwlock);/* Free the old policydb and SID table. */
Signature · 12 lines
1.6.2.5 -- Stephen Smalley 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.
Quoted 9 lines · Stephen Smalley
Drop remapping of netlink classes and bypass of permission checking based on netlink message type for policy version < 18. This removes compatibility code introduced when the original single netlink security class used for all netlink sockets was split into finer-grained netlink classes based on netlink protocol and when permission checking was added based on netlink message type in Linux 2.6.8. The only known distribution that shipped with SELinux and policy < 18 was Fedora Core 2, which was EOL'd on 2005-04-11.
Quoted 6 lines
Given that the remapping code was never updated to address the addition of newer netlink classes, that the corresponding userland support was dropped in 2005, and that the assumptions made by the remapping code about the fixed ordering among netlink classes in the policy may be violated in the future due to the dynamic class/perm discovery support, we should drop this compatibility code now.
Shouldn't we reject the load of such a policy as well? No reason to leave them with a false sense of working....
-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.
Quoted 17 lines · Eric Paris
Quoted 9 lines · Stephen Smalley
Drop remapping of netlink classes and bypass of permission checking based on netlink message type for policy version < 18. This removes compatibility code introduced when the original single netlink security class used for all netlink sockets was split into finer-grained netlink classes based on netlink protocol and when permission checking was added based on netlink message type in Linux 2.6.8. The only known distribution that shipped with SELinux and policy < 18 was Fedora Core 2, which was EOL'd on 2005-04-11.
Quoted 6 lines
Given that the remapping code was never updated to address the addition of newer netlink classes, that the corresponding userland support was dropped in 2005, and that the assumptions made by the remapping code about the fixed ordering among netlink classes in the policy may be violated in the future due to the dynamic class/perm discovery support, we should drop this compatibility code now.
Quoted 2 lines
Shouldn't we reject the load of such a policy as well? No reason to leave them with a false sense of working....
That seems worse - at that point we're explicitly dropping all compatibility with policy < 18 and requiring the user to upgrade his SELinux userspace and recompile his policy to a newer policy version if he wants to use a newer kernel.
Contrast that with loading policies < 18, booting up at least minimally (e.g. single-user boot should be fine), and only failing all netlink socket operations. The user could at that point add definitions and allow rules for the fine-grained netlink classes to his existing policy and recompile that policy with his existing checkpolicy, without needing to update his userspace.
Either way I suppose we are technically in violation of the "new kernels must not break existing userspace" rule, although the latter seems slightly more compatible to me (no need to upgrade their checkpolicy, just modify their policy sources and recompile it).
Alternatively, we could just leave the compat code as is (i.e. not apply this patch). It just seemed like an opportunity to remove some legacy cruft from long ago. The only situation where the compat code will in fact cause us a problem is if we allow arbitrary ordering of classes in the policy (moving class definitions into modules and not imposing any fixed ordering); at that point we'd have to replace the netlink class range comparisons with an explicit enumeration of the individual netlink classes. That won't be possible though until the dynamic class/perm discovery support is mainlined and all userspace code that uses fixed class and permission values is updated, which will take a while. And even then, we still need to be able to build policies that will work on older kernels and userspace, so some way of imposing an ordering will be required for a long time.
Signature · 8 lines
Stephen Smalley 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.
Quoted 1 line · Stephen Smalley
Signed-off-by Stephen Smalley <[email protected]>
Applied togit://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next
Signature · 7 lines
James Morris <[email protected]> -- 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.