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 LSM_STARTED_ALL,
89};
90
91struct dm_verity_digest {
92 const char *alg;
93 const u8 *digest;
94 size_t digest_len;
95};
96
97enum lsm_integrity_type {
98 LSM_INT_DMVERITY_SIG_VALID,
99 LSM_INT_DMVERITY_ROOTHASH,
100 LSM_INT_FSVERITY_BUILTINSIG_VALID,
101};
102
103/*
104 * These are reasons that can be passed to the security_locked_down()
105 * LSM hook. Lockdown reasons that protect kernel integrity (ie, the
106 * ability for userland to modify kernel code) are placed before
107 * LOCKDOWN_INTEGRITY_MAX. Lockdown reasons that protect kernel
108 * confidentiality (ie, the ability for userland to extract
109 * information from the running kernel that would otherwise be
110 * restricted) are placed before LOCKDOWN_CONFIDENTIALITY_MAX.
111 *
112 * LSM authors should note that the semantics of any given lockdown
113 * reason are not guaranteed to be stable - the same reason may block
114 * one set of features in one kernel release, and a slightly different
115 * set of features in a later kernel release. LSMs that seek to expose
116 * lockdown policy at any level of granularity other than "none",
117 * "integrity" or "confidentiality" are responsible for either
118 * ensuring that they expose a consistent level of functionality to
119 * userland, or ensuring that userland is aware that this is
120 * potentially a moving target. It is easy to misuse this information
121 * in a way that could break userspace. Please be careful not to do
122 * so.
123 *
124 * If you add to this, remember to extend lockdown_reasons in
125 * security/lockdown/lockdown.c.
126 */
127enum lockdown_reason {
128 LOCKDOWN_NONE,
129 LOCKDOWN_MODULE_SIGNATURE,
130 LOCKDOWN_DEV_MEM,
131 LOCKDOWN_EFI_TEST,
132 LOCKDOWN_KEXEC,
133 LOCKDOWN_HIBERNATION,
134 LOCKDOWN_PCI_ACCESS,
135 LOCKDOWN_IOPORT,
136 LOCKDOWN_MSR,
137 LOCKDOWN_ACPI_TABLES,
138 LOCKDOWN_DEVICE_TREE,
139 LOCKDOWN_PCMCIA_CIS,
140 LOCKDOWN_TIOCSSERIAL,
141 LOCKDOWN_MODULE_PARAMETERS,
142 LOCKDOWN_MMIOTRACE,
143 LOCKDOWN_DEBUGFS,
144 LOCKDOWN_XMON_WR,
145 LOCKDOWN_BPF_WRITE_USER,
146 LOCKDOWN_DBG_WRITE_KERNEL,
147 LOCKDOWN_RTAS_ERROR_INJECTION,
148 LOCKDOWN_INTEGRITY_MAX,
149 LOCKDOWN_KCORE,
150 LOCKDOWN_KPROBES,
151 LOCKDOWN_BPF_READ_KERNEL,
152 LOCKDOWN_DBG_READ_KERNEL,
153 LOCKDOWN_PERF,
154 LOCKDOWN_TRACEFS,
155 LOCKDOWN_XMON_RW,
156 LOCKDOWN_XFRM_SECRET,
157 LOCKDOWN_CONFIDENTIALITY_MAX,
158};
159
160/*
161 * Data exported by the security modules
162 */
163struct lsm_prop {
164 struct lsm_prop_selinux selinux;
165 struct lsm_prop_smack smack;
166 struct lsm_prop_apparmor apparmor;
167 struct lsm_prop_bpf bpf;
168};
169
170extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
171
172/* These functions are in security/commoncap.c */
173extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
174 int cap, unsigned int opts);
175extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
176extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
177extern int cap_ptrace_traceme(struct task_struct *parent);
178extern int cap_capget(const struct task_struct *target, kernel_cap_t *effective,
179 kernel_cap_t *inheritable, kernel_cap_t *permitted);
180extern int cap_capset(struct cred *new, const struct cred *old,
181 const kernel_cap_t *effective,
182 const kernel_cap_t *inheritable,
183 const kernel_cap_t *permitted);
184extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file);
185int cap_inode_setxattr(struct dentry *dentry, const char *name,
186 const void *value, size_t size, int flags);
187int cap_inode_removexattr(struct mnt_idmap *idmap,
188 struct dentry *dentry, const char *name);
189int cap_inode_need_killpriv(struct dentry *dentry);
190int cap_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
191int cap_inode_getsecurity(struct mnt_idmap *idmap,
192 struct inode *inode, const char *name, void **buffer,
193 bool alloc);
194extern int cap_mmap_addr(unsigned long addr);
195extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
196extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
197 unsigned long arg4, unsigned long arg5);
198extern int cap_task_setscheduler(struct task_struct *p);
199extern int cap_task_setioprio(struct task_struct *p, int ioprio);
200extern int cap_task_setnice(struct task_struct *p, int nice);
201extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
202
203struct msghdr;
204struct sk_buff;
205struct sock;
206struct sockaddr;
207struct socket;
208struct flowi_common;
209struct dst_entry;
210struct xfrm_selector;
211struct xfrm_policy;
212struct xfrm_state;
213struct xfrm_user_sec_ctx;
214struct seq_file;
215struct sctp_association;
216
217#ifdef CONFIG_MMU
218extern unsigned long mmap_min_addr;
219extern unsigned long dac_mmap_min_addr;
220#else
221#define mmap_min_addr 0UL
222#define dac_mmap_min_addr 0UL
223#endif
224
225/*
226 * A "security context" is the text representation of
227 * the information used by LSMs.
228 * This structure contains the string, its length, and which LSM
229 * it is useful for.
230 */
231struct lsm_context {
232 char *context; /* Provided by the module */
233 u32 len;
234 int id; /* Identifies the module */
235};
236
237/*
238 * Values used in the task_security_ops calls
239 */
240/* setuid or setgid, id0 == uid or gid */
241#define LSM_SETID_ID 1
242
243/* setreuid or setregid, id0 == real, id1 == eff */
244#define LSM_SETID_RE 2
245
246/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
247#define LSM_SETID_RES 4
248
249/* setfsuid or setfsgid, id0 == fsuid or fsgid */
250#define LSM_SETID_FS 8
251
252/* Flags for security_task_prlimit(). */
253#define LSM_PRLIMIT_READ 1
254#define LSM_PRLIMIT_WRITE 2
255
256/* forward declares to avoid warnings */
257struct sched_param;
258struct request_sock;
259
260/* bprm->unsafe reasons */
261#define LSM_UNSAFE_SHARE 1
262#define LSM_UNSAFE_PTRACE 2
263#define LSM_UNSAFE_NO_NEW_PRIVS 4
264
265#ifdef CONFIG_MMU
266extern int mmap_min_addr_handler(const struct ctl_table *table, int write,
267 void *buffer, size_t *lenp, loff_t *ppos);
268#endif
269
270/* security_inode_init_security callback function to write xattrs */
271typedef int (*initxattrs) (struct inode *inode,
272 const struct xattr *xattr_array, void *fs_data);
273
274
275/* Keep the kernel_load_data_id enum in sync with kernel_read_file_id */
276#define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM,
277#define __data_id_stringify(dummy, str) #str,
278
279enum kernel_load_data_id {
280 __kernel_read_file_id(__data_id_enumify)
281};
282
283static const char * const kernel_load_data_str[] = {
284 __kernel_read_file_id(__data_id_stringify)
285};
286
287static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
288{
289 if ((unsigned)id >= LOADING_MAX_ID)
290 return kernel_load_data_str[LOADING_UNKNOWN];
291
292 return kernel_load_data_str[id];
293}
294
295/**
296 * lsmprop_init - initialize a lsm_prop structure
297 * @prop: Pointer to the data to initialize
298 *
299 * Set all secid for all modules to the specified value.
300 */
301static inline void lsmprop_init(struct lsm_prop *prop)
302{
303 memset(prop, 0, sizeof(*prop));
304}
305
306#ifdef CONFIG_SECURITY
307
308/**
309 * lsmprop_is_set - report if there is a value in the lsm_prop
310 * @prop: Pointer to the exported LSM data
311 *
312 * Returns true if there is a value set, false otherwise
313 */
314static inline bool lsmprop_is_set(struct lsm_prop *prop)
315{
316 const struct lsm_prop empty = {};
317
318 return !!memcmp(prop, &empty, sizeof(*prop));
319}
320
321int call_blocking_lsm_notifier(enum lsm_event event, void *data);
322int register_blocking_lsm_notifier(struct notifier_block *nb);
323int unregister_blocking_lsm_notifier(struct notifier_block *nb);
324
325/* prototypes */
326extern int security_init(void);
327extern int early_security_init(void);
328extern u64 lsm_name_to_attr(const char *name);
329
330/* Security operations */
331int security_binder_set_context_mgr(const struct cred *mgr);
332int security_binder_transaction(const struct cred *from,
333 const struct cred *to);
334int security_binder_transfer_binder(const struct cred *from,
335 const struct cred *to);
336int security_binder_transfer_file(const struct cred *from,
337 const struct cred *to, const struct file *file);
338int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
339int security_ptrace_traceme(struct task_struct *parent);
340int security_capget(const struct task_struct *target,
341 kernel_cap_t *effective,
342 kernel_cap_t *inheritable,
343 kernel_cap_t *permitted);
344int security_capset(struct cred *new, const struct cred *old,
345 const kernel_cap_t *effective,
346 const kernel_cap_t *inheritable,
347 const kernel_cap_t *permitted);
348int security_capable(const struct cred *cred,
349 struct user_namespace *ns,
350 int cap,
351 unsigned int opts);
352int security_quotactl(int cmds, int type, int id, const struct super_block *sb);
353int security_quota_on(struct dentry *dentry);
354int security_syslog(int type);
355int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
356int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
357int security_bprm_creds_for_exec(struct linux_binprm *bprm);
358int security_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file);
359int security_bprm_check(struct linux_binprm *bprm);
360void security_bprm_committing_creds(const struct linux_binprm *bprm);
361void security_bprm_committed_creds(const struct linux_binprm *bprm);
362int security_fs_context_submount(struct fs_context *fc, struct super_block *reference);
363int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc);
364int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
365int security_sb_alloc(struct super_block *sb);
366void security_sb_delete(struct super_block *sb);
367void security_sb_free(struct super_block *sb);
368void security_free_mnt_opts(void **mnt_opts);
369int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
370int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
371int security_sb_remount(struct super_block *sb, void *mnt_opts);
372int security_sb_kern_mount(const struct super_block *sb);
373int security_sb_show_options(struct seq_file *m, struct super_block *sb);
374int security_sb_statfs(struct dentry *dentry);
375int security_sb_mount(const char *dev_name, const struct path *path,
376 const char *type, unsigned long flags, void *data);
377int security_sb_umount(struct vfsmount *mnt, int flags);
378int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
379int security_sb_set_mnt_opts(struct super_block *sb,
380 void *mnt_opts,
381 unsigned long kern_flags,
382 unsigned long *set_kern_flags);
383int security_sb_clone_mnt_opts(const struct super_block *oldsb,
384 struct super_block *newsb,
385 unsigned long kern_flags,
386 unsigned long *set_kern_flags);
387int security_move_mount(const struct path *from_path, const struct path *to_path);
388int security_dentry_init_security(struct dentry *dentry, int mode,
389 const struct qstr *name,
390 const char **xattr_name,
391 struct lsm_context *lsmcxt);
392int security_dentry_create_files_as(struct dentry *dentry, int mode,
393 const struct qstr *name,
394 const struct cred *old,
395 struct cred *new);
396int security_path_notify(const struct path *path, u64 mask,
397 unsigned int obj_type);
398int security_inode_alloc(struct inode *inode, gfp_t gfp);
399void security_inode_free(struct inode *inode);
400int security_inode_init_security(struct inode *inode, struct inode *dir,
401 const struct qstr *qstr,
402 initxattrs initxattrs, void *fs_data);
403int security_inode_init_security_anon(struct inode *inode,
404 const struct qstr *name,
405 const struct inode *context_inode);
406int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
407void security_inode_post_create_tmpfile(struct mnt_idmap *idmap,
408 struct inode *inode);
409int security_inode_link(struct dentry *old_dentry, struct inode *dir,
410 struct dentry *new_dentry);
411int security_inode_unlink(struct inode *dir, struct dentry *dentry);
412int security_inode_symlink(struct inode *dir, struct dentry *dentry,
413 const char *old_name);
414int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
415int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
416int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
417int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
418 struct inode *new_dir, struct dentry *new_dentry,
419 unsigned int flags);
420int security_inode_readlink(struct dentry *dentry);
421int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
422 bool rcu);
423int security_inode_permission(struct inode *inode, int mask);
424int security_inode_setattr(struct mnt_idmap *idmap,
425 struct dentry *dentry, struct iattr *attr);
426void security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
427 int ia_valid);
428int security_inode_getattr(const struct path *path);
429int security_inode_setxattr(struct mnt_idmap *idmap,
430 struct dentry *dentry, const char *name,
431 const void *value, size_t size, int flags);
432int security_inode_set_acl(struct mnt_idmap *idmap,
433 struct dentry *dentry, const char *acl_name,
434 struct posix_acl *kacl);
435void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,
436 struct posix_acl *kacl);
437int security_inode_get_acl(struct mnt_idmap *idmap,
438 struct dentry *dentry, const char *acl_name);
439int security_inode_remove_acl(struct mnt_idmap *idmap,
440 struct dentry *dentry, const char *acl_name);
441void security_inode_post_remove_acl(struct mnt_idmap *idmap,
442 struct dentry *dentry,
443 const char *acl_name);
444void security_inode_post_setxattr(struct dentry *dentry, const char *name,
445 const void *value, size_t size, int flags);
446int security_inode_getxattr(struct dentry *dentry, const char *name);
447int security_inode_listxattr(struct dentry *dentry);
448int security_inode_removexattr(struct mnt_idmap *idmap,
449 struct dentry *dentry, const char *name);
450void security_inode_post_removexattr(struct dentry *dentry, const char *name);
451int security_inode_file_setattr(struct dentry *dentry,
452 struct file_kattr *fa);
453int security_inode_file_getattr(struct dentry *dentry,
454 struct file_kattr *fa);
455int security_inode_need_killpriv(struct dentry *dentry);
456int security_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
457int security_inode_getsecurity(struct mnt_idmap *idmap,
458 struct inode *inode, const char *name,
459 void **buffer, bool alloc);
460int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
461int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
462void security_inode_getlsmprop(struct inode *inode, struct lsm_prop *prop);
463int security_inode_copy_up(struct dentry *src, struct cred **new);
464int security_inode_copy_up_xattr(struct dentry *src, const char *name);
465int security_inode_setintegrity(const struct inode *inode,
466 enum lsm_integrity_type type, const void *value,
467 size_t size);
468int security_kernfs_init_security(struct kernfs_node *kn_dir,
469 struct kernfs_node *kn);
470int security_file_permission(struct file *file, int mask);
471int security_file_alloc(struct file *file);
472void security_file_release(struct file *file);
473void security_file_free(struct file *file);
474int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
475int security_file_ioctl_compat(struct file *file, unsigned int cmd,
476 unsigned long arg);
477int security_mmap_file(struct file *file, unsigned long prot,
478 unsigned long flags);
479int security_mmap_addr(unsigned long addr);
480int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
481 unsigned long prot);
482int security_file_lock(struct file *file, unsigned int cmd);
483int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
484void security_file_set_fowner(struct file *file);
485int security_file_send_sigiotask(struct task_struct *tsk,
486 struct fown_struct *fown, int sig);
487int security_file_receive(struct file *file);
488int security_file_open(struct file *file);
489int security_file_post_open(struct file *file, int mask);
490int security_file_truncate(struct file *file);
491int security_task_alloc(struct task_struct *task, u64 clone_flags);
492void security_task_free(struct task_struct *task);
493int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
494void security_cred_free(struct cred *cred);
495int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
496void security_transfer_creds(struct cred *new, const struct cred *old);
497void security_cred_getsecid(const struct cred *c, u32 *secid);
498void security_cred_getlsmprop(const struct cred *c, struct lsm_prop *prop);
499int security_kernel_act_as(struct cred *new, u32 secid);
500int security_kernel_create_files_as(struct cred *new, struct inode *inode);
501int security_kernel_module_request(char *kmod_name);
502int security_kernel_load_data(enum kernel_load_data_id id, bool contents);
503int security_kernel_post_load_data(char *buf, loff_t size,
504 enum kernel_load_data_id id,
505 char *description);
506int security_kernel_read_file(struct file *file, enum kernel_read_file_id id,
507 bool contents);
508int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
509 enum kernel_read_file_id id);
510int security_task_fix_setuid(struct cred *new, const struct cred *old,
511 int flags);
512int security_task_fix_setgid(struct cred *new, const struct cred *old,
513 int flags);
514int security_task_fix_setgroups(struct cred *new, const struct cred *old);
515int security_task_setpgid(struct task_struct *p, pid_t pgid);
516int security_task_getpgid(struct task_struct *p);
517int security_task_getsid(struct task_struct *p);
518void security_current_getlsmprop_subj(struct lsm_prop *prop);
519void security_task_getlsmprop_obj(struct task_struct *p, struct lsm_prop *prop);
520int security_task_setnice(struct task_struct *p, int nice);
521int security_task_setioprio(struct task_struct *p, int ioprio);
522int security_task_getioprio(struct task_struct *p);
523int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
524 unsigned int flags);
525int security_task_setrlimit(struct task_struct *p, unsigned int resource,
526 struct rlimit *new_rlim);
527int security_task_setscheduler(struct task_struct *p);
528int security_task_getscheduler(struct task_struct *p);
529int security_task_movememory(struct task_struct *p);
530int security_task_kill(struct task_struct *p, struct kernel_siginfo *info,
531 int sig, const struct cred *cred);
532int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
533 unsigned long arg4, unsigned long arg5);
534void security_task_to_inode(struct task_struct *p, struct inode *inode);
535int security_create_user_ns(const struct cred *cred);
536int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
537void security_ipc_getlsmprop(struct kern_ipc_perm *ipcp, struct lsm_prop *prop);
538int security_msg_msg_alloc(struct msg_msg *msg);
539void security_msg_msg_free(struct msg_msg *msg);
540int security_msg_queue_alloc(struct kern_ipc_perm *msq);
541void security_msg_queue_free(struct kern_ipc_perm *msq);
542int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg);
543int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd);
544int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
545 struct msg_msg *msg, int msqflg);
546int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg,
547 struct task_struct *target, long type, int mode);
548int security_shm_alloc(struct kern_ipc_perm *shp);
549void security_shm_free(struct kern_ipc_perm *shp);
550int security_shm_associate(struct kern_ipc_perm *shp, int shmflg);
551int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd);
552int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg);
553int security_sem_alloc(struct kern_ipc_perm *sma);
554void security_sem_free(struct kern_ipc_perm *sma);
555int security_sem_associate(struct kern_ipc_perm *sma, int semflg);
556int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
557int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
558 unsigned nsops, int alter);
559void security_d_instantiate(struct dentry *dentry, struct inode *inode);
560int security_getselfattr(unsigned int attr, struct lsm_ctx __user *ctx,
561 u32 __user *size, u32 flags);
562int security_setselfattr(unsigned int attr, struct lsm_ctx __user *ctx,
563 u32 size, u32 flags);
564int security_getprocattr(struct task_struct *p, int lsmid, const char *name,
565 char **value);
566int security_setprocattr(int lsmid, const char *name, void *value, size_t size);
567int security_ismaclabel(const char *name);
568int security_secid_to_secctx(u32 secid, struct lsm_context *cp);
569int security_lsmprop_to_secctx(struct lsm_prop *prop, struct lsm_context *cp,
570 int lsmid);
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, const 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 u64 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 int lsmid)
1556{
1557 return -EOPNOTSUPP;
1558}
1559
1560static inline int security_secctx_to_secid(const char *secdata,
1561 u32 seclen,
1562 u32 *secid)
1563{
1564 return -EOPNOTSUPP;
1565}
1566
1567static inline void security_release_secctx(struct lsm_context *cp)
1568{
1569}
1570
1571static inline void security_inode_invalidate_secctx(struct inode *inode)
1572{
1573}
1574
1575static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
1576{
1577 return -EOPNOTSUPP;
1578}
1579static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
1580{
1581 return -EOPNOTSUPP;
1582}
1583static inline int security_inode_getsecctx(struct inode *inode,
1584 struct lsm_context *cp)
1585{
1586 return -EOPNOTSUPP;
1587}
1588static inline int security_locked_down(enum lockdown_reason what)
1589{
1590 return 0;
1591}
1592static inline int lsm_fill_user_ctx(struct lsm_ctx __user *uctx,
1593 u32 *uctx_len, void *val, size_t val_len,
1594 u64 id, u64 flags)
1595{
1596 return -EOPNOTSUPP;
1597}
1598
1599static inline int security_bdev_alloc(struct block_device *bdev)
1600{
1601 return 0;
1602}
1603
1604static inline void security_bdev_free(struct block_device *bdev)
1605{
1606}
1607
1608static inline int security_bdev_setintegrity(struct block_device *bdev,
1609 enum lsm_integrity_type type,
1610 const void *value, size_t size)
1611{
1612 return 0;
1613}
1614
1615#endif /* CONFIG_SECURITY */
1616
1617#if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
1618int security_post_notification(const struct cred *w_cred,
1619 const struct cred *cred,
1620 struct watch_notification *n);
1621#else
1622static inline int security_post_notification(const struct cred *w_cred,
1623 const struct cred *cred,
1624 struct watch_notification *n)
1625{
1626 return 0;
1627}
1628#endif
1629
1630#if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
1631int security_watch_key(struct key *key);
1632#else
1633static inline int security_watch_key(struct key *key)
1634{
1635 return 0;
1636}
1637#endif
1638
1639#ifdef CONFIG_SECURITY_NETWORK
1640
1641int security_netlink_send(struct sock *sk, struct sk_buff *skb);
1642int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
1643int security_unix_may_send(struct socket *sock, struct socket *other);
1644int security_socket_create(int family, int type, int protocol, int kern);
1645int security_socket_post_create(struct socket *sock, int family,
1646 int type, int protocol, int kern);
1647int security_socket_socketpair(struct socket *socka, struct socket *sockb);
1648int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
1649int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
1650int security_socket_listen(struct socket *sock, int backlog);
1651int security_socket_accept(struct socket *sock, struct socket *newsock);
1652int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
1653int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
1654 int size, int flags);
1655int security_socket_getsockname(struct socket *sock);
1656int security_socket_getpeername(struct socket *sock);
1657int security_socket_getsockopt(struct socket *sock, int level, int optname);
1658int security_socket_setsockopt(struct socket *sock, int level, int optname);
1659int security_socket_shutdown(struct socket *sock, int how);
1660int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
1661int security_socket_getpeersec_stream(struct socket *sock, sockptr_t optval,
1662 sockptr_t optlen, unsigned int len);
1663int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
1664int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
1665void security_sk_free(struct sock *sk);
1666void security_sk_clone(const struct sock *sk, struct sock *newsk);
1667void security_sk_classify_flow(const struct sock *sk,
1668 struct flowi_common *flic);
1669void security_req_classify_flow(const struct request_sock *req,
1670 struct flowi_common *flic);
1671void security_sock_graft(struct sock*sk, struct socket *parent);
1672int security_inet_conn_request(const struct sock *sk,
1673 struct sk_buff *skb, struct request_sock *req);
1674void security_inet_csk_clone(struct sock *newsk,
1675 const struct request_sock *req);
1676void security_inet_conn_established(struct sock *sk,
1677 struct sk_buff *skb);
1678int security_secmark_relabel_packet(u32 secid);
1679void security_secmark_refcount_inc(void);
1680void security_secmark_refcount_dec(void);
1681int security_tun_dev_alloc_security(void **security);
1682void security_tun_dev_free_security(void *security);
1683int security_tun_dev_create(void);
1684int security_tun_dev_attach_queue(void *security);
1685int security_tun_dev_attach(struct sock *sk, void *security);
1686int security_tun_dev_open(void *security);
1687int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb);
1688int security_sctp_bind_connect(struct sock *sk, int optname,
1689 struct sockaddr *address, int addrlen);
1690void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk,
1691 struct sock *newsk);
1692int security_sctp_assoc_established(struct sctp_association *asoc,
1693 struct sk_buff *skb);
1694int security_mptcp_add_subflow(struct sock *sk, struct sock *ssk);
1695
1696#else /* CONFIG_SECURITY_NETWORK */
1697static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
1698{
1699 return 0;
1700}
1701
1702static inline int security_unix_stream_connect(struct sock *sock,
1703 struct sock *other,
1704 struct sock *newsk)
1705{
1706 return 0;
1707}
1708
1709static inline int security_unix_may_send(struct socket *sock,
1710 struct socket *other)
1711{
1712 return 0;
1713}
1714
1715static inline int security_socket_create(int family, int type,
1716 int protocol, int kern)
1717{
1718 return 0;
1719}
1720
1721static inline int security_socket_post_create(struct socket *sock,
1722 int family,
1723 int type,
1724 int protocol, int kern)
1725{
1726 return 0;
1727}
1728
1729static inline int security_socket_socketpair(struct socket *socka,
1730 struct socket *sockb)
1731{
1732 return 0;
1733}
1734
1735static inline int security_socket_bind(struct socket *sock,
1736 struct sockaddr *address,
1737 int addrlen)
1738{
1739 return 0;
1740}
1741
1742static inline int security_socket_connect(struct socket *sock,
1743 struct sockaddr *address,
1744 int addrlen)
1745{
1746 return 0;
1747}
1748
1749static inline int security_socket_listen(struct socket *sock, int backlog)
1750{
1751 return 0;
1752}
1753
1754static inline int security_socket_accept(struct socket *sock,
1755 struct socket *newsock)
1756{
1757 return 0;
1758}
1759
1760static inline int security_socket_sendmsg(struct socket *sock,
1761 struct msghdr *msg, int size)
1762{
1763 return 0;
1764}
1765
1766static inline int security_socket_recvmsg(struct socket *sock,
1767 struct msghdr *msg, int size,
1768 int flags)
1769{
1770 return 0;
1771}
1772
1773static inline int security_socket_getsockname(struct socket *sock)
1774{
1775 return 0;
1776}
1777
1778static inline int security_socket_getpeername(struct socket *sock)
1779{
1780 return 0;
1781}
1782
1783static inline int security_socket_getsockopt(struct socket *sock,
1784 int level, int optname)
1785{
1786 return 0;
1787}
1788
1789static inline int security_socket_setsockopt(struct socket *sock,
1790 int level, int optname)
1791{
1792 return 0;
1793}
1794
1795static inline int security_socket_shutdown(struct socket *sock, int how)
1796{
1797 return 0;
1798}
1799static inline int security_sock_rcv_skb(struct sock *sk,
1800 struct sk_buff *skb)
1801{
1802 return 0;
1803}
1804
1805static inline int security_socket_getpeersec_stream(struct socket *sock,
1806 sockptr_t optval,
1807 sockptr_t optlen,
1808 unsigned int len)
1809{
1810 return -ENOPROTOOPT;
1811}
1812
1813static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
1814{
1815 return -ENOPROTOOPT;
1816}
1817
1818static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
1819{
1820 return 0;
1821}
1822
1823static inline void security_sk_free(struct sock *sk)
1824{
1825}
1826
1827static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
1828{
1829}
1830
1831static inline void security_sk_classify_flow(const struct sock *sk,
1832 struct flowi_common *flic)
1833{
1834}
1835
1836static inline void security_req_classify_flow(const struct request_sock *req,
1837 struct flowi_common *flic)
1838{
1839}
1840
1841static inline void security_sock_graft(struct sock *sk, struct socket *parent)
1842{
1843}
1844
1845static inline int security_inet_conn_request(const struct sock *sk,
1846 struct sk_buff *skb, struct request_sock *req)
1847{
1848 return 0;
1849}
1850
1851static inline void security_inet_csk_clone(struct sock *newsk,
1852 const struct request_sock *req)
1853{
1854}
1855
1856static inline void security_inet_conn_established(struct sock *sk,
1857 struct sk_buff *skb)
1858{
1859}
1860
1861static inline int security_secmark_relabel_packet(u32 secid)
1862{
1863 return 0;
1864}
1865
1866static inline void security_secmark_refcount_inc(void)
1867{
1868}
1869
1870static inline void security_secmark_refcount_dec(void)
1871{
1872}
1873
1874static inline int security_tun_dev_alloc_security(void **security)
1875{
1876 return 0;
1877}
1878
1879static inline void security_tun_dev_free_security(void *security)
1880{
1881}
1882
1883static inline int security_tun_dev_create(void)
1884{
1885 return 0;
1886}
1887
1888static inline int security_tun_dev_attach_queue(void *security)
1889{
1890 return 0;
1891}
1892
1893static inline int security_tun_dev_attach(struct sock *sk, void *security)
1894{
1895 return 0;
1896}
1897
1898static inline int security_tun_dev_open(void *security)
1899{
1900 return 0;
1901}
1902
1903static inline int security_sctp_assoc_request(struct sctp_association *asoc,
1904 struct sk_buff *skb)
1905{
1906 return 0;
1907}
1908
1909static inline int security_sctp_bind_connect(struct sock *sk, int optname,
1910 struct sockaddr *address,
1911 int addrlen)
1912{
1913 return 0;
1914}
1915
1916static inline void security_sctp_sk_clone(struct sctp_association *asoc,
1917 struct sock *sk,
1918 struct sock *newsk)
1919{
1920}
1921
1922static inline int security_sctp_assoc_established(struct sctp_association *asoc,
1923 struct sk_buff *skb)
1924{
1925 return 0;
1926}
1927
1928static inline int security_mptcp_add_subflow(struct sock *sk, struct sock *ssk)
1929{
1930 return 0;
1931}
1932#endif /* CONFIG_SECURITY_NETWORK */
1933
1934#ifdef CONFIG_SECURITY_INFINIBAND
1935int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey);
1936int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num);
1937int security_ib_alloc_security(void **sec);
1938void security_ib_free_security(void *sec);
1939#else /* CONFIG_SECURITY_INFINIBAND */
1940static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey)
1941{
1942 return 0;
1943}
1944
1945static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num)
1946{
1947 return 0;
1948}
1949
1950static inline int security_ib_alloc_security(void **sec)
1951{
1952 return 0;
1953}
1954
1955static inline void security_ib_free_security(void *sec)
1956{
1957}
1958#endif /* CONFIG_SECURITY_INFINIBAND */
1959
1960#ifdef CONFIG_SECURITY_NETWORK_XFRM
1961
1962int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1963 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
1964int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
1965void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
1966int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
1967int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1968int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1969 struct xfrm_sec_ctx *polsec, u32 secid);
1970int security_xfrm_state_delete(struct xfrm_state *x);
1971void security_xfrm_state_free(struct xfrm_state *x);
1972int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid);
1973int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1974 struct xfrm_policy *xp,
1975 const struct flowi_common *flic);
1976int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
1977void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic);
1978
1979#else /* CONFIG_SECURITY_NETWORK_XFRM */
1980
1981static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1982 struct xfrm_user_sec_ctx *sec_ctx,
1983 gfp_t gfp)
1984{
1985 return 0;
1986}
1987
1988static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
1989{
1990 return 0;
1991}
1992
1993static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
1994{
1995}
1996
1997static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
1998{
1999 return 0;
2000}
2001
2002static inline int security_xfrm_state_alloc(struct xfrm_state *x,
2003 struct xfrm_user_sec_ctx *sec_ctx)
2004{
2005 return 0;
2006}
2007
2008static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2009 struct xfrm_sec_ctx *polsec, u32 secid)
2010{
2011 return 0;
2012}
2013
2014static inline void security_xfrm_state_free(struct xfrm_state *x)
2015{
2016}
2017
2018static inline int security_xfrm_state_delete(struct xfrm_state *x)
2019{
2020 return 0;
2021}
2022
2023static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
2024{
2025 return 0;
2026}
2027
2028static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2029 struct xfrm_policy *xp,
2030 const struct flowi_common *flic)
2031{
2032 return 1;
2033}
2034
2035static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
2036{
2037 return 0;
2038}
2039
2040static inline void security_skb_classify_flow(struct sk_buff *skb,
2041 struct flowi_common *flic)
2042{
2043}
2044
2045#endif /* CONFIG_SECURITY_NETWORK_XFRM */
2046
2047#ifdef CONFIG_SECURITY_PATH
2048int security_path_unlink(const struct path *dir, struct dentry *dentry);
2049int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
2050int security_path_rmdir(const struct path *dir, struct dentry *dentry);
2051int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
2052 unsigned int dev);
2053void security_path_post_mknod(struct mnt_idmap *idmap, struct dentry *dentry);
2054int security_path_truncate(const struct path *path);
2055int security_path_symlink(const struct path *dir, struct dentry *dentry,
2056 const char *old_name);
2057int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
2058 struct dentry *new_dentry);
2059int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
2060 const struct path *new_dir, struct dentry *new_dentry,
2061 unsigned int flags);
2062int security_path_chmod(const struct path *path, umode_t mode);
2063int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
2064int security_path_chroot(const struct path *path);
2065#else /* CONFIG_SECURITY_PATH */
2066static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
2067{
2068 return 0;
2069}
2070
2071static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
2072 umode_t mode)
2073{
2074 return 0;
2075}
2076
2077static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
2078{
2079 return 0;
2080}
2081
2082static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
2083 umode_t mode, unsigned int dev)
2084{
2085 return 0;
2086}
2087
2088static inline void security_path_post_mknod(struct mnt_idmap *idmap,
2089 struct dentry *dentry)
2090{ }
2091
2092static inline int security_path_truncate(const struct path *path)
2093{
2094 return 0;
2095}
2096
2097static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
2098 const char *old_name)
2099{
2100 return 0;
2101}
2102
2103static inline int security_path_link(struct dentry *old_dentry,
2104 const struct path *new_dir,
2105 struct dentry *new_dentry)
2106{
2107 return 0;
2108}
2109
2110static inline int security_path_rename(const struct path *old_dir,
2111 struct dentry *old_dentry,
2112 const struct path *new_dir,
2113 struct dentry *new_dentry,
2114 unsigned int flags)
2115{
2116 return 0;
2117}
2118
2119static inline int security_path_chmod(const struct path *path, umode_t mode)
2120{
2121 return 0;
2122}
2123
2124static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
2125{
2126 return 0;
2127}
2128
2129static inline int security_path_chroot(const struct path *path)
2130{
2131 return 0;
2132}
2133#endif /* CONFIG_SECURITY_PATH */
2134
2135#ifdef CONFIG_KEYS
2136#ifdef CONFIG_SECURITY
2137
2138int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
2139void security_key_free(struct key *key);
2140int security_key_permission(key_ref_t key_ref, const struct cred *cred,
2141 enum key_need_perm need_perm);
2142int security_key_getsecurity(struct key *key, char **_buffer);
2143void security_key_post_create_or_update(struct key *keyring, struct key *key,
2144 const void *payload, size_t payload_len,
2145 unsigned long flags, bool create);
2146
2147#else
2148
2149static inline int security_key_alloc(struct key *key,
2150 const struct cred *cred,
2151 unsigned long flags)
2152{
2153 return 0;
2154}
2155
2156static inline void security_key_free(struct key *key)
2157{
2158}
2159
2160static inline int security_key_permission(key_ref_t key_ref,
2161 const struct cred *cred,
2162 enum key_need_perm need_perm)
2163{
2164 return 0;
2165}
2166
2167static inline int security_key_getsecurity(struct key *key, char **_buffer)
2168{
2169 *_buffer = NULL;
2170 return 0;
2171}
2172
2173static inline void security_key_post_create_or_update(struct key *keyring,
2174 struct key *key,
2175 const void *payload,
2176 size_t payload_len,
2177 unsigned long flags,
2178 bool create)
2179{ }
2180
2181#endif
2182#endif /* CONFIG_KEYS */
2183
2184#ifdef CONFIG_AUDIT
2185#ifdef CONFIG_SECURITY
2186int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule,
2187 gfp_t gfp);
2188int security_audit_rule_known(struct audit_krule *krule);
2189int security_audit_rule_match(struct lsm_prop *prop, u32 field, u32 op,
2190 void *lsmrule);
2191void security_audit_rule_free(void *lsmrule);
2192
2193#else
2194
2195static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
2196 void **lsmrule, gfp_t gfp)
2197{
2198 return 0;
2199}
2200
2201static inline int security_audit_rule_known(struct audit_krule *krule)
2202{
2203 return 0;
2204}
2205
2206static inline int security_audit_rule_match(struct lsm_prop *prop, u32 field,
2207 u32 op, void *lsmrule)
2208{
2209 return 0;
2210}
2211
2212static inline void security_audit_rule_free(void *lsmrule)
2213{ }
2214
2215#endif /* CONFIG_SECURITY */
2216#endif /* CONFIG_AUDIT */
2217
2218#ifdef CONFIG_SECURITYFS
2219
2220extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
2221 struct dentry *parent, void *data,
2222 const struct file_operations *fops);
2223extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2224struct dentry *securityfs_create_symlink(const char *name,
2225 struct dentry *parent,
2226 const char *target,
2227 const struct inode_operations *iops);
2228extern void securityfs_remove(struct dentry *dentry);
2229
2230#else /* CONFIG_SECURITYFS */
2231
2232static inline struct dentry *securityfs_create_dir(const char *name,
2233 struct dentry *parent)
2234{
2235 return ERR_PTR(-ENODEV);
2236}
2237
2238static inline struct dentry *securityfs_create_file(const char *name,
2239 umode_t mode,
2240 struct dentry *parent,
2241 void *data,
2242 const struct file_operations *fops)
2243{
2244 return ERR_PTR(-ENODEV);
2245}
2246
2247static inline struct dentry *securityfs_create_symlink(const char *name,
2248 struct dentry *parent,
2249 const char *target,
2250 const struct inode_operations *iops)
2251{
2252 return ERR_PTR(-ENODEV);
2253}
2254
2255static inline void securityfs_remove(struct dentry *dentry)
2256{}
2257
2258#endif
2259
2260#ifdef CONFIG_BPF_SYSCALL
2261union bpf_attr;
2262struct bpf_map;
2263struct bpf_prog;
2264struct bpf_token;
2265#ifdef CONFIG_SECURITY
2266extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size, bool kernel);
2267extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
2268extern int security_bpf_prog(struct bpf_prog *prog);
2269extern int security_bpf_map_create(struct bpf_map *map, union bpf_attr *attr,
2270 struct bpf_token *token, bool kernel);
2271extern void security_bpf_map_free(struct bpf_map *map);
2272extern int security_bpf_prog_load(struct bpf_prog *prog, union bpf_attr *attr,
2273 struct bpf_token *token, bool kernel);
2274extern void security_bpf_prog_free(struct bpf_prog *prog);
2275extern int security_bpf_token_create(struct bpf_token *token, union bpf_attr *attr,
2276 const struct path *path);
2277extern void security_bpf_token_free(struct bpf_token *token);
2278extern int security_bpf_token_cmd(const struct bpf_token *token, enum bpf_cmd cmd);
2279extern int security_bpf_token_capable(const struct bpf_token *token, int cap);
2280#else
2281static inline int security_bpf(int cmd, union bpf_attr *attr,
2282 unsigned int size, bool kernel)
2283{
2284 return 0;
2285}
2286
2287static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode)
2288{
2289 return 0;
2290}
2291
2292static inline int security_bpf_prog(struct bpf_prog *prog)
2293{
2294 return 0;
2295}
2296
2297static inline int security_bpf_map_create(struct bpf_map *map, union bpf_attr *attr,
2298 struct bpf_token *token, bool kernel)
2299{
2300 return 0;
2301}
2302
2303static inline void security_bpf_map_free(struct bpf_map *map)
2304{ }
2305
2306static inline int security_bpf_prog_load(struct bpf_prog *prog, union bpf_attr *attr,
2307 struct bpf_token *token, bool kernel)
2308{
2309 return 0;
2310}
2311
2312static inline void security_bpf_prog_free(struct bpf_prog *prog)
2313{ }
2314
2315static inline int security_bpf_token_create(struct bpf_token *token, union bpf_attr *attr,
2316 const struct path *path)
2317{
2318 return 0;
2319}
2320
2321static inline void security_bpf_token_free(struct bpf_token *token)
2322{ }
2323
2324static inline int security_bpf_token_cmd(const struct bpf_token *token, enum bpf_cmd cmd)
2325{
2326 return 0;
2327}
2328
2329static inline int security_bpf_token_capable(const struct bpf_token *token, int cap)
2330{
2331 return 0;
2332}
2333#endif /* CONFIG_SECURITY */
2334#endif /* CONFIG_BPF_SYSCALL */
2335
2336#ifdef CONFIG_PERF_EVENTS
2337struct perf_event_attr;
2338struct perf_event;
2339
2340#ifdef CONFIG_SECURITY
2341extern int security_perf_event_open(int type);
2342extern int security_perf_event_alloc(struct perf_event *event);
2343extern void security_perf_event_free(struct perf_event *event);
2344extern int security_perf_event_read(struct perf_event *event);
2345extern int security_perf_event_write(struct perf_event *event);
2346#else
2347static inline int security_perf_event_open(int type)
2348{
2349 return 0;
2350}
2351
2352static inline int security_perf_event_alloc(struct perf_event *event)
2353{
2354 return 0;
2355}
2356
2357static inline void security_perf_event_free(struct perf_event *event)
2358{
2359}
2360
2361static inline int security_perf_event_read(struct perf_event *event)
2362{
2363 return 0;
2364}
2365
2366static inline int security_perf_event_write(struct perf_event *event)
2367{
2368 return 0;
2369}
2370#endif /* CONFIG_SECURITY */
2371#endif /* CONFIG_PERF_EVENTS */
2372
2373#ifdef CONFIG_IO_URING
2374#ifdef CONFIG_SECURITY
2375extern int security_uring_override_creds(const struct cred *new);
2376extern int security_uring_sqpoll(void);
2377extern int security_uring_cmd(struct io_uring_cmd *ioucmd);
2378extern int security_uring_allowed(void);
2379#else
2380static inline int security_uring_override_creds(const struct cred *new)
2381{
2382 return 0;
2383}
2384static inline int security_uring_sqpoll(void)
2385{
2386 return 0;
2387}
2388static inline int security_uring_cmd(struct io_uring_cmd *ioucmd)
2389{
2390 return 0;
2391}
2392static inline int security_uring_allowed(void)
2393{
2394 return 0;
2395}
2396#endif /* CONFIG_SECURITY */
2397#endif /* CONFIG_IO_URING */
2398
2399#ifdef CONFIG_SECURITY
2400extern void security_initramfs_populated(void);
2401#else
2402static inline void security_initramfs_populated(void)
2403{
2404}
2405#endif /* CONFIG_SECURITY */
2406
2407#endif /* ! __LINUX_SECURITY_H */