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