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