Skip to content

Commit ca97d93

Browse files
xjamesmorrisJames Morris
authored andcommitted
security: mark LSM hooks as __ro_after_init
Mark all of the registration hooks as __ro_after_init (via the __lsm_ro_after_init macro). Signed-off-by: James Morris <james.l.morris@oracle.com> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Acked-by: Kees Cook <keescook@chromium.org>
1 parent dd0859d commit ca97d93

8 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎security/apparmor/lsm.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
587587
return error;
588588
}
589589

590-
static struct security_hook_list apparmor_hooks[] = {
590+
static struct security_hook_list apparmor_hooks[] __lsm_ro_after_init = {
591591
LSM_HOOK_INIT(ptrace_access_check, apparmor_ptrace_access_check),
592592
LSM_HOOK_INIT(ptrace_traceme, apparmor_ptrace_traceme),
593593
LSM_HOOK_INIT(capget, apparmor_capget),

‎security/commoncap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ int cap_mmap_file(struct file *file, unsigned long reqprot,
10711071

10721072
#ifdef CONFIG_SECURITY
10731073

1074-
struct security_hook_list capability_hooks[] = {
1074+
struct security_hook_list capability_hooks[] __lsm_ro_after_init = {
10751075
LSM_HOOK_INIT(capable, cap_capable),
10761076
LSM_HOOK_INIT(settime, cap_settime),
10771077
LSM_HOOK_INIT(ptrace_access_check, cap_ptrace_access_check),

‎security/loadpin/loadpin.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static int loadpin_read_file(struct file *file, enum kernel_read_file_id id)
174174
return 0;
175175
}
176176

177-
static struct security_hook_list loadpin_hooks[] = {
177+
static struct security_hook_list loadpin_hooks[] __lsm_ro_after_init = {
178178
LSM_HOOK_INIT(sb_free_security, loadpin_sb_free_security),
179179
LSM_HOOK_INIT(kernel_read_file, loadpin_read_file),
180180
};

‎security/security.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1628,7 +1628,7 @@ int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
16281628
}
16291629
#endif /* CONFIG_AUDIT */
16301630

1631-
struct security_hook_heads security_hook_heads = {
1631+
struct security_hook_heads security_hook_heads __lsm_ro_after_init = {
16321632
.binder_set_context_mgr =
16331633
LIST_HEAD_INIT(security_hook_heads.binder_set_context_mgr),
16341634
.binder_transaction =

‎security/selinux/hooks.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6123,7 +6123,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
61236123

61246124
#endif
61256125

6126-
static struct security_hook_list selinux_hooks[] = {
6126+
static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
61276127
LSM_HOOK_INIT(binder_set_context_mgr, selinux_binder_set_context_mgr),
61286128
LSM_HOOK_INIT(binder_transaction, selinux_binder_transaction),
61296129
LSM_HOOK_INIT(binder_transfer_binder, selinux_binder_transfer_binder),

‎security/smack/smack_lsm.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4633,7 +4633,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
46334633
return 0;
46344634
}
46354635

4636-
static struct security_hook_list smack_hooks[] = {
4636+
static struct security_hook_list smack_hooks[] __lsm_ro_after_init = {
46374637
LSM_HOOK_INIT(ptrace_access_check, smack_ptrace_access_check),
46384638
LSM_HOOK_INIT(ptrace_traceme, smack_ptrace_traceme),
46394639
LSM_HOOK_INIT(syslog, smack_syslog),

‎security/tomoyo/tomoyo.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
496496
* tomoyo_security_ops is a "struct security_operations" which is used for
497497
* registering TOMOYO.
498498
*/
499-
static struct security_hook_list tomoyo_hooks[] = {
499+
static struct security_hook_list tomoyo_hooks[] __lsm_ro_after_init = {
500500
LSM_HOOK_INIT(cred_alloc_blank, tomoyo_cred_alloc_blank),
501501
LSM_HOOK_INIT(cred_prepare, tomoyo_cred_prepare),
502502
LSM_HOOK_INIT(cred_transfer, tomoyo_cred_transfer),

‎security/yama/yama_lsm.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
428428
return rc;
429429
}
430430

431-
static struct security_hook_list yama_hooks[] = {
431+
static struct security_hook_list yama_hooks[] __lsm_ro_after_init = {
432432
LSM_HOOK_INIT(ptrace_access_check, yama_ptrace_access_check),
433433
LSM_HOOK_INIT(ptrace_traceme, yama_ptrace_traceme),
434434
LSM_HOOK_INIT(task_prctl, yama_task_prctl),

0 commit comments

Comments
 (0)