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