2 * Security plug functions
4 * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com>
5 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
6 * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com>
7 * Copyright (C) 2016 Mellanox Technologies
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
15 #include <linux/capability.h>
16 #include <linux/dcache.h>
17 #include <linux/module.h>
18 #include <linux/init.h>
19 #include <linux/kernel.h>
20 #include <linux/lsm_hooks.h>
21 #include <linux/integrity.h>
22 #include <linux/ima.h>
23 #include <linux/evm.h>
24 #include <linux/fsnotify.h>
25 #include <linux/mman.h>
26 #include <linux/mount.h>
27 #include <linux/personality.h>
28 #include <linux/backing-dev.h>
29 #include <linux/string.h>
30 #include <linux/msg.h>
31 #include <linux/prctl.h>
35 #define MAX_LSM_EVM_XATTR 2
37 /* Maximum number of letters for an LSM name string */
38 #define SECURITY_NAME_MAX 10
39 #define SECURITY_CHOSEN_NAMES_MAX (SECURITY_NAME_MAX * LSM_MAX_MAJOR)
40 #define MODULE_STACK "(stacking)"
42 struct security_hook_heads security_hook_heads __lsm_ro_after_init
;
43 static ATOMIC_NOTIFIER_HEAD(lsm_notifier_chain
);
48 * If stacking is enabled the task blob will always
49 * include an indicator of what security module data
50 * should be displayed. This is set with PR_SET_DISPLAY_LSM.
52 static struct lsm_blob_sizes blob_sizes
= {
53 #ifdef CONFIG_SECURITY_STACKING
54 .lbs_task
= SECURITY_NAME_MAX
+ 2,
58 /* Boot-time LSM user choice */
59 static __initdata
char chosen_lsms
[SECURITY_CHOSEN_NAMES_MAX
+ 1] =
60 #ifdef CONFIG_SECURITY_STACKING
63 CONFIG_DEFAULT_SECURITY
;
66 static void __init
do_security_initcalls(void)
69 call
= __security_initcall_start
;
70 while (call
< __security_initcall_end
) {
77 * security_init - initializes the security framework
79 * This should be called early in the kernel initialization sequence.
81 int __init
security_init(void)
84 struct list_head
*list
= (struct list_head
*) &security_hook_heads
;
86 for (i
= 0; i
< sizeof(security_hook_heads
) / sizeof(struct list_head
);
88 INIT_LIST_HEAD(&list
[i
]);
89 pr_info("Security Framework initialized\n");
92 * Load minor LSMs, with the capability module always first.
94 capability_add_hooks();
99 * The first call to a module specific init function
100 * updates the blob size requirements.
102 do_security_initcalls();
105 * The second call to a module specific init function
106 * adds hooks to the hook lists and does any other early
107 * initializations required.
109 do_security_initcalls();
111 #ifdef CONFIG_SECURITY_LSM_DEBUG
112 pr_info("LSM: cred blob size = %d\n", blob_sizes
.lbs_cred
);
113 pr_info("LSM: file blob size = %d\n", blob_sizes
.lbs_file
);
114 pr_info("LSM: inode blob size = %d\n", blob_sizes
.lbs_inode
);
115 pr_info("LSM: ipc blob size = %d\n", blob_sizes
.lbs_ipc
);
117 pr_info("LSM: key blob size = %d\n", blob_sizes
.lbs_key
);
118 #endif /* CONFIG_KEYS */
119 pr_info("LSM: msg_msg blob size = %d\n", blob_sizes
.lbs_msg_msg
);
120 pr_info("LSM: sock blob size = %d\n", blob_sizes
.lbs_sock
);
121 pr_info("LSM: superblock blob size = %d\n", blob_sizes
.lbs_superblock
);
122 pr_info("LSM: task blob size = %d\n", blob_sizes
.lbs_task
);
123 #endif /* CONFIG_SECURITY_LSM_DEBUG */
128 /* Save user chosen LSM */
129 static int __init
choose_lsm(char *str
)
131 strncpy(chosen_lsms
, str
, SECURITY_CHOSEN_NAMES_MAX
);
132 pr_info("LSM: command line set '%s' security module(s).\n",
136 __setup("security=", choose_lsm
);
138 static bool match_last_lsm(const char *list
, const char *lsm
)
142 if (WARN_ON(!list
|| !lsm
))
144 last
= strrchr(list
, ',');
146 /* Pass the comma, strcmp() will check for '\0' */
150 return !strcmp(last
, lsm
);
153 static int lsm_append(char *new, char **result
)
157 if (*result
== NULL
) {
158 *result
= kstrdup(new, GFP_KERNEL
);
160 /* Check if it is the last registered name */
161 if (match_last_lsm(*result
, new))
163 cp
= kasprintf(GFP_KERNEL
, "%s,%s", *result
, new);
173 * security_module_enable - Load given security module on boot ?
174 * @module: the name of the module
175 * @stacked: indicates that the module wants to be stacked
177 * Each LSM must pass this method before registering its own operations
178 * to avoid security registration races. This method may also be used
179 * to check if your LSM is currently loaded during kernel initialization.
185 * - The passed LSM is the one chosen by user at boot time,
186 * - or the passed LSM is configured as the default and the user did not
187 * choose an alternate LSM at boot time.
189 * Otherwise, return false.
191 #ifdef CONFIG_SECURITY_STACKING
192 static bool __init
cmp_lsms(const char *lsm
)
194 const char *str
= chosen_lsms
;
196 int len
= strlen(lsm
);
198 if (len
> SECURITY_NAME_MAX
) {
199 pr_info("LSM: security module name '%s' exceeds limit\n", lsm
);
202 for (split
= strchr(str
, ','); split
; split
= strchr(str
, ',')) {
203 if ((len
== split
- str
) && !strncmp(lsm
, str
, split
- str
))
207 if ((len
== strlen(str
)) && !strncmp(lsm
, str
, strlen(str
)))
213 bool __init
security_module_enable(const char *lsm
, const bool stacked
)
215 #ifdef CONFIG_SECURITY_STACKING
217 * Module defined on the command line security=XXXX
219 if (strcmp(chosen_lsms
, MODULE_STACK
))
220 return cmp_lsms(lsm
);
223 * Module configured as stacked.
227 if (strcmp(lsm
, chosen_lsms
) == 0)
234 * Keep the order of major modules for mapping secids.
236 static int lsm_next_major
;
239 * security_add_hooks - Add a modules hooks to the hook lists.
240 * @hooks: the hooks to add
241 * @count: the number of hooks to add
242 * @lsm: the name of the security module
244 * Each LSM has to register its hooks with the infrastructure.
246 void __init
security_add_hooks(struct security_hook_list
*hooks
, int count
,
250 int lsm_index
= lsm_next_major
++;
252 #ifdef CONFIG_SECURITY_LSM_DEBUG
253 pr_info("LSM: Security module %s gets index %d\n", lsm
, lsm_index
);
255 for (i
= 0; i
< count
; i
++) {
257 hooks
[i
].lsm_index
= lsm_index
;
258 list_add_tail_rcu(&hooks
[i
].list
, hooks
[i
].head
);
260 if (lsm_append(lsm
, &lsm_names
) < 0)
261 panic("%s - Cannot get early memory.\n", __func__
);
264 int call_lsm_notifier(enum lsm_event event
, void *data
)
266 return atomic_notifier_call_chain(&lsm_notifier_chain
, event
, data
);
268 EXPORT_SYMBOL(call_lsm_notifier
);
270 int register_lsm_notifier(struct notifier_block
*nb
)
272 return atomic_notifier_chain_register(&lsm_notifier_chain
, nb
);
274 EXPORT_SYMBOL(register_lsm_notifier
);
276 int unregister_lsm_notifier(struct notifier_block
*nb
)
278 return atomic_notifier_chain_unregister(&lsm_notifier_chain
, nb
);
280 EXPORT_SYMBOL(unregister_lsm_notifier
);
283 * lsm_cred_alloc - allocate a composite cred blob
284 * @cred: the cred that needs a blob
285 * @gfp: allocation type
287 * Allocate the cred blob for all the modules
289 * Returns 0, or -ENOMEM if memory can't be allocated.
291 int lsm_cred_alloc(struct cred
*cred
, gfp_t gfp
)
293 #ifdef CONFIG_SECURITY_LSM_DEBUG
295 pr_info("%s: Inbound cred blob is not NULL.\n", __func__
);
297 if (blob_sizes
.lbs_cred
== 0)
300 cred
->security
= kzalloc(blob_sizes
.lbs_cred
, gfp
);
301 if (cred
->security
== NULL
)
307 * lsm_early_cred - during initialization allocate a composite cred blob
308 * @cred: the cred that needs a blob
310 * Allocate the cred blob for all the modules if it's not already there
312 void lsm_early_cred(struct cred
*cred
)
317 panic("%s: NULL cred.\n", __func__
);
318 if (cred
->security
!= NULL
)
320 rc
= lsm_cred_alloc(cred
, GFP_KERNEL
);
322 panic("%s: Early cred alloc failed.\n", __func__
);
325 static void __init
lsm_set_size(int *need
, int *lbs
)
337 * security_add_blobs - Report blob sizes
338 * @needed: the size of blobs needed by the module
340 * Each LSM has to register its blobs with the infrastructure.
341 * The "needed" data tells the infrastructure how much memory
342 * the module requires for each of its blobs. On return the
343 * structure is filled with the offset that module should use
344 * from the blob pointer.
346 void __init
security_add_blobs(struct lsm_blob_sizes
*needed
)
348 lsm_set_size(&needed
->lbs_cred
, &blob_sizes
.lbs_cred
);
349 lsm_set_size(&needed
->lbs_file
, &blob_sizes
.lbs_file
);
350 lsm_set_size(&needed
->lbs_ipc
, &blob_sizes
.lbs_ipc
);
351 lsm_set_size(&needed
->lbs_key
, &blob_sizes
.lbs_key
);
352 lsm_set_size(&needed
->lbs_msg_msg
, &blob_sizes
.lbs_msg_msg
);
353 lsm_set_size(&needed
->lbs_sock
, &blob_sizes
.lbs_sock
);
354 lsm_set_size(&needed
->lbs_superblock
, &blob_sizes
.lbs_superblock
);
355 lsm_set_size(&needed
->lbs_task
, &blob_sizes
.lbs_task
);
357 * The inode blob gets an rcu_head in addition to
358 * what the modules might need.
360 if (needed
->lbs_inode
&& blob_sizes
.lbs_inode
== 0)
361 blob_sizes
.lbs_inode
= sizeof(struct rcu_head
);
362 lsm_set_size(&needed
->lbs_inode
, &blob_sizes
.lbs_inode
);
366 * lsm_file_alloc - allocate a composite file blob
367 * @file: the file that needs a blob
369 * Allocate the file blob for all the modules
371 * Returns 0, or -ENOMEM if memory can't be allocated.
373 int lsm_file_alloc(struct file
*file
)
375 #ifdef CONFIG_SECURITY_LSM_DEBUG
376 if (file
->f_security
)
377 pr_info("%s: Inbound file blob is not NULL.\n", __func__
);
379 if (blob_sizes
.lbs_file
== 0)
382 file
->f_security
= kzalloc(blob_sizes
.lbs_file
, GFP_KERNEL
);
383 if (file
->f_security
== NULL
)
388 #ifdef CONFIG_SECURITY_STACKING
389 static inline char *lsm_of_task(struct task_struct
*task
)
391 #ifdef CONFIG_SECURITY_LSM_DEBUG
392 if (task
->security
== NULL
)
393 pr_info("%s: task has no lsm name.\n", __func__
);
395 return task
->security
;
399 #ifdef CONFIG_SECURITY_STACKING
406 * lsm_parse_context - break a compound "context" into module data
407 * @cxt: the initial data, which will be modified
408 * @vlist: an array to receive the results
410 * Returns the number of entries, or -EINVAL if the cxt is unworkable.
412 static int lsm_parse_context(char *cxt
, struct lsm_value
*vlist
)
420 for (i
= 0; i
< LSM_MAX_MAJOR
; i
++) {
421 data
= strstr(lsm
, "='");
426 cp
= strchr(data
, '\'');
431 vlist
[i
].data
= data
;
444 #endif /* CONFIG_SECURITY_STACKING */
447 * lsm_task_alloc - allocate a composite task blob
448 * @task: the task that needs a blob
450 * Allocate the task blob for all the modules
452 * Returns 0, or -ENOMEM if memory can't be allocated.
454 int lsm_task_alloc(struct task_struct
*task
)
456 #ifdef CONFIG_SECURITY_LSM_DEBUG
458 pr_info("%s: Inbound task blob is not NULL.\n", __func__
);
460 if (blob_sizes
.lbs_task
== 0)
463 task
->security
= kzalloc(blob_sizes
.lbs_task
, GFP_KERNEL
);
464 if (task
->security
== NULL
)
467 /* inherit current display lsm */
468 #ifdef CONFIG_SECURITY_STACKING
469 if (current
->security
)
470 strcpy(task
->security
, lsm_of_task(current
));
476 * lsm_inode_alloc - allocate a composite inode blob
477 * @inode: the inode that needs a blob
479 * Allocate the inode blob for all the modules
481 * Returns 0, or -ENOMEM if memory can't be allocated.
483 int lsm_inode_alloc(struct inode
*inode
)
485 #ifdef CONFIG_SECURITY_LSM_DEBUG
486 if (inode
->i_security
)
487 pr_info("%s: Inbound inode blob is not NULL.\n", __func__
);
489 if (blob_sizes
.lbs_inode
== 0)
492 inode
->i_security
= kzalloc(blob_sizes
.lbs_inode
, GFP_KERNEL
);
493 if (inode
->i_security
== NULL
)
499 * lsm_early_inode - during initialization allocate a composite inode blob
500 * @inode: the inode that needs a blob
502 * Allocate the inode blob for all the modules if it's not already there
504 void lsm_early_inode(struct inode
*inode
)
509 panic("%s: NULL inode.\n", __func__
);
510 if (inode
->i_security
!= NULL
)
512 rc
= lsm_inode_alloc(inode
);
514 panic("%s: Early inode alloc failed.\n", __func__
);
518 * lsm_ipc_alloc - allocate a composite ipc blob
519 * @kip: the ipc that needs a blob
521 * Allocate the ipc blob for all the modules
523 * Returns 0, or -ENOMEM if memory can't be allocated.
525 int lsm_ipc_alloc(struct kern_ipc_perm
*kip
)
527 #ifdef CONFIG_SECURITY_LSM_DEBUG
529 pr_info("%s: Inbound ipc blob is not NULL.\n", __func__
);
531 if (blob_sizes
.lbs_ipc
== 0)
534 kip
->security
= kzalloc(blob_sizes
.lbs_ipc
, GFP_KERNEL
);
535 if (kip
->security
== NULL
)
542 * lsm_key_alloc - allocate a composite key blob
543 * @key: the key that needs a blob
545 * Allocate the key blob for all the modules
547 * Returns 0, or -ENOMEM if memory can't be allocated.
549 int lsm_key_alloc(struct key
*key
)
551 #ifdef CONFIG_SECURITY_LSM_DEBUG
553 pr_info("%s: Inbound key blob is not NULL.\n", __func__
);
555 if (blob_sizes
.lbs_key
== 0)
558 key
->security
= kzalloc(blob_sizes
.lbs_key
, GFP_KERNEL
);
559 if (key
->security
== NULL
)
563 #endif /* CONFIG_KEYS */
566 * lsm_msg_msg_alloc - allocate a composite msg_msg blob
567 * @mp: the msg_msg that needs a blob
569 * Allocate the ipc blob for all the modules
571 * Returns 0, or -ENOMEM if memory can't be allocated.
573 int lsm_msg_msg_alloc(struct msg_msg
*mp
)
575 #ifdef CONFIG_SECURITY_LSM_DEBUG
577 pr_info("%s: Inbound msg_msg blob is not NULL.\n", __func__
);
579 if (blob_sizes
.lbs_msg_msg
== 0)
582 mp
->security
= kzalloc(blob_sizes
.lbs_msg_msg
, GFP_KERNEL
);
583 if (mp
->security
== NULL
)
589 * lsm_sock_alloc - allocate a composite sock blob
590 * @sock: the sock that needs a blob
591 * @priority: allocation mode
593 * Allocate the sock blob for all the modules
595 * Returns 0, or -ENOMEM if memory can't be allocated.
597 int lsm_sock_alloc(struct sock
*sock
, gfp_t priority
)
599 #ifdef CONFIG_SECURITY_LSM_DEBUG
600 if (sock
->sk_security
)
601 pr_info("%s: Inbound sock blob is not NULL.\n", __func__
);
603 if (blob_sizes
.lbs_sock
== 0)
606 sock
->sk_security
= kzalloc(blob_sizes
.lbs_sock
, priority
);
607 if (sock
->sk_security
== NULL
)
613 * lsm_superblock_alloc - allocate a composite superblock blob
614 * @sb: the superblock that needs a blob
616 * Allocate the superblock blob for all the modules
618 * Returns 0, or -ENOMEM if memory can't be allocated.
620 int lsm_superblock_alloc(struct super_block
*sb
)
622 #ifdef CONFIG_SECURITY_LSM_DEBUG
624 pr_info("%s: Inbound superblock blob is not NULL.\n", __func__
);
626 if (blob_sizes
.lbs_superblock
== 0)
629 sb
->s_security
= kzalloc(blob_sizes
.lbs_superblock
, GFP_KERNEL
);
630 if (sb
->s_security
== NULL
)
636 * Hook list operation macros.
639 * This is a hook that does not return a value.
642 * This is a hook that returns a value.
645 #define call_void_hook(FUNC, ...) \
647 struct security_hook_list *P; \
649 list_for_each_entry(P, &security_hook_heads.FUNC, list) \
650 P->hook.FUNC(__VA_ARGS__); \
653 #define call_int_hook(FUNC, IRC, ...) ({ \
656 struct security_hook_list *P; \
658 list_for_each_entry(P, &security_hook_heads.FUNC, list) { \
659 RC = P->hook.FUNC(__VA_ARGS__); \
667 /* Security operations */
669 int security_binder_set_context_mgr(struct task_struct
*mgr
)
671 return call_int_hook(binder_set_context_mgr
, 0, mgr
);
674 int security_binder_transaction(struct task_struct
*from
,
675 struct task_struct
*to
)
677 return call_int_hook(binder_transaction
, 0, from
, to
);
680 int security_binder_transfer_binder(struct task_struct
*from
,
681 struct task_struct
*to
)
683 return call_int_hook(binder_transfer_binder
, 0, from
, to
);
686 int security_binder_transfer_file(struct task_struct
*from
,
687 struct task_struct
*to
, struct file
*file
)
689 return call_int_hook(binder_transfer_file
, 0, from
, to
, file
);
692 int security_ptrace_access_check(struct task_struct
*child
, unsigned int mode
)
694 return call_int_hook(ptrace_access_check
, 0, child
, mode
);
697 int security_ptrace_traceme(struct task_struct
*parent
)
699 return call_int_hook(ptrace_traceme
, 0, parent
);
702 int security_capget(struct task_struct
*target
,
703 kernel_cap_t
*effective
,
704 kernel_cap_t
*inheritable
,
705 kernel_cap_t
*permitted
)
707 return call_int_hook(capget
, 0, target
,
708 effective
, inheritable
, permitted
);
711 int security_capset(struct cred
*new, const struct cred
*old
,
712 const kernel_cap_t
*effective
,
713 const kernel_cap_t
*inheritable
,
714 const kernel_cap_t
*permitted
)
716 return call_int_hook(capset
, 0, new, old
,
717 effective
, inheritable
, permitted
);
720 int security_capable(const struct cred
*cred
, struct user_namespace
*ns
,
723 return call_int_hook(capable
, 0, cred
, ns
, cap
, SECURITY_CAP_AUDIT
);
726 int security_capable_noaudit(const struct cred
*cred
, struct user_namespace
*ns
,
729 return call_int_hook(capable
, 0, cred
, ns
, cap
, SECURITY_CAP_NOAUDIT
);
732 int security_quotactl(int cmds
, int type
, int id
, struct super_block
*sb
)
734 return call_int_hook(quotactl
, 0, cmds
, type
, id
, sb
);
737 int security_quota_on(struct dentry
*dentry
)
739 return call_int_hook(quota_on
, 0, dentry
);
742 int security_syslog(int type
)
744 return call_int_hook(syslog
, 0, type
);
747 int security_settime64(const struct timespec64
*ts
, const struct timezone
*tz
)
749 return call_int_hook(settime
, 0, ts
, tz
);
752 int security_vm_enough_memory_mm(struct mm_struct
*mm
, long pages
)
754 struct security_hook_list
*hp
;
755 int cap_sys_admin
= 1;
759 * The module will respond with a positive value if
760 * it thinks the __vm_enough_memory() call should be
761 * made with the cap_sys_admin set. If all of the modules
762 * agree that it should be set it will. If any module
763 * thinks it should not be set it won't.
765 list_for_each_entry(hp
, &security_hook_heads
.vm_enough_memory
, list
) {
766 rc
= hp
->hook
.vm_enough_memory(mm
, pages
);
772 return __vm_enough_memory(mm
, pages
, cap_sys_admin
);
775 int security_bprm_set_creds(struct linux_binprm
*bprm
)
777 return call_int_hook(bprm_set_creds
, 0, bprm
);
780 int security_bprm_check(struct linux_binprm
*bprm
)
784 ret
= call_int_hook(bprm_check_security
, 0, bprm
);
787 return ima_bprm_check(bprm
);
790 void security_bprm_committing_creds(struct linux_binprm
*bprm
)
792 call_void_hook(bprm_committing_creds
, bprm
);
795 void security_bprm_committed_creds(struct linux_binprm
*bprm
)
797 call_void_hook(bprm_committed_creds
, bprm
);
800 int security_bprm_secureexec(struct linux_binprm
*bprm
)
802 return call_int_hook(bprm_secureexec
, 0, bprm
);
805 int security_sb_alloc(struct super_block
*sb
)
807 int rc
= lsm_superblock_alloc(sb
);
811 return call_int_hook(sb_alloc_security
, 0, sb
);
814 void security_sb_free(struct super_block
*sb
)
816 call_void_hook(sb_free_security
, sb
);
817 kfree(sb
->s_security
);
818 sb
->s_security
= NULL
;
821 int security_sb_copy_data(char *orig
, char *copy
)
823 return call_int_hook(sb_copy_data
, 0, orig
, copy
);
825 EXPORT_SYMBOL(security_sb_copy_data
);
827 int security_sb_remount(struct super_block
*sb
, void *data
)
829 return call_int_hook(sb_remount
, 0, sb
, data
);
832 int security_sb_kern_mount(struct super_block
*sb
, int flags
, void *data
)
834 return call_int_hook(sb_kern_mount
, 0, sb
, flags
, data
);
837 int security_sb_show_options(struct seq_file
*m
, struct super_block
*sb
)
839 return call_int_hook(sb_show_options
, 0, m
, sb
);
842 int security_sb_statfs(struct dentry
*dentry
)
844 return call_int_hook(sb_statfs
, 0, dentry
);
847 int security_sb_mount(const char *dev_name
, const struct path
*path
,
848 const char *type
, unsigned long flags
, void *data
)
850 return call_int_hook(sb_mount
, 0, dev_name
, path
, type
, flags
, data
);
853 int security_sb_umount(struct vfsmount
*mnt
, int flags
)
855 return call_int_hook(sb_umount
, 0, mnt
, flags
);
858 int security_sb_pivotroot(const struct path
*old_path
, const struct path
*new_path
)
860 return call_int_hook(sb_pivotroot
, 0, old_path
, new_path
);
863 int security_sb_set_mnt_opts(struct super_block
*sb
,
864 struct security_mnt_opts
*opts
,
865 unsigned long kern_flags
,
866 unsigned long *set_kern_flags
)
868 return call_int_hook(sb_set_mnt_opts
,
869 opts
->num_mnt_opts
? -EOPNOTSUPP
: 0, sb
,
870 opts
, kern_flags
, set_kern_flags
);
872 EXPORT_SYMBOL(security_sb_set_mnt_opts
);
874 int security_sb_clone_mnt_opts(const struct super_block
*oldsb
,
875 struct super_block
*newsb
,
876 unsigned long kern_flags
,
877 unsigned long *set_kern_flags
)
879 return call_int_hook(sb_clone_mnt_opts
, 0, oldsb
, newsb
,
880 kern_flags
, set_kern_flags
);
882 EXPORT_SYMBOL(security_sb_clone_mnt_opts
);
884 int security_sb_parse_opts_str(char *options
, struct security_mnt_opts
*opts
)
886 return call_int_hook(sb_parse_opts_str
, 0, options
, opts
);
888 EXPORT_SYMBOL(security_sb_parse_opts_str
);
890 int security_inode_alloc(struct inode
*inode
)
892 int rc
= lsm_inode_alloc(inode
);
896 return call_int_hook(inode_alloc_security
, 0, inode
);
899 static void inode_free_by_rcu(struct rcu_head
*head
)
902 * The rcu head is at the start of the inode blob
907 void security_inode_free(struct inode
*inode
)
909 integrity_inode_free(inode
);
910 call_void_hook(inode_free_security
, inode
);
912 * The inode may still be referenced in a path walk and
913 * a call to security_inode_permission() can be made
914 * after inode_free_security() is called. Ideally, the VFS
915 * wouldn't do this, but fixing that is a much harder
916 * job. For now, simply free the i_security via RCU, and
917 * leave the current inode->i_security pointer intact.
918 * The inode will be freed after the RCU grace period too.
920 if (inode
->i_security
!= NULL
) {
921 call_rcu((struct rcu_head
*)inode
->i_security
,
923 inode
->i_security
= NULL
;
927 int security_dentry_init_security(struct dentry
*dentry
, int mode
,
928 const struct qstr
*name
, void **ctx
,
931 return call_int_hook(dentry_init_security
, -EOPNOTSUPP
, dentry
, mode
,
934 EXPORT_SYMBOL(security_dentry_init_security
);
936 int security_dentry_create_files_as(struct dentry
*dentry
, int mode
,
938 const struct cred
*old
, struct cred
*new)
940 return call_int_hook(dentry_create_files_as
, 0, dentry
, mode
,
943 EXPORT_SYMBOL(security_dentry_create_files_as
);
945 int security_inode_init_security(struct inode
*inode
, struct inode
*dir
,
946 const struct qstr
*qstr
,
947 const initxattrs initxattrs
, void *fs_data
)
949 struct xattr new_xattrs
[MAX_LSM_EVM_XATTR
+ 1];
950 struct xattr
*lsm_xattr
, *evm_xattr
, *xattr
;
953 if (unlikely(IS_PRIVATE(inode
)))
957 return call_int_hook(inode_init_security
, -EOPNOTSUPP
, inode
,
958 dir
, qstr
, NULL
, NULL
, NULL
);
959 memset(new_xattrs
, 0, sizeof(new_xattrs
));
960 lsm_xattr
= new_xattrs
;
961 ret
= call_int_hook(inode_init_security
, -EOPNOTSUPP
, inode
, dir
, qstr
,
964 &lsm_xattr
->value_len
);
968 evm_xattr
= lsm_xattr
+ 1;
969 ret
= evm_inode_init_security(inode
, lsm_xattr
, evm_xattr
);
972 ret
= initxattrs(inode
, new_xattrs
, fs_data
);
974 for (xattr
= new_xattrs
; xattr
->value
!= NULL
; xattr
++)
976 return (ret
== -EOPNOTSUPP
) ? 0 : ret
;
978 EXPORT_SYMBOL(security_inode_init_security
);
980 int security_old_inode_init_security(struct inode
*inode
, struct inode
*dir
,
981 const struct qstr
*qstr
, const char **name
,
982 void **value
, size_t *len
)
984 if (unlikely(IS_PRIVATE(inode
)))
986 return call_int_hook(inode_init_security
, -EOPNOTSUPP
, inode
, dir
,
987 qstr
, name
, value
, len
);
989 EXPORT_SYMBOL(security_old_inode_init_security
);
991 #ifdef CONFIG_SECURITY_PATH
992 int security_path_mknod(const struct path
*dir
, struct dentry
*dentry
, umode_t mode
,
995 if (unlikely(IS_PRIVATE(d_backing_inode(dir
->dentry
))))
997 return call_int_hook(path_mknod
, 0, dir
, dentry
, mode
, dev
);
999 EXPORT_SYMBOL(security_path_mknod
);
1001 int security_path_mkdir(const struct path
*dir
, struct dentry
*dentry
, umode_t mode
)
1003 if (unlikely(IS_PRIVATE(d_backing_inode(dir
->dentry
))))
1005 return call_int_hook(path_mkdir
, 0, dir
, dentry
, mode
);
1007 EXPORT_SYMBOL(security_path_mkdir
);
1009 int security_path_rmdir(const struct path
*dir
, struct dentry
*dentry
)
1011 if (unlikely(IS_PRIVATE(d_backing_inode(dir
->dentry
))))
1013 return call_int_hook(path_rmdir
, 0, dir
, dentry
);
1015 EXPORT_SYMBOL_GPL(security_path_rmdir
);
1017 int security_path_unlink(const struct path
*dir
, struct dentry
*dentry
)
1019 if (unlikely(IS_PRIVATE(d_backing_inode(dir
->dentry
))))
1021 return call_int_hook(path_unlink
, 0, dir
, dentry
);
1023 EXPORT_SYMBOL(security_path_unlink
);
1025 int security_path_symlink(const struct path
*dir
, struct dentry
*dentry
,
1026 const char *old_name
)
1028 if (unlikely(IS_PRIVATE(d_backing_inode(dir
->dentry
))))
1030 return call_int_hook(path_symlink
, 0, dir
, dentry
, old_name
);
1032 EXPORT_SYMBOL_GPL(security_path_symlink
);
1034 int security_path_link(struct dentry
*old_dentry
, const struct path
*new_dir
,
1035 struct dentry
*new_dentry
)
1037 if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry
))))
1039 return call_int_hook(path_link
, 0, old_dentry
, new_dir
, new_dentry
);
1041 EXPORT_SYMBOL_GPL(security_path_link
);
1043 int security_path_rename(const struct path
*old_dir
, struct dentry
*old_dentry
,
1044 const struct path
*new_dir
, struct dentry
*new_dentry
,
1047 if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry
)) ||
1048 (d_is_positive(new_dentry
) && IS_PRIVATE(d_backing_inode(new_dentry
)))))
1051 if (flags
& RENAME_EXCHANGE
) {
1052 int err
= call_int_hook(path_rename
, 0, new_dir
, new_dentry
,
1053 old_dir
, old_dentry
);
1058 return call_int_hook(path_rename
, 0, old_dir
, old_dentry
, new_dir
,
1061 EXPORT_SYMBOL(security_path_rename
);
1063 int security_path_truncate(const struct path
*path
)
1065 if (unlikely(IS_PRIVATE(d_backing_inode(path
->dentry
))))
1067 return call_int_hook(path_truncate
, 0, path
);
1069 EXPORT_SYMBOL_GPL(security_path_truncate
);
1071 int security_path_chmod(const struct path
*path
, umode_t mode
)
1073 if (unlikely(IS_PRIVATE(d_backing_inode(path
->dentry
))))
1075 return call_int_hook(path_chmod
, 0, path
, mode
);
1077 EXPORT_SYMBOL_GPL(security_path_chmod
);
1079 int security_path_chown(const struct path
*path
, kuid_t uid
, kgid_t gid
)
1081 if (unlikely(IS_PRIVATE(d_backing_inode(path
->dentry
))))
1083 return call_int_hook(path_chown
, 0, path
, uid
, gid
);
1085 EXPORT_SYMBOL_GPL(security_path_chown
);
1087 int security_path_chroot(const struct path
*path
)
1089 return call_int_hook(path_chroot
, 0, path
);
1093 int security_inode_create(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
)
1095 if (unlikely(IS_PRIVATE(dir
)))
1097 return call_int_hook(inode_create
, 0, dir
, dentry
, mode
);
1099 EXPORT_SYMBOL_GPL(security_inode_create
);
1101 int security_inode_link(struct dentry
*old_dentry
, struct inode
*dir
,
1102 struct dentry
*new_dentry
)
1104 if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry
))))
1106 return call_int_hook(inode_link
, 0, old_dentry
, dir
, new_dentry
);
1109 int security_inode_unlink(struct inode
*dir
, struct dentry
*dentry
)
1111 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1113 return call_int_hook(inode_unlink
, 0, dir
, dentry
);
1116 int security_inode_symlink(struct inode
*dir
, struct dentry
*dentry
,
1117 const char *old_name
)
1119 if (unlikely(IS_PRIVATE(dir
)))
1121 return call_int_hook(inode_symlink
, 0, dir
, dentry
, old_name
);
1124 int security_inode_mkdir(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
)
1126 if (unlikely(IS_PRIVATE(dir
)))
1128 return call_int_hook(inode_mkdir
, 0, dir
, dentry
, mode
);
1130 EXPORT_SYMBOL_GPL(security_inode_mkdir
);
1132 int security_inode_rmdir(struct inode
*dir
, struct dentry
*dentry
)
1134 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1136 return call_int_hook(inode_rmdir
, 0, dir
, dentry
);
1139 int security_inode_mknod(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
, dev_t dev
)
1141 if (unlikely(IS_PRIVATE(dir
)))
1143 return call_int_hook(inode_mknod
, 0, dir
, dentry
, mode
, dev
);
1146 int security_inode_rename(struct inode
*old_dir
, struct dentry
*old_dentry
,
1147 struct inode
*new_dir
, struct dentry
*new_dentry
,
1150 if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry
)) ||
1151 (d_is_positive(new_dentry
) && IS_PRIVATE(d_backing_inode(new_dentry
)))))
1154 if (flags
& RENAME_EXCHANGE
) {
1155 int err
= call_int_hook(inode_rename
, 0, new_dir
, new_dentry
,
1156 old_dir
, old_dentry
);
1161 return call_int_hook(inode_rename
, 0, old_dir
, old_dentry
,
1162 new_dir
, new_dentry
);
1165 int security_inode_readlink(struct dentry
*dentry
)
1167 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1169 return call_int_hook(inode_readlink
, 0, dentry
);
1171 EXPORT_SYMBOL_GPL(security_inode_readlink
);
1173 int security_inode_follow_link(struct dentry
*dentry
, struct inode
*inode
,
1176 if (unlikely(IS_PRIVATE(inode
)))
1178 return call_int_hook(inode_follow_link
, 0, dentry
, inode
, rcu
);
1181 int security_inode_permission(struct inode
*inode
, int mask
)
1183 if (unlikely(IS_PRIVATE(inode
)))
1185 return call_int_hook(inode_permission
, 0, inode
, mask
);
1187 EXPORT_SYMBOL_GPL(security_inode_permission
);
1189 int security_inode_setattr(struct dentry
*dentry
, struct iattr
*attr
)
1193 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1195 ret
= call_int_hook(inode_setattr
, 0, dentry
, attr
);
1198 return evm_inode_setattr(dentry
, attr
);
1200 EXPORT_SYMBOL_GPL(security_inode_setattr
);
1202 int security_inode_getattr(const struct path
*path
)
1204 if (unlikely(IS_PRIVATE(d_backing_inode(path
->dentry
))))
1206 return call_int_hook(inode_getattr
, 0, path
);
1209 int security_inode_setxattr(struct dentry
*dentry
, const char *name
,
1210 const void *value
, size_t size
, int flags
)
1214 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1217 * SELinux and Smack integrate the cap call,
1218 * so assume that all LSMs supplying this call do so.
1220 ret
= call_int_hook(inode_setxattr
, 1, dentry
, name
, value
, size
,
1224 ret
= cap_inode_setxattr(dentry
, name
, value
, size
, flags
);
1227 ret
= ima_inode_setxattr(dentry
, name
, value
, size
);
1230 return evm_inode_setxattr(dentry
, name
, value
, size
);
1233 void security_inode_post_setxattr(struct dentry
*dentry
, const char *name
,
1234 const void *value
, size_t size
, int flags
)
1236 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1238 call_void_hook(inode_post_setxattr
, dentry
, name
, value
, size
, flags
);
1239 evm_inode_post_setxattr(dentry
, name
, value
, size
);
1242 int security_inode_getxattr(struct dentry
*dentry
, const char *name
)
1244 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1246 return call_int_hook(inode_getxattr
, 0, dentry
, name
);
1249 int security_inode_listxattr(struct dentry
*dentry
)
1251 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1253 return call_int_hook(inode_listxattr
, 0, dentry
);
1256 int security_inode_removexattr(struct dentry
*dentry
, const char *name
)
1260 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1263 * SELinux and Smack integrate the cap call,
1264 * so assume that all LSMs supplying this call do so.
1266 ret
= call_int_hook(inode_removexattr
, 1, dentry
, name
);
1268 ret
= cap_inode_removexattr(dentry
, name
);
1271 ret
= ima_inode_removexattr(dentry
, name
);
1274 return evm_inode_removexattr(dentry
, name
);
1277 int security_inode_need_killpriv(struct dentry
*dentry
)
1279 return call_int_hook(inode_need_killpriv
, 0, dentry
);
1282 int security_inode_killpriv(struct dentry
*dentry
)
1284 return call_int_hook(inode_killpriv
, 0, dentry
);
1287 int security_inode_getsecurity(struct inode
*inode
, const char *name
, void **buffer
, bool alloc
)
1289 struct security_hook_list
*hp
;
1292 if (unlikely(IS_PRIVATE(inode
)))
1295 * Only one module will provide an attribute with a given name.
1297 list_for_each_entry(hp
, &security_hook_heads
.inode_getsecurity
, list
) {
1298 rc
= hp
->hook
.inode_getsecurity(inode
, name
, buffer
, alloc
);
1299 if (rc
!= -EOPNOTSUPP
)
1305 int security_inode_setsecurity(struct inode
*inode
, const char *name
, const void *value
, size_t size
, int flags
)
1307 struct security_hook_list
*hp
;
1310 if (unlikely(IS_PRIVATE(inode
)))
1313 * Only one module will provide an attribute with a given name.
1315 list_for_each_entry(hp
, &security_hook_heads
.inode_setsecurity
, list
) {
1316 rc
= hp
->hook
.inode_setsecurity(inode
, name
, value
, size
,
1318 if (rc
!= -EOPNOTSUPP
)
1324 int security_inode_listsecurity(struct inode
*inode
, char *buffer
, size_t buffer_size
)
1326 if (unlikely(IS_PRIVATE(inode
)))
1328 return call_int_hook(inode_listsecurity
, 0, inode
, buffer
, buffer_size
);
1330 EXPORT_SYMBOL(security_inode_listsecurity
);
1332 void security_inode_getsecid(struct inode
*inode
, u32
*secid
)
1334 call_void_hook(inode_getsecid
, inode
, secid
);
1337 int security_inode_copy_up(struct dentry
*src
, struct cred
**new)
1339 return call_int_hook(inode_copy_up
, 0, src
, new);
1341 EXPORT_SYMBOL(security_inode_copy_up
);
1343 int security_inode_copy_up_xattr(const char *name
)
1345 return call_int_hook(inode_copy_up_xattr
, -EOPNOTSUPP
, name
);
1347 EXPORT_SYMBOL(security_inode_copy_up_xattr
);
1349 int security_file_permission(struct file
*file
, int mask
)
1353 ret
= call_int_hook(file_permission
, 0, file
, mask
);
1357 return fsnotify_perm(file
, mask
);
1359 EXPORT_SYMBOL_GPL(security_file_permission
);
1361 int security_file_alloc(struct file
*file
)
1363 int rc
= lsm_file_alloc(file
);
1367 return call_int_hook(file_alloc_security
, 0, file
);
1370 void security_file_free(struct file
*file
)
1372 call_void_hook(file_free_security
, file
);
1374 kfree(file
->f_security
);
1375 file
->f_security
= NULL
;
1378 int security_file_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1380 return call_int_hook(file_ioctl
, 0, file
, cmd
, arg
);
1383 static inline unsigned long mmap_prot(struct file
*file
, unsigned long prot
)
1386 * Does we have PROT_READ and does the application expect
1387 * it to imply PROT_EXEC? If not, nothing to talk about...
1389 if ((prot
& (PROT_READ
| PROT_EXEC
)) != PROT_READ
)
1391 if (!(current
->personality
& READ_IMPLIES_EXEC
))
1394 * if that's an anonymous mapping, let it.
1397 return prot
| PROT_EXEC
;
1399 * ditto if it's not on noexec mount, except that on !MMU we need
1400 * NOMMU_MAP_EXEC (== VM_MAYEXEC) in this case
1402 if (!path_noexec(&file
->f_path
)) {
1404 if (file
->f_op
->mmap_capabilities
) {
1405 unsigned caps
= file
->f_op
->mmap_capabilities(file
);
1406 if (!(caps
& NOMMU_MAP_EXEC
))
1410 return prot
| PROT_EXEC
;
1412 /* anything on noexec mount won't get PROT_EXEC */
1416 int security_mmap_file(struct file
*file
, unsigned long prot
,
1417 unsigned long flags
)
1420 ret
= call_int_hook(mmap_file
, 0, file
, prot
,
1421 mmap_prot(file
, prot
), flags
);
1424 return ima_file_mmap(file
, prot
);
1426 EXPORT_SYMBOL_GPL(security_mmap_file
);
1428 int security_mmap_addr(unsigned long addr
)
1430 return call_int_hook(mmap_addr
, 0, addr
);
1433 int security_file_mprotect(struct vm_area_struct
*vma
, unsigned long reqprot
,
1436 return call_int_hook(file_mprotect
, 0, vma
, reqprot
, prot
);
1439 int security_file_lock(struct file
*file
, unsigned int cmd
)
1441 return call_int_hook(file_lock
, 0, file
, cmd
);
1444 int security_file_fcntl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1446 return call_int_hook(file_fcntl
, 0, file
, cmd
, arg
);
1449 void security_file_set_fowner(struct file
*file
)
1451 call_void_hook(file_set_fowner
, file
);
1454 int security_file_send_sigiotask(struct task_struct
*tsk
,
1455 struct fown_struct
*fown
, int sig
)
1457 return call_int_hook(file_send_sigiotask
, 0, tsk
, fown
, sig
);
1460 int security_file_receive(struct file
*file
)
1462 return call_int_hook(file_receive
, 0, file
);
1465 int security_file_open(struct file
*file
, const struct cred
*cred
)
1469 ret
= call_int_hook(file_open
, 0, file
, cred
);
1473 return fsnotify_perm(file
, MAY_OPEN
);
1476 int security_task_create(unsigned long clone_flags
)
1478 return call_int_hook(task_create
, 0, clone_flags
);
1481 int security_task_alloc(struct task_struct
*task
, unsigned long clone_flags
)
1483 int rc
= lsm_task_alloc(task
);
1487 return call_int_hook(task_alloc
, 0, task
, clone_flags
);
1490 void security_task_free(struct task_struct
*task
)
1492 call_void_hook(task_free
, task
);
1494 kfree(task
->security
);
1495 task
->security
= NULL
;
1498 int security_cred_alloc_blank(struct cred
*cred
, gfp_t gfp
)
1500 int rc
= lsm_cred_alloc(cred
, gfp
);
1505 return call_int_hook(cred_alloc_blank
, 0, cred
, gfp
);
1508 void security_cred_free(struct cred
*cred
)
1510 call_void_hook(cred_free
, cred
);
1512 kfree(cred
->security
);
1513 cred
->security
= NULL
;
1516 int security_prepare_creds(struct cred
*new, const struct cred
*old
, gfp_t gfp
)
1518 int rc
= lsm_cred_alloc(new, gfp
);
1523 return call_int_hook(cred_prepare
, 0, new, old
, gfp
);
1526 void security_transfer_creds(struct cred
*new, const struct cred
*old
)
1528 call_void_hook(cred_transfer
, new, old
);
1531 int security_kernel_act_as(struct cred
*new, u32 secid
)
1533 return call_int_hook(kernel_act_as
, 0, new, secid
);
1536 int security_kernel_create_files_as(struct cred
*new, struct inode
*inode
)
1538 return call_int_hook(kernel_create_files_as
, 0, new, inode
);
1541 int security_kernel_module_request(char *kmod_name
)
1543 return call_int_hook(kernel_module_request
, 0, kmod_name
);
1546 int security_kernel_read_file(struct file
*file
, enum kernel_read_file_id id
)
1550 ret
= call_int_hook(kernel_read_file
, 0, file
, id
);
1553 return ima_read_file(file
, id
);
1555 EXPORT_SYMBOL_GPL(security_kernel_read_file
);
1557 int security_kernel_post_read_file(struct file
*file
, char *buf
, loff_t size
,
1558 enum kernel_read_file_id id
)
1562 ret
= call_int_hook(kernel_post_read_file
, 0, file
, buf
, size
, id
);
1565 return ima_post_read_file(file
, buf
, size
, id
);
1567 EXPORT_SYMBOL_GPL(security_kernel_post_read_file
);
1569 int security_task_fix_setuid(struct cred
*new, const struct cred
*old
,
1572 return call_int_hook(task_fix_setuid
, 0, new, old
, flags
);
1575 int security_task_setpgid(struct task_struct
*p
, pid_t pgid
)
1577 return call_int_hook(task_setpgid
, 0, p
, pgid
);
1580 int security_task_getpgid(struct task_struct
*p
)
1582 return call_int_hook(task_getpgid
, 0, p
);
1585 int security_task_getsid(struct task_struct
*p
)
1587 return call_int_hook(task_getsid
, 0, p
);
1590 void security_task_getsecid(struct task_struct
*p
, u32
*secid
)
1593 call_void_hook(task_getsecid
, p
, secid
);
1595 EXPORT_SYMBOL(security_task_getsecid
);
1597 int security_task_setnice(struct task_struct
*p
, int nice
)
1599 return call_int_hook(task_setnice
, 0, p
, nice
);
1602 int security_task_setioprio(struct task_struct
*p
, int ioprio
)
1604 return call_int_hook(task_setioprio
, 0, p
, ioprio
);
1607 int security_task_getioprio(struct task_struct
*p
)
1609 return call_int_hook(task_getioprio
, 0, p
);
1612 int security_task_prlimit(const struct cred
*cred
, const struct cred
*tcred
,
1615 return call_int_hook(task_prlimit
, 0, cred
, tcred
, flags
);
1618 int security_task_setrlimit(struct task_struct
*p
, unsigned int resource
,
1619 struct rlimit
*new_rlim
)
1621 return call_int_hook(task_setrlimit
, 0, p
, resource
, new_rlim
);
1624 int security_task_setscheduler(struct task_struct
*p
)
1626 return call_int_hook(task_setscheduler
, 0, p
);
1629 int security_task_getscheduler(struct task_struct
*p
)
1631 return call_int_hook(task_getscheduler
, 0, p
);
1634 int security_task_movememory(struct task_struct
*p
)
1636 return call_int_hook(task_movememory
, 0, p
);
1639 int security_task_kill(struct task_struct
*p
, struct siginfo
*info
,
1642 return call_int_hook(task_kill
, 0, p
, info
, sig
, secid
);
1645 #ifdef CONFIG_SECURITY_STACKING
1646 static char *nolsm
= "-default";
1649 static int lsm_task_prctl(int option
, unsigned long arg2
, unsigned long arg3
,
1650 unsigned long arg4
, unsigned long arg5
)
1652 char *lsm
= lsm_of_task(current
);
1653 char buffer
[SECURITY_NAME_MAX
+ 1];
1654 __user
char *optval
= (__user
char *)arg2
;
1655 __user
int *optlen
= (__user
int *)arg3
;
1656 struct security_hook_list
*hp
;
1661 case PR_GET_DISPLAY_LSM
:
1663 if (lsm
[0] == '\0') {
1667 dlen
= strlen(lsm
) + 1;
1670 if (copy_to_user(optval
, lsm
, dlen
))
1672 if (put_user(dlen
, optlen
))
1675 case PR_SET_DISPLAY_LSM
:
1677 if (len
> SECURITY_NAME_MAX
)
1679 if (copy_from_user(buffer
, optval
, len
))
1682 /* verify the requested LSM is registered */
1683 list_for_each_entry(hp
, &security_hook_heads
.getprocattr
, list
) {
1684 if (!strcmp(buffer
, hp
->lsm
)) {
1685 strcpy(lsm
, hp
->lsm
);
1689 if (!strncmp(buffer
, nolsm
, NOLSMLEN
))
1702 int security_task_prctl(int option
, unsigned long arg2
, unsigned long arg3
,
1703 unsigned long arg4
, unsigned long arg5
)
1707 struct security_hook_list
*hp
;
1709 #ifdef CONFIG_SECURITY_STACKING
1710 rc
= lsm_task_prctl(option
, arg2
, arg3
, arg4
, arg5
);
1715 list_for_each_entry(hp
, &security_hook_heads
.task_prctl
, list
) {
1716 thisrc
= hp
->hook
.task_prctl(option
, arg2
, arg3
, arg4
, arg5
);
1717 if (thisrc
!= -ENOSYS
) {
1726 void security_task_to_inode(struct task_struct
*p
, struct inode
*inode
)
1728 call_void_hook(task_to_inode
, p
, inode
);
1731 int security_ipc_permission(struct kern_ipc_perm
*ipcp
, short flag
)
1733 return call_int_hook(ipc_permission
, 0, ipcp
, flag
);
1736 void security_ipc_getsecid(struct kern_ipc_perm
*ipcp
, u32
*secid
)
1739 call_void_hook(ipc_getsecid
, ipcp
, secid
);
1742 int security_msg_msg_alloc(struct msg_msg
*msg
)
1744 int rc
= lsm_msg_msg_alloc(msg
);
1748 return call_int_hook(msg_msg_alloc_security
, 0, msg
);
1751 void security_msg_msg_free(struct msg_msg
*msg
)
1753 call_void_hook(msg_msg_free_security
, msg
);
1754 kfree(msg
->security
);
1755 msg
->security
= NULL
;
1758 int security_msg_queue_alloc(struct msg_queue
*msq
)
1760 int rc
= lsm_ipc_alloc(&msq
->q_perm
);
1764 return call_int_hook(msg_queue_alloc_security
, 0, msq
);
1767 void security_msg_queue_free(struct msg_queue
*msq
)
1769 struct kern_ipc_perm
*kip
= &msq
->q_perm
;
1771 call_void_hook(msg_queue_free_security
, msq
);
1772 kfree(kip
->security
);
1773 kip
->security
= NULL
;
1776 int security_msg_queue_associate(struct msg_queue
*msq
, int msqflg
)
1778 return call_int_hook(msg_queue_associate
, 0, msq
, msqflg
);
1781 int security_msg_queue_msgctl(struct msg_queue
*msq
, int cmd
)
1783 return call_int_hook(msg_queue_msgctl
, 0, msq
, cmd
);
1786 int security_msg_queue_msgsnd(struct msg_queue
*msq
,
1787 struct msg_msg
*msg
, int msqflg
)
1789 return call_int_hook(msg_queue_msgsnd
, 0, msq
, msg
, msqflg
);
1792 int security_msg_queue_msgrcv(struct msg_queue
*msq
, struct msg_msg
*msg
,
1793 struct task_struct
*target
, long type
, int mode
)
1795 return call_int_hook(msg_queue_msgrcv
, 0, msq
, msg
, target
, type
, mode
);
1798 int security_shm_alloc(struct shmid_kernel
*shp
)
1800 int rc
= lsm_ipc_alloc(&shp
->shm_perm
);
1804 return call_int_hook(shm_alloc_security
, 0, shp
);
1807 void security_shm_free(struct shmid_kernel
*shp
)
1809 struct kern_ipc_perm
*kip
= &shp
->shm_perm
;
1811 call_void_hook(shm_free_security
, shp
);
1812 kfree(kip
->security
);
1813 kip
->security
= NULL
;
1816 int security_shm_associate(struct shmid_kernel
*shp
, int shmflg
)
1818 return call_int_hook(shm_associate
, 0, shp
, shmflg
);
1821 int security_shm_shmctl(struct shmid_kernel
*shp
, int cmd
)
1823 return call_int_hook(shm_shmctl
, 0, shp
, cmd
);
1826 int security_shm_shmat(struct shmid_kernel
*shp
, char __user
*shmaddr
, int shmflg
)
1828 return call_int_hook(shm_shmat
, 0, shp
, shmaddr
, shmflg
);
1831 int security_sem_alloc(struct sem_array
*sma
)
1833 int rc
= lsm_ipc_alloc(&sma
->sem_perm
);
1837 return call_int_hook(sem_alloc_security
, 0, sma
);
1840 void security_sem_free(struct sem_array
*sma
)
1842 struct kern_ipc_perm
*kip
= &sma
->sem_perm
;
1844 call_void_hook(sem_free_security
, sma
);
1845 kfree(kip
->security
);
1846 kip
->security
= NULL
;
1849 int security_sem_associate(struct sem_array
*sma
, int semflg
)
1851 return call_int_hook(sem_associate
, 0, sma
, semflg
);
1854 int security_sem_semctl(struct sem_array
*sma
, int cmd
)
1856 return call_int_hook(sem_semctl
, 0, sma
, cmd
);
1859 int security_sem_semop(struct sem_array
*sma
, struct sembuf
*sops
,
1860 unsigned nsops
, int alter
)
1862 return call_int_hook(sem_semop
, 0, sma
, sops
, nsops
, alter
);
1865 void security_d_instantiate(struct dentry
*dentry
, struct inode
*inode
)
1867 if (unlikely(inode
&& IS_PRIVATE(inode
)))
1869 call_void_hook(d_instantiate
, dentry
, inode
);
1871 EXPORT_SYMBOL(security_d_instantiate
);
1873 int security_getprocattr(struct task_struct
*p
, const char *lsm
, char *name
,
1876 #ifdef CONFIG_SECURITY_STACKING
1877 char *speclsm
= lsm_of_task(p
);
1879 struct security_hook_list
*hp
;
1886 * "context" requires work here in addition to what
1887 * the modules provide.
1889 if (strcmp(name
, "context") == 0) {
1892 list_for_each_entry(hp
,
1893 &security_hook_heads
.getprocattr
, list
) {
1894 if (lsm
!= NULL
&& strcmp(lsm
, hp
->lsm
))
1896 trc
= hp
->hook
.getprocattr(p
, "context", &vp
);
1904 if (*value
== NULL
) {
1907 cp
= kasprintf(GFP_KERNEL
, "%s,%s", *value
, vp
);
1919 return strlen(*value
);
1923 list_for_each_entry(hp
, &security_hook_heads
.getprocattr
, list
) {
1924 if (lsm
!= NULL
&& strcmp(lsm
, hp
->lsm
))
1926 #ifdef CONFIG_SECURITY_STACKING
1927 if (!lsm
&& speclsm
&& speclsm
[0] && strcmp(speclsm
, hp
->lsm
))
1930 rc
= hp
->hook
.getprocattr(p
, name
, value
);
1937 int security_setprocattr(const char *lsm
, const char *name
, void *value
,
1940 #ifdef CONFIG_SECURITY_STACKING
1941 char *speclsm
= lsm_of_task(current
);
1942 struct lsm_value
*lsm_value
= NULL
;
1947 struct security_hook_list
*hp
;
1953 * If lsm is NULL look at all the modules to find one
1954 * that processes name. If lsm is not NULL only look at
1957 * "context" is handled directly here.
1959 if (strcmp(name
, "context") == 0) {
1961 temp
= kmemdup(value
, size
+ 1, GFP_KERNEL
);
1966 cp
= strrchr(temp
, '\'');
1971 #ifdef CONFIG_SECURITY_STACKING
1972 lsm_value
= kzalloc(sizeof(*lsm_value
) * LSM_MAX_MAJOR
,
1979 count
= lsm_parse_context(temp
, lsm_value
);
1983 for (count
--; count
>= 0; count
--) {
1984 list_for_each_entry(hp
,
1985 &security_hook_heads
.setprocattr
, list
) {
1987 if (lsm
&& strcmp(lsm
, hp
->lsm
))
1989 if (!strcmp(hp
->lsm
, lsm_value
[count
].lsm
)) {
1990 rc
= hp
->hook
.setprocattr("context",
1991 lsm_value
[count
].data
,
1992 strlen(lsm_value
[count
].data
));
1996 if (rc
< 0 || (lsm
&& rc
>0))
1999 #else /* CONFIG_SECURITY_STACKING */
2000 cp
= strstr(temp
, "='");
2004 tvalue
= strchr(cp
+ 2, '\'');
2007 list_for_each_entry(hp
, &security_hook_heads
.setprocattr
,
2009 if (lsm
== NULL
|| !strcmp(lsm
, hp
->lsm
)) {
2010 rc
= hp
->hook
.setprocattr(name
, tvalue
, size
);
2014 #endif /* CONFIG_SECURITY_STACKING */
2017 #ifdef CONFIG_SECURITY_STACKING
2025 list_for_each_entry(hp
, &security_hook_heads
.setprocattr
, list
) {
2026 if (lsm
&& strcmp(lsm
, hp
->lsm
))
2028 #ifdef CONFIG_SECURITY_STACKING
2029 if (!lsm
&& speclsm
&& speclsm
[0] && strcmp(speclsm
, hp
->lsm
))
2032 rc
= hp
->hook
.setprocattr(name
, value
, size
);
2039 int security_netlink_send(struct sock
*sk
, struct sk_buff
*skb
)
2041 return call_int_hook(netlink_send
, 0, sk
, skb
);
2044 int security_ismaclabel(const char *name
)
2046 return call_int_hook(ismaclabel
, 0, name
);
2048 EXPORT_SYMBOL(security_ismaclabel
);
2050 int security_secid_to_secctx(u32 secid
, char **secdata
, u32
*seclen
)
2052 return call_int_hook(secid_to_secctx
, -EOPNOTSUPP
, secid
, secdata
,
2055 EXPORT_SYMBOL(security_secid_to_secctx
);
2057 int security_secctx_to_secid(const char *secdata
, u32 seclen
, u32
*secid
)
2060 return call_int_hook(secctx_to_secid
, 0, secdata
, seclen
, secid
);
2062 EXPORT_SYMBOL(security_secctx_to_secid
);
2064 void security_release_secctx(char *secdata
, u32 seclen
)
2066 #ifdef CONFIG_SECURITY_STACKING
2067 char *speclsm
= lsm_of_task(current
);
2069 struct security_hook_list
*hp
;
2071 list_for_each_entry(hp
, &security_hook_heads
.release_secctx
, list
) {
2072 #ifdef CONFIG_SECURITY_STACKING
2073 if (speclsm
[0] && strcmp(hp
->lsm
, speclsm
))
2076 hp
->hook
.release_secctx(secdata
, seclen
);
2080 EXPORT_SYMBOL(security_release_secctx
);
2082 void security_inode_invalidate_secctx(struct inode
*inode
)
2084 call_void_hook(inode_invalidate_secctx
, inode
);
2086 EXPORT_SYMBOL(security_inode_invalidate_secctx
);
2088 int security_inode_notifysecctx(struct inode
*inode
, void *ctx
, u32 ctxlen
)
2090 return call_int_hook(inode_notifysecctx
, 0, inode
, ctx
, ctxlen
);
2092 EXPORT_SYMBOL(security_inode_notifysecctx
);
2094 int security_inode_setsecctx(struct dentry
*dentry
, void *ctx
, u32 ctxlen
)
2096 return call_int_hook(inode_setsecctx
, 0, dentry
, ctx
, ctxlen
);
2098 EXPORT_SYMBOL(security_inode_setsecctx
);
2100 int security_inode_getsecctx(struct inode
*inode
, void **ctx
, u32
*ctxlen
)
2102 return call_int_hook(inode_getsecctx
, -EOPNOTSUPP
, inode
, ctx
, ctxlen
);
2104 EXPORT_SYMBOL(security_inode_getsecctx
);
2106 #ifdef CONFIG_SECURITY_NETWORK
2108 int security_unix_stream_connect(struct sock
*sock
, struct sock
*other
, struct sock
*newsk
)
2110 return call_int_hook(unix_stream_connect
, 0, sock
, other
, newsk
);
2112 EXPORT_SYMBOL(security_unix_stream_connect
);
2114 int security_unix_may_send(struct socket
*sock
, struct socket
*other
)
2116 return call_int_hook(unix_may_send
, 0, sock
, other
);
2118 EXPORT_SYMBOL(security_unix_may_send
);
2120 int security_socket_create(int family
, int type
, int protocol
, int kern
)
2122 return call_int_hook(socket_create
, 0, family
, type
, protocol
, kern
);
2125 int security_socket_post_create(struct socket
*sock
, int family
,
2126 int type
, int protocol
, int kern
)
2128 return call_int_hook(socket_post_create
, 0, sock
, family
, type
,
2132 int security_socket_bind(struct socket
*sock
, struct sockaddr
*address
, int addrlen
)
2134 return call_int_hook(socket_bind
, 0, sock
, address
, addrlen
);
2137 int security_socket_connect(struct socket
*sock
, struct sockaddr
*address
, int addrlen
)
2139 return call_int_hook(socket_connect
, 0, sock
, address
, addrlen
);
2142 int security_socket_listen(struct socket
*sock
, int backlog
)
2144 return call_int_hook(socket_listen
, 0, sock
, backlog
);
2147 int security_socket_accept(struct socket
*sock
, struct socket
*newsock
)
2149 return call_int_hook(socket_accept
, 0, sock
, newsock
);
2152 int security_socket_sendmsg(struct socket
*sock
, struct msghdr
*msg
, int size
)
2154 return call_int_hook(socket_sendmsg
, 0, sock
, msg
, size
);
2157 int security_socket_recvmsg(struct socket
*sock
, struct msghdr
*msg
,
2158 int size
, int flags
)
2160 return call_int_hook(socket_recvmsg
, 0, sock
, msg
, size
, flags
);
2163 int security_socket_getsockname(struct socket
*sock
)
2165 return call_int_hook(socket_getsockname
, 0, sock
);
2168 int security_socket_getpeername(struct socket
*sock
)
2170 return call_int_hook(socket_getpeername
, 0, sock
);
2173 int security_socket_getsockopt(struct socket
*sock
, int level
, int optname
)
2175 return call_int_hook(socket_getsockopt
, 0, sock
, level
, optname
);
2178 int security_socket_setsockopt(struct socket
*sock
, int level
, int optname
)
2180 return call_int_hook(socket_setsockopt
, 0, sock
, level
, optname
);
2183 int security_socket_shutdown(struct socket
*sock
, int how
)
2185 return call_int_hook(socket_shutdown
, 0, sock
, how
);
2188 int security_sock_rcv_skb(struct sock
*sk
, struct sk_buff
*skb
)
2190 return call_int_hook(socket_sock_rcv_skb
, 0, sk
, skb
);
2192 EXPORT_SYMBOL(security_sock_rcv_skb
);
2194 int security_socket_getpeersec_stream(struct socket
*sock
, char __user
*optval
,
2195 int __user
*optlen
, unsigned len
)
2197 #ifdef CONFIG_SECURITY_STACKING
2198 struct security_hook_list
*hp
;
2199 char *lsm
= lsm_of_task(current
);
2201 list_for_each_entry(hp
, &security_hook_heads
.socket_getpeersec_stream
,
2203 if (!lsm
|| !lsm
[0] || !strcmp(lsm
, hp
->lsm
))
2204 return hp
->hook
.socket_getpeersec_stream(sock
, optval
,
2207 return -ENOPROTOOPT
;
2209 return call_int_hook(socket_getpeersec_stream
, -ENOPROTOOPT
, sock
,
2210 optval
, optlen
, len
);
2214 int security_socket_getpeersec_dgram(struct socket
*sock
, struct sk_buff
*skb
, u32
*secid
)
2216 return call_int_hook(socket_getpeersec_dgram
, -ENOPROTOOPT
, sock
,
2219 EXPORT_SYMBOL(security_socket_getpeersec_dgram
);
2221 int security_sk_alloc(struct sock
*sk
, int family
, gfp_t priority
)
2223 int rc
= lsm_sock_alloc(sk
, priority
);
2227 return call_int_hook(sk_alloc_security
, 0, sk
, family
, priority
);
2230 void security_sk_free(struct sock
*sk
)
2232 call_void_hook(sk_free_security
, sk
);
2233 kfree(sk
->sk_security
);
2234 sk
->sk_security
= NULL
;
2237 void security_sk_clone(const struct sock
*sk
, struct sock
*newsk
)
2239 call_void_hook(sk_clone_security
, sk
, newsk
);
2241 EXPORT_SYMBOL(security_sk_clone
);
2243 void security_sk_classify_flow(struct sock
*sk
, struct flowi
*fl
)
2245 call_void_hook(sk_getsecid
, sk
, &fl
->flowi_secid
);
2247 EXPORT_SYMBOL(security_sk_classify_flow
);
2249 void security_req_classify_flow(const struct request_sock
*req
, struct flowi
*fl
)
2251 call_void_hook(req_classify_flow
, req
, fl
);
2253 EXPORT_SYMBOL(security_req_classify_flow
);
2255 void security_sock_graft(struct sock
*sk
, struct socket
*parent
)
2257 call_void_hook(sock_graft
, sk
, parent
);
2259 EXPORT_SYMBOL(security_sock_graft
);
2261 int security_inet_conn_request(struct sock
*sk
,
2262 struct sk_buff
*skb
, struct request_sock
*req
)
2264 return call_int_hook(inet_conn_request
, 0, sk
, skb
, req
);
2266 EXPORT_SYMBOL(security_inet_conn_request
);
2268 void security_inet_csk_clone(struct sock
*newsk
,
2269 const struct request_sock
*req
)
2271 call_void_hook(inet_csk_clone
, newsk
, req
);
2274 void security_inet_conn_established(struct sock
*sk
,
2275 struct sk_buff
*skb
)
2277 call_void_hook(inet_conn_established
, sk
, skb
);
2280 int security_secmark_relabel_packet(u32 secid
)
2282 return call_int_hook(secmark_relabel_packet
, 0, secid
);
2284 EXPORT_SYMBOL(security_secmark_relabel_packet
);
2286 void security_secmark_refcount_inc(void)
2288 call_void_hook(secmark_refcount_inc
);
2290 EXPORT_SYMBOL(security_secmark_refcount_inc
);
2292 void security_secmark_refcount_dec(void)
2294 call_void_hook(secmark_refcount_dec
);
2296 EXPORT_SYMBOL(security_secmark_refcount_dec
);
2298 int security_tun_dev_alloc_security(void **security
)
2300 return call_int_hook(tun_dev_alloc_security
, 0, security
);
2302 EXPORT_SYMBOL(security_tun_dev_alloc_security
);
2304 void security_tun_dev_free_security(void *security
)
2306 call_void_hook(tun_dev_free_security
, security
);
2308 EXPORT_SYMBOL(security_tun_dev_free_security
);
2310 int security_tun_dev_create(void)
2312 return call_int_hook(tun_dev_create
, 0);
2314 EXPORT_SYMBOL(security_tun_dev_create
);
2316 int security_tun_dev_attach_queue(void *security
)
2318 return call_int_hook(tun_dev_attach_queue
, 0, security
);
2320 EXPORT_SYMBOL(security_tun_dev_attach_queue
);
2322 int security_tun_dev_attach(struct sock
*sk
, void *security
)
2324 return call_int_hook(tun_dev_attach
, 0, sk
, security
);
2326 EXPORT_SYMBOL(security_tun_dev_attach
);
2328 int security_tun_dev_open(void *security
)
2330 return call_int_hook(tun_dev_open
, 0, security
);
2332 EXPORT_SYMBOL(security_tun_dev_open
);
2334 #endif /* CONFIG_SECURITY_NETWORK */
2336 #ifdef CONFIG_SECURITY_INFINIBAND
2338 int security_ib_pkey_access(void *sec
, u64 subnet_prefix
, u16 pkey
)
2340 return call_int_hook(ib_pkey_access
, 0, sec
, subnet_prefix
, pkey
);
2342 EXPORT_SYMBOL(security_ib_pkey_access
);
2344 int security_ib_endport_manage_subnet(void *sec
, const char *dev_name
, u8 port_num
)
2346 return call_int_hook(ib_endport_manage_subnet
, 0, sec
, dev_name
, port_num
);
2348 EXPORT_SYMBOL(security_ib_endport_manage_subnet
);
2350 int security_ib_alloc_security(void **sec
)
2352 return call_int_hook(ib_alloc_security
, 0, sec
);
2354 EXPORT_SYMBOL(security_ib_alloc_security
);
2356 void security_ib_free_security(void *sec
)
2358 call_void_hook(ib_free_security
, sec
);
2360 EXPORT_SYMBOL(security_ib_free_security
);
2361 #endif /* CONFIG_SECURITY_INFINIBAND */
2363 #ifdef CONFIG_SECURITY_NETWORK_XFRM
2365 int security_xfrm_policy_alloc(struct xfrm_sec_ctx
**ctxp
,
2366 struct xfrm_user_sec_ctx
*sec_ctx
,
2369 return call_int_hook(xfrm_policy_alloc_security
, 0, ctxp
, sec_ctx
, gfp
);
2371 EXPORT_SYMBOL(security_xfrm_policy_alloc
);
2373 int security_xfrm_policy_clone(struct xfrm_sec_ctx
*old_ctx
,
2374 struct xfrm_sec_ctx
**new_ctxp
)
2376 return call_int_hook(xfrm_policy_clone_security
, 0, old_ctx
, new_ctxp
);
2379 void security_xfrm_policy_free(struct xfrm_sec_ctx
*ctx
)
2381 call_void_hook(xfrm_policy_free_security
, ctx
);
2383 EXPORT_SYMBOL(security_xfrm_policy_free
);
2385 int security_xfrm_policy_delete(struct xfrm_sec_ctx
*ctx
)
2387 return call_int_hook(xfrm_policy_delete_security
, 0, ctx
);
2390 int security_xfrm_state_alloc(struct xfrm_state
*x
,
2391 struct xfrm_user_sec_ctx
*sec_ctx
)
2393 return call_int_hook(xfrm_state_alloc
, 0, x
, sec_ctx
);
2395 EXPORT_SYMBOL(security_xfrm_state_alloc
);
2397 int security_xfrm_state_alloc_acquire(struct xfrm_state
*x
,
2398 struct xfrm_sec_ctx
*polsec
, u32 secid
)
2400 return call_int_hook(xfrm_state_alloc_acquire
, 0, x
, polsec
, secid
);
2403 int security_xfrm_state_delete(struct xfrm_state
*x
)
2405 return call_int_hook(xfrm_state_delete_security
, 0, x
);
2407 EXPORT_SYMBOL(security_xfrm_state_delete
);
2409 void security_xfrm_state_free(struct xfrm_state
*x
)
2411 call_void_hook(xfrm_state_free_security
, x
);
2414 int security_xfrm_policy_lookup(struct xfrm_sec_ctx
*ctx
, u32 fl_secid
, u8 dir
)
2416 return call_int_hook(xfrm_policy_lookup
, 0, ctx
, fl_secid
, dir
);
2419 int security_xfrm_state_pol_flow_match(struct xfrm_state
*x
,
2420 struct xfrm_policy
*xp
,
2421 const struct flowi
*fl
)
2423 struct security_hook_list
*hp
;
2427 * Since this function is expected to return 0 or 1, the judgment
2428 * becomes difficult if multiple LSMs supply this call. Fortunately,
2429 * we can use the first LSM's judgment because currently only SELinux
2430 * supplies this call.
2432 * For speed optimization, we explicitly break the loop rather than
2435 list_for_each_entry(hp
, &security_hook_heads
.xfrm_state_pol_flow_match
,
2437 rc
= hp
->hook
.xfrm_state_pol_flow_match(x
, xp
, fl
);
2443 int security_xfrm_decode_session(struct sk_buff
*skb
, u32
*secid
)
2445 return call_int_hook(xfrm_decode_session
, 0, skb
, secid
, 1);
2448 void security_skb_classify_flow(struct sk_buff
*skb
, struct flowi
*fl
)
2450 int rc
= call_int_hook(xfrm_decode_session
, 0, skb
, &fl
->flowi_secid
,
2455 EXPORT_SYMBOL(security_skb_classify_flow
);
2457 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
2461 int security_key_alloc(struct key
*key
, const struct cred
*cred
,
2462 unsigned long flags
)
2464 int rc
= lsm_key_alloc(key
);
2468 return call_int_hook(key_alloc
, 0, key
, cred
, flags
);
2471 void security_key_free(struct key
*key
)
2473 call_void_hook(key_free
, key
);
2474 kfree(key
->security
);
2475 key
->security
= NULL
;
2478 int security_key_permission(key_ref_t key_ref
,
2479 const struct cred
*cred
, unsigned perm
)
2481 return call_int_hook(key_permission
, 0, key_ref
, cred
, perm
);
2484 int security_key_getsecurity(struct key
*key
, char **_buffer
)
2487 return call_int_hook(key_getsecurity
, 0, key
, _buffer
);
2490 #endif /* CONFIG_KEYS */
2494 int security_audit_rule_init(u32 field
, u32 op
, char *rulestr
, void **lsmrule
)
2496 return call_int_hook(audit_rule_init
, 0, field
, op
, rulestr
, lsmrule
);
2499 int security_audit_rule_known(struct audit_krule
*krule
)
2501 return call_int_hook(audit_rule_known
, 0, krule
);
2504 void security_audit_rule_free(void *lsmrule
)
2506 call_void_hook(audit_rule_free
, lsmrule
);
2509 int security_audit_rule_match(u32 secid
, u32 field
, u32 op
, void *lsmrule
,
2510 struct audit_context
*actx
)
2512 return call_int_hook(audit_rule_match
, 0, secid
, field
, op
, lsmrule
,
2515 #endif /* CONFIG_AUDIT */