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