aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/include
diff options
context:
space:
mode:
Diffstat (limited to 'security/selinux/include')
-rw-r--r--security/selinux/include/av_perm_to_string.h1
-rw-r--r--security/selinux/include/av_permissions.h1
-rw-r--r--security/selinux/include/objsec.h9
-rw-r--r--security/selinux/include/security.h2
-rw-r--r--security/selinux/include/selinux_netlabel.h119
-rw-r--r--security/selinux/include/xfrm.h43
6 files changed, 156 insertions, 19 deletions
diff --git a/security/selinux/include/av_perm_to_string.h b/security/selinux/include/av_perm_to_string.h
index 7c9b58380833..09fc8a2345eb 100644
--- a/security/selinux/include/av_perm_to_string.h
+++ b/security/selinux/include/av_perm_to_string.h
@@ -241,6 +241,7 @@
241 S_(SECCLASS_ASSOCIATION, ASSOCIATION__SENDTO, "sendto") 241 S_(SECCLASS_ASSOCIATION, ASSOCIATION__SENDTO, "sendto")
242 S_(SECCLASS_ASSOCIATION, ASSOCIATION__RECVFROM, "recvfrom") 242 S_(SECCLASS_ASSOCIATION, ASSOCIATION__RECVFROM, "recvfrom")
243 S_(SECCLASS_ASSOCIATION, ASSOCIATION__SETCONTEXT, "setcontext") 243 S_(SECCLASS_ASSOCIATION, ASSOCIATION__SETCONTEXT, "setcontext")
244 S_(SECCLASS_ASSOCIATION, ASSOCIATION__POLMATCH, "polmatch")
244 S_(SECCLASS_PACKET, PACKET__SEND, "send") 245 S_(SECCLASS_PACKET, PACKET__SEND, "send")
245 S_(SECCLASS_PACKET, PACKET__RECV, "recv") 246 S_(SECCLASS_PACKET, PACKET__RECV, "recv")
246 S_(SECCLASS_PACKET, PACKET__RELABELTO, "relabelto") 247 S_(SECCLASS_PACKET, PACKET__RELABELTO, "relabelto")
diff --git a/security/selinux/include/av_permissions.h b/security/selinux/include/av_permissions.h
index 69fd4b48202c..81f4f526c8b1 100644
--- a/security/selinux/include/av_permissions.h
+++ b/security/selinux/include/av_permissions.h
@@ -911,6 +911,7 @@
911#define ASSOCIATION__SENDTO 0x00000001UL 911#define ASSOCIATION__SENDTO 0x00000001UL
912#define ASSOCIATION__RECVFROM 0x00000002UL 912#define ASSOCIATION__RECVFROM 0x00000002UL
913#define ASSOCIATION__SETCONTEXT 0x00000004UL 913#define ASSOCIATION__SETCONTEXT 0x00000004UL
914#define ASSOCIATION__POLMATCH 0x00000008UL
914 915
915#define NETLINK_KOBJECT_UEVENT_SOCKET__IOCTL 0x00000001UL 916#define NETLINK_KOBJECT_UEVENT_SOCKET__IOCTL 0x00000001UL
916#define NETLINK_KOBJECT_UEVENT_SOCKET__READ 0x00000002UL 917#define NETLINK_KOBJECT_UEVENT_SOCKET__READ 0x00000002UL
diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h
index 940178865fc7..0a39bfd1319f 100644
--- a/security/selinux/include/objsec.h
+++ b/security/selinux/include/objsec.h
@@ -99,7 +99,16 @@ struct netif_security_struct {
99 99
100struct sk_security_struct { 100struct sk_security_struct {
101 struct sock *sk; /* back pointer to sk object */ 101 struct sock *sk; /* back pointer to sk object */
102 u32 sid; /* SID of this object */
102 u32 peer_sid; /* SID of peer */ 103 u32 peer_sid; /* SID of peer */
104#ifdef CONFIG_NETLABEL
105 u16 sclass; /* sock security class */
106 enum { /* NetLabel state */
107 NLBL_UNSET = 0,
108 NLBL_REQUIRE,
109 NLBL_LABELED,
110 } nlbl_state;
111#endif
103}; 112};
104 113
105struct key_security_struct { 114struct key_security_struct {
diff --git a/security/selinux/include/security.h b/security/selinux/include/security.h
index 063af47bb231..911954a692fa 100644
--- a/security/selinux/include/security.h
+++ b/security/selinux/include/security.h
@@ -78,6 +78,8 @@ int security_node_sid(u16 domain, void *addr, u32 addrlen,
78int security_validate_transition(u32 oldsid, u32 newsid, u32 tasksid, 78int security_validate_transition(u32 oldsid, u32 newsid, u32 tasksid,
79 u16 tclass); 79 u16 tclass);
80 80
81int security_sid_mls_copy(u32 sid, u32 mls_sid, u32 *new_sid);
82
81#define SECURITY_FS_USE_XATTR 1 /* use xattr */ 83#define SECURITY_FS_USE_XATTR 1 /* use xattr */
82#define SECURITY_FS_USE_TRANS 2 /* use transition SIDs, e.g. devpts/tmpfs */ 84#define SECURITY_FS_USE_TRANS 2 /* use transition SIDs, e.g. devpts/tmpfs */
83#define SECURITY_FS_USE_TASK 3 /* use task SIDs, e.g. pipefs/sockfs */ 85#define SECURITY_FS_USE_TASK 3 /* use task SIDs, e.g. pipefs/sockfs */
diff --git a/security/selinux/include/selinux_netlabel.h b/security/selinux/include/selinux_netlabel.h
new file mode 100644
index 000000000000..ecab4bddaaf4
--- /dev/null
+++ b/security/selinux/include/selinux_netlabel.h
@@ -0,0 +1,119 @@
1/*
2 * SELinux interface to the NetLabel subsystem
3 *
4 * Author : Paul Moore <paul.moore@hp.com>
5 *
6 */
7
8/*
9 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
19 * the GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27#ifndef _SELINUX_NETLABEL_H_
28#define _SELINUX_NETLABEL_H_
29
30#include <linux/types.h>
31#include <linux/fs.h>
32#include <linux/net.h>
33#include <linux/skbuff.h>
34#include <net/sock.h>
35
36#include "avc.h"
37#include "objsec.h"
38
39#ifdef CONFIG_NETLABEL
40void selinux_netlbl_cache_invalidate(void);
41int selinux_netlbl_socket_post_create(struct socket *sock,
42 int sock_family,
43 u32 sid);
44void selinux_netlbl_sock_graft(struct sock *sk, struct socket *sock);
45u32 selinux_netlbl_inet_conn_request(struct sk_buff *skb, u32 sock_sid);
46int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
47 struct sk_buff *skb,
48 struct avc_audit_data *ad);
49u32 selinux_netlbl_socket_getpeersec_stream(struct socket *sock);
50u32 selinux_netlbl_socket_getpeersec_dgram(struct sk_buff *skb);
51void selinux_netlbl_sk_security_init(struct sk_security_struct *ssec,
52 int family);
53void selinux_netlbl_sk_clone_security(struct sk_security_struct *ssec,
54 struct sk_security_struct *newssec);
55int selinux_netlbl_inode_permission(struct inode *inode, int mask);
56#else
57static inline void selinux_netlbl_cache_invalidate(void)
58{
59 return;
60}
61
62static inline int selinux_netlbl_socket_post_create(struct socket *sock,
63 int sock_family,
64 u32 sid)
65{
66 return 0;
67}
68
69static inline void selinux_netlbl_sock_graft(struct sock *sk,
70 struct socket *sock)
71{
72 return;
73}
74
75static inline u32 selinux_netlbl_inet_conn_request(struct sk_buff *skb,
76 u32 sock_sid)
77{
78 return SECSID_NULL;
79}
80
81static inline int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
82 struct sk_buff *skb,
83 struct avc_audit_data *ad)
84{
85 return 0;
86}
87
88static inline u32 selinux_netlbl_socket_getpeersec_stream(struct socket *sock)
89{
90 return SECSID_NULL;
91}
92
93static inline u32 selinux_netlbl_socket_getpeersec_dgram(struct sk_buff *skb)
94{
95 return SECSID_NULL;
96}
97
98static inline void selinux_netlbl_sk_security_init(
99 struct sk_security_struct *ssec,
100 int family)
101{
102 return;
103}
104
105static inline void selinux_netlbl_sk_clone_security(
106 struct sk_security_struct *ssec,
107 struct sk_security_struct *newssec)
108{
109 return;
110}
111
112static inline int selinux_netlbl_inode_permission(struct inode *inode,
113 int mask)
114{
115 return 0;
116}
117#endif /* CONFIG_NETLABEL */
118
119#endif
diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
index c96498a10eb8..81eb59890162 100644
--- a/security/selinux/include/xfrm.h
+++ b/security/selinux/include/xfrm.h
@@ -2,18 +2,25 @@
2 * SELinux support for the XFRM LSM hooks 2 * SELinux support for the XFRM LSM hooks
3 * 3 *
4 * Author : Trent Jaeger, <jaegert@us.ibm.com> 4 * Author : Trent Jaeger, <jaegert@us.ibm.com>
5 * Updated : Venkat Yekkirala, <vyekkirala@TrustedCS.com>
5 */ 6 */
6#ifndef _SELINUX_XFRM_H_ 7#ifndef _SELINUX_XFRM_H_
7#define _SELINUX_XFRM_H_ 8#define _SELINUX_XFRM_H_
8 9
9int selinux_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx); 10int selinux_xfrm_policy_alloc(struct xfrm_policy *xp,
11 struct xfrm_user_sec_ctx *sec_ctx, struct sock *sk);
10int selinux_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new); 12int selinux_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new);
11void selinux_xfrm_policy_free(struct xfrm_policy *xp); 13void selinux_xfrm_policy_free(struct xfrm_policy *xp);
12int selinux_xfrm_policy_delete(struct xfrm_policy *xp); 14int selinux_xfrm_policy_delete(struct xfrm_policy *xp);
13int selinux_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx); 15int selinux_xfrm_state_alloc(struct xfrm_state *x,
16 struct xfrm_user_sec_ctx *sec_ctx, struct xfrm_sec_ctx *pol, u32 secid);
14void selinux_xfrm_state_free(struct xfrm_state *x); 17void selinux_xfrm_state_free(struct xfrm_state *x);
15int selinux_xfrm_state_delete(struct xfrm_state *x); 18int selinux_xfrm_state_delete(struct xfrm_state *x);
16int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir); 19int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
20int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x,
21 struct xfrm_policy *xp, struct flowi *fl);
22int selinux_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm);
23
17 24
18/* 25/*
19 * Extract the security blob from the sock (it's actually on the socket) 26 * Extract the security blob from the sock (it's actually on the socket)
@@ -26,30 +33,23 @@ static inline struct inode_security_struct *get_sock_isec(struct sock *sk)
26 return SOCK_INODE(sk->sk_socket)->i_security; 33 return SOCK_INODE(sk->sk_socket)->i_security;
27} 34}
28 35
29
30static inline u32 selinux_no_sk_sid(struct flowi *fl)
31{
32 /* NOTE: no sock occurs on ICMP reply, forwards, ... */
33 /* icmp_reply: authorize as kernel packet */
34 if (fl && fl->proto == IPPROTO_ICMP) {
35 return SECINITSID_KERNEL;
36 }
37
38 return SECINITSID_ANY_SOCKET;
39}
40
41#ifdef CONFIG_SECURITY_NETWORK_XFRM 36#ifdef CONFIG_SECURITY_NETWORK_XFRM
42int selinux_xfrm_sock_rcv_skb(u32 sid, struct sk_buff *skb); 37int selinux_xfrm_sock_rcv_skb(u32 sid, struct sk_buff *skb,
43int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb); 38 struct avc_audit_data *ad);
39int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb,
40 struct avc_audit_data *ad);
44u32 selinux_socket_getpeer_stream(struct sock *sk); 41u32 selinux_socket_getpeer_stream(struct sock *sk);
45u32 selinux_socket_getpeer_dgram(struct sk_buff *skb); 42u32 selinux_socket_getpeer_dgram(struct sk_buff *skb);
43int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
46#else 44#else
47static inline int selinux_xfrm_sock_rcv_skb(u32 isec_sid, struct sk_buff *skb) 45static inline int selinux_xfrm_sock_rcv_skb(u32 isec_sid, struct sk_buff *skb,
46 struct avc_audit_data *ad)
48{ 47{
49 return 0; 48 return 0;
50} 49}
51 50
52static inline int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb) 51static inline int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb,
52 struct avc_audit_data *ad)
53{ 53{
54 return 0; 54 return 0;
55} 55}
@@ -63,6 +63,11 @@ static inline int selinux_socket_getpeer_dgram(struct sk_buff *skb)
63{ 63{
64 return SECSID_NULL; 64 return SECSID_NULL;
65} 65}
66static inline int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall)
67{
68 *sid = SECSID_NULL;
69 return 0;
70}
66#endif 71#endif
67 72
68#endif /* _SELINUX_XFRM_H_ */ 73#endif /* _SELINUX_XFRM_H_ */