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