aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
authorPaul Moore <paul.moore@hp.com>2008-04-10 10:48:14 -0400
committerJames Morris <jmorris@namei.org>2008-04-18 06:26:16 -0400
commit3e11217263d0521e212cb8a017fbc2a1514db78f (patch)
treed3b399c3d907cd90afd27003000fd9d99212f44b /security/selinux/hooks.c
parent832cbd9aa1293cba57d06571f5fc8f0917c672af (diff)
SELinux: Add network port SID cache
Much like we added a network node cache, this patch adds a network port cache. The design is taken almost completely from the network node cache which in turn was taken from the network interface cache. The basic idea is to cache entries in a hash table based on protocol/port information. The hash function only takes the port number into account since the number of different protocols in use at any one time is expected to be relatively small. Signed-off-by: Paul Moore <paul.moore@hp.com> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 93c809a6e4fa..34f2d46c7984 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -80,6 +80,7 @@
80#include "objsec.h" 80#include "objsec.h"
81#include "netif.h" 81#include "netif.h"
82#include "netnode.h" 82#include "netnode.h"
83#include "netport.h"
83#include "xfrm.h" 84#include "xfrm.h"
84#include "netlabel.h" 85#include "netlabel.h"
85 86
@@ -3670,10 +3671,8 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
3670 inet_get_local_port_range(&low, &high); 3671 inet_get_local_port_range(&low, &high);
3671 3672
3672 if (snum < max(PROT_SOCK, low) || snum > high) { 3673 if (snum < max(PROT_SOCK, low) || snum > high) {
3673 err = security_port_sid(sk->sk_family, 3674 err = sel_netport_sid(sk->sk_protocol,
3674 sk->sk_type, 3675 snum, &sid);
3675 sk->sk_protocol, snum,
3676 &sid);
3677 if (err) 3676 if (err)
3678 goto out; 3677 goto out;
3679 AVC_AUDIT_DATA_INIT(&ad,NET); 3678 AVC_AUDIT_DATA_INIT(&ad,NET);
@@ -3761,8 +3760,7 @@ static int selinux_socket_connect(struct socket *sock, struct sockaddr *address,
3761 snum = ntohs(addr6->sin6_port); 3760 snum = ntohs(addr6->sin6_port);
3762 } 3761 }
3763 3762
3764 err = security_port_sid(sk->sk_family, sk->sk_type, 3763 err = sel_netport_sid(sk->sk_protocol, snum, &sid);
3765 sk->sk_protocol, snum, &sid);
3766 if (err) 3764 if (err)
3767 goto out; 3765 goto out;
3768 3766
@@ -3993,9 +3991,8 @@ static int selinux_sock_rcv_skb_iptables_compat(struct sock *sk,
3993 3991
3994 if (!recv_perm) 3992 if (!recv_perm)
3995 return 0; 3993 return 0;
3996 err = security_port_sid(sk->sk_family, sk->sk_type, 3994 err = sel_netport_sid(sk->sk_protocol,
3997 sk->sk_protocol, ntohs(ad->u.net.sport), 3995 ntohs(ad->u.net.sport), &port_sid);
3998 &port_sid);
3999 if (unlikely(err)) { 3996 if (unlikely(err)) {
4000 printk(KERN_WARNING 3997 printk(KERN_WARNING
4001 "SELinux: failure in" 3998 "SELinux: failure in"
@@ -4416,9 +4413,8 @@ static int selinux_ip_postroute_iptables_compat(struct sock *sk,
4416 if (send_perm != 0) 4413 if (send_perm != 0)
4417 return 0; 4414 return 0;
4418 4415
4419 err = security_port_sid(sk->sk_family, sk->sk_type, 4416 err = sel_netport_sid(sk->sk_protocol,
4420 sk->sk_protocol, ntohs(ad->u.net.dport), 4417 ntohs(ad->u.net.dport), &port_sid);
4421 &port_sid);
4422 if (unlikely(err)) { 4418 if (unlikely(err)) {
4423 printk(KERN_WARNING 4419 printk(KERN_WARNING
4424 "SELinux: failure in" 4420 "SELinux: failure in"