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/bpf.h>
16 #include <linux/capability.h>
17 #include <linux/dcache.h>
18 #include <linux/module.h>
19 #include <linux/init.h>
20 #include <linux/kernel.h>
21 #include <linux/lsm_hooks.h>
22 #include <linux/integrity.h>
23 #include <linux/ima.h>
24 #include <linux/evm.h>
25 #include <linux/fsnotify.h>
26 #include <linux/mman.h>
27 #include <linux/mount.h>
28 #include <linux/personality.h>
29 #include <linux/backing-dev.h>
30 #include <linux/string.h>
31 #include <linux/msg.h>
32 #include <linux/prctl.h>
36 #define MAX_LSM_EVM_XATTR 2
38 /* Maximum number of letters for an LSM name string */
39 #define SECURITY_NAME_MAX 10
40 #define SECURITY_CHOSEN_NAMES_MAX (SECURITY_NAME_MAX * LSM_MAX_MAJOR)
41 #define MODULE_STACK "(stacking)"
43 struct security_hook_heads security_hook_heads __lsm_ro_after_init
;
44 static ATOMIC_NOTIFIER_HEAD(lsm_notifier_chain
);
46 static struct kmem_cache
*lsm_file_cache
;
47 static struct kmem_cache
*lsm_inode_cache
;
52 * If stacking is enabled the task blob will always
53 * include an indicator of what security module data
54 * should be displayed. This is set with PR_SET_DISPLAY_LSM.
56 static struct lsm_blob_sizes blob_sizes
= {
57 #ifdef CONFIG_SECURITY_STACKING
58 .lbs_task
= SECURITY_NAME_MAX
+ 6,
62 /* Boot-time LSM user choice */
63 static __initdata
char chosen_lsms
[SECURITY_CHOSEN_NAMES_MAX
+ 1] =
64 #ifdef CONFIG_SECURITY_STACKING
67 CONFIG_DEFAULT_SECURITY
;
69 static __initdata
char chosen_display_lsm
[SECURITY_NAME_MAX
+ 1]
70 #ifdef CONFIG_SECURITY_STACKING
71 = CONFIG_SECURITY_DEFAULT_DISPLAY_NAME
74 static char default_display_lsm
[SECURITY_NAME_MAX
+ 1];
76 static void __init
do_security_initcalls(void)
79 call
= __security_initcall_start
;
80 while (call
< __security_initcall_end
) {
87 * security_init - initializes the security framework
89 * This should be called early in the kernel initialization sequence.
91 int __init
security_init(void)
94 struct list_head
*list
= (struct list_head
*) &security_hook_heads
;
96 for (i
= 0; i
< sizeof(security_hook_heads
) / sizeof(struct list_head
);
98 INIT_LIST_HEAD(&list
[i
]);
99 pr_info("Security Framework initialized\n");
102 * Load minor LSMs, with the capability module always first.
104 capability_add_hooks();
109 * The first call to a module specific init function
110 * updates the blob size requirements.
112 do_security_initcalls();
115 * Create any kmem_caches needed for blobs
117 if (blob_sizes
.lbs_file
)
118 lsm_file_cache
= kmem_cache_create("lsm_file_cache",
119 blob_sizes
.lbs_file
, 0,
121 if (blob_sizes
.lbs_inode
)
122 lsm_inode_cache
= kmem_cache_create("lsm_inode_cache",
123 blob_sizes
.lbs_inode
, 0,
126 * The second call to a module specific init function
127 * adds hooks to the hook lists and does any other early
128 * initializations required.
130 do_security_initcalls();
132 #ifdef CONFIG_SECURITY_LSM_DEBUG
133 pr_info("LSM: cred blob size = %d\n", blob_sizes
.lbs_cred
);
134 pr_info("LSM: file blob size = %d\n", blob_sizes
.lbs_file
);
135 pr_info("LSM: inode blob size = %d\n", blob_sizes
.lbs_inode
);
136 pr_info("LSM: ipc blob size = %d\n", blob_sizes
.lbs_ipc
);
138 pr_info("LSM: key blob size = %d\n", blob_sizes
.lbs_key
);
139 #endif /* CONFIG_KEYS */
140 pr_info("LSM: msg_msg blob size = %d\n", blob_sizes
.lbs_msg_msg
);
141 pr_info("LSM: sock blob size = %d\n", blob_sizes
.lbs_sock
);
142 pr_info("LSM: superblock blob size = %d\n", blob_sizes
.lbs_superblock
);
143 pr_info("LSM: task blob size = %d\n", blob_sizes
.lbs_task
);
144 #endif /* CONFIG_SECURITY_LSM_DEBUG */
149 /* Save user chosen LSM */
150 static int __init
choose_lsm(char *str
)
152 strncpy(chosen_lsms
, str
, SECURITY_CHOSEN_NAMES_MAX
);
153 pr_info("LSM: command line set '%s' security module(s).\n",
157 __setup("security=", choose_lsm
);
159 static int __init
choose_display_lsm(char *str
)
161 strncpy(chosen_display_lsm
, str
, SECURITY_NAME_MAX
);
162 pr_info("LSM: command line set default display lsm %s'\n",
166 __setup("security.display=", choose_display_lsm
);
168 static bool match_last_lsm(const char *list
, const char *lsm
)
172 if (WARN_ON(!list
|| !lsm
))
174 last
= strrchr(list
, ',');
176 /* Pass the comma, strcmp() will check for '\0' */
180 return !strcmp(last
, lsm
);
183 static int lsm_append(char *new, char **result
)
187 if (*result
== NULL
) {
188 *result
= kstrdup(new, GFP_KERNEL
);
190 /* Check if it is the last registered name */
191 if (match_last_lsm(*result
, new))
193 cp
= kasprintf(GFP_KERNEL
, "%s,%s", *result
, new);
203 * security_module_enable - Load given security module on boot ?
204 * @module: the name of the module
205 * @stacked: indicates that the module wants to be stacked
207 * Each LSM must pass this method before registering its own operations
208 * to avoid security registration races. This method may also be used
209 * to check if your LSM is currently loaded during kernel initialization.
215 * - The passed LSM is the one chosen by user at boot time,
216 * - or the passed LSM is configured as the default and the user did not
217 * choose an alternate LSM at boot time.
219 * Otherwise, return false.
221 #ifdef CONFIG_SECURITY_STACKING
222 static bool __init
cmp_lsms(const char *lsm
)
224 const char *str
= chosen_lsms
;
226 int len
= strlen(lsm
);
228 if (len
> SECURITY_NAME_MAX
) {
229 pr_info("LSM: security module name '%s' exceeds limit\n", lsm
);
232 for (split
= strchr(str
, ','); split
; split
= strchr(str
, ',')) {
233 if ((len
== split
- str
) && !strncmp(lsm
, str
, split
- str
))
237 if ((len
== strlen(str
)) && !strncmp(lsm
, str
, strlen(str
)))
243 bool __init
security_module_enable(const char *lsm
, const bool stacked
)
245 #ifdef CONFIG_SECURITY_STACKING
247 * Module defined on the command line security=XXXX
249 if (strcmp(chosen_lsms
, MODULE_STACK
)) {
251 /* set to first LSM registered and then override */
252 if (!*default_display_lsm
)
253 strcpy(default_display_lsm
, lsm
);
254 else if (*chosen_display_lsm
&& !strcmp(chosen_display_lsm
, lsm
)) {
255 strcpy(default_display_lsm
, lsm
);
256 pr_info("LSM: default display lsm '%s'\n", default_display_lsm
);
263 * Module configured as stacked.
265 if (stacked
&& !*default_display_lsm
)
266 strcpy(default_display_lsm
, lsm
);
267 else if (stacked
&& *chosen_display_lsm
&& !strcmp(chosen_display_lsm
, lsm
)) {
268 strcpy(default_display_lsm
, lsm
);
269 pr_info("LSM: default display lsm '%s'\n", default_display_lsm
);
274 if (strcmp(lsm
, chosen_lsms
) == 0) {
275 strcpy(default_display_lsm
, lsm
);
283 * Keep the order of major modules for mapping secids.
285 static int lsm_next_major
;
288 * security_add_hooks - Add a modules hooks to the hook lists.
289 * @hooks: the hooks to add
290 * @count: the number of hooks to add
291 * @lsm: the name of the security module
293 * Each LSM has to register its hooks with the infrastructure.
295 void __init
security_add_hooks(struct security_hook_list
*hooks
, int count
,
299 int lsm_index
= lsm_next_major
++;
301 #ifdef CONFIG_SECURITY_LSM_DEBUG
302 pr_info("LSM: Security module %s gets index %d\n", lsm
, lsm_index
);
304 for (i
= 0; i
< count
; i
++) {
306 hooks
[i
].lsm_index
= lsm_index
;
307 list_add_tail_rcu(&hooks
[i
].list
, hooks
[i
].head
);
309 if (lsm_append(lsm
, &lsm_names
) < 0)
310 panic("%s - Cannot get early memory.\n", __func__
);
313 int call_lsm_notifier(enum lsm_event event
, void *data
)
315 return atomic_notifier_call_chain(&lsm_notifier_chain
, event
, data
);
317 EXPORT_SYMBOL(call_lsm_notifier
);
319 int register_lsm_notifier(struct notifier_block
*nb
)
321 return atomic_notifier_chain_register(&lsm_notifier_chain
, nb
);
323 EXPORT_SYMBOL(register_lsm_notifier
);
325 int unregister_lsm_notifier(struct notifier_block
*nb
)
327 return atomic_notifier_chain_unregister(&lsm_notifier_chain
, nb
);
329 EXPORT_SYMBOL(unregister_lsm_notifier
);
332 * lsm_cred_alloc - allocate a composite cred blob
333 * @cred: the cred that needs a blob
334 * @gfp: allocation type
336 * Allocate the cred blob for all the modules
338 * Returns 0, or -ENOMEM if memory can't be allocated.
340 int lsm_cred_alloc(struct cred
*cred
, gfp_t gfp
)
342 if (blob_sizes
.lbs_cred
== 0) {
343 cred
->security
= NULL
;
347 cred
->security
= kzalloc(blob_sizes
.lbs_cred
, gfp
);
348 if (cred
->security
== NULL
)
354 * lsm_early_cred - during initialization allocate a composite cred blob
355 * @cred: the cred that needs a blob
357 * Allocate the cred blob for all the modules if it's not already there
359 void lsm_early_cred(struct cred
*cred
)
364 panic("%s: NULL cred.\n", __func__
);
365 if (cred
->security
!= NULL
)
367 rc
= lsm_cred_alloc(cred
, GFP_KERNEL
);
369 panic("%s: Early cred alloc failed.\n", __func__
);
372 static void __init
lsm_set_size(int *need
, int *lbs
)
384 * security_add_blobs - Report blob sizes
385 * @needed: the size of blobs needed by the module
387 * Each LSM has to register its blobs with the infrastructure.
388 * The "needed" data tells the infrastructure how much memory
389 * the module requires for each of its blobs. On return the
390 * structure is filled with the offset that module should use
391 * from the blob pointer.
393 void __init
security_add_blobs(struct lsm_blob_sizes
*needed
)
395 lsm_set_size(&needed
->lbs_cred
, &blob_sizes
.lbs_cred
);
396 lsm_set_size(&needed
->lbs_file
, &blob_sizes
.lbs_file
);
397 lsm_set_size(&needed
->lbs_ipc
, &blob_sizes
.lbs_ipc
);
398 lsm_set_size(&needed
->lbs_key
, &blob_sizes
.lbs_key
);
399 lsm_set_size(&needed
->lbs_msg_msg
, &blob_sizes
.lbs_msg_msg
);
400 lsm_set_size(&needed
->lbs_sock
, &blob_sizes
.lbs_sock
);
401 lsm_set_size(&needed
->lbs_superblock
, &blob_sizes
.lbs_superblock
);
402 lsm_set_size(&needed
->lbs_task
, &blob_sizes
.lbs_task
);
404 * The inode blob gets an rcu_head in addition to
405 * what the modules might need.
407 if (needed
->lbs_inode
&& blob_sizes
.lbs_inode
== 0)
408 blob_sizes
.lbs_inode
= sizeof(struct rcu_head
);
409 lsm_set_size(&needed
->lbs_inode
, &blob_sizes
.lbs_inode
);
413 * lsm_file_alloc - allocate a composite file blob
414 * @file: the file that needs a blob
416 * Allocate the file blob for all the modules
418 * Returns 0, or -ENOMEM if memory can't be allocated.
420 int lsm_file_alloc(struct file
*file
)
422 if (!lsm_file_cache
) {
423 file
->f_security
= NULL
;
427 file
->f_security
= kmem_cache_zalloc(lsm_file_cache
, GFP_KERNEL
);
428 if (file
->f_security
== NULL
)
433 #ifdef CONFIG_SECURITY_STACKING
434 static inline char *lsm_of_task(struct task_struct
*task
)
436 #ifdef CONFIG_SECURITY_LSM_DEBUG
437 if (task
->security
== NULL
)
438 pr_info("%s: task has no lsm name.\n", __func__
);
440 return task
->security
;
445 * lsm_task_alloc - allocate a composite task blob
446 * @task: the task that needs a blob
448 * Allocate the task blob for all the modules
450 * Returns 0, or -ENOMEM if memory can't be allocated.
452 int lsm_task_alloc(struct task_struct
*task
)
454 if (blob_sizes
.lbs_task
== 0) {
455 task
->security
= NULL
;
459 task
->security
= kzalloc(blob_sizes
.lbs_task
, GFP_KERNEL
);
460 if (task
->security
== NULL
)
463 /* inherit current display lsm */
464 #ifdef CONFIG_SECURITY_STACKING
465 if (current
->security
)
466 strcpy(task
->security
, lsm_of_task(current
));
468 strcpy(task
->security
, default_display_lsm
);
474 * lsm_inode_alloc - allocate a composite inode blob
475 * @inode: the inode that needs a blob
477 * Allocate the inode blob for all the modules
479 * Returns 0, or -ENOMEM if memory can't be allocated.
481 int lsm_inode_alloc(struct inode
*inode
)
483 if (!lsm_inode_cache
) {
484 inode
->i_security
= NULL
;
488 inode
->i_security
= kmem_cache_zalloc(lsm_inode_cache
, GFP_KERNEL
);
489 if (inode
->i_security
== NULL
)
495 * lsm_early_inode - during initialization allocate a composite inode blob
496 * @inode: the inode that needs a blob
498 * Allocate the inode blob for all the modules if it's not already there
500 void lsm_early_inode(struct inode
*inode
)
505 panic("%s: NULL inode.\n", __func__
);
506 if (inode
->i_security
!= NULL
)
508 rc
= lsm_inode_alloc(inode
);
510 panic("%s: Early inode alloc failed.\n", __func__
);
514 * lsm_ipc_alloc - allocate a composite ipc blob
515 * @kip: the ipc that needs a blob
517 * Allocate the ipc blob for all the modules
519 * Returns 0, or -ENOMEM if memory can't be allocated.
521 int lsm_ipc_alloc(struct kern_ipc_perm
*kip
)
523 if (blob_sizes
.lbs_ipc
== 0) {
524 kip
->security
= NULL
;
528 kip
->security
= kzalloc(blob_sizes
.lbs_ipc
, GFP_KERNEL
);
529 if (kip
->security
== NULL
)
536 * lsm_key_alloc - allocate a composite key blob
537 * @key: the key that needs a blob
539 * Allocate the key blob for all the modules
541 * Returns 0, or -ENOMEM if memory can't be allocated.
543 int lsm_key_alloc(struct key
*key
)
545 if (blob_sizes
.lbs_key
== 0) {
546 key
->security
= NULL
;
550 key
->security
= kzalloc(blob_sizes
.lbs_key
, GFP_KERNEL
);
551 if (key
->security
== NULL
)
555 #endif /* CONFIG_KEYS */
558 * lsm_msg_msg_alloc - allocate a composite msg_msg blob
559 * @mp: the msg_msg that needs a blob
561 * Allocate the ipc blob for all the modules
563 * Returns 0, or -ENOMEM if memory can't be allocated.
565 int lsm_msg_msg_alloc(struct msg_msg
*mp
)
567 if (blob_sizes
.lbs_msg_msg
== 0) {
572 mp
->security
= kzalloc(blob_sizes
.lbs_msg_msg
, GFP_KERNEL
);
573 if (mp
->security
== NULL
)
579 * lsm_sock_alloc - allocate a composite sock blob
580 * @sock: the sock that needs a blob
581 * @priority: allocation mode
583 * Allocate the sock blob for all the modules
585 * Returns 0, or -ENOMEM if memory can't be allocated.
587 int lsm_sock_alloc(struct sock
*sock
, gfp_t priority
)
589 if (blob_sizes
.lbs_sock
== 0) {
590 sock
->sk_security
= NULL
;
594 sock
->sk_security
= kzalloc(blob_sizes
.lbs_sock
, priority
);
595 if (sock
->sk_security
== NULL
)
601 * lsm_superblock_alloc - allocate a composite superblock blob
602 * @sb: the superblock that needs a blob
604 * Allocate the superblock blob for all the modules
606 * Returns 0, or -ENOMEM if memory can't be allocated.
608 int lsm_superblock_alloc(struct super_block
*sb
)
610 if (blob_sizes
.lbs_superblock
== 0) {
611 sb
->s_security
= NULL
;
615 sb
->s_security
= kzalloc(blob_sizes
.lbs_superblock
, GFP_KERNEL
);
616 if (sb
->s_security
== NULL
)
622 * Hook list operation macros.
625 * This is a hook that does not return a value.
628 * This is a hook that returns a value.
631 #define call_void_hook(FUNC, ...) \
633 struct security_hook_list *P; \
635 list_for_each_entry(P, &security_hook_heads.FUNC, list) \
636 P->hook.FUNC(__VA_ARGS__); \
639 #define call_int_hook(FUNC, IRC, ...) ({ \
642 struct security_hook_list *P; \
644 list_for_each_entry(P, &security_hook_heads.FUNC, list) { \
645 RC = P->hook.FUNC(__VA_ARGS__); \
653 /* Security operations */
655 int security_binder_set_context_mgr(struct task_struct
*mgr
)
657 return call_int_hook(binder_set_context_mgr
, 0, mgr
);
660 int security_binder_transaction(struct task_struct
*from
,
661 struct task_struct
*to
)
663 return call_int_hook(binder_transaction
, 0, from
, to
);
666 int security_binder_transfer_binder(struct task_struct
*from
,
667 struct task_struct
*to
)
669 return call_int_hook(binder_transfer_binder
, 0, from
, to
);
672 int security_binder_transfer_file(struct task_struct
*from
,
673 struct task_struct
*to
, struct file
*file
)
675 return call_int_hook(binder_transfer_file
, 0, from
, to
, file
);
678 int security_ptrace_access_check(struct task_struct
*child
, unsigned int mode
)
680 return call_int_hook(ptrace_access_check
, 0, child
, mode
);
683 int security_ptrace_traceme(struct task_struct
*parent
)
685 return call_int_hook(ptrace_traceme
, 0, parent
);
688 int security_capget(struct task_struct
*target
,
689 kernel_cap_t
*effective
,
690 kernel_cap_t
*inheritable
,
691 kernel_cap_t
*permitted
)
693 return call_int_hook(capget
, 0, target
,
694 effective
, inheritable
, permitted
);
697 int security_capset(struct cred
*new, const struct cred
*old
,
698 const kernel_cap_t
*effective
,
699 const kernel_cap_t
*inheritable
,
700 const kernel_cap_t
*permitted
)
702 return call_int_hook(capset
, 0, new, old
,
703 effective
, inheritable
, permitted
);
706 int security_capable(const struct cred
*cred
, struct user_namespace
*ns
,
709 return call_int_hook(capable
, 0, cred
, ns
, cap
, SECURITY_CAP_AUDIT
);
712 int security_capable_noaudit(const struct cred
*cred
, struct user_namespace
*ns
,
715 return call_int_hook(capable
, 0, cred
, ns
, cap
, SECURITY_CAP_NOAUDIT
);
718 int security_quotactl(int cmds
, int type
, int id
, struct super_block
*sb
)
720 return call_int_hook(quotactl
, 0, cmds
, type
, id
, sb
);
723 int security_quota_on(struct dentry
*dentry
)
725 return call_int_hook(quota_on
, 0, dentry
);
728 int security_syslog(int type
)
730 return call_int_hook(syslog
, 0, type
);
733 int security_settime64(const struct timespec64
*ts
, const struct timezone
*tz
)
735 return call_int_hook(settime
, 0, ts
, tz
);
738 int security_vm_enough_memory_mm(struct mm_struct
*mm
, long pages
)
740 struct security_hook_list
*hp
;
741 int cap_sys_admin
= 1;
745 * The module will respond with a positive value if
746 * it thinks the __vm_enough_memory() call should be
747 * made with the cap_sys_admin set. If all of the modules
748 * agree that it should be set it will. If any module
749 * thinks it should not be set it won't.
751 list_for_each_entry(hp
, &security_hook_heads
.vm_enough_memory
, list
) {
752 rc
= hp
->hook
.vm_enough_memory(mm
, pages
);
758 return __vm_enough_memory(mm
, pages
, cap_sys_admin
);
761 int security_bprm_set_creds(struct linux_binprm
*bprm
)
763 return call_int_hook(bprm_set_creds
, 0, bprm
);
766 int security_bprm_check(struct linux_binprm
*bprm
)
770 ret
= call_int_hook(bprm_check_security
, 0, bprm
);
773 return ima_bprm_check(bprm
);
776 void security_bprm_committing_creds(struct linux_binprm
*bprm
)
778 call_void_hook(bprm_committing_creds
, bprm
);
781 void security_bprm_committed_creds(struct linux_binprm
*bprm
)
783 call_void_hook(bprm_committed_creds
, bprm
);
786 int security_sb_alloc(struct super_block
*sb
)
788 int rc
= lsm_superblock_alloc(sb
);
792 rc
= call_int_hook(sb_alloc_security
, 0, sb
);
794 security_sb_free(sb
);
798 void security_sb_free(struct super_block
*sb
)
800 call_void_hook(sb_free_security
, sb
);
801 kfree(sb
->s_security
);
802 sb
->s_security
= NULL
;
805 int security_sb_copy_data(char *orig
, char *copy
)
807 return call_int_hook(sb_copy_data
, 0, orig
, copy
);
809 EXPORT_SYMBOL(security_sb_copy_data
);
811 int security_sb_remount(struct super_block
*sb
, void *data
)
813 return call_int_hook(sb_remount
, 0, sb
, data
);
816 int security_sb_kern_mount(struct super_block
*sb
, int flags
, void *data
)
818 return call_int_hook(sb_kern_mount
, 0, sb
, flags
, data
);
821 int security_sb_show_options(struct seq_file
*m
, struct super_block
*sb
)
823 return call_int_hook(sb_show_options
, 0, m
, sb
);
826 int security_sb_statfs(struct dentry
*dentry
)
828 return call_int_hook(sb_statfs
, 0, dentry
);
831 int security_sb_mount(const char *dev_name
, const struct path
*path
,
832 const char *type
, unsigned long flags
, void *data
)
834 return call_int_hook(sb_mount
, 0, dev_name
, path
, type
, flags
, data
);
837 int security_sb_umount(struct vfsmount
*mnt
, int flags
)
839 return call_int_hook(sb_umount
, 0, mnt
, flags
);
842 int security_sb_pivotroot(const struct path
*old_path
, const struct path
*new_path
)
844 return call_int_hook(sb_pivotroot
, 0, old_path
, new_path
);
847 int security_sb_set_mnt_opts(struct super_block
*sb
,
848 struct security_mnt_opts
*opts
,
849 unsigned long kern_flags
,
850 unsigned long *set_kern_flags
)
852 return call_int_hook(sb_set_mnt_opts
,
853 opts
->num_mnt_opts
? -EOPNOTSUPP
: 0, sb
,
854 opts
, kern_flags
, set_kern_flags
);
856 EXPORT_SYMBOL(security_sb_set_mnt_opts
);
858 int security_sb_clone_mnt_opts(const struct super_block
*oldsb
,
859 struct super_block
*newsb
,
860 unsigned long kern_flags
,
861 unsigned long *set_kern_flags
)
863 return call_int_hook(sb_clone_mnt_opts
, 0, oldsb
, newsb
,
864 kern_flags
, set_kern_flags
);
866 EXPORT_SYMBOL(security_sb_clone_mnt_opts
);
868 int security_sb_parse_opts_str(char *options
, struct security_mnt_opts
*opts
)
870 return call_int_hook(sb_parse_opts_str
, 0, options
, opts
);
872 EXPORT_SYMBOL(security_sb_parse_opts_str
);
874 int security_inode_alloc(struct inode
*inode
)
876 int rc
= lsm_inode_alloc(inode
);
880 rc
= call_int_hook(inode_alloc_security
, 0, inode
);
882 security_inode_free(inode
);
886 static void inode_free_by_rcu(struct rcu_head
*head
)
889 * The rcu head is at the start of the inode blob
891 kmem_cache_free(lsm_inode_cache
, head
);
894 void security_inode_free(struct inode
*inode
)
896 integrity_inode_free(inode
);
897 call_void_hook(inode_free_security
, inode
);
899 * The inode may still be referenced in a path walk and
900 * a call to security_inode_permission() can be made
901 * after inode_free_security() is called. Ideally, the VFS
902 * wouldn't do this, but fixing that is a much harder
903 * job. For now, simply free the i_security via RCU, and
904 * leave the current inode->i_security pointer intact.
905 * The inode will be freed after the RCU grace period too.
907 if (inode
->i_security
)
908 call_rcu((struct rcu_head
*)inode
->i_security
,
912 int security_dentry_init_security(struct dentry
*dentry
, int mode
,
913 const struct qstr
*name
, void **ctx
,
916 return call_int_hook(dentry_init_security
, -EOPNOTSUPP
, dentry
, mode
,
919 EXPORT_SYMBOL(security_dentry_init_security
);
921 int security_dentry_create_files_as(struct dentry
*dentry
, int mode
,
923 const struct cred
*old
, struct cred
*new)
925 return call_int_hook(dentry_create_files_as
, 0, dentry
, mode
,
928 EXPORT_SYMBOL(security_dentry_create_files_as
);
930 int security_inode_init_security(struct inode
*inode
, struct inode
*dir
,
931 const struct qstr
*qstr
,
932 const initxattrs initxattrs
, void *fs_data
)
934 struct xattr new_xattrs
[MAX_LSM_EVM_XATTR
+ 1];
935 struct xattr
*lsm_xattr
, *evm_xattr
, *xattr
;
938 if (unlikely(IS_PRIVATE(inode
)))
942 return call_int_hook(inode_init_security
, -EOPNOTSUPP
, inode
,
943 dir
, qstr
, NULL
, NULL
, NULL
);
944 memset(new_xattrs
, 0, sizeof(new_xattrs
));
945 lsm_xattr
= new_xattrs
;
946 ret
= call_int_hook(inode_init_security
, -EOPNOTSUPP
, inode
, dir
, qstr
,
949 &lsm_xattr
->value_len
);
953 evm_xattr
= lsm_xattr
+ 1;
954 ret
= evm_inode_init_security(inode
, lsm_xattr
, evm_xattr
);
957 ret
= initxattrs(inode
, new_xattrs
, fs_data
);
959 for (xattr
= new_xattrs
; xattr
->value
!= NULL
; xattr
++)
961 return (ret
== -EOPNOTSUPP
) ? 0 : ret
;
963 EXPORT_SYMBOL(security_inode_init_security
);
965 int security_old_inode_init_security(struct inode
*inode
, struct inode
*dir
,
966 const struct qstr
*qstr
, const char **name
,
967 void **value
, size_t *len
)
969 if (unlikely(IS_PRIVATE(inode
)))
971 return call_int_hook(inode_init_security
, -EOPNOTSUPP
, inode
, dir
,
972 qstr
, name
, value
, len
);
974 EXPORT_SYMBOL(security_old_inode_init_security
);
976 #ifdef CONFIG_SECURITY_PATH
977 int security_path_mknod(const struct path
*dir
, struct dentry
*dentry
, umode_t mode
,
980 if (unlikely(IS_PRIVATE(d_backing_inode(dir
->dentry
))))
982 return call_int_hook(path_mknod
, 0, dir
, dentry
, mode
, dev
);
984 EXPORT_SYMBOL(security_path_mknod
);
986 int security_path_mkdir(const struct path
*dir
, struct dentry
*dentry
, umode_t mode
)
988 if (unlikely(IS_PRIVATE(d_backing_inode(dir
->dentry
))))
990 return call_int_hook(path_mkdir
, 0, dir
, dentry
, mode
);
992 EXPORT_SYMBOL(security_path_mkdir
);
994 int security_path_rmdir(const struct path
*dir
, struct dentry
*dentry
)
996 if (unlikely(IS_PRIVATE(d_backing_inode(dir
->dentry
))))
998 return call_int_hook(path_rmdir
, 0, dir
, dentry
);
1000 EXPORT_SYMBOL_GPL(security_path_rmdir
);
1002 int security_path_unlink(const struct path
*dir
, struct dentry
*dentry
)
1004 if (unlikely(IS_PRIVATE(d_backing_inode(dir
->dentry
))))
1006 return call_int_hook(path_unlink
, 0, dir
, dentry
);
1008 EXPORT_SYMBOL(security_path_unlink
);
1010 int security_path_symlink(const struct path
*dir
, struct dentry
*dentry
,
1011 const char *old_name
)
1013 if (unlikely(IS_PRIVATE(d_backing_inode(dir
->dentry
))))
1015 return call_int_hook(path_symlink
, 0, dir
, dentry
, old_name
);
1017 EXPORT_SYMBOL_GPL(security_path_symlink
);
1019 int security_path_link(struct dentry
*old_dentry
, const struct path
*new_dir
,
1020 struct dentry
*new_dentry
)
1022 if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry
))))
1024 return call_int_hook(path_link
, 0, old_dentry
, new_dir
, new_dentry
);
1026 EXPORT_SYMBOL_GPL(security_path_link
);
1028 int security_path_rename(const struct path
*old_dir
, struct dentry
*old_dentry
,
1029 const struct path
*new_dir
, struct dentry
*new_dentry
,
1032 if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry
)) ||
1033 (d_is_positive(new_dentry
) && IS_PRIVATE(d_backing_inode(new_dentry
)))))
1036 if (flags
& RENAME_EXCHANGE
) {
1037 int err
= call_int_hook(path_rename
, 0, new_dir
, new_dentry
,
1038 old_dir
, old_dentry
);
1043 return call_int_hook(path_rename
, 0, old_dir
, old_dentry
, new_dir
,
1046 EXPORT_SYMBOL(security_path_rename
);
1048 int security_path_truncate(const struct path
*path
)
1050 if (unlikely(IS_PRIVATE(d_backing_inode(path
->dentry
))))
1052 return call_int_hook(path_truncate
, 0, path
);
1054 EXPORT_SYMBOL_GPL(security_path_truncate
);
1056 int security_path_chmod(const struct path
*path
, umode_t mode
)
1058 if (unlikely(IS_PRIVATE(d_backing_inode(path
->dentry
))))
1060 return call_int_hook(path_chmod
, 0, path
, mode
);
1062 EXPORT_SYMBOL_GPL(security_path_chmod
);
1064 int security_path_chown(const struct path
*path
, kuid_t uid
, kgid_t gid
)
1066 if (unlikely(IS_PRIVATE(d_backing_inode(path
->dentry
))))
1068 return call_int_hook(path_chown
, 0, path
, uid
, gid
);
1070 EXPORT_SYMBOL_GPL(security_path_chown
);
1072 int security_path_chroot(const struct path
*path
)
1074 return call_int_hook(path_chroot
, 0, path
);
1078 int security_inode_create(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
)
1080 if (unlikely(IS_PRIVATE(dir
)))
1082 return call_int_hook(inode_create
, 0, dir
, dentry
, mode
);
1084 EXPORT_SYMBOL_GPL(security_inode_create
);
1086 int security_inode_link(struct dentry
*old_dentry
, struct inode
*dir
,
1087 struct dentry
*new_dentry
)
1089 if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry
))))
1091 return call_int_hook(inode_link
, 0, old_dentry
, dir
, new_dentry
);
1094 int security_inode_unlink(struct inode
*dir
, struct dentry
*dentry
)
1096 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1098 return call_int_hook(inode_unlink
, 0, dir
, dentry
);
1101 int security_inode_symlink(struct inode
*dir
, struct dentry
*dentry
,
1102 const char *old_name
)
1104 if (unlikely(IS_PRIVATE(dir
)))
1106 return call_int_hook(inode_symlink
, 0, dir
, dentry
, old_name
);
1109 int security_inode_mkdir(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
)
1111 if (unlikely(IS_PRIVATE(dir
)))
1113 return call_int_hook(inode_mkdir
, 0, dir
, dentry
, mode
);
1115 EXPORT_SYMBOL_GPL(security_inode_mkdir
);
1117 int security_inode_rmdir(struct inode
*dir
, struct dentry
*dentry
)
1119 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1121 return call_int_hook(inode_rmdir
, 0, dir
, dentry
);
1124 int security_inode_mknod(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
, dev_t dev
)
1126 if (unlikely(IS_PRIVATE(dir
)))
1128 return call_int_hook(inode_mknod
, 0, dir
, dentry
, mode
, dev
);
1131 int security_inode_rename(struct inode
*old_dir
, struct dentry
*old_dentry
,
1132 struct inode
*new_dir
, struct dentry
*new_dentry
,
1135 if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry
)) ||
1136 (d_is_positive(new_dentry
) && IS_PRIVATE(d_backing_inode(new_dentry
)))))
1139 if (flags
& RENAME_EXCHANGE
) {
1140 int err
= call_int_hook(inode_rename
, 0, new_dir
, new_dentry
,
1141 old_dir
, old_dentry
);
1146 return call_int_hook(inode_rename
, 0, old_dir
, old_dentry
,
1147 new_dir
, new_dentry
);
1150 int security_inode_readlink(struct dentry
*dentry
)
1152 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1154 return call_int_hook(inode_readlink
, 0, dentry
);
1156 EXPORT_SYMBOL_GPL(security_inode_readlink
);
1158 int security_inode_follow_link(struct dentry
*dentry
, struct inode
*inode
,
1161 if (unlikely(IS_PRIVATE(inode
)))
1163 return call_int_hook(inode_follow_link
, 0, dentry
, inode
, rcu
);
1166 int security_inode_permission(struct inode
*inode
, int mask
)
1168 if (unlikely(IS_PRIVATE(inode
)))
1170 return call_int_hook(inode_permission
, 0, inode
, mask
);
1172 EXPORT_SYMBOL_GPL(security_inode_permission
);
1174 int security_inode_setattr(struct dentry
*dentry
, struct iattr
*attr
)
1178 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1180 ret
= call_int_hook(inode_setattr
, 0, dentry
, attr
);
1183 return evm_inode_setattr(dentry
, attr
);
1185 EXPORT_SYMBOL_GPL(security_inode_setattr
);
1187 int security_inode_getattr(const struct path
*path
)
1189 if (unlikely(IS_PRIVATE(d_backing_inode(path
->dentry
))))
1191 return call_int_hook(inode_getattr
, 0, path
);
1194 int security_inode_setxattr(struct dentry
*dentry
, const char *name
,
1195 const void *value
, size_t size
, int flags
)
1199 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1202 * SELinux and Smack integrate the cap call,
1203 * so assume that all LSMs supplying this call do so.
1205 ret
= call_int_hook(inode_setxattr
, 1, dentry
, name
, value
, size
,
1209 ret
= cap_inode_setxattr(dentry
, name
, value
, size
, flags
);
1212 ret
= ima_inode_setxattr(dentry
, name
, value
, size
);
1215 return evm_inode_setxattr(dentry
, name
, value
, size
);
1218 void security_inode_post_setxattr(struct dentry
*dentry
, const char *name
,
1219 const void *value
, size_t size
, int flags
)
1221 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1223 call_void_hook(inode_post_setxattr
, dentry
, name
, value
, size
, flags
);
1224 evm_inode_post_setxattr(dentry
, name
, value
, size
);
1227 int security_inode_getxattr(struct dentry
*dentry
, const char *name
)
1229 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1231 return call_int_hook(inode_getxattr
, 0, dentry
, name
);
1234 int security_inode_listxattr(struct dentry
*dentry
)
1236 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1238 return call_int_hook(inode_listxattr
, 0, dentry
);
1241 int security_inode_removexattr(struct dentry
*dentry
, const char *name
)
1245 if (unlikely(IS_PRIVATE(d_backing_inode(dentry
))))
1248 * SELinux and Smack integrate the cap call,
1249 * so assume that all LSMs supplying this call do so.
1251 ret
= call_int_hook(inode_removexattr
, 1, dentry
, name
);
1253 ret
= cap_inode_removexattr(dentry
, name
);
1256 ret
= ima_inode_removexattr(dentry
, name
);
1259 return evm_inode_removexattr(dentry
, name
);
1262 int security_inode_need_killpriv(struct dentry
*dentry
)
1264 return call_int_hook(inode_need_killpriv
, 0, dentry
);
1267 int security_inode_killpriv(struct dentry
*dentry
)
1269 return call_int_hook(inode_killpriv
, 0, dentry
);
1272 int security_inode_getsecurity(struct inode
*inode
, const char *name
, void **buffer
, bool alloc
)
1274 struct security_hook_list
*hp
;
1277 if (unlikely(IS_PRIVATE(inode
)))
1280 * Only one module will provide an attribute with a given name.
1282 list_for_each_entry(hp
, &security_hook_heads
.inode_getsecurity
, list
) {
1283 rc
= hp
->hook
.inode_getsecurity(inode
, name
, buffer
, alloc
);
1284 if (rc
!= -EOPNOTSUPP
)
1290 int security_inode_setsecurity(struct inode
*inode
, const char *name
, const void *value
, size_t size
, int flags
)
1292 struct security_hook_list
*hp
;
1295 if (unlikely(IS_PRIVATE(inode
)))
1298 * Only one module will provide an attribute with a given name.
1300 list_for_each_entry(hp
, &security_hook_heads
.inode_setsecurity
, list
) {
1301 rc
= hp
->hook
.inode_setsecurity(inode
, name
, value
, size
,
1303 if (rc
!= -EOPNOTSUPP
)
1309 int security_inode_listsecurity(struct inode
*inode
, char *buffer
, size_t buffer_size
)
1311 if (unlikely(IS_PRIVATE(inode
)))
1313 return call_int_hook(inode_listsecurity
, 0, inode
, buffer
, buffer_size
);
1315 EXPORT_SYMBOL(security_inode_listsecurity
);
1317 void security_inode_getsecid(struct inode
*inode
, u32
*secid
)
1319 call_void_hook(inode_getsecid
, inode
, secid
);
1322 int security_inode_copy_up(struct dentry
*src
, struct cred
**new)
1324 return call_int_hook(inode_copy_up
, 0, src
, new);
1326 EXPORT_SYMBOL(security_inode_copy_up
);
1328 int security_inode_copy_up_xattr(const char *name
)
1330 return call_int_hook(inode_copy_up_xattr
, -EOPNOTSUPP
, name
);
1332 EXPORT_SYMBOL(security_inode_copy_up_xattr
);
1334 int security_file_permission(struct file
*file
, int mask
)
1338 ret
= call_int_hook(file_permission
, 0, file
, mask
);
1342 return fsnotify_perm(file
, mask
);
1344 EXPORT_SYMBOL_GPL(security_file_permission
);
1346 int security_file_alloc(struct file
*file
)
1348 int rc
= lsm_file_alloc(file
);
1352 rc
= call_int_hook(file_alloc_security
, 0, file
);
1354 security_file_free(file
);
1358 void security_file_free(struct file
*file
)
1362 if (!lsm_file_cache
)
1365 call_void_hook(file_free_security
, file
);
1367 blob
= file
->f_security
;
1368 file
->f_security
= NULL
;
1369 kmem_cache_free(lsm_file_cache
, blob
);
1372 int security_file_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1374 return call_int_hook(file_ioctl
, 0, file
, cmd
, arg
);
1377 static inline unsigned long mmap_prot(struct file
*file
, unsigned long prot
)
1380 * Does we have PROT_READ and does the application expect
1381 * it to imply PROT_EXEC? If not, nothing to talk about...
1383 if ((prot
& (PROT_READ
| PROT_EXEC
)) != PROT_READ
)
1385 if (!(current
->personality
& READ_IMPLIES_EXEC
))
1388 * if that's an anonymous mapping, let it.
1391 return prot
| PROT_EXEC
;
1393 * ditto if it's not on noexec mount, except that on !MMU we need
1394 * NOMMU_MAP_EXEC (== VM_MAYEXEC) in this case
1396 if (!path_noexec(&file
->f_path
)) {
1398 if (file
->f_op
->mmap_capabilities
) {
1399 unsigned caps
= file
->f_op
->mmap_capabilities(file
);
1400 if (!(caps
& NOMMU_MAP_EXEC
))
1404 return prot
| PROT_EXEC
;
1406 /* anything on noexec mount won't get PROT_EXEC */
1410 int security_mmap_file(struct file
*file
, unsigned long prot
,
1411 unsigned long flags
)
1414 ret
= call_int_hook(mmap_file
, 0, file
, prot
,
1415 mmap_prot(file
, prot
), flags
);
1418 return ima_file_mmap(file
, prot
);
1420 EXPORT_SYMBOL_GPL(security_mmap_file
);
1422 int security_mmap_addr(unsigned long addr
)
1424 return call_int_hook(mmap_addr
, 0, addr
);
1427 int security_file_mprotect(struct vm_area_struct
*vma
, unsigned long reqprot
,
1430 return call_int_hook(file_mprotect
, 0, vma
, reqprot
, prot
);
1433 int security_file_lock(struct file
*file
, unsigned int cmd
)
1435 return call_int_hook(file_lock
, 0, file
, cmd
);
1438 int security_file_fcntl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
1440 return call_int_hook(file_fcntl
, 0, file
, cmd
, arg
);
1443 void security_file_set_fowner(struct file
*file
)
1445 call_void_hook(file_set_fowner
, file
);
1448 int security_file_send_sigiotask(struct task_struct
*tsk
,
1449 struct fown_struct
*fown
, int sig
)
1451 return call_int_hook(file_send_sigiotask
, 0, tsk
, fown
, sig
);
1454 int security_file_receive(struct file
*file
)
1456 return call_int_hook(file_receive
, 0, file
);
1459 int security_file_open(struct file
*file
, const struct cred
*cred
)
1463 ret
= call_int_hook(file_open
, 0, file
, cred
);
1467 return fsnotify_perm(file
, MAY_OPEN
);
1470 int security_task_alloc(struct task_struct
*task
, unsigned long clone_flags
)
1472 int rc
= lsm_task_alloc(task
);
1476 rc
= call_int_hook(task_alloc
, 0, task
, clone_flags
);
1478 security_task_free(task
);
1482 void security_task_free(struct task_struct
*task
)
1484 call_void_hook(task_free
, task
);
1486 kfree(task
->security
);
1487 task
->security
= NULL
;
1490 int security_cred_alloc_blank(struct cred
*cred
, gfp_t gfp
)
1492 int rc
= lsm_cred_alloc(cred
, gfp
);
1497 rc
= call_int_hook(cred_alloc_blank
, 0, cred
, gfp
);
1499 security_cred_free(cred
);
1503 void security_cred_free(struct cred
*cred
)
1505 call_void_hook(cred_free
, cred
);
1507 kfree(cred
->security
);
1508 cred
->security
= NULL
;
1511 int security_prepare_creds(struct cred
*new, const struct cred
*old
, gfp_t gfp
)
1513 int rc
= lsm_cred_alloc(new, gfp
);
1518 rc
= call_int_hook(cred_prepare
, 0, new, old
, gfp
);
1520 security_cred_free(new);
1524 void security_transfer_creds(struct cred
*new, const struct cred
*old
)
1526 call_void_hook(cred_transfer
, new, old
);
1529 int security_kernel_act_as(struct cred
*new, u32 secid
)
1531 return call_int_hook(kernel_act_as
, 0, new, secid
);
1534 int security_kernel_create_files_as(struct cred
*new, struct inode
*inode
)
1536 return call_int_hook(kernel_create_files_as
, 0, new, inode
);
1539 int security_kernel_module_request(char *kmod_name
)
1541 return call_int_hook(kernel_module_request
, 0, kmod_name
);
1544 int security_kernel_read_file(struct file
*file
, enum kernel_read_file_id id
)
1548 ret
= call_int_hook(kernel_read_file
, 0, file
, id
);
1551 return ima_read_file(file
, id
);
1553 EXPORT_SYMBOL_GPL(security_kernel_read_file
);
1555 int security_kernel_post_read_file(struct file
*file
, char *buf
, loff_t size
,
1556 enum kernel_read_file_id id
)
1560 ret
= call_int_hook(kernel_post_read_file
, 0, file
, buf
, size
, id
);
1563 return ima_post_read_file(file
, buf
, size
, id
);
1565 EXPORT_SYMBOL_GPL(security_kernel_post_read_file
);
1567 int security_task_fix_setuid(struct cred
*new, const struct cred
*old
,
1570 return call_int_hook(task_fix_setuid
, 0, new, old
, flags
);
1573 int security_task_setpgid(struct task_struct
*p
, pid_t pgid
)
1575 return call_int_hook(task_setpgid
, 0, p
, pgid
);
1578 int security_task_getpgid(struct task_struct
*p
)
1580 return call_int_hook(task_getpgid
, 0, p
);
1583 int security_task_getsid(struct task_struct
*p
)
1585 return call_int_hook(task_getsid
, 0, p
);
1588 void security_task_getsecid(struct task_struct
*p
, u32
*secid
)
1591 call_void_hook(task_getsecid
, p
, secid
);
1593 EXPORT_SYMBOL(security_task_getsecid
);
1595 int security_task_setnice(struct task_struct
*p
, int nice
)
1597 return call_int_hook(task_setnice
, 0, p
, nice
);
1600 int security_task_setioprio(struct task_struct
*p
, int ioprio
)
1602 return call_int_hook(task_setioprio
, 0, p
, ioprio
);
1605 int security_task_getioprio(struct task_struct
*p
)
1607 return call_int_hook(task_getioprio
, 0, p
);
1610 int security_task_prlimit(const struct cred
*cred
, const struct cred
*tcred
,
1613 return call_int_hook(task_prlimit
, 0, cred
, tcred
, flags
);
1616 int security_task_setrlimit(struct task_struct
*p
, unsigned int resource
,
1617 struct rlimit
*new_rlim
)
1619 return call_int_hook(task_setrlimit
, 0, p
, resource
, new_rlim
);
1622 int security_task_setscheduler(struct task_struct
*p
)
1624 return call_int_hook(task_setscheduler
, 0, p
);
1627 int security_task_getscheduler(struct task_struct
*p
)
1629 return call_int_hook(task_getscheduler
, 0, p
);
1632 int security_task_movememory(struct task_struct
*p
)
1634 return call_int_hook(task_movememory
, 0, p
);
1637 int security_task_kill(struct task_struct
*p
, struct siginfo
*info
,
1640 return call_int_hook(task_kill
, 0, p
, info
, sig
, secid
);
1643 #ifdef CONFIG_SECURITY_STACKING
1644 static char *nolsm
= "-default";
1647 static bool is_registered_lsm(const char *str
, size_t size
)
1649 struct security_hook_list
*hp
;
1651 list_for_each_entry(hp
, &security_hook_heads
.getprocattr
, list
) {
1652 if (size
== strlen(hp
->lsm
) && !strncmp(str
, hp
->lsm
, size
))
1659 static bool set_lsm_of_current(const char *str
, size_t size
)
1661 char *lsm
= lsm_of_task(current
);
1663 if (is_registered_lsm(str
, size
)) {
1664 strncpy(lsm
, str
, size
);
1666 } else if (size
== NOLSMLEN
&& !strncmp(str
, nolsm
, size
)) {
1674 static int lsm_task_prctl(int option
, unsigned long arg2
, unsigned long arg3
,
1675 unsigned long arg4
, unsigned long arg5
)
1677 char *lsm
= lsm_of_task(current
);
1678 char buffer
[SECURITY_NAME_MAX
+ 1];
1679 __user
char *optval
= (__user
char *)arg2
;
1680 __user
int *optlen
= (__user
int *)arg3
;
1685 case PR_GET_DISPLAY_LSM
:
1687 if (lsm
[0] == '\0') {
1691 dlen
= strlen(lsm
) + 1;
1694 if (copy_to_user(optval
, lsm
, dlen
))
1696 if (put_user(dlen
, optlen
))
1699 case PR_SET_DISPLAY_LSM
:
1701 if (len
> SECURITY_NAME_MAX
)
1703 if (copy_from_user(buffer
, optval
, len
))
1706 /* verify the requested LSM is registered */
1707 if (!set_lsm_of_current(buffer
, len
))
1717 int security_task_prctl(int option
, unsigned long arg2
, unsigned long arg3
,
1718 unsigned long arg4
, unsigned long arg5
)
1722 struct security_hook_list
*hp
;
1724 #ifdef CONFIG_SECURITY_STACKING
1725 rc
= lsm_task_prctl(option
, arg2
, arg3
, arg4
, arg5
);
1730 list_for_each_entry(hp
, &security_hook_heads
.task_prctl
, list
) {
1731 thisrc
= hp
->hook
.task_prctl(option
, arg2
, arg3
, arg4
, arg5
);
1732 if (thisrc
!= -ENOSYS
) {
1741 void security_task_to_inode(struct task_struct
*p
, struct inode
*inode
)
1743 call_void_hook(task_to_inode
, p
, inode
);
1746 int security_ipc_permission(struct kern_ipc_perm
*ipcp
, short flag
)
1748 return call_int_hook(ipc_permission
, 0, ipcp
, flag
);
1751 void security_ipc_getsecid(struct kern_ipc_perm
*ipcp
, u32
*secid
)
1754 call_void_hook(ipc_getsecid
, ipcp
, secid
);
1757 int security_msg_msg_alloc(struct msg_msg
*msg
)
1759 int rc
= lsm_msg_msg_alloc(msg
);
1763 rc
= call_int_hook(msg_msg_alloc_security
, 0, msg
);
1765 security_msg_msg_free(msg
);
1769 void security_msg_msg_free(struct msg_msg
*msg
)
1771 call_void_hook(msg_msg_free_security
, msg
);
1772 kfree(msg
->security
);
1773 msg
->security
= NULL
;
1776 int security_msg_queue_alloc(struct msg_queue
*msq
)
1778 int rc
= lsm_ipc_alloc(&msq
->q_perm
);
1782 rc
= call_int_hook(msg_queue_alloc_security
, 0, msq
);
1784 security_msg_queue_free(msq
);
1788 void security_msg_queue_free(struct msg_queue
*msq
)
1790 struct kern_ipc_perm
*kip
= &msq
->q_perm
;
1792 call_void_hook(msg_queue_free_security
, msq
);
1793 kfree(kip
->security
);
1794 kip
->security
= NULL
;
1797 int security_msg_queue_associate(struct msg_queue
*msq
, int msqflg
)
1799 return call_int_hook(msg_queue_associate
, 0, msq
, msqflg
);
1802 int security_msg_queue_msgctl(struct msg_queue
*msq
, int cmd
)
1804 return call_int_hook(msg_queue_msgctl
, 0, msq
, cmd
);
1807 int security_msg_queue_msgsnd(struct msg_queue
*msq
,
1808 struct msg_msg
*msg
, int msqflg
)
1810 return call_int_hook(msg_queue_msgsnd
, 0, msq
, msg
, msqflg
);
1813 int security_msg_queue_msgrcv(struct msg_queue
*msq
, struct msg_msg
*msg
,
1814 struct task_struct
*target
, long type
, int mode
)
1816 return call_int_hook(msg_queue_msgrcv
, 0, msq
, msg
, target
, type
, mode
);
1819 int security_shm_alloc(struct shmid_kernel
*shp
)
1821 int rc
= lsm_ipc_alloc(&shp
->shm_perm
);
1825 rc
= call_int_hook(shm_alloc_security
, 0, shp
);
1827 security_shm_free(shp
);
1831 void security_shm_free(struct shmid_kernel
*shp
)
1833 struct kern_ipc_perm
*kip
= &shp
->shm_perm
;
1835 call_void_hook(shm_free_security
, shp
);
1836 kfree(kip
->security
);
1837 kip
->security
= NULL
;
1840 int security_shm_associate(struct shmid_kernel
*shp
, int shmflg
)
1842 return call_int_hook(shm_associate
, 0, shp
, shmflg
);
1845 int security_shm_shmctl(struct shmid_kernel
*shp
, int cmd
)
1847 return call_int_hook(shm_shmctl
, 0, shp
, cmd
);
1850 int security_shm_shmat(struct shmid_kernel
*shp
, char __user
*shmaddr
, int shmflg
)
1852 return call_int_hook(shm_shmat
, 0, shp
, shmaddr
, shmflg
);
1855 int security_sem_alloc(struct sem_array
*sma
)
1857 int rc
= lsm_ipc_alloc(&sma
->sem_perm
);
1861 rc
= call_int_hook(sem_alloc_security
, 0, sma
);
1863 security_sem_free(sma
);
1867 void security_sem_free(struct sem_array
*sma
)
1869 struct kern_ipc_perm
*kip
= &sma
->sem_perm
;
1871 call_void_hook(sem_free_security
, sma
);
1872 kfree(kip
->security
);
1873 kip
->security
= NULL
;
1876 int security_sem_associate(struct sem_array
*sma
, int semflg
)
1878 return call_int_hook(sem_associate
, 0, sma
, semflg
);
1881 int security_sem_semctl(struct sem_array
*sma
, int cmd
)
1883 return call_int_hook(sem_semctl
, 0, sma
, cmd
);
1886 int security_sem_semop(struct sem_array
*sma
, struct sembuf
*sops
,
1887 unsigned nsops
, int alter
)
1889 return call_int_hook(sem_semop
, 0, sma
, sops
, nsops
, alter
);
1892 void security_d_instantiate(struct dentry
*dentry
, struct inode
*inode
)
1894 if (unlikely(inode
&& IS_PRIVATE(inode
)))
1896 call_void_hook(d_instantiate
, dentry
, inode
);
1898 EXPORT_SYMBOL(security_d_instantiate
);
1900 int security_getprocattr(struct task_struct
*p
, const char *lsm
, char *name
,
1903 #ifdef CONFIG_SECURITY_STACKING
1904 char *speclsm
= lsm_of_task(p
);
1906 struct security_hook_list
*hp
;
1909 if (strcmp(name
, "display_lsm") == 0) {
1910 *value
= kstrdup(current
->security
, GFP_KERNEL
);
1913 return strlen(*value
);
1916 list_for_each_entry(hp
, &security_hook_heads
.getprocattr
, list
) {
1917 if (lsm
!= NULL
&& strcmp(lsm
, hp
->lsm
))
1919 #ifdef CONFIG_SECURITY_STACKING
1920 if (!lsm
&& speclsm
&& speclsm
[0] && strcmp(speclsm
, hp
->lsm
))
1923 rc
= hp
->hook
.getprocattr(p
, name
, value
);
1930 int security_setprocattr(const char *lsm
, const char *name
, void *value
,
1933 #ifdef CONFIG_SECURITY_STACKING
1934 char *speclsm
= lsm_of_task(current
);
1938 struct security_hook_list
*hp
;
1944 if (strcmp(name
, "display_lsm") == 0) {
1945 #ifdef CONFIG_SECURITY_STACKING
1946 if (set_lsm_of_current(value
, size
))
1952 list_for_each_entry(hp
, &security_hook_heads
.setprocattr
, list
) {
1953 #ifdef CONFIG_SECURITY_STACKING
1954 if (!lsm
&& speclsm
&& speclsm
[0] && strcmp(speclsm
, hp
->lsm
))
1957 rc
= hp
->hook
.setprocattr(name
, value
, size
);
1964 int security_netlink_send(struct sock
*sk
, struct sk_buff
*skb
)
1966 return call_int_hook(netlink_send
, 0, sk
, skb
);
1969 int security_ismaclabel(const char *name
)
1971 return call_int_hook(ismaclabel
, 0, name
);
1973 EXPORT_SYMBOL(security_ismaclabel
);
1975 int security_secid_to_secctx(u32 secid
, char **secdata
, u32
*seclen
)
1977 return call_int_hook(secid_to_secctx
, -EOPNOTSUPP
, secid
, secdata
,
1980 EXPORT_SYMBOL(security_secid_to_secctx
);
1982 int security_secctx_to_secid(const char *secdata
, u32 seclen
, u32
*secid
)
1985 return call_int_hook(secctx_to_secid
, 0, secdata
, seclen
, secid
);
1987 EXPORT_SYMBOL(security_secctx_to_secid
);
1989 void security_release_secctx(char *secdata
, u32 seclen
)
1991 #ifdef CONFIG_SECURITY_STACKING
1992 char *speclsm
= lsm_of_task(current
);
1994 struct security_hook_list
*hp
;
1996 list_for_each_entry(hp
, &security_hook_heads
.release_secctx
, list
) {
1997 #ifdef CONFIG_SECURITY_STACKING
1998 if (speclsm
[0] && strcmp(hp
->lsm
, speclsm
))
2001 hp
->hook
.release_secctx(secdata
, seclen
);
2005 EXPORT_SYMBOL(security_release_secctx
);
2007 void security_inode_invalidate_secctx(struct inode
*inode
)
2009 call_void_hook(inode_invalidate_secctx
, inode
);
2011 EXPORT_SYMBOL(security_inode_invalidate_secctx
);
2013 int security_inode_notifysecctx(struct inode
*inode
, void *ctx
, u32 ctxlen
)
2015 return call_int_hook(inode_notifysecctx
, 0, inode
, ctx
, ctxlen
);
2017 EXPORT_SYMBOL(security_inode_notifysecctx
);
2019 int security_inode_setsecctx(struct dentry
*dentry
, void *ctx
, u32 ctxlen
)
2021 return call_int_hook(inode_setsecctx
, 0, dentry
, ctx
, ctxlen
);
2023 EXPORT_SYMBOL(security_inode_setsecctx
);
2025 int security_inode_getsecctx(struct inode
*inode
, void **ctx
, u32
*ctxlen
)
2027 return call_int_hook(inode_getsecctx
, -EOPNOTSUPP
, inode
, ctx
, ctxlen
);
2029 EXPORT_SYMBOL(security_inode_getsecctx
);
2031 #ifdef CONFIG_SECURITY_NETWORK
2033 int security_unix_stream_connect(struct sock
*sock
, struct sock
*other
, struct sock
*newsk
)
2035 return call_int_hook(unix_stream_connect
, 0, sock
, other
, newsk
);
2037 EXPORT_SYMBOL(security_unix_stream_connect
);
2039 int security_unix_may_send(struct socket
*sock
, struct socket
*other
)
2041 return call_int_hook(unix_may_send
, 0, sock
, other
);
2043 EXPORT_SYMBOL(security_unix_may_send
);
2045 int security_socket_create(int family
, int type
, int protocol
, int kern
)
2047 return call_int_hook(socket_create
, 0, family
, type
, protocol
, kern
);
2050 int security_socket_post_create(struct socket
*sock
, int family
,
2051 int type
, int protocol
, int kern
)
2053 return call_int_hook(socket_post_create
, 0, sock
, family
, type
,
2057 int security_socket_bind(struct socket
*sock
, struct sockaddr
*address
, int addrlen
)
2059 return call_int_hook(socket_bind
, 0, sock
, address
, addrlen
);
2062 int security_socket_connect(struct socket
*sock
, struct sockaddr
*address
, int addrlen
)
2064 return call_int_hook(socket_connect
, 0, sock
, address
, addrlen
);
2067 int security_socket_listen(struct socket
*sock
, int backlog
)
2069 return call_int_hook(socket_listen
, 0, sock
, backlog
);
2072 int security_socket_accept(struct socket
*sock
, struct socket
*newsock
)
2074 return call_int_hook(socket_accept
, 0, sock
, newsock
);
2077 int security_socket_sendmsg(struct socket
*sock
, struct msghdr
*msg
, int size
)
2079 return call_int_hook(socket_sendmsg
, 0, sock
, msg
, size
);
2082 int security_socket_recvmsg(struct socket
*sock
, struct msghdr
*msg
,
2083 int size
, int flags
)
2085 return call_int_hook(socket_recvmsg
, 0, sock
, msg
, size
, flags
);
2088 int security_socket_getsockname(struct socket
*sock
)
2090 return call_int_hook(socket_getsockname
, 0, sock
);
2093 int security_socket_getpeername(struct socket
*sock
)
2095 return call_int_hook(socket_getpeername
, 0, sock
);
2098 int security_socket_getsockopt(struct socket
*sock
, int level
, int optname
)
2100 return call_int_hook(socket_getsockopt
, 0, sock
, level
, optname
);
2103 int security_socket_setsockopt(struct socket
*sock
, int level
, int optname
)
2105 return call_int_hook(socket_setsockopt
, 0, sock
, level
, optname
);
2108 int security_socket_shutdown(struct socket
*sock
, int how
)
2110 return call_int_hook(socket_shutdown
, 0, sock
, how
);
2113 int security_sock_rcv_skb(struct sock
*sk
, struct sk_buff
*skb
)
2115 return call_int_hook(socket_sock_rcv_skb
, 0, sk
, skb
);
2117 EXPORT_SYMBOL(security_sock_rcv_skb
);
2119 int security_socket_getpeersec_stream(struct socket
*sock
, char __user
*optval
,
2120 int __user
*optlen
, unsigned len
)
2122 #ifdef CONFIG_SECURITY_STACKING
2123 struct security_hook_list
*hp
;
2124 char *lsm
= lsm_of_task(current
);
2126 list_for_each_entry(hp
, &security_hook_heads
.socket_getpeersec_stream
,
2128 if (!lsm
|| !lsm
[0] || !strcmp(lsm
, hp
->lsm
))
2129 return hp
->hook
.socket_getpeersec_stream(sock
, optval
,
2132 return -ENOPROTOOPT
;
2134 return call_int_hook(socket_getpeersec_stream
, -ENOPROTOOPT
, sock
,
2135 optval
, optlen
, len
);
2139 int security_socket_getpeersec_dgram(struct socket
*sock
, struct sk_buff
*skb
, u32
*secid
)
2141 return call_int_hook(socket_getpeersec_dgram
, -ENOPROTOOPT
, sock
,
2144 EXPORT_SYMBOL(security_socket_getpeersec_dgram
);
2146 int security_sk_alloc(struct sock
*sk
, int family
, gfp_t priority
)
2148 int rc
= lsm_sock_alloc(sk
, priority
);
2152 rc
= call_int_hook(sk_alloc_security
, 0, sk
, family
, priority
);
2154 security_sk_free(sk
);
2158 void security_sk_free(struct sock
*sk
)
2160 call_void_hook(sk_free_security
, sk
);
2161 kfree(sk
->sk_security
);
2162 sk
->sk_security
= NULL
;
2165 void security_sk_clone(const struct sock
*sk
, struct sock
*newsk
)
2167 call_void_hook(sk_clone_security
, sk
, newsk
);
2169 EXPORT_SYMBOL(security_sk_clone
);
2171 void security_sk_classify_flow(struct sock
*sk
, struct flowi
*fl
)
2173 call_void_hook(sk_getsecid
, sk
, &fl
->flowi_secid
);
2175 EXPORT_SYMBOL(security_sk_classify_flow
);
2177 void security_req_classify_flow(const struct request_sock
*req
, struct flowi
*fl
)
2179 call_void_hook(req_classify_flow
, req
, fl
);
2181 EXPORT_SYMBOL(security_req_classify_flow
);
2183 void security_sock_graft(struct sock
*sk
, struct socket
*parent
)
2185 call_void_hook(sock_graft
, sk
, parent
);
2187 EXPORT_SYMBOL(security_sock_graft
);
2189 int security_inet_conn_request(struct sock
*sk
,
2190 struct sk_buff
*skb
, struct request_sock
*req
)
2192 return call_int_hook(inet_conn_request
, 0, sk
, skb
, req
);
2194 EXPORT_SYMBOL(security_inet_conn_request
);
2196 void security_inet_csk_clone(struct sock
*newsk
,
2197 const struct request_sock
*req
)
2199 call_void_hook(inet_csk_clone
, newsk
, req
);
2202 void security_inet_conn_established(struct sock
*sk
,
2203 struct sk_buff
*skb
)
2205 call_void_hook(inet_conn_established
, sk
, skb
);
2208 int security_secmark_relabel_packet(u32 secid
)
2210 return call_int_hook(secmark_relabel_packet
, 0, secid
);
2212 EXPORT_SYMBOL(security_secmark_relabel_packet
);
2214 void security_secmark_refcount_inc(void)
2216 call_void_hook(secmark_refcount_inc
);
2218 EXPORT_SYMBOL(security_secmark_refcount_inc
);
2220 void security_secmark_refcount_dec(void)
2222 call_void_hook(secmark_refcount_dec
);
2224 EXPORT_SYMBOL(security_secmark_refcount_dec
);
2226 int security_tun_dev_alloc_security(void **security
)
2228 return call_int_hook(tun_dev_alloc_security
, 0, security
);
2230 EXPORT_SYMBOL(security_tun_dev_alloc_security
);
2232 void security_tun_dev_free_security(void *security
)
2234 call_void_hook(tun_dev_free_security
, security
);
2236 EXPORT_SYMBOL(security_tun_dev_free_security
);
2238 int security_tun_dev_create(void)
2240 return call_int_hook(tun_dev_create
, 0);
2242 EXPORT_SYMBOL(security_tun_dev_create
);
2244 int security_tun_dev_attach_queue(void *security
)
2246 return call_int_hook(tun_dev_attach_queue
, 0, security
);
2248 EXPORT_SYMBOL(security_tun_dev_attach_queue
);
2250 int security_tun_dev_attach(struct sock
*sk
, void *security
)
2252 return call_int_hook(tun_dev_attach
, 0, sk
, security
);
2254 EXPORT_SYMBOL(security_tun_dev_attach
);
2256 int security_tun_dev_open(void *security
)
2258 return call_int_hook(tun_dev_open
, 0, security
);
2260 EXPORT_SYMBOL(security_tun_dev_open
);
2262 #endif /* CONFIG_SECURITY_NETWORK */
2264 #ifdef CONFIG_SECURITY_INFINIBAND
2266 int security_ib_pkey_access(void *sec
, u64 subnet_prefix
, u16 pkey
)
2268 return call_int_hook(ib_pkey_access
, 0, sec
, subnet_prefix
, pkey
);
2270 EXPORT_SYMBOL(security_ib_pkey_access
);
2272 int security_ib_endport_manage_subnet(void *sec
, const char *dev_name
, u8 port_num
)
2274 return call_int_hook(ib_endport_manage_subnet
, 0, sec
, dev_name
, port_num
);
2276 EXPORT_SYMBOL(security_ib_endport_manage_subnet
);
2278 int security_ib_alloc_security(void **sec
)
2280 return call_int_hook(ib_alloc_security
, 0, sec
);
2282 EXPORT_SYMBOL(security_ib_alloc_security
);
2284 void security_ib_free_security(void *sec
)
2286 call_void_hook(ib_free_security
, sec
);
2288 EXPORT_SYMBOL(security_ib_free_security
);
2289 #endif /* CONFIG_SECURITY_INFINIBAND */
2291 #ifdef CONFIG_SECURITY_NETWORK_XFRM
2293 int security_xfrm_policy_alloc(struct xfrm_sec_ctx
**ctxp
,
2294 struct xfrm_user_sec_ctx
*sec_ctx
,
2297 return call_int_hook(xfrm_policy_alloc_security
, 0, ctxp
, sec_ctx
, gfp
);
2299 EXPORT_SYMBOL(security_xfrm_policy_alloc
);
2301 int security_xfrm_policy_clone(struct xfrm_sec_ctx
*old_ctx
,
2302 struct xfrm_sec_ctx
**new_ctxp
)
2304 return call_int_hook(xfrm_policy_clone_security
, 0, old_ctx
, new_ctxp
);
2307 void security_xfrm_policy_free(struct xfrm_sec_ctx
*ctx
)
2309 call_void_hook(xfrm_policy_free_security
, ctx
);
2311 EXPORT_SYMBOL(security_xfrm_policy_free
);
2313 int security_xfrm_policy_delete(struct xfrm_sec_ctx
*ctx
)
2315 return call_int_hook(xfrm_policy_delete_security
, 0, ctx
);
2318 int security_xfrm_state_alloc(struct xfrm_state
*x
,
2319 struct xfrm_user_sec_ctx
*sec_ctx
)
2321 return call_int_hook(xfrm_state_alloc
, 0, x
, sec_ctx
);
2323 EXPORT_SYMBOL(security_xfrm_state_alloc
);
2325 int security_xfrm_state_alloc_acquire(struct xfrm_state
*x
,
2326 struct xfrm_sec_ctx
*polsec
, u32 secid
)
2328 return call_int_hook(xfrm_state_alloc_acquire
, 0, x
, polsec
, secid
);
2331 int security_xfrm_state_delete(struct xfrm_state
*x
)
2333 return call_int_hook(xfrm_state_delete_security
, 0, x
);
2335 EXPORT_SYMBOL(security_xfrm_state_delete
);
2337 void security_xfrm_state_free(struct xfrm_state
*x
)
2339 call_void_hook(xfrm_state_free_security
, x
);
2342 int security_xfrm_policy_lookup(struct xfrm_sec_ctx
*ctx
, u32 fl_secid
, u8 dir
)
2344 return call_int_hook(xfrm_policy_lookup
, 0, ctx
, fl_secid
, dir
);
2347 int security_xfrm_state_pol_flow_match(struct xfrm_state
*x
,
2348 struct xfrm_policy
*xp
,
2349 const struct flowi
*fl
)
2351 struct security_hook_list
*hp
;
2355 * Since this function is expected to return 0 or 1, the judgment
2356 * becomes difficult if multiple LSMs supply this call. Fortunately,
2357 * we can use the first LSM's judgment because currently only SELinux
2358 * supplies this call.
2360 * For speed optimization, we explicitly break the loop rather than
2363 list_for_each_entry(hp
, &security_hook_heads
.xfrm_state_pol_flow_match
,
2365 rc
= hp
->hook
.xfrm_state_pol_flow_match(x
, xp
, fl
);
2371 int security_xfrm_decode_session(struct sk_buff
*skb
, u32
*secid
)
2373 return call_int_hook(xfrm_decode_session
, 0, skb
, secid
, 1);
2376 void security_skb_classify_flow(struct sk_buff
*skb
, struct flowi
*fl
)
2378 int rc
= call_int_hook(xfrm_decode_session
, 0, skb
, &fl
->flowi_secid
,
2383 EXPORT_SYMBOL(security_skb_classify_flow
);
2385 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
2389 int security_key_alloc(struct key
*key
, const struct cred
*cred
,
2390 unsigned long flags
)
2392 int rc
= lsm_key_alloc(key
);
2396 rc
= call_int_hook(key_alloc
, 0, key
, cred
, flags
);
2398 security_key_free(key
);
2402 void security_key_free(struct key
*key
)
2404 call_void_hook(key_free
, key
);
2405 kfree(key
->security
);
2406 key
->security
= NULL
;
2409 int security_key_permission(key_ref_t key_ref
,
2410 const struct cred
*cred
, unsigned perm
)
2412 return call_int_hook(key_permission
, 0, key_ref
, cred
, perm
);
2415 int security_key_getsecurity(struct key
*key
, char **_buffer
)
2418 return call_int_hook(key_getsecurity
, 0, key
, _buffer
);
2421 #endif /* CONFIG_KEYS */
2425 int security_audit_rule_init(u32 field
, u32 op
, char *rulestr
, void **lsmrule
)
2427 return call_int_hook(audit_rule_init
, 0, field
, op
, rulestr
, lsmrule
);
2430 int security_audit_rule_known(struct audit_krule
*krule
)
2432 return call_int_hook(audit_rule_known
, 0, krule
);
2435 void security_audit_rule_free(void *lsmrule
)
2437 call_void_hook(audit_rule_free
, lsmrule
);
2440 int security_audit_rule_match(u32 secid
, u32 field
, u32 op
, void *lsmrule
,
2441 struct audit_context
*actx
)
2443 return call_int_hook(audit_rule_match
, 0, secid
, field
, op
, lsmrule
,
2446 #endif /* CONFIG_AUDIT */
2448 #ifdef CONFIG_BPF_SYSCALL
2449 int security_bpf(int cmd
, union bpf_attr
*attr
, unsigned int size
)
2451 return call_int_hook(bpf
, 0, cmd
, attr
, size
);
2453 int security_bpf_map(struct bpf_map
*map
, fmode_t fmode
)
2455 return call_int_hook(bpf_map
, 0, map
, fmode
);
2457 int security_bpf_prog(struct bpf_prog
*prog
)
2459 return call_int_hook(bpf_prog
, 0, prog
);
2461 int security_bpf_map_alloc(struct bpf_map
*map
)
2463 return call_int_hook(bpf_map_alloc_security
, 0, map
);
2465 int security_bpf_prog_alloc(struct bpf_prog_aux
*aux
)
2467 return call_int_hook(bpf_prog_alloc_security
, 0, aux
);
2469 void security_bpf_map_free(struct bpf_map
*map
)
2471 call_void_hook(bpf_map_free_security
, map
);
2473 void security_bpf_prog_free(struct bpf_prog_aux
*aux
)
2475 call_void_hook(bpf_prog_free_security
, aux
);
2477 #endif /* CONFIG_BPF_SYSCALL */