Skip to content

Commit 941fc5b

Browse files
stephensmalleyxjamesmorris
authored andcommitted
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. Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org>
1 parent 8753f6b commit 941fc5b

2 files changed

Lines changed: 1 addition & 30 deletions

File tree

‎security/selinux/hooks.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191

9292
#define NUM_SEL_MNT_OPTS 5
9393

94-
extern unsigned int policydb_loaded_version;
9594
extern int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm);
9695
extern struct security_operations *security_ops;
9796

@@ -4714,10 +4713,7 @@ static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb)
47144713
if (err)
47154714
return err;
47164715

4717-
if (policydb_loaded_version >= POLICYDB_VERSION_NLCLASS)
4718-
err = selinux_nlmsg_perm(sk, skb);
4719-
4720-
return err;
4716+
return selinux_nlmsg_perm(sk, skb);
47214717
}
47224718

47234719
static int selinux_netlink_recv(struct sk_buff *skb, int capability)

‎security/selinux/ss/services.c‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
#include "audit.h"
6666

6767
extern void selnl_notify_policyload(u32 seqno);
68-
unsigned int policydb_loaded_version;
6968

7069
int selinux_policycap_netpeer;
7170
int selinux_policycap_openperm;
@@ -616,17 +615,6 @@ static int context_struct_compute_av(struct context *scontext,
616615
struct ebitmap_node *snode, *tnode;
617616
unsigned int i, j;
618617

619-
/*
620-
* Remap extended Netlink classes for old policy versions.
621-
* Do this here rather than socket_type_to_security_class()
622-
* in case a newer policy version is loaded, allowing sockets
623-
* to remain in the correct class.
624-
*/
625-
if (policydb_loaded_version < POLICYDB_VERSION_NLCLASS)
626-
if (tclass >= unmap_class(SECCLASS_NETLINK_ROUTE_SOCKET) &&
627-
tclass <= unmap_class(SECCLASS_NETLINK_DNRT_SOCKET))
628-
tclass = unmap_class(SECCLASS_NETLINK_SOCKET);
629-
630618
/*
631619
* Initialize the access vectors to the default values.
632620
*/
@@ -761,17 +749,6 @@ int security_validate_transition(u32 oldsid, u32 newsid, u32 tasksid,
761749

762750
tclass = unmap_class(orig_tclass);
763751

764-
/*
765-
* Remap extended Netlink classes for old policy versions.
766-
* Do this here rather than socket_type_to_security_class()
767-
* in case a newer policy version is loaded, allowing sockets
768-
* to remain in the correct class.
769-
*/
770-
if (policydb_loaded_version < POLICYDB_VERSION_NLCLASS)
771-
if (tclass >= unmap_class(SECCLASS_NETLINK_ROUTE_SOCKET) &&
772-
tclass <= unmap_class(SECCLASS_NETLINK_DNRT_SOCKET))
773-
tclass = unmap_class(SECCLASS_NETLINK_SOCKET);
774-
775752
if (!tclass || tclass > policydb.p_classes.nprim) {
776753
printk(KERN_ERR "SELinux: %s: unrecognized class %d\n",
777754
__func__, tclass);
@@ -1766,7 +1743,6 @@ int security_load_policy(void *data, size_t len)
17661743
return -EINVAL;
17671744
}
17681745
security_load_policycaps();
1769-
policydb_loaded_version = policydb.policyvers;
17701746
ss_initialized = 1;
17711747
seqno = ++latest_granting;
17721748
selinux_complete_init();
@@ -1829,7 +1805,6 @@ int security_load_policy(void *data, size_t len)
18291805
current_mapping = map;
18301806
current_mapping_size = map_size;
18311807
seqno = ++latest_granting;
1832-
policydb_loaded_version = policydb.policyvers;
18331808
write_unlock_irq(&policy_rwlock);
18341809

18351810
/* Free the old policydb and SID table. */

0 commit comments

Comments
 (0)