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