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