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