1313 * Copyright (C) 2003 Red Hat, Inc., James Morris <jmorris@redhat.com>
1414 * Copyright (C) 2016 Mellanox Technologies
1515 */
16+
1617#ifndef _SELINUX_OBJSEC_H_
1718#define _SELINUX_OBJSEC_H_
1819
2930#include "avc.h"
3031
3132struct task_security_struct {
32- u32 osid ; /* SID prior to last execve */
33- u32 sid ; /* current SID */
34- u32 exec_sid ; /* exec SID */
35- u32 create_sid ; /* fscreate SID */
36- u32 keycreate_sid ; /* keycreate SID */
37- u32 sockcreate_sid ; /* fscreate SID */
33+ u32 osid ; /* SID prior to last execve */
34+ u32 sid ; /* current SID */
35+ u32 exec_sid ; /* exec SID */
36+ u32 create_sid ; /* fscreate SID */
37+ u32 keycreate_sid ; /* keycreate SID */
38+ u32 sockcreate_sid ; /* fscreate SID */
3839} __randomize_layout ;
3940
4041enum label_initialized {
41- LABEL_INVALID , /* invalid or not initialized */
42- LABEL_INITIALIZED , /* initialized */
42+ LABEL_INVALID , /* invalid or not initialized */
43+ LABEL_INITIALIZED , /* initialized */
4344 LABEL_PENDING
4445};
4546
4647struct inode_security_struct {
47- struct inode * inode ; /* back pointer to inode object */
48- struct list_head list ; /* list of inode_security_struct */
49- u32 task_sid ; /* SID of creating task */
50- u32 sid ; /* SID of this object */
51- u16 sclass ; /* security class of this object */
52- unsigned char initialized ; /* initialization flag */
48+ struct inode * inode ; /* back pointer to inode object */
49+ struct list_head list ; /* list of inode_security_struct */
50+ u32 task_sid ; /* SID of creating task */
51+ u32 sid ; /* SID of this object */
52+ u16 sclass ; /* security class of this object */
53+ unsigned char initialized ; /* initialization flag */
5354 spinlock_t lock ;
5455};
5556
5657struct file_security_struct {
57- u32 sid ; /* SID of open file description */
58- u32 fown_sid ; /* SID of file owner (for SIGIO) */
59- u32 isid ; /* SID of inode at the time of file open */
60- u32 pseqno ; /* Policy seqno at the time of file open */
58+ u32 sid ; /* SID of open file description */
59+ u32 fown_sid ; /* SID of file owner (for SIGIO) */
60+ u32 isid ; /* SID of inode at the time of file open */
61+ u32 pseqno ; /* Policy seqno at the time of file open */
6162};
6263
6364struct superblock_security_struct {
64- u32 sid ; /* SID of file system superblock */
65- u32 def_sid ; /* default SID for labeling */
66- u32 mntpoint_sid ; /* SECURITY_FS_USE_MNTPOINT context for files */
67- unsigned short behavior ; /* labeling behavior */
68- unsigned short flags ; /* which mount options were specified */
65+ u32 sid ; /* SID of file system superblock */
66+ u32 def_sid ; /* default SID for labeling */
67+ u32 mntpoint_sid ; /* SECURITY_FS_USE_MNTPOINT context for files */
68+ unsigned short behavior ; /* labeling behavior */
69+ unsigned short flags ; /* which mount options were specified */
6970 struct mutex lock ;
7071 struct list_head isec_head ;
7172 spinlock_t isec_lock ;
7273};
7374
7475struct msg_security_struct {
75- u32 sid ; /* SID of message */
76+ u32 sid ; /* SID of message */
7677};
7778
7879struct ipc_security_struct {
79- u16 sclass ; /* security class of this object */
80- u32 sid ; /* SID of IPC resource */
80+ u16 sclass ; /* security class of this object */
81+ u32 sid ; /* SID of IPC resource */
8182};
8283
8384struct netif_security_struct {
84- struct net * ns ; /* network namespace */
85- int ifindex ; /* device index */
86- u32 sid ; /* SID for this interface */
85+ struct net * ns ; /* network namespace */
86+ int ifindex ; /* device index */
87+ u32 sid ; /* SID for this interface */
8788};
8889
8990struct netnode_security_struct {
9091 union {
91- __be32 ipv4 ; /* IPv4 node address */
92- struct in6_addr ipv6 ; /* IPv6 node address */
92+ __be32 ipv4 ; /* IPv4 node address */
93+ struct in6_addr ipv6 ; /* IPv6 node address */
9394 } addr ;
94- u32 sid ; /* SID for this node */
95- u16 family ; /* address family */
95+ u32 sid ; /* SID for this node */
96+ u16 family ; /* address family */
9697};
9798
9899struct netport_security_struct {
99- u32 sid ; /* SID for this node */
100- u16 port ; /* port number */
101- u8 protocol ; /* transport protocol */
100+ u32 sid ; /* SID for this node */
101+ u16 port ; /* port number */
102+ u8 protocol ; /* transport protocol */
102103};
103104
104105struct sk_security_struct {
105106#ifdef CONFIG_NETLABEL
106- enum { /* NetLabel state */
107- NLBL_UNSET = 0 ,
108- NLBL_REQUIRE ,
109- NLBL_LABELED ,
110- NLBL_REQSKB ,
111- NLBL_CONNLABELED ,
107+ enum { /* NetLabel state */
108+ NLBL_UNSET = 0 ,
109+ NLBL_REQUIRE ,
110+ NLBL_LABELED ,
111+ NLBL_REQSKB ,
112+ NLBL_CONNLABELED ,
112113 } nlbl_state ;
113114 struct netlbl_lsm_secattr * nlbl_secattr ; /* NetLabel sec attributes */
114115#endif
115- u32 sid ; /* SID of this object */
116- u32 peer_sid ; /* SID of peer */
117- u16 sclass ; /* sock security class */
118- enum { /* SCTP association state */
119- SCTP_ASSOC_UNSET = 0 ,
120- SCTP_ASSOC_SET ,
116+ u32 sid ; /* SID of this object */
117+ u32 peer_sid ; /* SID of peer */
118+ u16 sclass ; /* sock security class */
119+ enum { /* SCTP association state */
120+ SCTP_ASSOC_UNSET = 0 ,
121+ SCTP_ASSOC_SET ,
121122 } sctp_assoc_state ;
122123};
123124
124125struct tun_security_struct {
125- u32 sid ; /* SID for the tun device sockets */
126+ u32 sid ; /* SID for the tun device sockets */
126127};
127128
128129struct key_security_struct {
129- u32 sid ; /* SID of key */
130+ u32 sid ; /* SID of key */
130131};
131132
132133struct ib_security_struct {
133- u32 sid ; /* SID of the queue pair or MAD agent */
134+ u32 sid ; /* SID of the queue pair or MAD agent */
134135};
135136
136137struct pkey_security_struct {
137- u64 subnet_prefix ; /* Port subnet prefix */
138- u16 pkey ; /* PKey number */
139- u32 sid ; /* SID of pkey */
138+ u64 subnet_prefix ; /* Port subnet prefix */
139+ u16 pkey ; /* PKey number */
140+ u32 sid ; /* SID of pkey */
140141};
141142
142143struct bpf_security_struct {
143- u32 sid ; /* SID of bpf obj creator */
144+ u32 sid ; /* SID of bpf obj creator */
144145};
145146
146147struct perf_event_security_struct {
147- u32 sid ; /* SID of perf_event obj creator */
148+ u32 sid ; /* SID of perf_event obj creator */
148149};
149150
150151extern struct lsm_blob_sizes selinux_blob_sizes ;
@@ -158,22 +159,22 @@ static inline struct file_security_struct *selinux_file(const struct file *file)
158159 return file -> f_security + selinux_blob_sizes .lbs_file ;
159160}
160161
161- static inline struct inode_security_struct * selinux_inode (
162- const struct inode * inode )
162+ static inline struct inode_security_struct *
163+ selinux_inode ( const struct inode * inode )
163164{
164165 if (unlikely (!inode -> i_security ))
165166 return NULL ;
166167 return inode -> i_security + selinux_blob_sizes .lbs_inode ;
167168}
168169
169- static inline struct msg_security_struct * selinux_msg_msg (
170- const struct msg_msg * msg_msg )
170+ static inline struct msg_security_struct *
171+ selinux_msg_msg ( const struct msg_msg * msg_msg )
171172{
172173 return msg_msg -> security + selinux_blob_sizes .lbs_msg_msg ;
173174}
174175
175- static inline struct ipc_security_struct * selinux_ipc (
176- const struct kern_ipc_perm * ipc )
176+ static inline struct ipc_security_struct *
177+ selinux_ipc ( const struct kern_ipc_perm * ipc )
177178{
178179 return ipc -> security + selinux_blob_sizes .lbs_ipc ;
179180}
@@ -188,8 +189,8 @@ static inline u32 current_sid(void)
188189 return tsec -> sid ;
189190}
190191
191- static inline struct superblock_security_struct * selinux_superblock (
192- const struct super_block * superblock )
192+ static inline struct superblock_security_struct *
193+ selinux_superblock ( const struct super_block * superblock )
193194{
194195 return superblock -> s_security + selinux_blob_sizes .lbs_superblock ;
195196}
0 commit comments