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