Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lsm: cleanup lsm_hooks.h

Some cleanup and style corrections for lsm_hooks.h.

* Drop the lsm_inode_alloc() extern declaration, it is not needed.
* Relocate lsm_get_xattr_slot() and extern variables in the file to
improve grouping of related objects.
* Don't use tabs to needlessly align structure fields.

Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>

+44 -45
+43 -44
include/linux/lsm_hooks.h
··· 51 51 * Contains the information that identifies the LSM. 52 52 */ 53 53 struct lsm_id { 54 - const char *name; 55 - u64 id; 54 + const char *name; 55 + u64 id; 56 56 }; 57 57 58 58 /* ··· 60 60 * For use with generic list macros for common operations. 61 61 */ 62 62 struct 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; 67 67 } __randomize_layout; 68 68 69 69 /* 70 70 * Security blob size or offset data. 71 71 */ 72 72 struct 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; 86 86 }; 87 - 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 87 106 88 /* 107 89 * LSM_RET_VOID is used as the default value in LSM_HOOK definitions for void ··· 99 117 */ 100 118 #define LSM_HOOK_INIT(HEAD, HOOK) \ 101 119 { .head = &security_hook_heads.HEAD, .hook = { .HEAD = HOOK } } 102 - 103 - extern struct security_hook_heads security_hook_heads; 104 - extern char *lsm_names; 105 120 106 121 extern void security_add_hooks(struct security_hook_list *hooks, int count, 107 122 const struct lsm_id *lsmid); ··· 121 142 struct lsm_blob_sizes *blobs; /* Optional: for blob sharing. */ 122 143 }; 123 144 124 - extern struct lsm_info __start_lsm_info[], __end_lsm_info[]; 125 - extern struct lsm_info __start_early_lsm_info[], __end_early_lsm_info[]; 126 - 127 145 #define DEFINE_LSM(lsm) \ 128 146 static struct lsm_info __lsm_##lsm \ 129 147 __used __section(".lsm_info.init") \ ··· 131 155 __used __section(".early_lsm_info.init") \ 132 156 __aligned(sizeof(unsigned long)) 133 157 134 - extern int lsm_inode_alloc(struct inode *inode); 158 + /* DO NOT tamper with these variables outside of the LSM framework */ 159 + extern char *lsm_names; 160 + extern struct security_hook_heads security_hook_heads; 161 + extern struct lsm_static_calls_table static_calls_table __ro_after_init; 162 + extern struct lsm_info __start_lsm_info[], __end_lsm_info[]; 163 + extern struct lsm_info __start_early_lsm_info[], __end_early_lsm_info[]; 164 + 165 + /** 166 + * lsm_get_xattr_slot - Return the next available slot and increment the index 167 + * @xattrs: array storing LSM-provided xattrs 168 + * @xattr_count: number of already stored xattrs (updated) 169 + * 170 + * Retrieve the first available slot in the @xattrs array to fill with an xattr, 171 + * and increment @xattr_count. 172 + * 173 + * Return: The slot to fill in @xattrs if non-NULL, NULL otherwise. 174 + */ 175 + static inline struct xattr *lsm_get_xattr_slot(struct xattr *xattrs, 176 + int *xattr_count) 177 + { 178 + if (unlikely(!xattrs)) 179 + return NULL; 180 + return &xattrs[(*xattr_count)++]; 181 + } 135 182 136 183 #endif /* ! __LINUX_LSM_HOOKS_H */
+1 -1
security/security.c
··· 689 689 * 690 690 * Returns 0, or -ENOMEM if memory can't be allocated. 691 691 */ 692 - int lsm_inode_alloc(struct inode *inode) 692 + static int lsm_inode_alloc(struct inode *inode) 693 693 { 694 694 if (!lsm_inode_cache) { 695 695 inode->i_security = NULL;