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,
117 LOCKDOWN_DEVICE_TREE,
119 LOCKDOWN_TIOCSSERIAL,
120 LOCKDOWN_MODULE_PARAMETERS,
124 LOCKDOWN_BPF_WRITE_USER,
125 LOCKDOWN_DBG_WRITE_KERNEL,
126 LOCKDOWN_RTAS_ERROR_INJECTION,
127 LOCKDOWN_INTEGRITY_MAX,
130 LOCKDOWN_BPF_READ_KERNEL,
131 LOCKDOWN_DBG_READ_KERNEL,
135 LOCKDOWN_XFRM_SECRET,
136 LOCKDOWN_CONFIDENTIALITY_MAX,
139 extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
141 /* These functions are in security/commoncap.c */
142 extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
143 int cap, unsigned int opts);
144 extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
145 extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
146 extern int cap_ptrace_traceme(struct task_struct *parent);
147 extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
148 extern int cap_capset(struct cred *new, const struct cred *old,
149 const kernel_cap_t *effective,
150 const kernel_cap_t *inheritable,
151 const kernel_cap_t *permitted);
152 extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
153 int cap_inode_setxattr(struct dentry *dentry, const char *name,
154 const void *value, size_t size, int flags);
155 int cap_inode_removexattr(struct user_namespace *mnt_userns,
156 struct dentry *dentry, const char *name);
157 int cap_inode_need_killpriv(struct dentry *dentry);
158 int cap_inode_killpriv(struct user_namespace *mnt_userns,
159 struct dentry *dentry);
160 int cap_inode_getsecurity(struct user_namespace *mnt_userns,
161 struct inode *inode, const char *name, void **buffer,
163 extern int cap_mmap_addr(unsigned long addr);
164 extern int cap_mmap_file(struct file *file, unsigned long reqprot,
165 unsigned long prot, unsigned long flags);
166 extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
167 extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
168 unsigned long arg4, unsigned long arg5);
169 extern int cap_task_setscheduler(struct task_struct *p);
170 extern int cap_task_setioprio(struct task_struct *p, int ioprio);
171 extern int cap_task_setnice(struct task_struct *p, int nice);
172 extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
181 struct xfrm_selector;
184 struct xfrm_user_sec_ctx;
186 struct sctp_association;
189 extern unsigned long mmap_min_addr;
190 extern unsigned long dac_mmap_min_addr;
192 #define mmap_min_addr 0UL
193 #define dac_mmap_min_addr 0UL
197 * Values used in the task_security_ops calls
199 /* setuid or setgid, id0 == uid or gid */
200 #define LSM_SETID_ID 1
202 /* setreuid or setregid, id0 == real, id1 == eff */
203 #define LSM_SETID_RE 2
205 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
206 #define LSM_SETID_RES 4
208 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
209 #define LSM_SETID_FS 8
211 /* Flags for security_task_prlimit(). */
212 #define LSM_PRLIMIT_READ 1
213 #define LSM_PRLIMIT_WRITE 2
215 /* forward declares to avoid warnings */
219 /* bprm->unsafe reasons */
220 #define LSM_UNSAFE_SHARE 1
221 #define LSM_UNSAFE_PTRACE 2
222 #define LSM_UNSAFE_NO_NEW_PRIVS 4
225 extern int mmap_min_addr_handler(struct ctl_table *table, int write,
226 void *buffer, size_t *lenp, loff_t *ppos);
229 /* security_inode_init_security callback function to write xattrs */
230 typedef int (*initxattrs) (struct inode *inode,
231 const struct xattr *xattr_array, void *fs_data);
234 /* Keep the kernel_load_data_id enum in sync with kernel_read_file_id */
235 #define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM,
236 #define __data_id_stringify(dummy, str) #str,
238 enum kernel_load_data_id {
239 __kernel_read_file_id(__data_id_enumify)
242 static const char * const kernel_load_data_str[] = {
243 __kernel_read_file_id(__data_id_stringify)
246 static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
248 if ((unsigned)id >= LOADING_MAX_ID)
249 return kernel_load_data_str[LOADING_UNKNOWN];
251 return kernel_load_data_str[id];
254 #ifdef CONFIG_SECURITY
256 int call_blocking_lsm_notifier(enum lsm_event event, void *data);
257 int register_blocking_lsm_notifier(struct notifier_block *nb);
258 int unregister_blocking_lsm_notifier(struct notifier_block *nb);
261 extern int security_init(void);
262 extern int early_security_init(void);
264 /* Security operations */
265 int security_binder_set_context_mgr(const struct cred *mgr);
266 int security_binder_transaction(const struct cred *from,
267 const struct cred *to);
268 int security_binder_transfer_binder(const struct cred *from,
269 const struct cred *to);
270 int security_binder_transfer_file(const struct cred *from,
271 const struct cred *to, struct file *file);
272 int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
273 int security_ptrace_traceme(struct task_struct *parent);
274 int security_capget(struct task_struct *target,
275 kernel_cap_t *effective,
276 kernel_cap_t *inheritable,
277 kernel_cap_t *permitted);
278 int security_capset(struct cred *new, const struct cred *old,
279 const kernel_cap_t *effective,
280 const kernel_cap_t *inheritable,
281 const kernel_cap_t *permitted);
282 int security_capable(const struct cred *cred,
283 struct user_namespace *ns,
286 int security_quotactl(int cmds, int type, int id, struct super_block *sb);
287 int security_quota_on(struct dentry *dentry);
288 int security_syslog(int type);
289 int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
290 int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
291 int security_bprm_creds_for_exec(struct linux_binprm *bprm);
292 int security_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
293 int security_bprm_check(struct linux_binprm *bprm);
294 void security_bprm_committing_creds(struct linux_binprm *bprm);
295 void security_bprm_committed_creds(struct linux_binprm *bprm);
296 int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc);
297 int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
298 int security_sb_alloc(struct super_block *sb);
299 void security_sb_delete(struct super_block *sb);
300 void security_sb_free(struct super_block *sb);
301 void security_free_mnt_opts(void **mnt_opts);
302 int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
303 int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
304 int security_sb_remount(struct super_block *sb, void *mnt_opts);
305 int security_sb_kern_mount(struct super_block *sb);
306 int security_sb_show_options(struct seq_file *m, struct super_block *sb);
307 int security_sb_statfs(struct dentry *dentry);
308 int security_sb_mount(const char *dev_name, const struct path *path,
309 const char *type, unsigned long flags, void *data);
310 int security_sb_umount(struct vfsmount *mnt, int flags);
311 int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
312 int security_sb_set_mnt_opts(struct super_block *sb,
314 unsigned long kern_flags,
315 unsigned long *set_kern_flags);
316 int security_sb_clone_mnt_opts(const struct super_block *oldsb,
317 struct super_block *newsb,
318 unsigned long kern_flags,
319 unsigned long *set_kern_flags);
320 int security_move_mount(const struct path *from_path, const struct path *to_path);
321 int security_dentry_init_security(struct dentry *dentry, int mode,
322 const struct qstr *name,
323 const char **xattr_name, void **ctx,
325 int security_dentry_create_files_as(struct dentry *dentry, int mode,
327 const struct cred *old,
329 int security_path_notify(const struct path *path, u64 mask,
330 unsigned int obj_type);
331 int security_inode_alloc(struct inode *inode);
332 void security_inode_free(struct inode *inode);
333 int security_inode_init_security(struct inode *inode, struct inode *dir,
334 const struct qstr *qstr,
335 initxattrs initxattrs, void *fs_data);
336 int security_inode_init_security_anon(struct inode *inode,
337 const struct qstr *name,
338 const struct inode *context_inode);
339 int security_old_inode_init_security(struct inode *inode, struct inode *dir,
340 const struct qstr *qstr, const char **name,
341 void **value, size_t *len);
342 int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
343 int security_inode_link(struct dentry *old_dentry, struct inode *dir,
344 struct dentry *new_dentry);
345 int security_inode_unlink(struct inode *dir, struct dentry *dentry);
346 int security_inode_symlink(struct inode *dir, struct dentry *dentry,
347 const char *old_name);
348 int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
349 int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
350 int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
351 int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
352 struct inode *new_dir, struct dentry *new_dentry,
354 int security_inode_readlink(struct dentry *dentry);
355 int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
357 int security_inode_permission(struct inode *inode, int mask);
358 int security_inode_setattr(struct user_namespace *mnt_userns,
359 struct dentry *dentry, struct iattr *attr);
360 int security_inode_getattr(const struct path *path);
361 int security_inode_setxattr(struct user_namespace *mnt_userns,
362 struct dentry *dentry, const char *name,
363 const void *value, size_t size, int flags);
364 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
365 const void *value, size_t size, int flags);
366 int security_inode_getxattr(struct dentry *dentry, const char *name);
367 int security_inode_listxattr(struct dentry *dentry);
368 int security_inode_removexattr(struct user_namespace *mnt_userns,
369 struct dentry *dentry, const char *name);
370 int security_inode_need_killpriv(struct dentry *dentry);
371 int security_inode_killpriv(struct user_namespace *mnt_userns,
372 struct dentry *dentry);
373 int security_inode_getsecurity(struct user_namespace *mnt_userns,
374 struct inode *inode, const char *name,
375 void **buffer, bool alloc);
376 int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
377 int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
378 void security_inode_getsecid(struct inode *inode, u32 *secid);
379 int security_inode_copy_up(struct dentry *src, struct cred **new);
380 int security_inode_copy_up_xattr(const char *name);
381 int security_kernfs_init_security(struct kernfs_node *kn_dir,
382 struct kernfs_node *kn);
383 int security_file_permission(struct file *file, int mask);
384 int security_file_alloc(struct file *file);
385 void security_file_free(struct file *file);
386 int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
387 int security_mmap_file(struct file *file, unsigned long prot,
388 unsigned long flags);
389 int security_mmap_addr(unsigned long addr);
390 int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
392 int security_file_lock(struct file *file, unsigned int cmd);
393 int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
394 void security_file_set_fowner(struct file *file);
395 int security_file_send_sigiotask(struct task_struct *tsk,
396 struct fown_struct *fown, int sig);
397 int security_file_receive(struct file *file);
398 int security_file_open(struct file *file);
399 int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
400 void security_task_free(struct task_struct *task);
401 int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
402 void security_cred_free(struct cred *cred);
403 int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
404 void security_transfer_creds(struct cred *new, const struct cred *old);
405 void security_cred_getsecid(const struct cred *c, u32 *secid);
406 int security_kernel_act_as(struct cred *new, u32 secid);
407 int security_kernel_create_files_as(struct cred *new, struct inode *inode);
408 int security_kernel_module_request(char *kmod_name);
409 int security_kernel_load_data(enum kernel_load_data_id id, bool contents);
410 int security_kernel_post_load_data(char *buf, loff_t size,
411 enum kernel_load_data_id id,
413 int security_kernel_read_file(struct file *file, enum kernel_read_file_id id,
415 int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
416 enum kernel_read_file_id id);
417 int security_task_fix_setuid(struct cred *new, const struct cred *old,
419 int security_task_fix_setgid(struct cred *new, const struct cred *old,
421 int security_task_fix_setgroups(struct cred *new, const struct cred *old);
422 int security_task_setpgid(struct task_struct *p, pid_t pgid);
423 int security_task_getpgid(struct task_struct *p);
424 int security_task_getsid(struct task_struct *p);
425 void security_current_getsecid_subj(u32 *secid);
426 void security_task_getsecid_obj(struct task_struct *p, u32 *secid);
427 int security_task_setnice(struct task_struct *p, int nice);
428 int security_task_setioprio(struct task_struct *p, int ioprio);
429 int security_task_getioprio(struct task_struct *p);
430 int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
432 int security_task_setrlimit(struct task_struct *p, unsigned int resource,
433 struct rlimit *new_rlim);
434 int security_task_setscheduler(struct task_struct *p);
435 int security_task_getscheduler(struct task_struct *p);
436 int security_task_movememory(struct task_struct *p);
437 int security_task_kill(struct task_struct *p, struct kernel_siginfo *info,
438 int sig, const struct cred *cred);
439 int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
440 unsigned long arg4, unsigned long arg5);
441 void security_task_to_inode(struct task_struct *p, struct inode *inode);
442 int security_create_user_ns(const struct cred *cred);
443 int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
444 void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
445 int security_msg_msg_alloc(struct msg_msg *msg);
446 void security_msg_msg_free(struct msg_msg *msg);
447 int security_msg_queue_alloc(struct kern_ipc_perm *msq);
448 void security_msg_queue_free(struct kern_ipc_perm *msq);
449 int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg);
450 int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd);
451 int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
452 struct msg_msg *msg, int msqflg);
453 int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg,
454 struct task_struct *target, long type, int mode);
455 int security_shm_alloc(struct kern_ipc_perm *shp);
456 void security_shm_free(struct kern_ipc_perm *shp);
457 int security_shm_associate(struct kern_ipc_perm *shp, int shmflg);
458 int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd);
459 int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg);
460 int security_sem_alloc(struct kern_ipc_perm *sma);
461 void security_sem_free(struct kern_ipc_perm *sma);
462 int security_sem_associate(struct kern_ipc_perm *sma, int semflg);
463 int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
464 int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
465 unsigned nsops, int alter);
466 void security_d_instantiate(struct dentry *dentry, struct inode *inode);
467 int security_getprocattr(struct task_struct *p, const char *lsm, const char *name,
469 int security_setprocattr(const char *lsm, const char *name, void *value,
471 int security_netlink_send(struct sock *sk, struct sk_buff *skb);
472 int security_ismaclabel(const char *name);
473 int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
474 int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
475 void security_release_secctx(char *secdata, u32 seclen);
476 void security_inode_invalidate_secctx(struct inode *inode);
477 int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
478 int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
479 int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
480 int security_locked_down(enum lockdown_reason what);
481 #else /* CONFIG_SECURITY */
483 static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data)
488 static inline int register_blocking_lsm_notifier(struct notifier_block *nb)
493 static inline int unregister_blocking_lsm_notifier(struct notifier_block *nb)
498 static inline void security_free_mnt_opts(void **mnt_opts)
503 * This is the default capabilities functionality. Most of these functions
504 * are just stubbed out, but a few must call the proper capable code.
507 static inline int security_init(void)
512 static inline int early_security_init(void)
517 static inline int security_binder_set_context_mgr(const struct cred *mgr)
522 static inline int security_binder_transaction(const struct cred *from,
523 const struct cred *to)
528 static inline int security_binder_transfer_binder(const struct cred *from,
529 const struct cred *to)
534 static inline int security_binder_transfer_file(const struct cred *from,
535 const struct cred *to,
541 static inline int security_ptrace_access_check(struct task_struct *child,
544 return cap_ptrace_access_check(child, mode);
547 static inline int security_ptrace_traceme(struct task_struct *parent)
549 return cap_ptrace_traceme(parent);
552 static inline int security_capget(struct task_struct *target,
553 kernel_cap_t *effective,
554 kernel_cap_t *inheritable,
555 kernel_cap_t *permitted)
557 return cap_capget(target, effective, inheritable, permitted);
560 static inline int security_capset(struct cred *new,
561 const struct cred *old,
562 const kernel_cap_t *effective,
563 const kernel_cap_t *inheritable,
564 const kernel_cap_t *permitted)
566 return cap_capset(new, old, effective, inheritable, permitted);
569 static inline int security_capable(const struct cred *cred,
570 struct user_namespace *ns,
574 return cap_capable(cred, ns, cap, opts);
577 static inline int security_quotactl(int cmds, int type, int id,
578 struct super_block *sb)
583 static inline int security_quota_on(struct dentry *dentry)
588 static inline int security_syslog(int type)
593 static inline int security_settime64(const struct timespec64 *ts,
594 const struct timezone *tz)
596 return cap_settime(ts, tz);
599 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
601 return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages));
604 static inline int security_bprm_creds_for_exec(struct linux_binprm *bprm)
609 static inline int security_bprm_creds_from_file(struct linux_binprm *bprm,
612 return cap_bprm_creds_from_file(bprm, file);
615 static inline int security_bprm_check(struct linux_binprm *bprm)
620 static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
624 static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
628 static inline int security_fs_context_dup(struct fs_context *fc,
629 struct fs_context *src_fc)
633 static inline int security_fs_context_parse_param(struct fs_context *fc,
634 struct fs_parameter *param)
639 static inline int security_sb_alloc(struct super_block *sb)
644 static inline void security_sb_delete(struct super_block *sb)
647 static inline void security_sb_free(struct super_block *sb)
650 static inline int security_sb_eat_lsm_opts(char *options,
656 static inline int security_sb_remount(struct super_block *sb,
662 static inline int security_sb_mnt_opts_compat(struct super_block *sb,
669 static inline int security_sb_kern_mount(struct super_block *sb)
674 static inline int security_sb_show_options(struct seq_file *m,
675 struct super_block *sb)
680 static inline int security_sb_statfs(struct dentry *dentry)
685 static inline int security_sb_mount(const char *dev_name, const struct path *path,
686 const char *type, unsigned long flags,
692 static inline int security_sb_umount(struct vfsmount *mnt, int flags)
697 static inline int security_sb_pivotroot(const struct path *old_path,
698 const struct path *new_path)
703 static inline int security_sb_set_mnt_opts(struct super_block *sb,
705 unsigned long kern_flags,
706 unsigned long *set_kern_flags)
711 static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
712 struct super_block *newsb,
713 unsigned long kern_flags,
714 unsigned long *set_kern_flags)
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,
742 const char **xattr_name,
749 static inline int security_dentry_create_files_as(struct dentry *dentry,
750 int mode, struct qstr *name,
751 const struct cred *old,
758 static inline int security_inode_init_security(struct inode *inode,
760 const struct qstr *qstr,
761 const initxattrs xattrs,
767 static inline int security_inode_init_security_anon(struct inode *inode,
768 const struct qstr *name,
769 const struct inode *context_inode)
774 static inline int security_old_inode_init_security(struct inode *inode,
776 const struct qstr *qstr,
778 void **value, size_t *len)
783 static inline int security_inode_create(struct inode *dir,
784 struct dentry *dentry,
790 static inline int security_inode_link(struct dentry *old_dentry,
792 struct dentry *new_dentry)
797 static inline int security_inode_unlink(struct inode *dir,
798 struct dentry *dentry)
803 static inline int security_inode_symlink(struct inode *dir,
804 struct dentry *dentry,
805 const char *old_name)
810 static inline int security_inode_mkdir(struct inode *dir,
811 struct dentry *dentry,
817 static inline int security_inode_rmdir(struct inode *dir,
818 struct dentry *dentry)
823 static inline int security_inode_mknod(struct inode *dir,
824 struct dentry *dentry,
830 static inline int security_inode_rename(struct inode *old_dir,
831 struct dentry *old_dentry,
832 struct inode *new_dir,
833 struct dentry *new_dentry,
839 static inline int security_inode_readlink(struct dentry *dentry)
844 static inline int security_inode_follow_link(struct dentry *dentry,
851 static inline int security_inode_permission(struct inode *inode, int mask)
856 static inline int security_inode_setattr(struct user_namespace *mnt_userns,
857 struct dentry *dentry,
863 static inline int security_inode_getattr(const struct path *path)
868 static inline int security_inode_setxattr(struct user_namespace *mnt_userns,
869 struct dentry *dentry, const char *name, const void *value,
870 size_t size, int flags)
872 return cap_inode_setxattr(dentry, name, value, size, flags);
875 static inline void security_inode_post_setxattr(struct dentry *dentry,
876 const char *name, const void *value, size_t size, int flags)
879 static inline int security_inode_getxattr(struct dentry *dentry,
885 static inline int security_inode_listxattr(struct dentry *dentry)
890 static inline int security_inode_removexattr(struct user_namespace *mnt_userns,
891 struct dentry *dentry,
894 return cap_inode_removexattr(mnt_userns, dentry, name);
897 static inline int security_inode_need_killpriv(struct dentry *dentry)
899 return cap_inode_need_killpriv(dentry);
902 static inline int security_inode_killpriv(struct user_namespace *mnt_userns,
903 struct dentry *dentry)
905 return cap_inode_killpriv(mnt_userns, dentry);
908 static inline int security_inode_getsecurity(struct user_namespace *mnt_userns,
910 const char *name, void **buffer,
913 return cap_inode_getsecurity(mnt_userns, inode, name, buffer, alloc);
916 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
921 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
926 static inline void security_inode_getsecid(struct inode *inode, u32 *secid)
931 static inline int security_inode_copy_up(struct dentry *src, struct cred **new)
936 static inline int security_kernfs_init_security(struct kernfs_node *kn_dir,
937 struct kernfs_node *kn)
942 static inline int security_inode_copy_up_xattr(const char *name)
947 static inline int security_file_permission(struct file *file, int mask)
952 static inline int security_file_alloc(struct file *file)
957 static inline void security_file_free(struct file *file)
960 static inline int security_file_ioctl(struct file *file, unsigned int cmd,
966 static inline int security_mmap_file(struct file *file, unsigned long prot,
972 static inline int security_mmap_addr(unsigned long addr)
974 return cap_mmap_addr(addr);
977 static inline int security_file_mprotect(struct vm_area_struct *vma,
978 unsigned long reqprot,
984 static inline int security_file_lock(struct file *file, unsigned int cmd)
989 static inline int security_file_fcntl(struct file *file, unsigned int cmd,
995 static inline void security_file_set_fowner(struct file *file)
1000 static inline int security_file_send_sigiotask(struct task_struct *tsk,
1001 struct fown_struct *fown,
1007 static inline int security_file_receive(struct file *file)
1012 static inline int security_file_open(struct file *file)
1017 static inline int security_task_alloc(struct task_struct *task,
1018 unsigned long clone_flags)
1023 static inline void security_task_free(struct task_struct *task)
1026 static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
1031 static inline void security_cred_free(struct cred *cred)
1034 static inline int security_prepare_creds(struct cred *new,
1035 const struct cred *old,
1041 static inline void security_transfer_creds(struct cred *new,
1042 const struct cred *old)
1046 static inline void security_cred_getsecid(const struct cred *c, u32 *secid)
1051 static inline int security_kernel_act_as(struct cred *cred, u32 secid)
1056 static inline int security_kernel_create_files_as(struct cred *cred,
1057 struct inode *inode)
1062 static inline int security_kernel_module_request(char *kmod_name)
1067 static inline int security_kernel_load_data(enum kernel_load_data_id id, bool contents)
1072 static inline int security_kernel_post_load_data(char *buf, loff_t size,
1073 enum kernel_load_data_id id,
1079 static inline int security_kernel_read_file(struct file *file,
1080 enum kernel_read_file_id id,
1086 static inline int security_kernel_post_read_file(struct file *file,
1087 char *buf, loff_t size,
1088 enum kernel_read_file_id id)
1093 static inline int security_task_fix_setuid(struct cred *new,
1094 const struct cred *old,
1097 return cap_task_fix_setuid(new, old, flags);
1100 static inline int security_task_fix_setgid(struct cred *new,
1101 const struct cred *old,
1107 static inline int security_task_fix_setgroups(struct cred *new,
1108 const struct cred *old)
1113 static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
1118 static inline int security_task_getpgid(struct task_struct *p)
1123 static inline int security_task_getsid(struct task_struct *p)
1128 static inline void security_current_getsecid_subj(u32 *secid)
1133 static inline void security_task_getsecid_obj(struct task_struct *p, u32 *secid)
1138 static inline int security_task_setnice(struct task_struct *p, int nice)
1140 return cap_task_setnice(p, nice);
1143 static inline int security_task_setioprio(struct task_struct *p, int ioprio)
1145 return cap_task_setioprio(p, ioprio);
1148 static inline int security_task_getioprio(struct task_struct *p)
1153 static inline int security_task_prlimit(const struct cred *cred,
1154 const struct cred *tcred,
1160 static inline int security_task_setrlimit(struct task_struct *p,
1161 unsigned int resource,
1162 struct rlimit *new_rlim)
1167 static inline int security_task_setscheduler(struct task_struct *p)
1169 return cap_task_setscheduler(p);
1172 static inline int security_task_getscheduler(struct task_struct *p)
1177 static inline int security_task_movememory(struct task_struct *p)
1182 static inline int security_task_kill(struct task_struct *p,
1183 struct kernel_siginfo *info, int sig,
1184 const struct cred *cred)
1189 static inline int security_task_prctl(int option, unsigned long arg2,
1194 return cap_task_prctl(option, arg2, arg3, arg4, arg5);
1197 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1200 static inline int security_create_user_ns(const struct cred *cred)
1205 static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
1211 static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
1216 static inline int security_msg_msg_alloc(struct msg_msg *msg)
1221 static inline void security_msg_msg_free(struct msg_msg *msg)
1224 static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq)
1229 static inline void security_msg_queue_free(struct kern_ipc_perm *msq)
1232 static inline int security_msg_queue_associate(struct kern_ipc_perm *msq,
1238 static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd)
1243 static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
1244 struct msg_msg *msg, int msqflg)
1249 static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq,
1250 struct msg_msg *msg,
1251 struct task_struct *target,
1252 long type, int mode)
1257 static inline int security_shm_alloc(struct kern_ipc_perm *shp)
1262 static inline void security_shm_free(struct kern_ipc_perm *shp)
1265 static inline int security_shm_associate(struct kern_ipc_perm *shp,
1271 static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd)
1276 static inline int security_shm_shmat(struct kern_ipc_perm *shp,
1277 char __user *shmaddr, int shmflg)
1282 static inline int security_sem_alloc(struct kern_ipc_perm *sma)
1287 static inline void security_sem_free(struct kern_ipc_perm *sma)
1290 static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg)
1295 static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd)
1300 static inline int security_sem_semop(struct kern_ipc_perm *sma,
1301 struct sembuf *sops, unsigned nsops,
1307 static inline void security_d_instantiate(struct dentry *dentry,
1308 struct inode *inode)
1311 static inline int security_getprocattr(struct task_struct *p, const char *lsm,
1312 const char *name, char **value)
1317 static inline int security_setprocattr(const char *lsm, char *name,
1318 void *value, size_t size)
1323 static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
1328 static inline int security_ismaclabel(const char *name)
1333 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
1338 static inline int security_secctx_to_secid(const char *secdata,
1345 static inline void security_release_secctx(char *secdata, u32 seclen)
1349 static inline void security_inode_invalidate_secctx(struct inode *inode)
1353 static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
1357 static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
1361 static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
1365 static inline int security_locked_down(enum lockdown_reason what)
1369 #endif /* CONFIG_SECURITY */
1371 #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
1372 int security_post_notification(const struct cred *w_cred,
1373 const struct cred *cred,
1374 struct watch_notification *n);
1376 static inline int security_post_notification(const struct cred *w_cred,
1377 const struct cred *cred,
1378 struct watch_notification *n)
1384 #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
1385 int security_watch_key(struct key *key);
1387 static inline int security_watch_key(struct key *key)
1393 #ifdef CONFIG_SECURITY_NETWORK
1395 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
1396 int security_unix_may_send(struct socket *sock, struct socket *other);
1397 int security_socket_create(int family, int type, int protocol, int kern);
1398 int security_socket_post_create(struct socket *sock, int family,
1399 int type, int protocol, int kern);
1400 int security_socket_socketpair(struct socket *socka, struct socket *sockb);
1401 int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
1402 int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
1403 int security_socket_listen(struct socket *sock, int backlog);
1404 int security_socket_accept(struct socket *sock, struct socket *newsock);
1405 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
1406 int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
1407 int size, int flags);
1408 int security_socket_getsockname(struct socket *sock);
1409 int security_socket_getpeername(struct socket *sock);
1410 int security_socket_getsockopt(struct socket *sock, int level, int optname);
1411 int security_socket_setsockopt(struct socket *sock, int level, int optname);
1412 int security_socket_shutdown(struct socket *sock, int how);
1413 int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
1414 int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
1415 int __user *optlen, unsigned len);
1416 int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
1417 int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
1418 void security_sk_free(struct sock *sk);
1419 void security_sk_clone(const struct sock *sk, struct sock *newsk);
1420 void security_sk_classify_flow(struct sock *sk, struct flowi_common *flic);
1421 void security_req_classify_flow(const struct request_sock *req,
1422 struct flowi_common *flic);
1423 void security_sock_graft(struct sock*sk, struct socket *parent);
1424 int security_inet_conn_request(const struct sock *sk,
1425 struct sk_buff *skb, struct request_sock *req);
1426 void security_inet_csk_clone(struct sock *newsk,
1427 const struct request_sock *req);
1428 void security_inet_conn_established(struct sock *sk,
1429 struct sk_buff *skb);
1430 int security_secmark_relabel_packet(u32 secid);
1431 void security_secmark_refcount_inc(void);
1432 void security_secmark_refcount_dec(void);
1433 int security_tun_dev_alloc_security(void **security);
1434 void security_tun_dev_free_security(void *security);
1435 int security_tun_dev_create(void);
1436 int security_tun_dev_attach_queue(void *security);
1437 int security_tun_dev_attach(struct sock *sk, void *security);
1438 int security_tun_dev_open(void *security);
1439 int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb);
1440 int security_sctp_bind_connect(struct sock *sk, int optname,
1441 struct sockaddr *address, int addrlen);
1442 void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk,
1443 struct sock *newsk);
1444 int security_sctp_assoc_established(struct sctp_association *asoc,
1445 struct sk_buff *skb);
1447 #else /* CONFIG_SECURITY_NETWORK */
1448 static inline int security_unix_stream_connect(struct sock *sock,
1455 static inline int security_unix_may_send(struct socket *sock,
1456 struct socket *other)
1461 static inline int security_socket_create(int family, int type,
1462 int protocol, int kern)
1467 static inline int security_socket_post_create(struct socket *sock,
1470 int protocol, int kern)
1475 static inline int security_socket_socketpair(struct socket *socka,
1476 struct socket *sockb)
1481 static inline int security_socket_bind(struct socket *sock,
1482 struct sockaddr *address,
1488 static inline int security_socket_connect(struct socket *sock,
1489 struct sockaddr *address,
1495 static inline int security_socket_listen(struct socket *sock, int backlog)
1500 static inline int security_socket_accept(struct socket *sock,
1501 struct socket *newsock)
1506 static inline int security_socket_sendmsg(struct socket *sock,
1507 struct msghdr *msg, int size)
1512 static inline int security_socket_recvmsg(struct socket *sock,
1513 struct msghdr *msg, int size,
1519 static inline int security_socket_getsockname(struct socket *sock)
1524 static inline int security_socket_getpeername(struct socket *sock)
1529 static inline int security_socket_getsockopt(struct socket *sock,
1530 int level, int optname)
1535 static inline int security_socket_setsockopt(struct socket *sock,
1536 int level, int optname)
1541 static inline int security_socket_shutdown(struct socket *sock, int how)
1545 static inline int security_sock_rcv_skb(struct sock *sk,
1546 struct sk_buff *skb)
1551 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
1552 int __user *optlen, unsigned len)
1554 return -ENOPROTOOPT;
1557 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
1559 return -ENOPROTOOPT;
1562 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
1567 static inline void security_sk_free(struct sock *sk)
1571 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
1575 static inline void security_sk_classify_flow(struct sock *sk,
1576 struct flowi_common *flic)
1580 static inline void security_req_classify_flow(const struct request_sock *req,
1581 struct flowi_common *flic)
1585 static inline void security_sock_graft(struct sock *sk, struct socket *parent)
1589 static inline int security_inet_conn_request(const struct sock *sk,
1590 struct sk_buff *skb, struct request_sock *req)
1595 static inline void security_inet_csk_clone(struct sock *newsk,
1596 const struct request_sock *req)
1600 static inline void security_inet_conn_established(struct sock *sk,
1601 struct sk_buff *skb)
1605 static inline int security_secmark_relabel_packet(u32 secid)
1610 static inline void security_secmark_refcount_inc(void)
1614 static inline void security_secmark_refcount_dec(void)
1618 static inline int security_tun_dev_alloc_security(void **security)
1623 static inline void security_tun_dev_free_security(void *security)
1627 static inline int security_tun_dev_create(void)
1632 static inline int security_tun_dev_attach_queue(void *security)
1637 static inline int security_tun_dev_attach(struct sock *sk, void *security)
1642 static inline int security_tun_dev_open(void *security)
1647 static inline int security_sctp_assoc_request(struct sctp_association *asoc,
1648 struct sk_buff *skb)
1653 static inline int security_sctp_bind_connect(struct sock *sk, int optname,
1654 struct sockaddr *address,
1660 static inline void security_sctp_sk_clone(struct sctp_association *asoc,
1666 static inline int security_sctp_assoc_established(struct sctp_association *asoc,
1667 struct sk_buff *skb)
1671 #endif /* CONFIG_SECURITY_NETWORK */
1673 #ifdef CONFIG_SECURITY_INFINIBAND
1674 int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey);
1675 int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num);
1676 int security_ib_alloc_security(void **sec);
1677 void security_ib_free_security(void *sec);
1678 #else /* CONFIG_SECURITY_INFINIBAND */
1679 static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey)
1684 static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num)
1689 static inline int security_ib_alloc_security(void **sec)
1694 static inline void security_ib_free_security(void *sec)
1697 #endif /* CONFIG_SECURITY_INFINIBAND */
1699 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1701 int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1702 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
1703 int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
1704 void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
1705 int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
1706 int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1707 int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1708 struct xfrm_sec_ctx *polsec, u32 secid);
1709 int security_xfrm_state_delete(struct xfrm_state *x);
1710 void security_xfrm_state_free(struct xfrm_state *x);
1711 int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid);
1712 int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1713 struct xfrm_policy *xp,
1714 const struct flowi_common *flic);
1715 int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
1716 void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic);
1718 #else /* CONFIG_SECURITY_NETWORK_XFRM */
1720 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1721 struct xfrm_user_sec_ctx *sec_ctx,
1727 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
1732 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
1736 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
1741 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
1742 struct xfrm_user_sec_ctx *sec_ctx)
1747 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1748 struct xfrm_sec_ctx *polsec, u32 secid)
1753 static inline void security_xfrm_state_free(struct xfrm_state *x)
1757 static inline int security_xfrm_state_delete(struct xfrm_state *x)
1762 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
1767 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1768 struct xfrm_policy *xp,
1769 const struct flowi_common *flic)
1774 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
1779 static inline void security_skb_classify_flow(struct sk_buff *skb,
1780 struct flowi_common *flic)
1784 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1786 #ifdef CONFIG_SECURITY_PATH
1787 int security_path_unlink(const struct path *dir, struct dentry *dentry);
1788 int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
1789 int security_path_rmdir(const struct path *dir, struct dentry *dentry);
1790 int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
1792 int security_path_truncate(const struct path *path);
1793 int security_path_symlink(const struct path *dir, struct dentry *dentry,
1794 const char *old_name);
1795 int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
1796 struct dentry *new_dentry);
1797 int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
1798 const struct path *new_dir, struct dentry *new_dentry,
1799 unsigned int flags);
1800 int security_path_chmod(const struct path *path, umode_t mode);
1801 int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
1802 int security_path_chroot(const struct path *path);
1803 #else /* CONFIG_SECURITY_PATH */
1804 static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
1809 static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
1815 static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
1820 static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
1821 umode_t mode, unsigned int dev)
1826 static inline int security_path_truncate(const struct path *path)
1831 static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
1832 const char *old_name)
1837 static inline int security_path_link(struct dentry *old_dentry,
1838 const struct path *new_dir,
1839 struct dentry *new_dentry)
1844 static inline int security_path_rename(const struct path *old_dir,
1845 struct dentry *old_dentry,
1846 const struct path *new_dir,
1847 struct dentry *new_dentry,
1853 static inline int security_path_chmod(const struct path *path, umode_t mode)
1858 static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
1863 static inline int security_path_chroot(const struct path *path)
1867 #endif /* CONFIG_SECURITY_PATH */
1870 #ifdef CONFIG_SECURITY
1872 int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
1873 void security_key_free(struct key *key);
1874 int security_key_permission(key_ref_t key_ref, const struct cred *cred,
1875 enum key_need_perm need_perm);
1876 int security_key_getsecurity(struct key *key, char **_buffer);
1880 static inline int security_key_alloc(struct key *key,
1881 const struct cred *cred,
1882 unsigned long flags)
1887 static inline void security_key_free(struct key *key)
1891 static inline int security_key_permission(key_ref_t key_ref,
1892 const struct cred *cred,
1893 enum key_need_perm need_perm)
1898 static inline int security_key_getsecurity(struct key *key, char **_buffer)
1905 #endif /* CONFIG_KEYS */
1908 #ifdef CONFIG_SECURITY
1909 int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
1910 int security_audit_rule_known(struct audit_krule *krule);
1911 int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule);
1912 void security_audit_rule_free(void *lsmrule);
1916 static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
1922 static inline int security_audit_rule_known(struct audit_krule *krule)
1927 static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
1933 static inline void security_audit_rule_free(void *lsmrule)
1936 #endif /* CONFIG_SECURITY */
1937 #endif /* CONFIG_AUDIT */
1939 #ifdef CONFIG_SECURITYFS
1941 extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
1942 struct dentry *parent, void *data,
1943 const struct file_operations *fops);
1944 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1945 struct dentry *securityfs_create_symlink(const char *name,
1946 struct dentry *parent,
1948 const struct inode_operations *iops);
1949 extern void securityfs_remove(struct dentry *dentry);
1951 #else /* CONFIG_SECURITYFS */
1953 static inline struct dentry *securityfs_create_dir(const char *name,
1954 struct dentry *parent)
1956 return ERR_PTR(-ENODEV);
1959 static inline struct dentry *securityfs_create_file(const char *name,
1961 struct dentry *parent,
1963 const struct file_operations *fops)
1965 return ERR_PTR(-ENODEV);
1968 static inline struct dentry *securityfs_create_symlink(const char *name,
1969 struct dentry *parent,
1971 const struct inode_operations *iops)
1973 return ERR_PTR(-ENODEV);
1976 static inline void securityfs_remove(struct dentry *dentry)
1981 #ifdef CONFIG_BPF_SYSCALL
1985 struct bpf_prog_aux;
1986 #ifdef CONFIG_SECURITY
1987 extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size);
1988 extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
1989 extern int security_bpf_prog(struct bpf_prog *prog);
1990 extern int security_bpf_map_alloc(struct bpf_map *map);
1991 extern void security_bpf_map_free(struct bpf_map *map);
1992 extern int security_bpf_prog_alloc(struct bpf_prog_aux *aux);
1993 extern void security_bpf_prog_free(struct bpf_prog_aux *aux);
1995 static inline int security_bpf(int cmd, union bpf_attr *attr,
2001 static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode)
2006 static inline int security_bpf_prog(struct bpf_prog *prog)
2011 static inline int security_bpf_map_alloc(struct bpf_map *map)
2016 static inline void security_bpf_map_free(struct bpf_map *map)
2019 static inline int security_bpf_prog_alloc(struct bpf_prog_aux *aux)
2024 static inline void security_bpf_prog_free(struct bpf_prog_aux *aux)
2026 #endif /* CONFIG_SECURITY */
2027 #endif /* CONFIG_BPF_SYSCALL */
2029 #ifdef CONFIG_PERF_EVENTS
2030 struct perf_event_attr;
2033 #ifdef CONFIG_SECURITY
2034 extern int security_perf_event_open(struct perf_event_attr *attr, int type);
2035 extern int security_perf_event_alloc(struct perf_event *event);
2036 extern void security_perf_event_free(struct perf_event *event);
2037 extern int security_perf_event_read(struct perf_event *event);
2038 extern int security_perf_event_write(struct perf_event *event);
2040 static inline int security_perf_event_open(struct perf_event_attr *attr,
2046 static inline int security_perf_event_alloc(struct perf_event *event)
2051 static inline void security_perf_event_free(struct perf_event *event)
2055 static inline int security_perf_event_read(struct perf_event *event)
2060 static inline int security_perf_event_write(struct perf_event *event)
2064 #endif /* CONFIG_SECURITY */
2065 #endif /* CONFIG_PERF_EVENTS */
2067 #ifdef CONFIG_IO_URING
2068 #ifdef CONFIG_SECURITY
2069 extern int security_uring_override_creds(const struct cred *new);
2070 extern int security_uring_sqpoll(void);
2071 extern int security_uring_cmd(struct io_uring_cmd *ioucmd);
2073 static inline int security_uring_override_creds(const struct cred *new)
2077 static inline int security_uring_sqpoll(void)
2081 static inline int security_uring_cmd(struct io_uring_cmd *ioucmd)
2085 #endif /* CONFIG_SECURITY */
2086 #endif /* CONFIG_IO_URING */
2088 #endif /* ! __LINUX_SECURITY_H */