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