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