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