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