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