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