This source file includes following definitions.
- selinux_cred
- selinux_file
- selinux_inode
- selinux_msg_msg
- selinux_ipc
- current_sid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #ifndef _SELINUX_OBJSEC_H_
17 #define _SELINUX_OBJSEC_H_
18
19 #include <linux/list.h>
20 #include <linux/sched.h>
21 #include <linux/fs.h>
22 #include <linux/binfmts.h>
23 #include <linux/in.h>
24 #include <linux/spinlock.h>
25 #include <linux/lsm_hooks.h>
26 #include <linux/msg.h>
27 #include <net/net_namespace.h>
28 #include "flask.h"
29 #include "avc.h"
30
31 struct task_security_struct {
32 u32 osid;
33 u32 sid;
34 u32 exec_sid;
35 u32 create_sid;
36 u32 keycreate_sid;
37 u32 sockcreate_sid;
38 };
39
40 enum label_initialized {
41 LABEL_INVALID,
42 LABEL_INITIALIZED,
43 LABEL_PENDING
44 };
45
46 struct inode_security_struct {
47 struct inode *inode;
48 struct list_head list;
49 u32 task_sid;
50 u32 sid;
51 u16 sclass;
52 unsigned char initialized;
53 spinlock_t lock;
54 };
55
56 struct file_security_struct {
57 u32 sid;
58 u32 fown_sid;
59 u32 isid;
60 u32 pseqno;
61 };
62
63 struct superblock_security_struct {
64 struct super_block *sb;
65 u32 sid;
66 u32 def_sid;
67 u32 mntpoint_sid;
68 unsigned short behavior;
69 unsigned short flags;
70 struct mutex lock;
71 struct list_head isec_head;
72 spinlock_t isec_lock;
73 };
74
75 struct msg_security_struct {
76 u32 sid;
77 };
78
79 struct ipc_security_struct {
80 u16 sclass;
81 u32 sid;
82 };
83
84 struct netif_security_struct {
85 struct net *ns;
86 int ifindex;
87 u32 sid;
88 };
89
90 struct netnode_security_struct {
91 union {
92 __be32 ipv4;
93 struct in6_addr ipv6;
94 } addr;
95 u32 sid;
96 u16 family;
97 };
98
99 struct netport_security_struct {
100 u32 sid;
101 u16 port;
102 u8 protocol;
103 };
104
105 struct sk_security_struct {
106 #ifdef CONFIG_NETLABEL
107 enum {
108 NLBL_UNSET = 0,
109 NLBL_REQUIRE,
110 NLBL_LABELED,
111 NLBL_REQSKB,
112 NLBL_CONNLABELED,
113 } nlbl_state;
114 struct netlbl_lsm_secattr *nlbl_secattr;
115 #endif
116 u32 sid;
117 u32 peer_sid;
118 u16 sclass;
119 enum {
120 SCTP_ASSOC_UNSET = 0,
121 SCTP_ASSOC_SET,
122 } sctp_assoc_state;
123 };
124
125 struct tun_security_struct {
126 u32 sid;
127 };
128
129 struct key_security_struct {
130 u32 sid;
131 };
132
133 struct ib_security_struct {
134 u32 sid;
135 };
136
137 struct pkey_security_struct {
138 u64 subnet_prefix;
139 u16 pkey;
140 u32 sid;
141 };
142
143 struct bpf_security_struct {
144 u32 sid;
145 };
146
147 extern struct lsm_blob_sizes selinux_blob_sizes;
148 static inline struct task_security_struct *selinux_cred(const struct cred *cred)
149 {
150 return cred->security + selinux_blob_sizes.lbs_cred;
151 }
152
153 static inline struct file_security_struct *selinux_file(const struct file *file)
154 {
155 return file->f_security + selinux_blob_sizes.lbs_file;
156 }
157
158 static inline struct inode_security_struct *selinux_inode(
159 const struct inode *inode)
160 {
161 if (unlikely(!inode->i_security))
162 return NULL;
163 return inode->i_security + selinux_blob_sizes.lbs_inode;
164 }
165
166 static inline struct msg_security_struct *selinux_msg_msg(
167 const struct msg_msg *msg_msg)
168 {
169 return msg_msg->security + selinux_blob_sizes.lbs_msg_msg;
170 }
171
172 static inline struct ipc_security_struct *selinux_ipc(
173 const struct kern_ipc_perm *ipc)
174 {
175 return ipc->security + selinux_blob_sizes.lbs_ipc;
176 }
177
178
179
180
181 static inline u32 current_sid(void)
182 {
183 const struct task_security_struct *tsec = selinux_cred(current_cred());
184
185 return tsec->sid;
186 }
187
188 #endif