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