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