xref: /linux-6.15/include/linux/security.h (revision 870b7fdc)
1 /*
2  * Linux Security plug
3  *
4  * Copyright (C) 2001 WireX Communications, Inc <[email protected]>
5  * Copyright (C) 2001 Greg Kroah-Hartman <[email protected]>
6  * Copyright (C) 2001 Networks Associates Technology, Inc <[email protected]>
7  * Copyright (C) 2001 James Morris <[email protected]>
8  * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group)
9  * Copyright (C) 2016 Mellanox Techonologies
10  *
11  *	This program is free software; you can redistribute it and/or modify
12  *	it under the terms of the GNU General Public License as published by
13  *	the Free Software Foundation; either version 2 of the License, or
14  *	(at your option) any later version.
15  *
16  *	Due to this file being licensed under the GPL there is controversy over
17  *	whether this permits you to write a module that #includes this file
18  *	without placing your module under the GPL.  Please consult a lawyer for
19  *	advice before doing this.
20  *
21  */
22 
23 #ifndef __LINUX_SECURITY_H
24 #define __LINUX_SECURITY_H
25 
26 #include <linux/kernel_read_file.h>
27 #include <linux/key.h>
28 #include <linux/capability.h>
29 #include <linux/fs.h>
30 #include <linux/slab.h>
31 #include <linux/err.h>
32 #include <linux/string.h>
33 #include <linux/mm.h>
34 #include <linux/sockptr.h>
35 #include <linux/bpf.h>
36 #include <uapi/linux/lsm.h>
37 #include <linux/lsm/selinux.h>
38 #include <linux/lsm/smack.h>
39 #include <linux/lsm/apparmor.h>
40 #include <linux/lsm/bpf.h>
41 
42 struct linux_binprm;
43 struct cred;
44 struct rlimit;
45 struct kernel_siginfo;
46 struct sembuf;
47 struct kern_ipc_perm;
48 struct audit_context;
49 struct super_block;
50 struct inode;
51 struct dentry;
52 struct file;
53 struct vfsmount;
54 struct path;
55 struct qstr;
56 struct iattr;
57 struct fown_struct;
58 struct file_operations;
59 struct msg_msg;
60 struct xattr;
61 struct kernfs_node;
62 struct xfrm_sec_ctx;
63 struct mm_struct;
64 struct fs_context;
65 struct fs_parameter;
66 enum fs_value_type;
67 struct watch;
68 struct watch_notification;
69 struct lsm_ctx;
70 
71 /* Default (no) options for the capable function */
72 #define CAP_OPT_NONE 0x0
73 /* If capable should audit the security request */
74 #define CAP_OPT_NOAUDIT BIT(1)
75 /* If capable is being called by a setid function */
76 #define CAP_OPT_INSETID BIT(2)
77 
78 /* LSM Agnostic defines for security_sb_set_mnt_opts() flags */
79 #define SECURITY_LSM_NATIVE_LABELS	1
80 
81 struct ctl_table;
82 struct audit_krule;
83 struct user_namespace;
84 struct timezone;
85 
86 enum lsm_event {
87 	LSM_POLICY_CHANGE,
88 };
89 
90 struct dm_verity_digest {
91 	const char *alg;
92 	const u8 *digest;
93 	size_t digest_len;
94 };
95 
96 enum lsm_integrity_type {
97 	LSM_INT_DMVERITY_SIG_VALID,
98 	LSM_INT_DMVERITY_ROOTHASH,
99 	LSM_INT_FSVERITY_BUILTINSIG_VALID,
100 };
101 
102 /*
103  * These are reasons that can be passed to the security_locked_down()
104  * LSM hook. Lockdown reasons that protect kernel integrity (ie, the
105  * ability for userland to modify kernel code) are placed before
106  * LOCKDOWN_INTEGRITY_MAX.  Lockdown reasons that protect kernel
107  * confidentiality (ie, the ability for userland to extract
108  * information from the running kernel that would otherwise be
109  * restricted) are placed before LOCKDOWN_CONFIDENTIALITY_MAX.
110  *
111  * LSM authors should note that the semantics of any given lockdown
112  * reason are not guaranteed to be stable - the same reason may block
113  * one set of features in one kernel release, and a slightly different
114  * set of features in a later kernel release. LSMs that seek to expose
115  * lockdown policy at any level of granularity other than "none",
116  * "integrity" or "confidentiality" are responsible for either
117  * ensuring that they expose a consistent level of functionality to
118  * userland, or ensuring that userland is aware that this is
119  * potentially a moving target. It is easy to misuse this information
120  * in a way that could break userspace. Please be careful not to do
121  * so.
122  *
123  * If you add to this, remember to extend lockdown_reasons in
124  * security/lockdown/lockdown.c.
125  */
126 enum lockdown_reason {
127 	LOCKDOWN_NONE,
128 	LOCKDOWN_MODULE_SIGNATURE,
129 	LOCKDOWN_DEV_MEM,
130 	LOCKDOWN_EFI_TEST,
131 	LOCKDOWN_KEXEC,
132 	LOCKDOWN_HIBERNATION,
133 	LOCKDOWN_PCI_ACCESS,
134 	LOCKDOWN_IOPORT,
135 	LOCKDOWN_MSR,
136 	LOCKDOWN_ACPI_TABLES,
137 	LOCKDOWN_DEVICE_TREE,
138 	LOCKDOWN_PCMCIA_CIS,
139 	LOCKDOWN_TIOCSSERIAL,
140 	LOCKDOWN_MODULE_PARAMETERS,
141 	LOCKDOWN_MMIOTRACE,
142 	LOCKDOWN_DEBUGFS,
143 	LOCKDOWN_XMON_WR,
144 	LOCKDOWN_BPF_WRITE_USER,
145 	LOCKDOWN_DBG_WRITE_KERNEL,
146 	LOCKDOWN_RTAS_ERROR_INJECTION,
147 	LOCKDOWN_INTEGRITY_MAX,
148 	LOCKDOWN_KCORE,
149 	LOCKDOWN_KPROBES,
150 	LOCKDOWN_BPF_READ_KERNEL,
151 	LOCKDOWN_DBG_READ_KERNEL,
152 	LOCKDOWN_PERF,
153 	LOCKDOWN_TRACEFS,
154 	LOCKDOWN_XMON_RW,
155 	LOCKDOWN_XFRM_SECRET,
156 	LOCKDOWN_CONFIDENTIALITY_MAX,
157 };
158 
159 /* scaffolding */
160 struct lsm_prop_scaffold {
161 	u32 secid;
162 };
163 
164 /*
165  * Data exported by the security modules
166  */
167 struct lsm_prop {
168 	struct lsm_prop_selinux selinux;
169 	struct lsm_prop_smack smack;
170 	struct lsm_prop_apparmor apparmor;
171 	struct lsm_prop_bpf bpf;
172 	struct lsm_prop_scaffold scaffold;
173 };
174 
175 extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
176 extern u32 lsm_active_cnt;
177 extern const struct lsm_id *lsm_idlist[];
178 
179 /* These functions are in security/commoncap.c */
180 extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
181 		       int cap, unsigned int opts);
182 extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
183 extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
184 extern int cap_ptrace_traceme(struct task_struct *parent);
185 extern int cap_capget(const struct task_struct *target, kernel_cap_t *effective,
186 		      kernel_cap_t *inheritable, kernel_cap_t *permitted);
187 extern int cap_capset(struct cred *new, const struct cred *old,
188 		      const kernel_cap_t *effective,
189 		      const kernel_cap_t *inheritable,
190 		      const kernel_cap_t *permitted);
191 extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file);
192 int cap_inode_setxattr(struct dentry *dentry, const char *name,
193 		       const void *value, size_t size, int flags);
194 int cap_inode_removexattr(struct mnt_idmap *idmap,
195 			  struct dentry *dentry, const char *name);
196 int cap_inode_need_killpriv(struct dentry *dentry);
197 int cap_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
198 int cap_inode_getsecurity(struct mnt_idmap *idmap,
199 			  struct inode *inode, const char *name, void **buffer,
200 			  bool alloc);
201 extern int cap_mmap_addr(unsigned long addr);
202 extern int cap_mmap_file(struct file *file, unsigned long reqprot,
203 			 unsigned long prot, unsigned long flags);
204 extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
205 extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
206 			  unsigned long arg4, unsigned long arg5);
207 extern int cap_task_setscheduler(struct task_struct *p);
208 extern int cap_task_setioprio(struct task_struct *p, int ioprio);
209 extern int cap_task_setnice(struct task_struct *p, int nice);
210 extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
211 
212 struct msghdr;
213 struct sk_buff;
214 struct sock;
215 struct sockaddr;
216 struct socket;
217 struct flowi_common;
218 struct dst_entry;
219 struct xfrm_selector;
220 struct xfrm_policy;
221 struct xfrm_state;
222 struct xfrm_user_sec_ctx;
223 struct seq_file;
224 struct sctp_association;
225 
226 #ifdef CONFIG_MMU
227 extern unsigned long mmap_min_addr;
228 extern unsigned long dac_mmap_min_addr;
229 #else
230 #define mmap_min_addr		0UL
231 #define dac_mmap_min_addr	0UL
232 #endif
233 
234 /*
235  * Values used in the task_security_ops calls
236  */
237 /* setuid or setgid, id0 == uid or gid */
238 #define LSM_SETID_ID	1
239 
240 /* setreuid or setregid, id0 == real, id1 == eff */
241 #define LSM_SETID_RE	2
242 
243 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
244 #define LSM_SETID_RES	4
245 
246 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
247 #define LSM_SETID_FS	8
248 
249 /* Flags for security_task_prlimit(). */
250 #define LSM_PRLIMIT_READ  1
251 #define LSM_PRLIMIT_WRITE 2
252 
253 /* forward declares to avoid warnings */
254 struct sched_param;
255 struct request_sock;
256 
257 /* bprm->unsafe reasons */
258 #define LSM_UNSAFE_SHARE	1
259 #define LSM_UNSAFE_PTRACE	2
260 #define LSM_UNSAFE_NO_NEW_PRIVS	4
261 
262 #ifdef CONFIG_MMU
263 extern int mmap_min_addr_handler(const struct ctl_table *table, int write,
264 				 void *buffer, size_t *lenp, loff_t *ppos);
265 #endif
266 
267 /* security_inode_init_security callback function to write xattrs */
268 typedef int (*initxattrs) (struct inode *inode,
269 			   const struct xattr *xattr_array, void *fs_data);
270 
271 
272 /* Keep the kernel_load_data_id enum in sync with kernel_read_file_id */
273 #define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM,
274 #define __data_id_stringify(dummy, str) #str,
275 
276 enum kernel_load_data_id {
277 	__kernel_read_file_id(__data_id_enumify)
278 };
279 
280 static const char * const kernel_load_data_str[] = {
281 	__kernel_read_file_id(__data_id_stringify)
282 };
283 
284 static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
285 {
286 	if ((unsigned)id >= LOADING_MAX_ID)
287 		return kernel_load_data_str[LOADING_UNKNOWN];
288 
289 	return kernel_load_data_str[id];
290 }
291 
292 #ifdef CONFIG_SECURITY
293 
294 int call_blocking_lsm_notifier(enum lsm_event event, void *data);
295 int register_blocking_lsm_notifier(struct notifier_block *nb);
296 int unregister_blocking_lsm_notifier(struct notifier_block *nb);
297 
298 /* prototypes */
299 extern int security_init(void);
300 extern int early_security_init(void);
301 extern u64 lsm_name_to_attr(const char *name);
302 
303 /* Security operations */
304 int security_binder_set_context_mgr(const struct cred *mgr);
305 int security_binder_transaction(const struct cred *from,
306 				const struct cred *to);
307 int security_binder_transfer_binder(const struct cred *from,
308 				    const struct cred *to);
309 int security_binder_transfer_file(const struct cred *from,
310 				  const struct cred *to, const struct file *file);
311 int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
312 int security_ptrace_traceme(struct task_struct *parent);
313 int security_capget(const struct task_struct *target,
314 		    kernel_cap_t *effective,
315 		    kernel_cap_t *inheritable,
316 		    kernel_cap_t *permitted);
317 int security_capset(struct cred *new, const struct cred *old,
318 		    const kernel_cap_t *effective,
319 		    const kernel_cap_t *inheritable,
320 		    const kernel_cap_t *permitted);
321 int security_capable(const struct cred *cred,
322 		       struct user_namespace *ns,
323 		       int cap,
324 		       unsigned int opts);
325 int security_quotactl(int cmds, int type, int id, const struct super_block *sb);
326 int security_quota_on(struct dentry *dentry);
327 int security_syslog(int type);
328 int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
329 int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
330 int security_bprm_creds_for_exec(struct linux_binprm *bprm);
331 int security_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file);
332 int security_bprm_check(struct linux_binprm *bprm);
333 void security_bprm_committing_creds(const struct linux_binprm *bprm);
334 void security_bprm_committed_creds(const struct linux_binprm *bprm);
335 int security_fs_context_submount(struct fs_context *fc, struct super_block *reference);
336 int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc);
337 int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
338 int security_sb_alloc(struct super_block *sb);
339 void security_sb_delete(struct super_block *sb);
340 void security_sb_free(struct super_block *sb);
341 void security_free_mnt_opts(void **mnt_opts);
342 int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
343 int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
344 int security_sb_remount(struct super_block *sb, void *mnt_opts);
345 int security_sb_kern_mount(const struct super_block *sb);
346 int security_sb_show_options(struct seq_file *m, struct super_block *sb);
347 int security_sb_statfs(struct dentry *dentry);
348 int security_sb_mount(const char *dev_name, const struct path *path,
349 		      const char *type, unsigned long flags, void *data);
350 int security_sb_umount(struct vfsmount *mnt, int flags);
351 int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
352 int security_sb_set_mnt_opts(struct super_block *sb,
353 				void *mnt_opts,
354 				unsigned long kern_flags,
355 				unsigned long *set_kern_flags);
356 int security_sb_clone_mnt_opts(const struct super_block *oldsb,
357 				struct super_block *newsb,
358 				unsigned long kern_flags,
359 				unsigned long *set_kern_flags);
360 int security_move_mount(const struct path *from_path, const struct path *to_path);
361 int security_dentry_init_security(struct dentry *dentry, int mode,
362 				  const struct qstr *name,
363 				  const char **xattr_name, void **ctx,
364 				  u32 *ctxlen);
365 int security_dentry_create_files_as(struct dentry *dentry, int mode,
366 					struct qstr *name,
367 					const struct cred *old,
368 					struct cred *new);
369 int security_path_notify(const struct path *path, u64 mask,
370 					unsigned int obj_type);
371 int security_inode_alloc(struct inode *inode);
372 void security_inode_free(struct inode *inode);
373 int security_inode_init_security(struct inode *inode, struct inode *dir,
374 				 const struct qstr *qstr,
375 				 initxattrs initxattrs, void *fs_data);
376 int security_inode_init_security_anon(struct inode *inode,
377 				      const struct qstr *name,
378 				      const struct inode *context_inode);
379 int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
380 void security_inode_post_create_tmpfile(struct mnt_idmap *idmap,
381 					struct inode *inode);
382 int security_inode_link(struct dentry *old_dentry, struct inode *dir,
383 			 struct dentry *new_dentry);
384 int security_inode_unlink(struct inode *dir, struct dentry *dentry);
385 int security_inode_symlink(struct inode *dir, struct dentry *dentry,
386 			   const char *old_name);
387 int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
388 int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
389 int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
390 int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
391 			  struct inode *new_dir, struct dentry *new_dentry,
392 			  unsigned int flags);
393 int security_inode_readlink(struct dentry *dentry);
394 int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
395 			       bool rcu);
396 int security_inode_permission(struct inode *inode, int mask);
397 int security_inode_setattr(struct mnt_idmap *idmap,
398 			   struct dentry *dentry, struct iattr *attr);
399 void security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
400 				 int ia_valid);
401 int security_inode_getattr(const struct path *path);
402 int security_inode_setxattr(struct mnt_idmap *idmap,
403 			    struct dentry *dentry, const char *name,
404 			    const void *value, size_t size, int flags);
405 int security_inode_set_acl(struct mnt_idmap *idmap,
406 			   struct dentry *dentry, const char *acl_name,
407 			   struct posix_acl *kacl);
408 void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,
409 				 struct posix_acl *kacl);
410 int security_inode_get_acl(struct mnt_idmap *idmap,
411 			   struct dentry *dentry, const char *acl_name);
412 int security_inode_remove_acl(struct mnt_idmap *idmap,
413 			      struct dentry *dentry, const char *acl_name);
414 void security_inode_post_remove_acl(struct mnt_idmap *idmap,
415 				    struct dentry *dentry,
416 				    const char *acl_name);
417 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
418 				  const void *value, size_t size, int flags);
419 int security_inode_getxattr(struct dentry *dentry, const char *name);
420 int security_inode_listxattr(struct dentry *dentry);
421 int security_inode_removexattr(struct mnt_idmap *idmap,
422 			       struct dentry *dentry, const char *name);
423 void security_inode_post_removexattr(struct dentry *dentry, const char *name);
424 int security_inode_need_killpriv(struct dentry *dentry);
425 int security_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
426 int security_inode_getsecurity(struct mnt_idmap *idmap,
427 			       struct inode *inode, const char *name,
428 			       void **buffer, bool alloc);
429 int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
430 int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
431 void security_inode_getsecid(struct inode *inode, u32 *secid);
432 int security_inode_copy_up(struct dentry *src, struct cred **new);
433 int security_inode_copy_up_xattr(struct dentry *src, const char *name);
434 int security_inode_setintegrity(const struct inode *inode,
435 				enum lsm_integrity_type type, const void *value,
436 				size_t size);
437 int security_kernfs_init_security(struct kernfs_node *kn_dir,
438 				  struct kernfs_node *kn);
439 int security_file_permission(struct file *file, int mask);
440 int security_file_alloc(struct file *file);
441 void security_file_release(struct file *file);
442 void security_file_free(struct file *file);
443 int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
444 int security_file_ioctl_compat(struct file *file, unsigned int cmd,
445 			       unsigned long arg);
446 int security_mmap_file(struct file *file, unsigned long prot,
447 			unsigned long flags);
448 int security_mmap_addr(unsigned long addr);
449 int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
450 			   unsigned long prot);
451 int security_file_lock(struct file *file, unsigned int cmd);
452 int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
453 void security_file_set_fowner(struct file *file);
454 int security_file_send_sigiotask(struct task_struct *tsk,
455 				 struct fown_struct *fown, int sig);
456 int security_file_receive(struct file *file);
457 int security_file_open(struct file *file);
458 int security_file_post_open(struct file *file, int mask);
459 int security_file_truncate(struct file *file);
460 int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
461 void security_task_free(struct task_struct *task);
462 int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
463 void security_cred_free(struct cred *cred);
464 int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
465 void security_transfer_creds(struct cred *new, const struct cred *old);
466 void security_cred_getsecid(const struct cred *c, u32 *secid);
467 int security_kernel_act_as(struct cred *new, u32 secid);
468 int security_kernel_create_files_as(struct cred *new, struct inode *inode);
469 int security_kernel_module_request(char *kmod_name);
470 int security_kernel_load_data(enum kernel_load_data_id id, bool contents);
471 int security_kernel_post_load_data(char *buf, loff_t size,
472 				   enum kernel_load_data_id id,
473 				   char *description);
474 int security_kernel_read_file(struct file *file, enum kernel_read_file_id id,
475 			      bool contents);
476 int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
477 				   enum kernel_read_file_id id);
478 int security_task_fix_setuid(struct cred *new, const struct cred *old,
479 			     int flags);
480 int security_task_fix_setgid(struct cred *new, const struct cred *old,
481 			     int flags);
482 int security_task_fix_setgroups(struct cred *new, const struct cred *old);
483 int security_task_setpgid(struct task_struct *p, pid_t pgid);
484 int security_task_getpgid(struct task_struct *p);
485 int security_task_getsid(struct task_struct *p);
486 void security_current_getsecid_subj(u32 *secid);
487 void security_task_getsecid_obj(struct task_struct *p, u32 *secid);
488 int security_task_setnice(struct task_struct *p, int nice);
489 int security_task_setioprio(struct task_struct *p, int ioprio);
490 int security_task_getioprio(struct task_struct *p);
491 int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
492 			  unsigned int flags);
493 int security_task_setrlimit(struct task_struct *p, unsigned int resource,
494 		struct rlimit *new_rlim);
495 int security_task_setscheduler(struct task_struct *p);
496 int security_task_getscheduler(struct task_struct *p);
497 int security_task_movememory(struct task_struct *p);
498 int security_task_kill(struct task_struct *p, struct kernel_siginfo *info,
499 			int sig, const struct cred *cred);
500 int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
501 			unsigned long arg4, unsigned long arg5);
502 void security_task_to_inode(struct task_struct *p, struct inode *inode);
503 int security_create_user_ns(const struct cred *cred);
504 int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
505 void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
506 int security_msg_msg_alloc(struct msg_msg *msg);
507 void security_msg_msg_free(struct msg_msg *msg);
508 int security_msg_queue_alloc(struct kern_ipc_perm *msq);
509 void security_msg_queue_free(struct kern_ipc_perm *msq);
510 int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg);
511 int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd);
512 int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
513 			      struct msg_msg *msg, int msqflg);
514 int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg,
515 			      struct task_struct *target, long type, int mode);
516 int security_shm_alloc(struct kern_ipc_perm *shp);
517 void security_shm_free(struct kern_ipc_perm *shp);
518 int security_shm_associate(struct kern_ipc_perm *shp, int shmflg);
519 int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd);
520 int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg);
521 int security_sem_alloc(struct kern_ipc_perm *sma);
522 void security_sem_free(struct kern_ipc_perm *sma);
523 int security_sem_associate(struct kern_ipc_perm *sma, int semflg);
524 int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
525 int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
526 			unsigned nsops, int alter);
527 void security_d_instantiate(struct dentry *dentry, struct inode *inode);
528 int security_getselfattr(unsigned int attr, struct lsm_ctx __user *ctx,
529 			 u32 __user *size, u32 flags);
530 int security_setselfattr(unsigned int attr, struct lsm_ctx __user *ctx,
531 			 u32 size, u32 flags);
532 int security_getprocattr(struct task_struct *p, int lsmid, const char *name,
533 			 char **value);
534 int security_setprocattr(int lsmid, const char *name, void *value, size_t size);
535 int security_netlink_send(struct sock *sk, struct sk_buff *skb);
536 int security_ismaclabel(const char *name);
537 int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
538 int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
539 void security_release_secctx(char *secdata, u32 seclen);
540 void security_inode_invalidate_secctx(struct inode *inode);
541 int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
542 int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
543 int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
544 int security_locked_down(enum lockdown_reason what);
545 int lsm_fill_user_ctx(struct lsm_ctx __user *uctx, u32 *uctx_len,
546 		      void *val, size_t val_len, u64 id, u64 flags);
547 int security_bdev_alloc(struct block_device *bdev);
548 void security_bdev_free(struct block_device *bdev);
549 int security_bdev_setintegrity(struct block_device *bdev,
550 			       enum lsm_integrity_type type, const void *value,
551 			       size_t size);
552 #else /* CONFIG_SECURITY */
553 
554 static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data)
555 {
556 	return 0;
557 }
558 
559 static inline int register_blocking_lsm_notifier(struct notifier_block *nb)
560 {
561 	return 0;
562 }
563 
564 static inline  int unregister_blocking_lsm_notifier(struct notifier_block *nb)
565 {
566 	return 0;
567 }
568 
569 static inline u64 lsm_name_to_attr(const char *name)
570 {
571 	return LSM_ATTR_UNDEF;
572 }
573 
574 static inline void security_free_mnt_opts(void **mnt_opts)
575 {
576 }
577 
578 /*
579  * This is the default capabilities functionality.  Most of these functions
580  * are just stubbed out, but a few must call the proper capable code.
581  */
582 
583 static inline int security_init(void)
584 {
585 	return 0;
586 }
587 
588 static inline int early_security_init(void)
589 {
590 	return 0;
591 }
592 
593 static inline int security_binder_set_context_mgr(const struct cred *mgr)
594 {
595 	return 0;
596 }
597 
598 static inline int security_binder_transaction(const struct cred *from,
599 					      const struct cred *to)
600 {
601 	return 0;
602 }
603 
604 static inline int security_binder_transfer_binder(const struct cred *from,
605 						  const struct cred *to)
606 {
607 	return 0;
608 }
609 
610 static inline int security_binder_transfer_file(const struct cred *from,
611 						const struct cred *to,
612 						const struct file *file)
613 {
614 	return 0;
615 }
616 
617 static inline int security_ptrace_access_check(struct task_struct *child,
618 					     unsigned int mode)
619 {
620 	return cap_ptrace_access_check(child, mode);
621 }
622 
623 static inline int security_ptrace_traceme(struct task_struct *parent)
624 {
625 	return cap_ptrace_traceme(parent);
626 }
627 
628 static inline int security_capget(const struct task_struct *target,
629 				   kernel_cap_t *effective,
630 				   kernel_cap_t *inheritable,
631 				   kernel_cap_t *permitted)
632 {
633 	return cap_capget(target, effective, inheritable, permitted);
634 }
635 
636 static inline int security_capset(struct cred *new,
637 				   const struct cred *old,
638 				   const kernel_cap_t *effective,
639 				   const kernel_cap_t *inheritable,
640 				   const kernel_cap_t *permitted)
641 {
642 	return cap_capset(new, old, effective, inheritable, permitted);
643 }
644 
645 static inline int security_capable(const struct cred *cred,
646 				   struct user_namespace *ns,
647 				   int cap,
648 				   unsigned int opts)
649 {
650 	return cap_capable(cred, ns, cap, opts);
651 }
652 
653 static inline int security_quotactl(int cmds, int type, int id,
654 				     const struct super_block *sb)
655 {
656 	return 0;
657 }
658 
659 static inline int security_quota_on(struct dentry *dentry)
660 {
661 	return 0;
662 }
663 
664 static inline int security_syslog(int type)
665 {
666 	return 0;
667 }
668 
669 static inline int security_settime64(const struct timespec64 *ts,
670 				     const struct timezone *tz)
671 {
672 	return cap_settime(ts, tz);
673 }
674 
675 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
676 {
677 	return __vm_enough_memory(mm, pages, !cap_vm_enough_memory(mm, pages));
678 }
679 
680 static inline int security_bprm_creds_for_exec(struct linux_binprm *bprm)
681 {
682 	return 0;
683 }
684 
685 static inline int security_bprm_creds_from_file(struct linux_binprm *bprm,
686 						const struct file *file)
687 {
688 	return cap_bprm_creds_from_file(bprm, file);
689 }
690 
691 static inline int security_bprm_check(struct linux_binprm *bprm)
692 {
693 	return 0;
694 }
695 
696 static inline void security_bprm_committing_creds(const struct linux_binprm *bprm)
697 {
698 }
699 
700 static inline void security_bprm_committed_creds(const struct linux_binprm *bprm)
701 {
702 }
703 
704 static inline int security_fs_context_submount(struct fs_context *fc,
705 					   struct super_block *reference)
706 {
707 	return 0;
708 }
709 static inline int security_fs_context_dup(struct fs_context *fc,
710 					  struct fs_context *src_fc)
711 {
712 	return 0;
713 }
714 static inline int security_fs_context_parse_param(struct fs_context *fc,
715 						  struct fs_parameter *param)
716 {
717 	return -ENOPARAM;
718 }
719 
720 static inline int security_sb_alloc(struct super_block *sb)
721 {
722 	return 0;
723 }
724 
725 static inline void security_sb_delete(struct super_block *sb)
726 { }
727 
728 static inline void security_sb_free(struct super_block *sb)
729 { }
730 
731 static inline int security_sb_eat_lsm_opts(char *options,
732 					   void **mnt_opts)
733 {
734 	return 0;
735 }
736 
737 static inline int security_sb_remount(struct super_block *sb,
738 				      void *mnt_opts)
739 {
740 	return 0;
741 }
742 
743 static inline int security_sb_mnt_opts_compat(struct super_block *sb,
744 					      void *mnt_opts)
745 {
746 	return 0;
747 }
748 
749 
750 static inline int security_sb_kern_mount(struct super_block *sb)
751 {
752 	return 0;
753 }
754 
755 static inline int security_sb_show_options(struct seq_file *m,
756 					   struct super_block *sb)
757 {
758 	return 0;
759 }
760 
761 static inline int security_sb_statfs(struct dentry *dentry)
762 {
763 	return 0;
764 }
765 
766 static inline int security_sb_mount(const char *dev_name, const struct path *path,
767 				    const char *type, unsigned long flags,
768 				    void *data)
769 {
770 	return 0;
771 }
772 
773 static inline int security_sb_umount(struct vfsmount *mnt, int flags)
774 {
775 	return 0;
776 }
777 
778 static inline int security_sb_pivotroot(const struct path *old_path,
779 					const struct path *new_path)
780 {
781 	return 0;
782 }
783 
784 static inline int security_sb_set_mnt_opts(struct super_block *sb,
785 					   void *mnt_opts,
786 					   unsigned long kern_flags,
787 					   unsigned long *set_kern_flags)
788 {
789 	return 0;
790 }
791 
792 static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
793 					      struct super_block *newsb,
794 					      unsigned long kern_flags,
795 					      unsigned long *set_kern_flags)
796 {
797 	return 0;
798 }
799 
800 static inline int security_move_mount(const struct path *from_path,
801 				      const struct path *to_path)
802 {
803 	return 0;
804 }
805 
806 static inline int security_path_notify(const struct path *path, u64 mask,
807 				unsigned int obj_type)
808 {
809 	return 0;
810 }
811 
812 static inline int security_inode_alloc(struct inode *inode)
813 {
814 	return 0;
815 }
816 
817 static inline void security_inode_free(struct inode *inode)
818 { }
819 
820 static inline int security_dentry_init_security(struct dentry *dentry,
821 						 int mode,
822 						 const struct qstr *name,
823 						 const char **xattr_name,
824 						 void **ctx,
825 						 u32 *ctxlen)
826 {
827 	return -EOPNOTSUPP;
828 }
829 
830 static inline int security_dentry_create_files_as(struct dentry *dentry,
831 						  int mode, struct qstr *name,
832 						  const struct cred *old,
833 						  struct cred *new)
834 {
835 	return 0;
836 }
837 
838 
839 static inline int security_inode_init_security(struct inode *inode,
840 						struct inode *dir,
841 						const struct qstr *qstr,
842 						const initxattrs xattrs,
843 						void *fs_data)
844 {
845 	return 0;
846 }
847 
848 static inline int security_inode_init_security_anon(struct inode *inode,
849 						    const struct qstr *name,
850 						    const struct inode *context_inode)
851 {
852 	return 0;
853 }
854 
855 static inline int security_inode_create(struct inode *dir,
856 					 struct dentry *dentry,
857 					 umode_t mode)
858 {
859 	return 0;
860 }
861 
862 static inline void
863 security_inode_post_create_tmpfile(struct mnt_idmap *idmap, struct inode *inode)
864 { }
865 
866 static inline int security_inode_link(struct dentry *old_dentry,
867 				       struct inode *dir,
868 				       struct dentry *new_dentry)
869 {
870 	return 0;
871 }
872 
873 static inline int security_inode_unlink(struct inode *dir,
874 					 struct dentry *dentry)
875 {
876 	return 0;
877 }
878 
879 static inline int security_inode_symlink(struct inode *dir,
880 					  struct dentry *dentry,
881 					  const char *old_name)
882 {
883 	return 0;
884 }
885 
886 static inline int security_inode_mkdir(struct inode *dir,
887 					struct dentry *dentry,
888 					int mode)
889 {
890 	return 0;
891 }
892 
893 static inline int security_inode_rmdir(struct inode *dir,
894 					struct dentry *dentry)
895 {
896 	return 0;
897 }
898 
899 static inline int security_inode_mknod(struct inode *dir,
900 					struct dentry *dentry,
901 					int mode, dev_t dev)
902 {
903 	return 0;
904 }
905 
906 static inline int security_inode_rename(struct inode *old_dir,
907 					 struct dentry *old_dentry,
908 					 struct inode *new_dir,
909 					 struct dentry *new_dentry,
910 					 unsigned int flags)
911 {
912 	return 0;
913 }
914 
915 static inline int security_inode_readlink(struct dentry *dentry)
916 {
917 	return 0;
918 }
919 
920 static inline int security_inode_follow_link(struct dentry *dentry,
921 					     struct inode *inode,
922 					     bool rcu)
923 {
924 	return 0;
925 }
926 
927 static inline int security_inode_permission(struct inode *inode, int mask)
928 {
929 	return 0;
930 }
931 
932 static inline int security_inode_setattr(struct mnt_idmap *idmap,
933 					 struct dentry *dentry,
934 					 struct iattr *attr)
935 {
936 	return 0;
937 }
938 
939 static inline void
940 security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
941 			    int ia_valid)
942 { }
943 
944 static inline int security_inode_getattr(const struct path *path)
945 {
946 	return 0;
947 }
948 
949 static inline int security_inode_setxattr(struct mnt_idmap *idmap,
950 		struct dentry *dentry, const char *name, const void *value,
951 		size_t size, int flags)
952 {
953 	return cap_inode_setxattr(dentry, name, value, size, flags);
954 }
955 
956 static inline int security_inode_set_acl(struct mnt_idmap *idmap,
957 					 struct dentry *dentry,
958 					 const char *acl_name,
959 					 struct posix_acl *kacl)
960 {
961 	return 0;
962 }
963 
964 static inline void security_inode_post_set_acl(struct dentry *dentry,
965 					       const char *acl_name,
966 					       struct posix_acl *kacl)
967 { }
968 
969 static inline int security_inode_get_acl(struct mnt_idmap *idmap,
970 					 struct dentry *dentry,
971 					 const char *acl_name)
972 {
973 	return 0;
974 }
975 
976 static inline int security_inode_remove_acl(struct mnt_idmap *idmap,
977 					    struct dentry *dentry,
978 					    const char *acl_name)
979 {
980 	return 0;
981 }
982 
983 static inline void security_inode_post_remove_acl(struct mnt_idmap *idmap,
984 						  struct dentry *dentry,
985 						  const char *acl_name)
986 { }
987 
988 static inline void security_inode_post_setxattr(struct dentry *dentry,
989 		const char *name, const void *value, size_t size, int flags)
990 { }
991 
992 static inline int security_inode_getxattr(struct dentry *dentry,
993 			const char *name)
994 {
995 	return 0;
996 }
997 
998 static inline int security_inode_listxattr(struct dentry *dentry)
999 {
1000 	return 0;
1001 }
1002 
1003 static inline int security_inode_removexattr(struct mnt_idmap *idmap,
1004 					     struct dentry *dentry,
1005 					     const char *name)
1006 {
1007 	return cap_inode_removexattr(idmap, dentry, name);
1008 }
1009 
1010 static inline void security_inode_post_removexattr(struct dentry *dentry,
1011 						   const char *name)
1012 { }
1013 
1014 static inline int security_inode_need_killpriv(struct dentry *dentry)
1015 {
1016 	return cap_inode_need_killpriv(dentry);
1017 }
1018 
1019 static inline int security_inode_killpriv(struct mnt_idmap *idmap,
1020 					  struct dentry *dentry)
1021 {
1022 	return cap_inode_killpriv(idmap, dentry);
1023 }
1024 
1025 static inline int security_inode_getsecurity(struct mnt_idmap *idmap,
1026 					     struct inode *inode,
1027 					     const char *name, void **buffer,
1028 					     bool alloc)
1029 {
1030 	return cap_inode_getsecurity(idmap, inode, name, buffer, alloc);
1031 }
1032 
1033 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1034 {
1035 	return -EOPNOTSUPP;
1036 }
1037 
1038 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1039 {
1040 	return 0;
1041 }
1042 
1043 static inline void security_inode_getsecid(struct inode *inode, u32 *secid)
1044 {
1045 	*secid = 0;
1046 }
1047 
1048 static inline int security_inode_copy_up(struct dentry *src, struct cred **new)
1049 {
1050 	return 0;
1051 }
1052 
1053 static inline int security_inode_setintegrity(const struct inode *inode,
1054 					      enum lsm_integrity_type type,
1055 					      const void *value, size_t size)
1056 {
1057 	return 0;
1058 }
1059 
1060 static inline int security_kernfs_init_security(struct kernfs_node *kn_dir,
1061 						struct kernfs_node *kn)
1062 {
1063 	return 0;
1064 }
1065 
1066 static inline int security_inode_copy_up_xattr(struct dentry *src, const char *name)
1067 {
1068 	return -EOPNOTSUPP;
1069 }
1070 
1071 static inline int security_file_permission(struct file *file, int mask)
1072 {
1073 	return 0;
1074 }
1075 
1076 static inline int security_file_alloc(struct file *file)
1077 {
1078 	return 0;
1079 }
1080 
1081 static inline void security_file_release(struct file *file)
1082 { }
1083 
1084 static inline void security_file_free(struct file *file)
1085 { }
1086 
1087 static inline int security_file_ioctl(struct file *file, unsigned int cmd,
1088 				      unsigned long arg)
1089 {
1090 	return 0;
1091 }
1092 
1093 static inline int security_file_ioctl_compat(struct file *file,
1094 					     unsigned int cmd,
1095 					     unsigned long arg)
1096 {
1097 	return 0;
1098 }
1099 
1100 static inline int security_mmap_file(struct file *file, unsigned long prot,
1101 				     unsigned long flags)
1102 {
1103 	return 0;
1104 }
1105 
1106 static inline int security_mmap_addr(unsigned long addr)
1107 {
1108 	return cap_mmap_addr(addr);
1109 }
1110 
1111 static inline int security_file_mprotect(struct vm_area_struct *vma,
1112 					 unsigned long reqprot,
1113 					 unsigned long prot)
1114 {
1115 	return 0;
1116 }
1117 
1118 static inline int security_file_lock(struct file *file, unsigned int cmd)
1119 {
1120 	return 0;
1121 }
1122 
1123 static inline int security_file_fcntl(struct file *file, unsigned int cmd,
1124 				      unsigned long arg)
1125 {
1126 	return 0;
1127 }
1128 
1129 static inline void security_file_set_fowner(struct file *file)
1130 {
1131 	return;
1132 }
1133 
1134 static inline int security_file_send_sigiotask(struct task_struct *tsk,
1135 					       struct fown_struct *fown,
1136 					       int sig)
1137 {
1138 	return 0;
1139 }
1140 
1141 static inline int security_file_receive(struct file *file)
1142 {
1143 	return 0;
1144 }
1145 
1146 static inline int security_file_open(struct file *file)
1147 {
1148 	return 0;
1149 }
1150 
1151 static inline int security_file_post_open(struct file *file, int mask)
1152 {
1153 	return 0;
1154 }
1155 
1156 static inline int security_file_truncate(struct file *file)
1157 {
1158 	return 0;
1159 }
1160 
1161 static inline int security_task_alloc(struct task_struct *task,
1162 				      unsigned long clone_flags)
1163 {
1164 	return 0;
1165 }
1166 
1167 static inline void security_task_free(struct task_struct *task)
1168 { }
1169 
1170 static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
1171 {
1172 	return 0;
1173 }
1174 
1175 static inline void security_cred_free(struct cred *cred)
1176 { }
1177 
1178 static inline int security_prepare_creds(struct cred *new,
1179 					 const struct cred *old,
1180 					 gfp_t gfp)
1181 {
1182 	return 0;
1183 }
1184 
1185 static inline void security_transfer_creds(struct cred *new,
1186 					   const struct cred *old)
1187 {
1188 }
1189 
1190 static inline void security_cred_getsecid(const struct cred *c, u32 *secid)
1191 {
1192 	*secid = 0;
1193 }
1194 
1195 static inline int security_kernel_act_as(struct cred *cred, u32 secid)
1196 {
1197 	return 0;
1198 }
1199 
1200 static inline int security_kernel_create_files_as(struct cred *cred,
1201 						  struct inode *inode)
1202 {
1203 	return 0;
1204 }
1205 
1206 static inline int security_kernel_module_request(char *kmod_name)
1207 {
1208 	return 0;
1209 }
1210 
1211 static inline int security_kernel_load_data(enum kernel_load_data_id id, bool contents)
1212 {
1213 	return 0;
1214 }
1215 
1216 static inline int security_kernel_post_load_data(char *buf, loff_t size,
1217 						 enum kernel_load_data_id id,
1218 						 char *description)
1219 {
1220 	return 0;
1221 }
1222 
1223 static inline int security_kernel_read_file(struct file *file,
1224 					    enum kernel_read_file_id id,
1225 					    bool contents)
1226 {
1227 	return 0;
1228 }
1229 
1230 static inline int security_kernel_post_read_file(struct file *file,
1231 						 char *buf, loff_t size,
1232 						 enum kernel_read_file_id id)
1233 {
1234 	return 0;
1235 }
1236 
1237 static inline int security_task_fix_setuid(struct cred *new,
1238 					   const struct cred *old,
1239 					   int flags)
1240 {
1241 	return cap_task_fix_setuid(new, old, flags);
1242 }
1243 
1244 static inline int security_task_fix_setgid(struct cred *new,
1245 					   const struct cred *old,
1246 					   int flags)
1247 {
1248 	return 0;
1249 }
1250 
1251 static inline int security_task_fix_setgroups(struct cred *new,
1252 					   const struct cred *old)
1253 {
1254 	return 0;
1255 }
1256 
1257 static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
1258 {
1259 	return 0;
1260 }
1261 
1262 static inline int security_task_getpgid(struct task_struct *p)
1263 {
1264 	return 0;
1265 }
1266 
1267 static inline int security_task_getsid(struct task_struct *p)
1268 {
1269 	return 0;
1270 }
1271 
1272 static inline void security_current_getsecid_subj(u32 *secid)
1273 {
1274 	*secid = 0;
1275 }
1276 
1277 static inline void security_task_getsecid_obj(struct task_struct *p, u32 *secid)
1278 {
1279 	*secid = 0;
1280 }
1281 
1282 static inline int security_task_setnice(struct task_struct *p, int nice)
1283 {
1284 	return cap_task_setnice(p, nice);
1285 }
1286 
1287 static inline int security_task_setioprio(struct task_struct *p, int ioprio)
1288 {
1289 	return cap_task_setioprio(p, ioprio);
1290 }
1291 
1292 static inline int security_task_getioprio(struct task_struct *p)
1293 {
1294 	return 0;
1295 }
1296 
1297 static inline int security_task_prlimit(const struct cred *cred,
1298 					const struct cred *tcred,
1299 					unsigned int flags)
1300 {
1301 	return 0;
1302 }
1303 
1304 static inline int security_task_setrlimit(struct task_struct *p,
1305 					  unsigned int resource,
1306 					  struct rlimit *new_rlim)
1307 {
1308 	return 0;
1309 }
1310 
1311 static inline int security_task_setscheduler(struct task_struct *p)
1312 {
1313 	return cap_task_setscheduler(p);
1314 }
1315 
1316 static inline int security_task_getscheduler(struct task_struct *p)
1317 {
1318 	return 0;
1319 }
1320 
1321 static inline int security_task_movememory(struct task_struct *p)
1322 {
1323 	return 0;
1324 }
1325 
1326 static inline int security_task_kill(struct task_struct *p,
1327 				     struct kernel_siginfo *info, int sig,
1328 				     const struct cred *cred)
1329 {
1330 	return 0;
1331 }
1332 
1333 static inline int security_task_prctl(int option, unsigned long arg2,
1334 				      unsigned long arg3,
1335 				      unsigned long arg4,
1336 				      unsigned long arg5)
1337 {
1338 	return cap_task_prctl(option, arg2, arg3, arg4, arg5);
1339 }
1340 
1341 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1342 { }
1343 
1344 static inline int security_create_user_ns(const struct cred *cred)
1345 {
1346 	return 0;
1347 }
1348 
1349 static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
1350 					  short flag)
1351 {
1352 	return 0;
1353 }
1354 
1355 static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
1356 {
1357 	*secid = 0;
1358 }
1359 
1360 static inline int security_msg_msg_alloc(struct msg_msg *msg)
1361 {
1362 	return 0;
1363 }
1364 
1365 static inline void security_msg_msg_free(struct msg_msg *msg)
1366 { }
1367 
1368 static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq)
1369 {
1370 	return 0;
1371 }
1372 
1373 static inline void security_msg_queue_free(struct kern_ipc_perm *msq)
1374 { }
1375 
1376 static inline int security_msg_queue_associate(struct kern_ipc_perm *msq,
1377 					       int msqflg)
1378 {
1379 	return 0;
1380 }
1381 
1382 static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd)
1383 {
1384 	return 0;
1385 }
1386 
1387 static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
1388 					    struct msg_msg *msg, int msqflg)
1389 {
1390 	return 0;
1391 }
1392 
1393 static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq,
1394 					    struct msg_msg *msg,
1395 					    struct task_struct *target,
1396 					    long type, int mode)
1397 {
1398 	return 0;
1399 }
1400 
1401 static inline int security_shm_alloc(struct kern_ipc_perm *shp)
1402 {
1403 	return 0;
1404 }
1405 
1406 static inline void security_shm_free(struct kern_ipc_perm *shp)
1407 { }
1408 
1409 static inline int security_shm_associate(struct kern_ipc_perm *shp,
1410 					 int shmflg)
1411 {
1412 	return 0;
1413 }
1414 
1415 static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd)
1416 {
1417 	return 0;
1418 }
1419 
1420 static inline int security_shm_shmat(struct kern_ipc_perm *shp,
1421 				     char __user *shmaddr, int shmflg)
1422 {
1423 	return 0;
1424 }
1425 
1426 static inline int security_sem_alloc(struct kern_ipc_perm *sma)
1427 {
1428 	return 0;
1429 }
1430 
1431 static inline void security_sem_free(struct kern_ipc_perm *sma)
1432 { }
1433 
1434 static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg)
1435 {
1436 	return 0;
1437 }
1438 
1439 static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd)
1440 {
1441 	return 0;
1442 }
1443 
1444 static inline int security_sem_semop(struct kern_ipc_perm *sma,
1445 				     struct sembuf *sops, unsigned nsops,
1446 				     int alter)
1447 {
1448 	return 0;
1449 }
1450 
1451 static inline void security_d_instantiate(struct dentry *dentry,
1452 					  struct inode *inode)
1453 { }
1454 
1455 static inline int security_getselfattr(unsigned int attr,
1456 				       struct lsm_ctx __user *ctx,
1457 				       size_t __user *size, u32 flags)
1458 {
1459 	return -EOPNOTSUPP;
1460 }
1461 
1462 static inline int security_setselfattr(unsigned int attr,
1463 				       struct lsm_ctx __user *ctx,
1464 				       size_t size, u32 flags)
1465 {
1466 	return -EOPNOTSUPP;
1467 }
1468 
1469 static inline int security_getprocattr(struct task_struct *p, int lsmid,
1470 				       const char *name, char **value)
1471 {
1472 	return -EINVAL;
1473 }
1474 
1475 static inline int security_setprocattr(int lsmid, char *name, void *value,
1476 				       size_t size)
1477 {
1478 	return -EINVAL;
1479 }
1480 
1481 static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
1482 {
1483 	return 0;
1484 }
1485 
1486 static inline int security_ismaclabel(const char *name)
1487 {
1488 	return 0;
1489 }
1490 
1491 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
1492 {
1493 	return -EOPNOTSUPP;
1494 }
1495 
1496 static inline int security_secctx_to_secid(const char *secdata,
1497 					   u32 seclen,
1498 					   u32 *secid)
1499 {
1500 	return -EOPNOTSUPP;
1501 }
1502 
1503 static inline void security_release_secctx(char *secdata, u32 seclen)
1504 {
1505 }
1506 
1507 static inline void security_inode_invalidate_secctx(struct inode *inode)
1508 {
1509 }
1510 
1511 static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
1512 {
1513 	return -EOPNOTSUPP;
1514 }
1515 static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
1516 {
1517 	return -EOPNOTSUPP;
1518 }
1519 static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
1520 {
1521 	return -EOPNOTSUPP;
1522 }
1523 static inline int security_locked_down(enum lockdown_reason what)
1524 {
1525 	return 0;
1526 }
1527 static inline int lsm_fill_user_ctx(struct lsm_ctx __user *uctx,
1528 				    u32 *uctx_len, void *val, size_t val_len,
1529 				    u64 id, u64 flags)
1530 {
1531 	return -EOPNOTSUPP;
1532 }
1533 
1534 static inline int security_bdev_alloc(struct block_device *bdev)
1535 {
1536 	return 0;
1537 }
1538 
1539 static inline void security_bdev_free(struct block_device *bdev)
1540 {
1541 }
1542 
1543 static inline int security_bdev_setintegrity(struct block_device *bdev,
1544 					     enum lsm_integrity_type type,
1545 					     const void *value, size_t size)
1546 {
1547 	return 0;
1548 }
1549 
1550 #endif	/* CONFIG_SECURITY */
1551 
1552 #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
1553 int security_post_notification(const struct cred *w_cred,
1554 			       const struct cred *cred,
1555 			       struct watch_notification *n);
1556 #else
1557 static inline int security_post_notification(const struct cred *w_cred,
1558 					     const struct cred *cred,
1559 					     struct watch_notification *n)
1560 {
1561 	return 0;
1562 }
1563 #endif
1564 
1565 #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
1566 int security_watch_key(struct key *key);
1567 #else
1568 static inline int security_watch_key(struct key *key)
1569 {
1570 	return 0;
1571 }
1572 #endif
1573 
1574 #ifdef CONFIG_SECURITY_NETWORK
1575 
1576 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
1577 int security_unix_may_send(struct socket *sock,  struct socket *other);
1578 int security_socket_create(int family, int type, int protocol, int kern);
1579 int security_socket_post_create(struct socket *sock, int family,
1580 				int type, int protocol, int kern);
1581 int security_socket_socketpair(struct socket *socka, struct socket *sockb);
1582 int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
1583 int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
1584 int security_socket_listen(struct socket *sock, int backlog);
1585 int security_socket_accept(struct socket *sock, struct socket *newsock);
1586 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
1587 int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
1588 			    int size, int flags);
1589 int security_socket_getsockname(struct socket *sock);
1590 int security_socket_getpeername(struct socket *sock);
1591 int security_socket_getsockopt(struct socket *sock, int level, int optname);
1592 int security_socket_setsockopt(struct socket *sock, int level, int optname);
1593 int security_socket_shutdown(struct socket *sock, int how);
1594 int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
1595 int security_socket_getpeersec_stream(struct socket *sock, sockptr_t optval,
1596 				      sockptr_t optlen, unsigned int len);
1597 int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
1598 int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
1599 void security_sk_free(struct sock *sk);
1600 void security_sk_clone(const struct sock *sk, struct sock *newsk);
1601 void security_sk_classify_flow(const struct sock *sk,
1602 			       struct flowi_common *flic);
1603 void security_req_classify_flow(const struct request_sock *req,
1604 				struct flowi_common *flic);
1605 void security_sock_graft(struct sock*sk, struct socket *parent);
1606 int security_inet_conn_request(const struct sock *sk,
1607 			struct sk_buff *skb, struct request_sock *req);
1608 void security_inet_csk_clone(struct sock *newsk,
1609 			const struct request_sock *req);
1610 void security_inet_conn_established(struct sock *sk,
1611 			struct sk_buff *skb);
1612 int security_secmark_relabel_packet(u32 secid);
1613 void security_secmark_refcount_inc(void);
1614 void security_secmark_refcount_dec(void);
1615 int security_tun_dev_alloc_security(void **security);
1616 void security_tun_dev_free_security(void *security);
1617 int security_tun_dev_create(void);
1618 int security_tun_dev_attach_queue(void *security);
1619 int security_tun_dev_attach(struct sock *sk, void *security);
1620 int security_tun_dev_open(void *security);
1621 int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb);
1622 int security_sctp_bind_connect(struct sock *sk, int optname,
1623 			       struct sockaddr *address, int addrlen);
1624 void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk,
1625 			    struct sock *newsk);
1626 int security_sctp_assoc_established(struct sctp_association *asoc,
1627 				    struct sk_buff *skb);
1628 int security_mptcp_add_subflow(struct sock *sk, struct sock *ssk);
1629 
1630 #else	/* CONFIG_SECURITY_NETWORK */
1631 static inline int security_unix_stream_connect(struct sock *sock,
1632 					       struct sock *other,
1633 					       struct sock *newsk)
1634 {
1635 	return 0;
1636 }
1637 
1638 static inline int security_unix_may_send(struct socket *sock,
1639 					 struct socket *other)
1640 {
1641 	return 0;
1642 }
1643 
1644 static inline int security_socket_create(int family, int type,
1645 					 int protocol, int kern)
1646 {
1647 	return 0;
1648 }
1649 
1650 static inline int security_socket_post_create(struct socket *sock,
1651 					      int family,
1652 					      int type,
1653 					      int protocol, int kern)
1654 {
1655 	return 0;
1656 }
1657 
1658 static inline int security_socket_socketpair(struct socket *socka,
1659 					     struct socket *sockb)
1660 {
1661 	return 0;
1662 }
1663 
1664 static inline int security_socket_bind(struct socket *sock,
1665 				       struct sockaddr *address,
1666 				       int addrlen)
1667 {
1668 	return 0;
1669 }
1670 
1671 static inline int security_socket_connect(struct socket *sock,
1672 					  struct sockaddr *address,
1673 					  int addrlen)
1674 {
1675 	return 0;
1676 }
1677 
1678 static inline int security_socket_listen(struct socket *sock, int backlog)
1679 {
1680 	return 0;
1681 }
1682 
1683 static inline int security_socket_accept(struct socket *sock,
1684 					 struct socket *newsock)
1685 {
1686 	return 0;
1687 }
1688 
1689 static inline int security_socket_sendmsg(struct socket *sock,
1690 					  struct msghdr *msg, int size)
1691 {
1692 	return 0;
1693 }
1694 
1695 static inline int security_socket_recvmsg(struct socket *sock,
1696 					  struct msghdr *msg, int size,
1697 					  int flags)
1698 {
1699 	return 0;
1700 }
1701 
1702 static inline int security_socket_getsockname(struct socket *sock)
1703 {
1704 	return 0;
1705 }
1706 
1707 static inline int security_socket_getpeername(struct socket *sock)
1708 {
1709 	return 0;
1710 }
1711 
1712 static inline int security_socket_getsockopt(struct socket *sock,
1713 					     int level, int optname)
1714 {
1715 	return 0;
1716 }
1717 
1718 static inline int security_socket_setsockopt(struct socket *sock,
1719 					     int level, int optname)
1720 {
1721 	return 0;
1722 }
1723 
1724 static inline int security_socket_shutdown(struct socket *sock, int how)
1725 {
1726 	return 0;
1727 }
1728 static inline int security_sock_rcv_skb(struct sock *sk,
1729 					struct sk_buff *skb)
1730 {
1731 	return 0;
1732 }
1733 
1734 static inline int security_socket_getpeersec_stream(struct socket *sock,
1735 						    sockptr_t optval,
1736 						    sockptr_t optlen,
1737 						    unsigned int len)
1738 {
1739 	return -ENOPROTOOPT;
1740 }
1741 
1742 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
1743 {
1744 	return -ENOPROTOOPT;
1745 }
1746 
1747 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
1748 {
1749 	return 0;
1750 }
1751 
1752 static inline void security_sk_free(struct sock *sk)
1753 {
1754 }
1755 
1756 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
1757 {
1758 }
1759 
1760 static inline void security_sk_classify_flow(const struct sock *sk,
1761 					     struct flowi_common *flic)
1762 {
1763 }
1764 
1765 static inline void security_req_classify_flow(const struct request_sock *req,
1766 					      struct flowi_common *flic)
1767 {
1768 }
1769 
1770 static inline void security_sock_graft(struct sock *sk, struct socket *parent)
1771 {
1772 }
1773 
1774 static inline int security_inet_conn_request(const struct sock *sk,
1775 			struct sk_buff *skb, struct request_sock *req)
1776 {
1777 	return 0;
1778 }
1779 
1780 static inline void security_inet_csk_clone(struct sock *newsk,
1781 			const struct request_sock *req)
1782 {
1783 }
1784 
1785 static inline void security_inet_conn_established(struct sock *sk,
1786 			struct sk_buff *skb)
1787 {
1788 }
1789 
1790 static inline int security_secmark_relabel_packet(u32 secid)
1791 {
1792 	return 0;
1793 }
1794 
1795 static inline void security_secmark_refcount_inc(void)
1796 {
1797 }
1798 
1799 static inline void security_secmark_refcount_dec(void)
1800 {
1801 }
1802 
1803 static inline int security_tun_dev_alloc_security(void **security)
1804 {
1805 	return 0;
1806 }
1807 
1808 static inline void security_tun_dev_free_security(void *security)
1809 {
1810 }
1811 
1812 static inline int security_tun_dev_create(void)
1813 {
1814 	return 0;
1815 }
1816 
1817 static inline int security_tun_dev_attach_queue(void *security)
1818 {
1819 	return 0;
1820 }
1821 
1822 static inline int security_tun_dev_attach(struct sock *sk, void *security)
1823 {
1824 	return 0;
1825 }
1826 
1827 static inline int security_tun_dev_open(void *security)
1828 {
1829 	return 0;
1830 }
1831 
1832 static inline int security_sctp_assoc_request(struct sctp_association *asoc,
1833 					      struct sk_buff *skb)
1834 {
1835 	return 0;
1836 }
1837 
1838 static inline int security_sctp_bind_connect(struct sock *sk, int optname,
1839 					     struct sockaddr *address,
1840 					     int addrlen)
1841 {
1842 	return 0;
1843 }
1844 
1845 static inline void security_sctp_sk_clone(struct sctp_association *asoc,
1846 					  struct sock *sk,
1847 					  struct sock *newsk)
1848 {
1849 }
1850 
1851 static inline int security_sctp_assoc_established(struct sctp_association *asoc,
1852 						  struct sk_buff *skb)
1853 {
1854 	return 0;
1855 }
1856 
1857 static inline int security_mptcp_add_subflow(struct sock *sk, struct sock *ssk)
1858 {
1859 	return 0;
1860 }
1861 #endif	/* CONFIG_SECURITY_NETWORK */
1862 
1863 #ifdef CONFIG_SECURITY_INFINIBAND
1864 int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey);
1865 int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num);
1866 int security_ib_alloc_security(void **sec);
1867 void security_ib_free_security(void *sec);
1868 #else	/* CONFIG_SECURITY_INFINIBAND */
1869 static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey)
1870 {
1871 	return 0;
1872 }
1873 
1874 static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num)
1875 {
1876 	return 0;
1877 }
1878 
1879 static inline int security_ib_alloc_security(void **sec)
1880 {
1881 	return 0;
1882 }
1883 
1884 static inline void security_ib_free_security(void *sec)
1885 {
1886 }
1887 #endif	/* CONFIG_SECURITY_INFINIBAND */
1888 
1889 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1890 
1891 int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1892 			       struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
1893 int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
1894 void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
1895 int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
1896 int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1897 int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1898 				      struct xfrm_sec_ctx *polsec, u32 secid);
1899 int security_xfrm_state_delete(struct xfrm_state *x);
1900 void security_xfrm_state_free(struct xfrm_state *x);
1901 int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid);
1902 int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1903 				       struct xfrm_policy *xp,
1904 				       const struct flowi_common *flic);
1905 int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
1906 void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic);
1907 
1908 #else	/* CONFIG_SECURITY_NETWORK_XFRM */
1909 
1910 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1911 					     struct xfrm_user_sec_ctx *sec_ctx,
1912 					     gfp_t gfp)
1913 {
1914 	return 0;
1915 }
1916 
1917 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
1918 {
1919 	return 0;
1920 }
1921 
1922 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
1923 {
1924 }
1925 
1926 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
1927 {
1928 	return 0;
1929 }
1930 
1931 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
1932 					struct xfrm_user_sec_ctx *sec_ctx)
1933 {
1934 	return 0;
1935 }
1936 
1937 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1938 					struct xfrm_sec_ctx *polsec, u32 secid)
1939 {
1940 	return 0;
1941 }
1942 
1943 static inline void security_xfrm_state_free(struct xfrm_state *x)
1944 {
1945 }
1946 
1947 static inline int security_xfrm_state_delete(struct xfrm_state *x)
1948 {
1949 	return 0;
1950 }
1951 
1952 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
1953 {
1954 	return 0;
1955 }
1956 
1957 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1958 						     struct xfrm_policy *xp,
1959 						     const struct flowi_common *flic)
1960 {
1961 	return 1;
1962 }
1963 
1964 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
1965 {
1966 	return 0;
1967 }
1968 
1969 static inline void security_skb_classify_flow(struct sk_buff *skb,
1970 					      struct flowi_common *flic)
1971 {
1972 }
1973 
1974 #endif	/* CONFIG_SECURITY_NETWORK_XFRM */
1975 
1976 #ifdef CONFIG_SECURITY_PATH
1977 int security_path_unlink(const struct path *dir, struct dentry *dentry);
1978 int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
1979 int security_path_rmdir(const struct path *dir, struct dentry *dentry);
1980 int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
1981 			unsigned int dev);
1982 void security_path_post_mknod(struct mnt_idmap *idmap, struct dentry *dentry);
1983 int security_path_truncate(const struct path *path);
1984 int security_path_symlink(const struct path *dir, struct dentry *dentry,
1985 			  const char *old_name);
1986 int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
1987 		       struct dentry *new_dentry);
1988 int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
1989 			 const struct path *new_dir, struct dentry *new_dentry,
1990 			 unsigned int flags);
1991 int security_path_chmod(const struct path *path, umode_t mode);
1992 int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
1993 int security_path_chroot(const struct path *path);
1994 #else	/* CONFIG_SECURITY_PATH */
1995 static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
1996 {
1997 	return 0;
1998 }
1999 
2000 static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
2001 				      umode_t mode)
2002 {
2003 	return 0;
2004 }
2005 
2006 static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
2007 {
2008 	return 0;
2009 }
2010 
2011 static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
2012 				      umode_t mode, unsigned int dev)
2013 {
2014 	return 0;
2015 }
2016 
2017 static inline void security_path_post_mknod(struct mnt_idmap *idmap,
2018 					    struct dentry *dentry)
2019 { }
2020 
2021 static inline int security_path_truncate(const struct path *path)
2022 {
2023 	return 0;
2024 }
2025 
2026 static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
2027 					const char *old_name)
2028 {
2029 	return 0;
2030 }
2031 
2032 static inline int security_path_link(struct dentry *old_dentry,
2033 				     const struct path *new_dir,
2034 				     struct dentry *new_dentry)
2035 {
2036 	return 0;
2037 }
2038 
2039 static inline int security_path_rename(const struct path *old_dir,
2040 				       struct dentry *old_dentry,
2041 				       const struct path *new_dir,
2042 				       struct dentry *new_dentry,
2043 				       unsigned int flags)
2044 {
2045 	return 0;
2046 }
2047 
2048 static inline int security_path_chmod(const struct path *path, umode_t mode)
2049 {
2050 	return 0;
2051 }
2052 
2053 static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
2054 {
2055 	return 0;
2056 }
2057 
2058 static inline int security_path_chroot(const struct path *path)
2059 {
2060 	return 0;
2061 }
2062 #endif	/* CONFIG_SECURITY_PATH */
2063 
2064 #ifdef CONFIG_KEYS
2065 #ifdef CONFIG_SECURITY
2066 
2067 int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
2068 void security_key_free(struct key *key);
2069 int security_key_permission(key_ref_t key_ref, const struct cred *cred,
2070 			    enum key_need_perm need_perm);
2071 int security_key_getsecurity(struct key *key, char **_buffer);
2072 void security_key_post_create_or_update(struct key *keyring, struct key *key,
2073 					const void *payload, size_t payload_len,
2074 					unsigned long flags, bool create);
2075 
2076 #else
2077 
2078 static inline int security_key_alloc(struct key *key,
2079 				     const struct cred *cred,
2080 				     unsigned long flags)
2081 {
2082 	return 0;
2083 }
2084 
2085 static inline void security_key_free(struct key *key)
2086 {
2087 }
2088 
2089 static inline int security_key_permission(key_ref_t key_ref,
2090 					  const struct cred *cred,
2091 					  enum key_need_perm need_perm)
2092 {
2093 	return 0;
2094 }
2095 
2096 static inline int security_key_getsecurity(struct key *key, char **_buffer)
2097 {
2098 	*_buffer = NULL;
2099 	return 0;
2100 }
2101 
2102 static inline void security_key_post_create_or_update(struct key *keyring,
2103 						      struct key *key,
2104 						      const void *payload,
2105 						      size_t payload_len,
2106 						      unsigned long flags,
2107 						      bool create)
2108 { }
2109 
2110 #endif
2111 #endif /* CONFIG_KEYS */
2112 
2113 #ifdef CONFIG_AUDIT
2114 #ifdef CONFIG_SECURITY
2115 int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule,
2116 			     gfp_t gfp);
2117 int security_audit_rule_known(struct audit_krule *krule);
2118 int security_audit_rule_match(struct lsm_prop *prop, u32 field, u32 op,
2119 			      void *lsmrule);
2120 void security_audit_rule_free(void *lsmrule);
2121 
2122 #else
2123 
2124 static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
2125 					   void **lsmrule, gfp_t gfp)
2126 {
2127 	return 0;
2128 }
2129 
2130 static inline int security_audit_rule_known(struct audit_krule *krule)
2131 {
2132 	return 0;
2133 }
2134 
2135 static inline int security_audit_rule_match(struct lsm_prop *prop, u32 field,
2136 					    u32 op, void *lsmrule)
2137 {
2138 	return 0;
2139 }
2140 
2141 static inline void security_audit_rule_free(void *lsmrule)
2142 { }
2143 
2144 #endif /* CONFIG_SECURITY */
2145 #endif /* CONFIG_AUDIT */
2146 
2147 #ifdef CONFIG_SECURITYFS
2148 
2149 extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
2150 					     struct dentry *parent, void *data,
2151 					     const struct file_operations *fops);
2152 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2153 struct dentry *securityfs_create_symlink(const char *name,
2154 					 struct dentry *parent,
2155 					 const char *target,
2156 					 const struct inode_operations *iops);
2157 extern void securityfs_remove(struct dentry *dentry);
2158 extern void securityfs_recursive_remove(struct dentry *dentry);
2159 
2160 #else /* CONFIG_SECURITYFS */
2161 
2162 static inline struct dentry *securityfs_create_dir(const char *name,
2163 						   struct dentry *parent)
2164 {
2165 	return ERR_PTR(-ENODEV);
2166 }
2167 
2168 static inline struct dentry *securityfs_create_file(const char *name,
2169 						    umode_t mode,
2170 						    struct dentry *parent,
2171 						    void *data,
2172 						    const struct file_operations *fops)
2173 {
2174 	return ERR_PTR(-ENODEV);
2175 }
2176 
2177 static inline struct dentry *securityfs_create_symlink(const char *name,
2178 					struct dentry *parent,
2179 					const char *target,
2180 					const struct inode_operations *iops)
2181 {
2182 	return ERR_PTR(-ENODEV);
2183 }
2184 
2185 static inline void securityfs_remove(struct dentry *dentry)
2186 {}
2187 
2188 #endif
2189 
2190 #ifdef CONFIG_BPF_SYSCALL
2191 union bpf_attr;
2192 struct bpf_map;
2193 struct bpf_prog;
2194 struct bpf_token;
2195 #ifdef CONFIG_SECURITY
2196 extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size);
2197 extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
2198 extern int security_bpf_prog(struct bpf_prog *prog);
2199 extern int security_bpf_map_create(struct bpf_map *map, union bpf_attr *attr,
2200 				   struct bpf_token *token);
2201 extern void security_bpf_map_free(struct bpf_map *map);
2202 extern int security_bpf_prog_load(struct bpf_prog *prog, union bpf_attr *attr,
2203 				  struct bpf_token *token);
2204 extern void security_bpf_prog_free(struct bpf_prog *prog);
2205 extern int security_bpf_token_create(struct bpf_token *token, union bpf_attr *attr,
2206 				     const struct path *path);
2207 extern void security_bpf_token_free(struct bpf_token *token);
2208 extern int security_bpf_token_cmd(const struct bpf_token *token, enum bpf_cmd cmd);
2209 extern int security_bpf_token_capable(const struct bpf_token *token, int cap);
2210 #else
2211 static inline int security_bpf(int cmd, union bpf_attr *attr,
2212 					     unsigned int size)
2213 {
2214 	return 0;
2215 }
2216 
2217 static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode)
2218 {
2219 	return 0;
2220 }
2221 
2222 static inline int security_bpf_prog(struct bpf_prog *prog)
2223 {
2224 	return 0;
2225 }
2226 
2227 static inline int security_bpf_map_create(struct bpf_map *map, union bpf_attr *attr,
2228 					  struct bpf_token *token)
2229 {
2230 	return 0;
2231 }
2232 
2233 static inline void security_bpf_map_free(struct bpf_map *map)
2234 { }
2235 
2236 static inline int security_bpf_prog_load(struct bpf_prog *prog, union bpf_attr *attr,
2237 					 struct bpf_token *token)
2238 {
2239 	return 0;
2240 }
2241 
2242 static inline void security_bpf_prog_free(struct bpf_prog *prog)
2243 { }
2244 
2245 static inline int security_bpf_token_create(struct bpf_token *token, union bpf_attr *attr,
2246 					    const struct path *path)
2247 {
2248 	return 0;
2249 }
2250 
2251 static inline void security_bpf_token_free(struct bpf_token *token)
2252 { }
2253 
2254 static inline int security_bpf_token_cmd(const struct bpf_token *token, enum bpf_cmd cmd)
2255 {
2256 	return 0;
2257 }
2258 
2259 static inline int security_bpf_token_capable(const struct bpf_token *token, int cap)
2260 {
2261 	return 0;
2262 }
2263 #endif /* CONFIG_SECURITY */
2264 #endif /* CONFIG_BPF_SYSCALL */
2265 
2266 #ifdef CONFIG_PERF_EVENTS
2267 struct perf_event_attr;
2268 struct perf_event;
2269 
2270 #ifdef CONFIG_SECURITY
2271 extern int security_perf_event_open(struct perf_event_attr *attr, int type);
2272 extern int security_perf_event_alloc(struct perf_event *event);
2273 extern void security_perf_event_free(struct perf_event *event);
2274 extern int security_perf_event_read(struct perf_event *event);
2275 extern int security_perf_event_write(struct perf_event *event);
2276 #else
2277 static inline int security_perf_event_open(struct perf_event_attr *attr,
2278 					   int type)
2279 {
2280 	return 0;
2281 }
2282 
2283 static inline int security_perf_event_alloc(struct perf_event *event)
2284 {
2285 	return 0;
2286 }
2287 
2288 static inline void security_perf_event_free(struct perf_event *event)
2289 {
2290 }
2291 
2292 static inline int security_perf_event_read(struct perf_event *event)
2293 {
2294 	return 0;
2295 }
2296 
2297 static inline int security_perf_event_write(struct perf_event *event)
2298 {
2299 	return 0;
2300 }
2301 #endif /* CONFIG_SECURITY */
2302 #endif /* CONFIG_PERF_EVENTS */
2303 
2304 #ifdef CONFIG_IO_URING
2305 #ifdef CONFIG_SECURITY
2306 extern int security_uring_override_creds(const struct cred *new);
2307 extern int security_uring_sqpoll(void);
2308 extern int security_uring_cmd(struct io_uring_cmd *ioucmd);
2309 #else
2310 static inline int security_uring_override_creds(const struct cred *new)
2311 {
2312 	return 0;
2313 }
2314 static inline int security_uring_sqpoll(void)
2315 {
2316 	return 0;
2317 }
2318 static inline int security_uring_cmd(struct io_uring_cmd *ioucmd)
2319 {
2320 	return 0;
2321 }
2322 #endif /* CONFIG_SECURITY */
2323 #endif /* CONFIG_IO_URING */
2324 
2325 #ifdef CONFIG_SECURITY
2326 extern void security_initramfs_populated(void);
2327 #else
2328 static inline void security_initramfs_populated(void)
2329 {
2330 }
2331 #endif /* CONFIG_SECURITY */
2332 
2333 #endif /* ! __LINUX_SECURITY_H */
2334