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
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.
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.
23 #ifndef __LINUX_SECURITY_H
24 #define __LINUX_SECURITY_H
26 #include <linux/kernel_read_file.h>
27 #include <linux/key.h>
28 #include <linux/capability.h>
30 #include <linux/slab.h>
31 #include <linux/err.h>
32 #include <linux/string.h>
38 struct kernel_siginfo;
51 struct file_operations;
61 struct watch_notification;
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)
70 /* LSM Agnostic defines for fs_context::lsm_flags */
71 #define SECURITY_LSM_NATIVE_LABELS 1
75 struct user_namespace;
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.
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
103 * If you add to this, remember to extend lockdown_reasons in
104 * security/lockdown/lockdown.c.
106 enum lockdown_reason {
108 LOCKDOWN_MODULE_SIGNATURE,
112 LOCKDOWN_HIBERNATION,
116 LOCKDOWN_ACPI_TABLES,
118 LOCKDOWN_TIOCSSERIAL,
119 LOCKDOWN_MODULE_PARAMETERS,
123 LOCKDOWN_BPF_WRITE_USER,
124 LOCKDOWN_INTEGRITY_MAX,
127 LOCKDOWN_BPF_READ_KERNEL,
131 LOCKDOWN_XFRM_SECRET,
132 LOCKDOWN_CONFIDENTIALITY_MAX,
135 extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
137 /* These functions are in security/commoncap.c */
138 extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
139 int cap, unsigned int opts);
140 extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
141 extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
142 extern int cap_ptrace_traceme(struct task_struct *parent);
143 extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
144 extern int cap_capset(struct cred *new, const struct cred *old,
145 const kernel_cap_t *effective,
146 const kernel_cap_t *inheritable,
147 const kernel_cap_t *permitted);
148 extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
149 int cap_inode_setxattr(struct dentry *dentry, const char *name,
150 const void *value, size_t size, int flags);
151 int cap_inode_removexattr(struct user_namespace *mnt_userns,
152 struct dentry *dentry, const char *name);
153 int cap_inode_need_killpriv(struct dentry *dentry);
154 int cap_inode_killpriv(struct user_namespace *mnt_userns,
155 struct dentry *dentry);
156 int cap_inode_getsecurity(struct user_namespace *mnt_userns,
157 struct inode *inode, const char *name, void **buffer,
159 extern int cap_mmap_addr(unsigned long addr);
160 extern int cap_mmap_file(struct file *file, unsigned long reqprot,
161 unsigned long prot, unsigned long flags);
162 extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
163 extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
164 unsigned long arg4, unsigned long arg5);
165 extern int cap_task_setscheduler(struct task_struct *p);
166 extern int cap_task_setioprio(struct task_struct *p, int ioprio);
167 extern int cap_task_setnice(struct task_struct *p, int nice);
168 extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
177 struct xfrm_selector;
180 struct xfrm_user_sec_ctx;
182 struct sctp_endpoint;
185 extern unsigned long mmap_min_addr;
186 extern unsigned long dac_mmap_min_addr;
188 #define mmap_min_addr 0UL
189 #define dac_mmap_min_addr 0UL
193 * Values used in the task_security_ops calls
195 /* setuid or setgid, id0 == uid or gid */
196 #define LSM_SETID_ID 1
198 /* setreuid or setregid, id0 == real, id1 == eff */
199 #define LSM_SETID_RE 2
201 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
202 #define LSM_SETID_RES 4
204 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
205 #define LSM_SETID_FS 8
207 /* Flags for security_task_prlimit(). */
208 #define LSM_PRLIMIT_READ 1
209 #define LSM_PRLIMIT_WRITE 2
211 /* forward declares to avoid warnings */
215 /* bprm->unsafe reasons */
216 #define LSM_UNSAFE_SHARE 1
217 #define LSM_UNSAFE_PTRACE 2
218 #define LSM_UNSAFE_NO_NEW_PRIVS 4
221 extern int mmap_min_addr_handler(struct ctl_table *table, int write,
222 void *buffer, size_t *lenp, loff_t *ppos);
225 /* security_inode_init_security callback function to write xattrs */
226 typedef int (*initxattrs) (struct inode *inode,
227 const struct xattr *xattr_array, void *fs_data);
230 /* Keep the kernel_load_data_id enum in sync with kernel_read_file_id */
231 #define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM,
232 #define __data_id_stringify(dummy, str) #str,
234 enum kernel_load_data_id {
235 __kernel_read_file_id(__data_id_enumify)
238 static const char * const kernel_load_data_str[] = {
239 __kernel_read_file_id(__data_id_stringify)
242 static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
244 if ((unsigned)id >= LOADING_MAX_ID)
245 return kernel_load_data_str[LOADING_UNKNOWN];
247 return kernel_load_data_str[id];
250 #ifdef CONFIG_SECURITY
252 int call_blocking_lsm_notifier(enum lsm_event event, void *data);
253 int register_blocking_lsm_notifier(struct notifier_block *nb);
254 int unregister_blocking_lsm_notifier(struct notifier_block *nb);
257 extern int security_init(void);
258 extern int early_security_init(void);
260 /* Security operations */
261 int security_binder_set_context_mgr(struct task_struct *mgr);
262 int security_binder_transaction(struct task_struct *from,
263 struct task_struct *to);
264 int security_binder_transfer_binder(struct task_struct *from,
265 struct task_struct *to);
266 int security_binder_transfer_file(struct task_struct *from,
267 struct task_struct *to, struct file *file);
268 int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
269 int security_ptrace_traceme(struct task_struct *parent);
270 int security_capget(struct task_struct *target,
271 kernel_cap_t *effective,
272 kernel_cap_t *inheritable,
273 kernel_cap_t *permitted);
274 int security_capset(struct cred *new, const struct cred *old,
275 const kernel_cap_t *effective,
276 const kernel_cap_t *inheritable,
277 const kernel_cap_t *permitted);
278 int security_capable(const struct cred *cred,
279 struct user_namespace *ns,
282 int security_quotactl(int cmds, int type, int id, struct super_block *sb);
283 int security_quota_on(struct dentry *dentry);
284 int security_syslog(int type);
285 int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
286 int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
287 int security_bprm_creds_for_exec(struct linux_binprm *bprm);
288 int security_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
289 int security_bprm_check(struct linux_binprm *bprm);
290 void security_bprm_committing_creds(struct linux_binprm *bprm);
291 void security_bprm_committed_creds(struct linux_binprm *bprm);
292 int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc);
293 int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
294 int security_sb_alloc(struct super_block *sb);
295 void security_sb_delete(struct super_block *sb);
296 void security_sb_free(struct super_block *sb);
297 void security_free_mnt_opts(void **mnt_opts);
298 int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
299 int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
300 int security_sb_remount(struct super_block *sb, void *mnt_opts);
301 int security_sb_kern_mount(struct super_block *sb);
302 int security_sb_show_options(struct seq_file *m, struct super_block *sb);
303 int security_sb_statfs(struct dentry *dentry);
304 int security_sb_mount(const char *dev_name, const struct path *path,
305 const char *type, unsigned long flags, void *data);
306 int security_sb_umount(struct vfsmount *mnt, int flags);
307 int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
308 int security_sb_set_mnt_opts(struct super_block *sb,
310 unsigned long kern_flags,
311 unsigned long *set_kern_flags);
312 int security_sb_clone_mnt_opts(const struct super_block *oldsb,
313 struct super_block *newsb,
314 unsigned long kern_flags,
315 unsigned long *set_kern_flags);
316 int security_add_mnt_opt(const char *option, const char *val,
317 int len, void **mnt_opts);
318 int security_move_mount(const struct path *from_path, const struct path *to_path);
319 int security_dentry_init_security(struct dentry *dentry, int mode,
320 const struct qstr *name, void **ctx,
322 int security_dentry_create_files_as(struct dentry *dentry, int mode,
324 const struct cred *old,
326 int security_path_notify(const struct path *path, u64 mask,
327 unsigned int obj_type);
328 int security_inode_alloc(struct inode *inode);
329 void security_inode_free(struct inode *inode);
330 int security_inode_init_security(struct inode *inode, struct inode *dir,
331 const struct qstr *qstr,
332 initxattrs initxattrs, void *fs_data);
333 int security_inode_init_security_anon(struct inode *inode,
334 const struct qstr *name,
335 const struct inode *context_inode);
336 int security_old_inode_init_security(struct inode *inode, struct inode *dir,
337 const struct qstr *qstr, const char **name,
338 void **value, size_t *len);
339 int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
340 int security_inode_link(struct dentry *old_dentry, struct inode *dir,
341 struct dentry *new_dentry);
342 int security_inode_unlink(struct inode *dir, struct dentry *dentry);
343 int security_inode_symlink(struct inode *dir, struct dentry *dentry,
344 const char *old_name);
345 int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
346 int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
347 int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
348 int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
349 struct inode *new_dir, struct dentry *new_dentry,
351 int security_inode_readlink(struct dentry *dentry);
352 int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
354 int security_inode_permission(struct inode *inode, int mask);
355 int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
356 int security_inode_getattr(const struct path *path);
357 int security_inode_setxattr(struct user_namespace *mnt_userns,
358 struct dentry *dentry, const char *name,
359 const void *value, size_t size, int flags);
360 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
361 const void *value, size_t size, int flags);
362 int security_inode_getxattr(struct dentry *dentry, const char *name);
363 int security_inode_listxattr(struct dentry *dentry);
364 int security_inode_removexattr(struct user_namespace *mnt_userns,
365 struct dentry *dentry, const char *name);
366 int security_inode_need_killpriv(struct dentry *dentry);
367 int security_inode_killpriv(struct user_namespace *mnt_userns,
368 struct dentry *dentry);
369 int security_inode_getsecurity(struct user_namespace *mnt_userns,
370 struct inode *inode, const char *name,
371 void **buffer, bool alloc);
372 int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
373 int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
374 void security_inode_getsecid(struct inode *inode, u32 *secid);
375 int security_inode_copy_up(struct dentry *src, struct cred **new);
376 int security_inode_copy_up_xattr(const char *name);
377 int security_kernfs_init_security(struct kernfs_node *kn_dir,
378 struct kernfs_node *kn);
379 int security_file_permission(struct file *file, int mask);
380 int security_file_alloc(struct file *file);
381 void security_file_free(struct file *file);
382 int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
383 int security_mmap_file(struct file *file, unsigned long prot,
384 unsigned long flags);
385 int security_mmap_addr(unsigned long addr);
386 int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
388 int security_file_lock(struct file *file, unsigned int cmd);
389 int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
390 void security_file_set_fowner(struct file *file);
391 int security_file_send_sigiotask(struct task_struct *tsk,
392 struct fown_struct *fown, int sig);
393 int security_file_receive(struct file *file);
394 int security_file_open(struct file *file);
395 int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
396 void security_task_free(struct task_struct *task);
397 int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
398 void security_cred_free(struct cred *cred);
399 int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
400 void security_transfer_creds(struct cred *new, const struct cred *old);
401 void security_cred_getsecid(const struct cred *c, u32 *secid);
402 int security_kernel_act_as(struct cred *new, u32 secid);
403 int security_kernel_create_files_as(struct cred *new, struct inode *inode);
404 int security_kernel_module_request(char *kmod_name);
405 int security_kernel_load_data(enum kernel_load_data_id id, bool contents);
406 int security_kernel_post_load_data(char *buf, loff_t size,
407 enum kernel_load_data_id id,
409 int security_kernel_read_file(struct file *file, enum kernel_read_file_id id,
411 int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
412 enum kernel_read_file_id id);
413 int security_task_fix_setuid(struct cred *new, const struct cred *old,
415 int security_task_fix_setgid(struct cred *new, const struct cred *old,
417 int security_task_setpgid(struct task_struct *p, pid_t pgid);
418 int security_task_getpgid(struct task_struct *p);
419 int security_task_getsid(struct task_struct *p);
420 void security_task_getsecid_subj(struct task_struct *p, u32 *secid);
421 void security_task_getsecid_obj(struct task_struct *p, u32 *secid);
422 int security_task_setnice(struct task_struct *p, int nice);
423 int security_task_setioprio(struct task_struct *p, int ioprio);
424 int security_task_getioprio(struct task_struct *p);
425 int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
427 int security_task_setrlimit(struct task_struct *p, unsigned int resource,
428 struct rlimit *new_rlim);
429 int security_task_setscheduler(struct task_struct *p);
430 int security_task_getscheduler(struct task_struct *p);
431 int security_task_movememory(struct task_struct *p);
432 int security_task_kill(struct task_struct *p, struct kernel_siginfo *info,
433 int sig, const struct cred *cred);
434 int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
435 unsigned long arg4, unsigned long arg5);
436 void security_task_to_inode(struct task_struct *p, struct inode *inode);
437 int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
438 void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
439 int security_msg_msg_alloc(struct msg_msg *msg);
440 void security_msg_msg_free(struct msg_msg *msg);
441 int security_msg_queue_alloc(struct kern_ipc_perm *msq);
442 void security_msg_queue_free(struct kern_ipc_perm *msq);
443 int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg);
444 int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd);
445 int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
446 struct msg_msg *msg, int msqflg);
447 int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg,
448 struct task_struct *target, long type, int mode);
449 int security_shm_alloc(struct kern_ipc_perm *shp);
450 void security_shm_free(struct kern_ipc_perm *shp);
451 int security_shm_associate(struct kern_ipc_perm *shp, int shmflg);
452 int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd);
453 int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg);
454 int security_sem_alloc(struct kern_ipc_perm *sma);
455 void security_sem_free(struct kern_ipc_perm *sma);
456 int security_sem_associate(struct kern_ipc_perm *sma, int semflg);
457 int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
458 int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
459 unsigned nsops, int alter);
460 void security_d_instantiate(struct dentry *dentry, struct inode *inode);
461 int security_getprocattr(struct task_struct *p, const char *lsm, char *name,
463 int security_setprocattr(const char *lsm, const char *name, void *value,
465 int security_netlink_send(struct sock *sk, struct sk_buff *skb);
466 int security_ismaclabel(const char *name);
467 int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
468 int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
469 void security_release_secctx(char *secdata, u32 seclen);
470 void security_inode_invalidate_secctx(struct inode *inode);
471 int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
472 int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
473 int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
474 int security_locked_down(enum lockdown_reason what);
475 #else /* CONFIG_SECURITY */
477 static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data)
482 static inline int register_blocking_lsm_notifier(struct notifier_block *nb)
487 static inline int unregister_blocking_lsm_notifier(struct notifier_block *nb)
492 static inline void security_free_mnt_opts(void **mnt_opts)
497 * This is the default capabilities functionality. Most of these functions
498 * are just stubbed out, but a few must call the proper capable code.
501 static inline int security_init(void)
506 static inline int early_security_init(void)
511 static inline int security_binder_set_context_mgr(struct task_struct *mgr)
516 static inline int security_binder_transaction(struct task_struct *from,
517 struct task_struct *to)
522 static inline int security_binder_transfer_binder(struct task_struct *from,
523 struct task_struct *to)
528 static inline int security_binder_transfer_file(struct task_struct *from,
529 struct task_struct *to,
535 static inline int security_ptrace_access_check(struct task_struct *child,
538 return cap_ptrace_access_check(child, mode);
541 static inline int security_ptrace_traceme(struct task_struct *parent)
543 return cap_ptrace_traceme(parent);
546 static inline int security_capget(struct task_struct *target,
547 kernel_cap_t *effective,
548 kernel_cap_t *inheritable,
549 kernel_cap_t *permitted)
551 return cap_capget(target, effective, inheritable, permitted);
554 static inline int security_capset(struct cred *new,
555 const struct cred *old,
556 const kernel_cap_t *effective,
557 const kernel_cap_t *inheritable,
558 const kernel_cap_t *permitted)
560 return cap_capset(new, old, effective, inheritable, permitted);
563 static inline int security_capable(const struct cred *cred,
564 struct user_namespace *ns,
568 return cap_capable(cred, ns, cap, opts);
571 static inline int security_quotactl(int cmds, int type, int id,
572 struct super_block *sb)
577 static inline int security_quota_on(struct dentry *dentry)
582 static inline int security_syslog(int type)
587 static inline int security_settime64(const struct timespec64 *ts,
588 const struct timezone *tz)
590 return cap_settime(ts, tz);
593 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
595 return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages));
598 static inline int security_bprm_creds_for_exec(struct linux_binprm *bprm)
603 static inline int security_bprm_creds_from_file(struct linux_binprm *bprm,
606 return cap_bprm_creds_from_file(bprm, file);
609 static inline int security_bprm_check(struct linux_binprm *bprm)
614 static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
618 static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
622 static inline int security_fs_context_dup(struct fs_context *fc,
623 struct fs_context *src_fc)
627 static inline int security_fs_context_parse_param(struct fs_context *fc,
628 struct fs_parameter *param)
633 static inline int security_sb_alloc(struct super_block *sb)
638 static inline void security_sb_delete(struct super_block *sb)
641 static inline void security_sb_free(struct super_block *sb)
644 static inline int security_sb_eat_lsm_opts(char *options,
650 static inline int security_sb_remount(struct super_block *sb,
656 static inline int security_sb_mnt_opts_compat(struct super_block *sb,
663 static inline int security_sb_kern_mount(struct super_block *sb)
668 static inline int security_sb_show_options(struct seq_file *m,
669 struct super_block *sb)
674 static inline int security_sb_statfs(struct dentry *dentry)
679 static inline int security_sb_mount(const char *dev_name, const struct path *path,
680 const char *type, unsigned long flags,
686 static inline int security_sb_umount(struct vfsmount *mnt, int flags)
691 static inline int security_sb_pivotroot(const struct path *old_path,
692 const struct path *new_path)
697 static inline int security_sb_set_mnt_opts(struct super_block *sb,
699 unsigned long kern_flags,
700 unsigned long *set_kern_flags)
705 static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
706 struct super_block *newsb,
707 unsigned long kern_flags,
708 unsigned long *set_kern_flags)
713 static inline int security_add_mnt_opt(const char *option, const char *val,
714 int len, void **mnt_opts)
719 static inline int security_move_mount(const struct path *from_path,
720 const struct path *to_path)
725 static inline int security_path_notify(const struct path *path, u64 mask,
726 unsigned int obj_type)
731 static inline int security_inode_alloc(struct inode *inode)
736 static inline void security_inode_free(struct inode *inode)
739 static inline int security_dentry_init_security(struct dentry *dentry,
741 const struct qstr *name,
748 static inline int security_dentry_create_files_as(struct dentry *dentry,
749 int mode, struct qstr *name,
750 const struct cred *old,
757 static inline int security_inode_init_security(struct inode *inode,
759 const struct qstr *qstr,
760 const initxattrs xattrs,
766 static inline int security_inode_init_security_anon(struct inode *inode,
767 const struct qstr *name,
768 const struct inode *context_inode)
773 static inline int security_old_inode_init_security(struct inode *inode,
775 const struct qstr *qstr,
777 void **value, size_t *len)
782 static inline int security_inode_create(struct inode *dir,
783 struct dentry *dentry,
789 static inline int security_inode_link(struct dentry *old_dentry,
791 struct dentry *new_dentry)
796 static inline int security_inode_unlink(struct inode *dir,
797 struct dentry *dentry)
802 static inline int security_inode_symlink(struct inode *dir,
803 struct dentry *dentry,
804 const char *old_name)
809 static inline int security_inode_mkdir(struct inode *dir,
810 struct dentry *dentry,
816 static inline int security_inode_rmdir(struct inode *dir,
817 struct dentry *dentry)
822 static inline int security_inode_mknod(struct inode *dir,
823 struct dentry *dentry,
829 static inline int security_inode_rename(struct inode *old_dir,
830 struct dentry *old_dentry,
831 struct inode *new_dir,
832 struct dentry *new_dentry,
838 static inline int security_inode_readlink(struct dentry *dentry)
843 static inline int security_inode_follow_link(struct dentry *dentry,
850 static inline int security_inode_permission(struct inode *inode, int mask)
855 static inline int security_inode_setattr(struct dentry *dentry,
861 static inline int security_inode_getattr(const struct path *path)
866 static inline int security_inode_setxattr(struct user_namespace *mnt_userns,
867 struct dentry *dentry, const char *name, const void *value,
868 size_t size, int flags)
870 return cap_inode_setxattr(dentry, name, value, size, flags);
873 static inline void security_inode_post_setxattr(struct dentry *dentry,
874 const char *name, const void *value, size_t size, int flags)
877 static inline int security_inode_getxattr(struct dentry *dentry,
883 static inline int security_inode_listxattr(struct dentry *dentry)
888 static inline int security_inode_removexattr(struct user_namespace *mnt_userns,
889 struct dentry *dentry,
892 return cap_inode_removexattr(mnt_userns, dentry, name);
895 static inline int security_inode_need_killpriv(struct dentry *dentry)
897 return cap_inode_need_killpriv(dentry);
900 static inline int security_inode_killpriv(struct user_namespace *mnt_userns,
901 struct dentry *dentry)
903 return cap_inode_killpriv(mnt_userns, dentry);
906 static inline int security_inode_getsecurity(struct user_namespace *mnt_userns,
908 const char *name, void **buffer,
911 return cap_inode_getsecurity(mnt_userns, inode, name, buffer, alloc);
914 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
919 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
924 static inline void security_inode_getsecid(struct inode *inode, u32 *secid)
929 static inline int security_inode_copy_up(struct dentry *src, struct cred **new)
934 static inline int security_kernfs_init_security(struct kernfs_node *kn_dir,
935 struct kernfs_node *kn)
940 static inline int security_inode_copy_up_xattr(const char *name)
945 static inline int security_file_permission(struct file *file, int mask)
950 static inline int security_file_alloc(struct file *file)
955 static inline void security_file_free(struct file *file)
958 static inline int security_file_ioctl(struct file *file, unsigned int cmd,
964 static inline int security_mmap_file(struct file *file, unsigned long prot,
970 static inline int security_mmap_addr(unsigned long addr)
972 return cap_mmap_addr(addr);
975 static inline int security_file_mprotect(struct vm_area_struct *vma,
976 unsigned long reqprot,
982 static inline int security_file_lock(struct file *file, unsigned int cmd)
987 static inline int security_file_fcntl(struct file *file, unsigned int cmd,
993 static inline void security_file_set_fowner(struct file *file)
998 static inline int security_file_send_sigiotask(struct task_struct *tsk,
999 struct fown_struct *fown,
1005 static inline int security_file_receive(struct file *file)
1010 static inline int security_file_open(struct file *file)
1015 static inline int security_task_alloc(struct task_struct *task,
1016 unsigned long clone_flags)
1021 static inline void security_task_free(struct task_struct *task)
1024 static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
1029 static inline void security_cred_free(struct cred *cred)
1032 static inline int security_prepare_creds(struct cred *new,
1033 const struct cred *old,
1039 static inline void security_transfer_creds(struct cred *new,
1040 const struct cred *old)
1044 static inline int security_kernel_act_as(struct cred *cred, u32 secid)
1049 static inline int security_kernel_create_files_as(struct cred *cred,
1050 struct inode *inode)
1055 static inline int security_kernel_module_request(char *kmod_name)
1060 static inline int security_kernel_load_data(enum kernel_load_data_id id, bool contents)
1065 static inline int security_kernel_post_load_data(char *buf, loff_t size,
1066 enum kernel_load_data_id id,
1072 static inline int security_kernel_read_file(struct file *file,
1073 enum kernel_read_file_id id,
1079 static inline int security_kernel_post_read_file(struct file *file,
1080 char *buf, loff_t size,
1081 enum kernel_read_file_id id)
1086 static inline int security_task_fix_setuid(struct cred *new,
1087 const struct cred *old,
1090 return cap_task_fix_setuid(new, old, flags);
1093 static inline int security_task_fix_setgid(struct cred *new,
1094 const struct cred *old,
1100 static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
1105 static inline int security_task_getpgid(struct task_struct *p)
1110 static inline int security_task_getsid(struct task_struct *p)
1115 static inline void security_task_getsecid_subj(struct task_struct *p, u32 *secid)
1120 static inline void security_task_getsecid_obj(struct task_struct *p, u32 *secid)
1125 static inline int security_task_setnice(struct task_struct *p, int nice)
1127 return cap_task_setnice(p, nice);
1130 static inline int security_task_setioprio(struct task_struct *p, int ioprio)
1132 return cap_task_setioprio(p, ioprio);
1135 static inline int security_task_getioprio(struct task_struct *p)
1140 static inline int security_task_prlimit(const struct cred *cred,
1141 const struct cred *tcred,
1147 static inline int security_task_setrlimit(struct task_struct *p,
1148 unsigned int resource,
1149 struct rlimit *new_rlim)
1154 static inline int security_task_setscheduler(struct task_struct *p)
1156 return cap_task_setscheduler(p);
1159 static inline int security_task_getscheduler(struct task_struct *p)
1164 static inline int security_task_movememory(struct task_struct *p)
1169 static inline int security_task_kill(struct task_struct *p,
1170 struct kernel_siginfo *info, int sig,
1171 const struct cred *cred)
1176 static inline int security_task_prctl(int option, unsigned long arg2,
1181 return cap_task_prctl(option, arg2, arg3, arg4, arg5);
1184 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1187 static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
1193 static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
1198 static inline int security_msg_msg_alloc(struct msg_msg *msg)
1203 static inline void security_msg_msg_free(struct msg_msg *msg)
1206 static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq)
1211 static inline void security_msg_queue_free(struct kern_ipc_perm *msq)
1214 static inline int security_msg_queue_associate(struct kern_ipc_perm *msq,
1220 static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd)
1225 static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
1226 struct msg_msg *msg, int msqflg)
1231 static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq,
1232 struct msg_msg *msg,
1233 struct task_struct *target,
1234 long type, int mode)
1239 static inline int security_shm_alloc(struct kern_ipc_perm *shp)
1244 static inline void security_shm_free(struct kern_ipc_perm *shp)
1247 static inline int security_shm_associate(struct kern_ipc_perm *shp,
1253 static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd)
1258 static inline int security_shm_shmat(struct kern_ipc_perm *shp,
1259 char __user *shmaddr, int shmflg)
1264 static inline int security_sem_alloc(struct kern_ipc_perm *sma)
1269 static inline void security_sem_free(struct kern_ipc_perm *sma)
1272 static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg)
1277 static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd)
1282 static inline int security_sem_semop(struct kern_ipc_perm *sma,
1283 struct sembuf *sops, unsigned nsops,
1289 static inline void security_d_instantiate(struct dentry *dentry,
1290 struct inode *inode)
1293 static inline int security_getprocattr(struct task_struct *p, const char *lsm,
1294 char *name, char **value)
1299 static inline int security_setprocattr(const char *lsm, char *name,
1300 void *value, size_t size)
1305 static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
1310 static inline int security_ismaclabel(const char *name)
1315 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
1320 static inline int security_secctx_to_secid(const char *secdata,
1327 static inline void security_release_secctx(char *secdata, u32 seclen)
1331 static inline void security_inode_invalidate_secctx(struct inode *inode)
1335 static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
1339 static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
1343 static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
1347 static inline int security_locked_down(enum lockdown_reason what)
1351 #endif /* CONFIG_SECURITY */
1353 #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
1354 int security_post_notification(const struct cred *w_cred,
1355 const struct cred *cred,
1356 struct watch_notification *n);
1358 static inline int security_post_notification(const struct cred *w_cred,
1359 const struct cred *cred,
1360 struct watch_notification *n)
1366 #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
1367 int security_watch_key(struct key *key);
1369 static inline int security_watch_key(struct key *key)
1375 #ifdef CONFIG_SECURITY_NETWORK
1377 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
1378 int security_unix_may_send(struct socket *sock, struct socket *other);
1379 int security_socket_create(int family, int type, int protocol, int kern);
1380 int security_socket_post_create(struct socket *sock, int family,
1381 int type, int protocol, int kern);
1382 int security_socket_socketpair(struct socket *socka, struct socket *sockb);
1383 int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
1384 int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
1385 int security_socket_listen(struct socket *sock, int backlog);
1386 int security_socket_accept(struct socket *sock, struct socket *newsock);
1387 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
1388 int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
1389 int size, int flags);
1390 int security_socket_getsockname(struct socket *sock);
1391 int security_socket_getpeername(struct socket *sock);
1392 int security_socket_getsockopt(struct socket *sock, int level, int optname);
1393 int security_socket_setsockopt(struct socket *sock, int level, int optname);
1394 int security_socket_shutdown(struct socket *sock, int how);
1395 int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
1396 int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
1397 int __user *optlen, unsigned len);
1398 int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
1399 int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
1400 void security_sk_free(struct sock *sk);
1401 void security_sk_clone(const struct sock *sk, struct sock *newsk);
1402 void security_sk_classify_flow(struct sock *sk, struct flowi_common *flic);
1403 void security_req_classify_flow(const struct request_sock *req,
1404 struct flowi_common *flic);
1405 void security_sock_graft(struct sock*sk, struct socket *parent);
1406 int security_inet_conn_request(const struct sock *sk,
1407 struct sk_buff *skb, struct request_sock *req);
1408 void security_inet_csk_clone(struct sock *newsk,
1409 const struct request_sock *req);
1410 void security_inet_conn_established(struct sock *sk,
1411 struct sk_buff *skb);
1412 int security_secmark_relabel_packet(u32 secid);
1413 void security_secmark_refcount_inc(void);
1414 void security_secmark_refcount_dec(void);
1415 int security_tun_dev_alloc_security(void **security);
1416 void security_tun_dev_free_security(void *security);
1417 int security_tun_dev_create(void);
1418 int security_tun_dev_attach_queue(void *security);
1419 int security_tun_dev_attach(struct sock *sk, void *security);
1420 int security_tun_dev_open(void *security);
1421 int security_sctp_assoc_request(struct sctp_endpoint *ep, struct sk_buff *skb);
1422 int security_sctp_bind_connect(struct sock *sk, int optname,
1423 struct sockaddr *address, int addrlen);
1424 void security_sctp_sk_clone(struct sctp_endpoint *ep, struct sock *sk,
1425 struct sock *newsk);
1427 #else /* CONFIG_SECURITY_NETWORK */
1428 static inline int security_unix_stream_connect(struct sock *sock,
1435 static inline int security_unix_may_send(struct socket *sock,
1436 struct socket *other)
1441 static inline int security_socket_create(int family, int type,
1442 int protocol, int kern)
1447 static inline int security_socket_post_create(struct socket *sock,
1450 int protocol, int kern)
1455 static inline int security_socket_socketpair(struct socket *socka,
1456 struct socket *sockb)
1461 static inline int security_socket_bind(struct socket *sock,
1462 struct sockaddr *address,
1468 static inline int security_socket_connect(struct socket *sock,
1469 struct sockaddr *address,
1475 static inline int security_socket_listen(struct socket *sock, int backlog)
1480 static inline int security_socket_accept(struct socket *sock,
1481 struct socket *newsock)
1486 static inline int security_socket_sendmsg(struct socket *sock,
1487 struct msghdr *msg, int size)
1492 static inline int security_socket_recvmsg(struct socket *sock,
1493 struct msghdr *msg, int size,
1499 static inline int security_socket_getsockname(struct socket *sock)
1504 static inline int security_socket_getpeername(struct socket *sock)
1509 static inline int security_socket_getsockopt(struct socket *sock,
1510 int level, int optname)
1515 static inline int security_socket_setsockopt(struct socket *sock,
1516 int level, int optname)
1521 static inline int security_socket_shutdown(struct socket *sock, int how)
1525 static inline int security_sock_rcv_skb(struct sock *sk,
1526 struct sk_buff *skb)
1531 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
1532 int __user *optlen, unsigned len)
1534 return -ENOPROTOOPT;
1537 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
1539 return -ENOPROTOOPT;
1542 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
1547 static inline void security_sk_free(struct sock *sk)
1551 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
1555 static inline void security_sk_classify_flow(struct sock *sk,
1556 struct flowi_common *flic)
1560 static inline void security_req_classify_flow(const struct request_sock *req,
1561 struct flowi_common *flic)
1565 static inline void security_sock_graft(struct sock *sk, struct socket *parent)
1569 static inline int security_inet_conn_request(const struct sock *sk,
1570 struct sk_buff *skb, struct request_sock *req)
1575 static inline void security_inet_csk_clone(struct sock *newsk,
1576 const struct request_sock *req)
1580 static inline void security_inet_conn_established(struct sock *sk,
1581 struct sk_buff *skb)
1585 static inline int security_secmark_relabel_packet(u32 secid)
1590 static inline void security_secmark_refcount_inc(void)
1594 static inline void security_secmark_refcount_dec(void)
1598 static inline int security_tun_dev_alloc_security(void **security)
1603 static inline void security_tun_dev_free_security(void *security)
1607 static inline int security_tun_dev_create(void)
1612 static inline int security_tun_dev_attach_queue(void *security)
1617 static inline int security_tun_dev_attach(struct sock *sk, void *security)
1622 static inline int security_tun_dev_open(void *security)
1627 static inline int security_sctp_assoc_request(struct sctp_endpoint *ep,
1628 struct sk_buff *skb)
1633 static inline int security_sctp_bind_connect(struct sock *sk, int optname,
1634 struct sockaddr *address,
1640 static inline void security_sctp_sk_clone(struct sctp_endpoint *ep,
1645 #endif /* CONFIG_SECURITY_NETWORK */
1647 #ifdef CONFIG_SECURITY_INFINIBAND
1648 int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey);
1649 int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num);
1650 int security_ib_alloc_security(void **sec);
1651 void security_ib_free_security(void *sec);
1652 #else /* CONFIG_SECURITY_INFINIBAND */
1653 static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey)
1658 static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num)
1663 static inline int security_ib_alloc_security(void **sec)
1668 static inline void security_ib_free_security(void *sec)
1671 #endif /* CONFIG_SECURITY_INFINIBAND */
1673 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1675 int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1676 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
1677 int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
1678 void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
1679 int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
1680 int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1681 int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1682 struct xfrm_sec_ctx *polsec, u32 secid);
1683 int security_xfrm_state_delete(struct xfrm_state *x);
1684 void security_xfrm_state_free(struct xfrm_state *x);
1685 int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid);
1686 int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1687 struct xfrm_policy *xp,
1688 const struct flowi_common *flic);
1689 int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
1690 void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic);
1692 #else /* CONFIG_SECURITY_NETWORK_XFRM */
1694 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1695 struct xfrm_user_sec_ctx *sec_ctx,
1701 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
1706 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
1710 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
1715 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
1716 struct xfrm_user_sec_ctx *sec_ctx)
1721 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1722 struct xfrm_sec_ctx *polsec, u32 secid)
1727 static inline void security_xfrm_state_free(struct xfrm_state *x)
1731 static inline int security_xfrm_state_delete(struct xfrm_state *x)
1736 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
1741 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1742 struct xfrm_policy *xp,
1743 const struct flowi_common *flic)
1748 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
1753 static inline void security_skb_classify_flow(struct sk_buff *skb,
1754 struct flowi_common *flic)
1758 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1760 #ifdef CONFIG_SECURITY_PATH
1761 int security_path_unlink(const struct path *dir, struct dentry *dentry);
1762 int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
1763 int security_path_rmdir(const struct path *dir, struct dentry *dentry);
1764 int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
1766 int security_path_truncate(const struct path *path);
1767 int security_path_symlink(const struct path *dir, struct dentry *dentry,
1768 const char *old_name);
1769 int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
1770 struct dentry *new_dentry);
1771 int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
1772 const struct path *new_dir, struct dentry *new_dentry,
1773 unsigned int flags);
1774 int security_path_chmod(const struct path *path, umode_t mode);
1775 int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
1776 int security_path_chroot(const struct path *path);
1777 #else /* CONFIG_SECURITY_PATH */
1778 static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
1783 static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
1789 static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
1794 static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
1795 umode_t mode, unsigned int dev)
1800 static inline int security_path_truncate(const struct path *path)
1805 static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
1806 const char *old_name)
1811 static inline int security_path_link(struct dentry *old_dentry,
1812 const struct path *new_dir,
1813 struct dentry *new_dentry)
1818 static inline int security_path_rename(const struct path *old_dir,
1819 struct dentry *old_dentry,
1820 const struct path *new_dir,
1821 struct dentry *new_dentry,
1827 static inline int security_path_chmod(const struct path *path, umode_t mode)
1832 static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
1837 static inline int security_path_chroot(const struct path *path)
1841 #endif /* CONFIG_SECURITY_PATH */
1844 #ifdef CONFIG_SECURITY
1846 int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
1847 void security_key_free(struct key *key);
1848 int security_key_permission(key_ref_t key_ref, const struct cred *cred,
1849 enum key_need_perm need_perm);
1850 int security_key_getsecurity(struct key *key, char **_buffer);
1854 static inline int security_key_alloc(struct key *key,
1855 const struct cred *cred,
1856 unsigned long flags)
1861 static inline void security_key_free(struct key *key)
1865 static inline int security_key_permission(key_ref_t key_ref,
1866 const struct cred *cred,
1867 enum key_need_perm need_perm)
1872 static inline int security_key_getsecurity(struct key *key, char **_buffer)
1879 #endif /* CONFIG_KEYS */
1882 #ifdef CONFIG_SECURITY
1883 int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
1884 int security_audit_rule_known(struct audit_krule *krule);
1885 int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule);
1886 void security_audit_rule_free(void *lsmrule);
1890 static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
1896 static inline int security_audit_rule_known(struct audit_krule *krule)
1901 static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
1907 static inline void security_audit_rule_free(void *lsmrule)
1910 #endif /* CONFIG_SECURITY */
1911 #endif /* CONFIG_AUDIT */
1913 #ifdef CONFIG_SECURITYFS
1915 extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
1916 struct dentry *parent, void *data,
1917 const struct file_operations *fops);
1918 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1919 struct dentry *securityfs_create_symlink(const char *name,
1920 struct dentry *parent,
1922 const struct inode_operations *iops);
1923 extern void securityfs_remove(struct dentry *dentry);
1925 #else /* CONFIG_SECURITYFS */
1927 static inline struct dentry *securityfs_create_dir(const char *name,
1928 struct dentry *parent)
1930 return ERR_PTR(-ENODEV);
1933 static inline struct dentry *securityfs_create_file(const char *name,
1935 struct dentry *parent,
1937 const struct file_operations *fops)
1939 return ERR_PTR(-ENODEV);
1942 static inline struct dentry *securityfs_create_symlink(const char *name,
1943 struct dentry *parent,
1945 const struct inode_operations *iops)
1947 return ERR_PTR(-ENODEV);
1950 static inline void securityfs_remove(struct dentry *dentry)
1955 #ifdef CONFIG_BPF_SYSCALL
1959 struct bpf_prog_aux;
1960 #ifdef CONFIG_SECURITY
1961 extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size);
1962 extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
1963 extern int security_bpf_prog(struct bpf_prog *prog);
1964 extern int security_bpf_map_alloc(struct bpf_map *map);
1965 extern void security_bpf_map_free(struct bpf_map *map);
1966 extern int security_bpf_prog_alloc(struct bpf_prog_aux *aux);
1967 extern void security_bpf_prog_free(struct bpf_prog_aux *aux);
1969 static inline int security_bpf(int cmd, union bpf_attr *attr,
1975 static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode)
1980 static inline int security_bpf_prog(struct bpf_prog *prog)
1985 static inline int security_bpf_map_alloc(struct bpf_map *map)
1990 static inline void security_bpf_map_free(struct bpf_map *map)
1993 static inline int security_bpf_prog_alloc(struct bpf_prog_aux *aux)
1998 static inline void security_bpf_prog_free(struct bpf_prog_aux *aux)
2000 #endif /* CONFIG_SECURITY */
2001 #endif /* CONFIG_BPF_SYSCALL */
2003 #ifdef CONFIG_PERF_EVENTS
2004 struct perf_event_attr;
2007 #ifdef CONFIG_SECURITY
2008 extern int security_perf_event_open(struct perf_event_attr *attr, int type);
2009 extern int security_perf_event_alloc(struct perf_event *event);
2010 extern void security_perf_event_free(struct perf_event *event);
2011 extern int security_perf_event_read(struct perf_event *event);
2012 extern int security_perf_event_write(struct perf_event *event);
2014 static inline int security_perf_event_open(struct perf_event_attr *attr,
2020 static inline int security_perf_event_alloc(struct perf_event *event)
2025 static inline void security_perf_event_free(struct perf_event *event)
2029 static inline int security_perf_event_read(struct perf_event *event)
2034 static inline int security_perf_event_write(struct perf_event *event)
2038 #endif /* CONFIG_SECURITY */
2039 #endif /* CONFIG_PERF_EVENTS */
2041 #endif /* ! __LINUX_SECURITY_H */