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