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