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