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