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