@@ -51,58 +51,40 @@ struct security_hook_heads {
5151 * Contains the information that identifies the LSM.
5252 */
5353struct lsm_id {
54- const char * name ;
55- u64 id ;
54+ const char * name ;
55+ u64 id ;
5656};
5757
5858/*
5959 * Security module hook list structure.
6060 * For use with generic list macros for common operations.
6161 */
6262struct security_hook_list {
63- struct hlist_node list ;
64- struct hlist_head * head ;
65- union security_list_options hook ;
66- const struct lsm_id * lsmid ;
63+ struct hlist_node list ;
64+ struct hlist_head * head ;
65+ union security_list_options hook ;
66+ const struct lsm_id * lsmid ;
6767} __randomize_layout ;
6868
6969/*
7070 * Security blob size or offset data.
7171 */
7272struct lsm_blob_sizes {
73- int lbs_cred ;
74- int lbs_file ;
75- int lbs_ib ;
76- int lbs_inode ;
77- int lbs_sock ;
78- int lbs_superblock ;
79- int lbs_ipc ;
80- int lbs_key ;
81- int lbs_msg_msg ;
82- int lbs_perf_event ;
83- int lbs_task ;
84- int lbs_xattr_count ; /* number of xattr slots in new_xattrs array */
85- int lbs_tun_dev ;
73+ int lbs_cred ;
74+ int lbs_file ;
75+ int lbs_ib ;
76+ int lbs_inode ;
77+ int lbs_sock ;
78+ int lbs_superblock ;
79+ int lbs_ipc ;
80+ int lbs_key ;
81+ int lbs_msg_msg ;
82+ int lbs_perf_event ;
83+ int lbs_task ;
84+ int lbs_xattr_count ; /* number of xattr slots in new_xattrs array */
85+ int lbs_tun_dev ;
8686};
8787
88- /**
89- * lsm_get_xattr_slot - Return the next available slot and increment the index
90- * @xattrs: array storing LSM-provided xattrs
91- * @xattr_count: number of already stored xattrs (updated)
92- *
93- * Retrieve the first available slot in the @xattrs array to fill with an xattr,
94- * and increment @xattr_count.
95- *
96- * Return: The slot to fill in @xattrs if non-NULL, NULL otherwise.
97- */
98- static inline struct xattr * lsm_get_xattr_slot (struct xattr * xattrs ,
99- int * xattr_count )
100- {
101- if (unlikely (!xattrs ))
102- return NULL ;
103- return & xattrs [(* xattr_count )++ ];
104- }
105-
10688/*
10789 * LSM_RET_VOID is used as the default value in LSM_HOOK definitions for void
10890 * LSM hooks (in include/linux/lsm_hook_defs.h).
@@ -118,9 +100,6 @@ static inline struct xattr *lsm_get_xattr_slot(struct xattr *xattrs,
118100#define LSM_HOOK_INIT (HEAD , HOOK ) \
119101 { .head = &security_hook_heads.HEAD, .hook = { .HEAD = HOOK } }
120102
121- extern struct security_hook_heads security_hook_heads ;
122- extern char * lsm_names ;
123-
124103extern void security_add_hooks (struct security_hook_list * hooks , int count ,
125104 const struct lsm_id * lsmid );
126105
@@ -142,9 +121,6 @@ struct lsm_info {
142121 struct lsm_blob_sizes * blobs ; /* Optional: for blob sharing. */
143122};
144123
145- extern struct lsm_info __start_lsm_info [], __end_lsm_info [];
146- extern struct lsm_info __start_early_lsm_info [], __end_early_lsm_info [];
147-
148124#define DEFINE_LSM (lsm ) \
149125 static struct lsm_info __lsm_##lsm \
150126 __used __section(".lsm_info.init") \
@@ -155,6 +131,29 @@ extern struct lsm_info __start_early_lsm_info[], __end_early_lsm_info[];
155131 __used __section(".early_lsm_info.init") \
156132 __aligned(sizeof(unsigned long))
157133
158- extern int lsm_inode_alloc (struct inode * inode );
134+ /* DO NOT tamper with these variables outside of the LSM framework */
135+ extern char * lsm_names ;
136+ extern struct security_hook_heads security_hook_heads ;
137+ extern struct lsm_static_calls_table static_calls_table __ro_after_init ;
138+ extern struct lsm_info __start_lsm_info [], __end_lsm_info [];
139+ extern struct lsm_info __start_early_lsm_info [], __end_early_lsm_info [];
140+
141+ /**
142+ * lsm_get_xattr_slot - Return the next available slot and increment the index
143+ * @xattrs: array storing LSM-provided xattrs
144+ * @xattr_count: number of already stored xattrs (updated)
145+ *
146+ * Retrieve the first available slot in the @xattrs array to fill with an xattr,
147+ * and increment @xattr_count.
148+ *
149+ * Return: The slot to fill in @xattrs if non-NULL, NULL otherwise.
150+ */
151+ static inline struct xattr * lsm_get_xattr_slot (struct xattr * xattrs ,
152+ int * xattr_count )
153+ {
154+ if (unlikely (!xattrs ))
155+ return NULL ;
156+ return & xattrs [(* xattr_count )++ ];
157+ }
159158
160159#endif /* ! __LINUX_LSM_HOOKS_H */
0 commit comments