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>
34 #include <linux/sockptr.h>
39 struct kernel_siginfo;
52 struct file_operations;
62 struct watch_notification;
64 /* Default (no) options for the capable function */
65 #define CAP_OPT_NONE 0x0
66 /* If capable should audit the security request */
67 #define CAP_OPT_NOAUDIT BIT(1)
68 /* If capable is being called by a setid function */
69 #define CAP_OPT_INSETID BIT(2)
71 /* LSM Agnostic defines for security_sb_set_mnt_opts() flags */
72 #define SECURITY_LSM_NATIVE_LABELS 1
76 struct user_namespace;
84 * These are reasons that can be passed to the security_locked_down()
85 * LSM hook. Lockdown reasons that protect kernel integrity (ie, the
86 * ability for userland to modify kernel code) are placed before
87 * LOCKDOWN_INTEGRITY_MAX. Lockdown reasons that protect kernel
88 * confidentiality (ie, the ability for userland to extract
89 * information from the running kernel that would otherwise be
90 * restricted) are placed before LOCKDOWN_CONFIDENTIALITY_MAX.
92 * LSM authors should note that the semantics of any given lockdown
93 * reason are not guaranteed to be stable - the same reason may block
94 * one set of features in one kernel release, and a slightly different
95 * set of features in a later kernel release. LSMs that seek to expose
96 * lockdown policy at any level of granularity other than "none",
97 * "integrity" or "confidentiality" are responsible for either
98 * ensuring that they expose a consistent level of functionality to
99 * userland, or ensuring that userland is aware that this is
100 * potentially a moving target. It is easy to misuse this information
101 * in a way that could break userspace. Please be careful not to do
104 * If you add to this, remember to extend lockdown_reasons in
105 * security/lockdown/lockdown.c.
107 enum lockdown_reason {
109 LOCKDOWN_MODULE_SIGNATURE,
113 LOCKDOWN_HIBERNATION,
117 LOCKDOWN_ACPI_TABLES,
118 LOCKDOWN_DEVICE_TREE,
120 LOCKDOWN_TIOCSSERIAL,
121 LOCKDOWN_MODULE_PARAMETERS,
125 LOCKDOWN_BPF_WRITE_USER,
126 LOCKDOWN_DBG_WRITE_KERNEL,
127 LOCKDOWN_RTAS_ERROR_INJECTION,
128 LOCKDOWN_INTEGRITY_MAX,
131 LOCKDOWN_BPF_READ_KERNEL,
132 LOCKDOWN_DBG_READ_KERNEL,
136 LOCKDOWN_XFRM_SECRET,
137 LOCKDOWN_CONFIDENTIALITY_MAX,
140 extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
142 /* These functions are in security/commoncap.c */
143 extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
144 int cap, unsigned int opts);
145 extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
146 extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
147 extern int cap_ptrace_traceme(struct task_struct *parent);
148 extern int cap_capget(const struct task_struct *target, kernel_cap_t *effective,
149 kernel_cap_t *inheritable, kernel_cap_t *permitted);
150 extern int cap_capset(struct cred *new, const struct cred *old,
151 const kernel_cap_t *effective,
152 const kernel_cap_t *inheritable,
153 const kernel_cap_t *permitted);
154 extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
155 int cap_inode_setxattr(struct dentry *dentry, const char *name,
156 const void *value, size_t size, int flags);
157 int cap_inode_removexattr(struct mnt_idmap *idmap,
158 struct dentry *dentry, const char *name);
159 int cap_inode_need_killpriv(struct dentry *dentry);
160 int cap_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
161 int cap_inode_getsecurity(struct mnt_idmap *idmap,
162 struct inode *inode, const char *name, void **buffer,
164 extern int cap_mmap_addr(unsigned long addr);
165 extern int cap_mmap_file(struct file *file, unsigned long reqprot,
166 unsigned long prot, unsigned long flags);
167 extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
168 extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
169 unsigned long arg4, unsigned long arg5);
170 extern int cap_task_setscheduler(struct task_struct *p);
171 extern int cap_task_setioprio(struct task_struct *p, int ioprio);
172 extern int cap_task_setnice(struct task_struct *p, int nice);
173 extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
182 struct xfrm_selector;
185 struct xfrm_user_sec_ctx;
187 struct sctp_association;
190 extern unsigned long mmap_min_addr;
191 extern unsigned long dac_mmap_min_addr;
193 #define mmap_min_addr 0UL
194 #define dac_mmap_min_addr 0UL
198 * Values used in the task_security_ops calls
200 /* setuid or setgid, id0 == uid or gid */
201 #define LSM_SETID_ID 1
203 /* setreuid or setregid, id0 == real, id1 == eff */
204 #define LSM_SETID_RE 2
206 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
207 #define LSM_SETID_RES 4
209 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
210 #define LSM_SETID_FS 8
212 /* Flags for security_task_prlimit(). */
213 #define LSM_PRLIMIT_READ 1
214 #define LSM_PRLIMIT_WRITE 2
216 /* forward declares to avoid warnings */
220 /* bprm->unsafe reasons */
221 #define LSM_UNSAFE_SHARE 1
222 #define LSM_UNSAFE_PTRACE 2
223 #define LSM_UNSAFE_NO_NEW_PRIVS 4
226 extern int mmap_min_addr_handler(struct ctl_table *table, int write,
227 void *buffer, size_t *lenp, loff_t *ppos);
230 /* security_inode_init_security callback function to write xattrs */
231 typedef int (*initxattrs) (struct inode *inode,
232 const struct xattr *xattr_array, void *fs_data);
235 /* Keep the kernel_load_data_id enum in sync with kernel_read_file_id */
236 #define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM,
237 #define __data_id_stringify(dummy, str) #str,
239 enum kernel_load_data_id {
240 __kernel_read_file_id(__data_id_enumify)
243 static const char * const kernel_load_data_str[] = {
244 __kernel_read_file_id(__data_id_stringify)
247 static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
249 if ((unsigned)id >= LOADING_MAX_ID)
250 return kernel_load_data_str[LOADING_UNKNOWN];
252 return kernel_load_data_str[id];
255 #ifdef CONFIG_SECURITY
257 int call_blocking_lsm_notifier(enum lsm_event event, void *data);
258 int register_blocking_lsm_notifier(struct notifier_block *nb);
259 int unregister_blocking_lsm_notifier(struct notifier_block *nb);
262 extern int security_init(void);
263 extern int early_security_init(void);
265 /* Security operations */
266 int security_binder_set_context_mgr(const struct cred *mgr);
267 int security_binder_transaction(const struct cred *from,
268 const struct cred *to);
269 int security_binder_transfer_binder(const struct cred *from,
270 const struct cred *to);
271 int security_binder_transfer_file(const struct cred *from,
272 const struct cred *to, const struct file *file);
273 int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
274 int security_ptrace_traceme(struct task_struct *parent);
275 int security_capget(const struct task_struct *target,
276 kernel_cap_t *effective,
277 kernel_cap_t *inheritable,
278 kernel_cap_t *permitted);
279 int security_capset(struct cred *new, const struct cred *old,
280 const kernel_cap_t *effective,
281 const kernel_cap_t *inheritable,
282 const kernel_cap_t *permitted);
283 int security_capable(const struct cred *cred,
284 struct user_namespace *ns,
287 int security_quotactl(int cmds, int type, int id, struct super_block *sb);
288 int security_quota_on(struct dentry *dentry);
289 int security_syslog(int type);
290 int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
291 int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
292 int security_bprm_creds_for_exec(struct linux_binprm *bprm);
293 int security_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
294 int security_bprm_check(struct linux_binprm *bprm);
295 void security_bprm_committing_creds(struct linux_binprm *bprm);
296 void security_bprm_committed_creds(struct linux_binprm *bprm);
297 int security_fs_context_submount(struct fs_context *fc, struct super_block *reference);
298 int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc);
299 int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
300 int security_sb_alloc(struct super_block *sb);
301 void security_sb_delete(struct super_block *sb);
302 void security_sb_free(struct super_block *sb);
303 void security_free_mnt_opts(void **mnt_opts);
304 int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
305 int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
306 int security_sb_remount(struct super_block *sb, void *mnt_opts);
307 int security_sb_kern_mount(struct super_block *sb);
308 int security_sb_show_options(struct seq_file *m, struct super_block *sb);
309 int security_sb_statfs(struct dentry *dentry);
310 int security_sb_mount(const char *dev_name, const struct path *path,
311 const char *type, unsigned long flags, void *data);
312 int security_sb_umount(struct vfsmount *mnt, int flags);
313 int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
314 int security_sb_set_mnt_opts(struct super_block *sb,
316 unsigned long kern_flags,
317 unsigned long *set_kern_flags);
318 int security_sb_clone_mnt_opts(const struct super_block *oldsb,
319 struct super_block *newsb,
320 unsigned long kern_flags,
321 unsigned long *set_kern_flags);
322 int security_move_mount(const struct path *from_path, const struct path *to_path);
323 int security_dentry_init_security(struct dentry *dentry, int mode,
324 const struct qstr *name,
325 const char **xattr_name, void **ctx,
327 int security_dentry_create_files_as(struct dentry *dentry, int mode,
329 const struct cred *old,
331 int security_path_notify(const struct path *path, u64 mask,
332 unsigned int obj_type);
333 int security_inode_alloc(struct inode *inode);
334 void security_inode_free(struct inode *inode);
335 int security_inode_init_security(struct inode *inode, struct inode *dir,
336 const struct qstr *qstr,
337 initxattrs initxattrs, void *fs_data);
338 int security_inode_init_security_anon(struct inode *inode,
339 const struct qstr *name,
340 const struct inode *context_inode);
341 int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
342 int security_inode_link(struct dentry *old_dentry, struct inode *dir,
343 struct dentry *new_dentry);
344 int security_inode_unlink(struct inode *dir, struct dentry *dentry);
345 int security_inode_symlink(struct inode *dir, struct dentry *dentry,
346 const char *old_name);
347 int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
348 int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
349 int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
350 int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
351 struct inode *new_dir, struct dentry *new_dentry,
353 int security_inode_readlink(struct dentry *dentry);
354 int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
356 int security_inode_permission(struct inode *inode, int mask);
357 int security_inode_setattr(struct mnt_idmap *idmap,
358 struct dentry *dentry, struct iattr *attr);
359 int security_inode_getattr(const struct path *path);
360 int security_inode_setxattr(struct mnt_idmap *idmap,
361 struct dentry *dentry, const char *name,
362 const void *value, size_t size, int flags);
363 int security_inode_set_acl(struct mnt_idmap *idmap,
364 struct dentry *dentry, const char *acl_name,
365 struct posix_acl *kacl);
366 int security_inode_get_acl(struct mnt_idmap *idmap,
367 struct dentry *dentry, const char *acl_name);
368 int security_inode_remove_acl(struct mnt_idmap *idmap,
369 struct dentry *dentry, const char *acl_name);
370 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
371 const void *value, size_t size, int flags);
372 int security_inode_getxattr(struct dentry *dentry, const char *name);
373 int security_inode_listxattr(struct dentry *dentry);
374 int security_inode_removexattr(struct mnt_idmap *idmap,
375 struct dentry *dentry, const char *name);
376 int security_inode_need_killpriv(struct dentry *dentry);
377 int security_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
378 int security_inode_getsecurity(struct mnt_idmap *idmap,
379 struct inode *inode, const char *name,
380 void **buffer, bool alloc);
381 int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
382 int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
383 void security_inode_getsecid(struct inode *inode, u32 *secid);
384 int security_inode_copy_up(struct dentry *src, struct cred **new);
385 int security_inode_copy_up_xattr(const char *name);
386 int security_kernfs_init_security(struct kernfs_node *kn_dir,
387 struct kernfs_node *kn);
388 int security_file_permission(struct file *file, int mask);
389 int security_file_alloc(struct file *file);
390 void security_file_free(struct file *file);
391 int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
392 int security_file_ioctl_compat(struct file *file, unsigned int cmd,
394 int security_mmap_file(struct file *file, unsigned long prot,
395 unsigned long flags);
396 int security_mmap_addr(unsigned long addr);
397 int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
399 int security_file_lock(struct file *file, unsigned int cmd);
400 int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
401 void security_file_set_fowner(struct file *file);
402 int security_file_send_sigiotask(struct task_struct *tsk,
403 struct fown_struct *fown, int sig);
404 int security_file_receive(struct file *file);
405 int security_file_open(struct file *file);
406 int security_file_truncate(struct file *file);
407 int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
408 void security_task_free(struct task_struct *task);
409 int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
410 void security_cred_free(struct cred *cred);
411 int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
412 void security_transfer_creds(struct cred *new, const struct cred *old);
413 void security_cred_getsecid(const struct cred *c, u32 *secid);
414 int security_kernel_act_as(struct cred *new, u32 secid);
415 int security_kernel_create_files_as(struct cred *new, struct inode *inode);
416 int security_kernel_module_request(char *kmod_name);
417 int security_kernel_load_data(enum kernel_load_data_id id, bool contents);
418 int security_kernel_post_load_data(char *buf, loff_t size,
419 enum kernel_load_data_id id,
421 int security_kernel_read_file(struct file *file, enum kernel_read_file_id id,
423 int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
424 enum kernel_read_file_id id);
425 int security_task_fix_setuid(struct cred *new, const struct cred *old,
427 int security_task_fix_setgid(struct cred *new, const struct cred *old,
429 int security_task_fix_setgroups(struct cred *new, const struct cred *old);
430 int security_task_setpgid(struct task_struct *p, pid_t pgid);
431 int security_task_getpgid(struct task_struct *p);
432 int security_task_getsid(struct task_struct *p);
433 void security_current_getsecid_subj(u32 *secid);
434 void security_task_getsecid_obj(struct task_struct *p, u32 *secid);
435 int security_task_setnice(struct task_struct *p, int nice);
436 int security_task_setioprio(struct task_struct *p, int ioprio);
437 int security_task_getioprio(struct task_struct *p);
438 int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
440 int security_task_setrlimit(struct task_struct *p, unsigned int resource,
441 struct rlimit *new_rlim);
442 int security_task_setscheduler(struct task_struct *p);
443 int security_task_getscheduler(struct task_struct *p);
444 int security_task_movememory(struct task_struct *p);
445 int security_task_kill(struct task_struct *p, struct kernel_siginfo *info,
446 int sig, const struct cred *cred);
447 int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
448 unsigned long arg4, unsigned long arg5);
449 void security_task_to_inode(struct task_struct *p, struct inode *inode);
450 int security_create_user_ns(const struct cred *cred);
451 int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
452 void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
453 int security_msg_msg_alloc(struct msg_msg *msg);
454 void security_msg_msg_free(struct msg_msg *msg);
455 int security_msg_queue_alloc(struct kern_ipc_perm *msq);
456 void security_msg_queue_free(struct kern_ipc_perm *msq);
457 int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg);
458 int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd);
459 int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
460 struct msg_msg *msg, int msqflg);
461 int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg,
462 struct task_struct *target, long type, int mode);
463 int security_shm_alloc(struct kern_ipc_perm *shp);
464 void security_shm_free(struct kern_ipc_perm *shp);
465 int security_shm_associate(struct kern_ipc_perm *shp, int shmflg);
466 int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd);
467 int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg);
468 int security_sem_alloc(struct kern_ipc_perm *sma);
469 void security_sem_free(struct kern_ipc_perm *sma);
470 int security_sem_associate(struct kern_ipc_perm *sma, int semflg);
471 int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
472 int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
473 unsigned nsops, int alter);
474 void security_d_instantiate(struct dentry *dentry, struct inode *inode);
475 int security_getprocattr(struct task_struct *p, const char *lsm, const char *name,
477 int security_setprocattr(const char *lsm, const char *name, void *value,
479 int security_netlink_send(struct sock *sk, struct sk_buff *skb);
480 int security_ismaclabel(const char *name);
481 int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
482 int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
483 void security_release_secctx(char *secdata, u32 seclen);
484 void security_inode_invalidate_secctx(struct inode *inode);
485 int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
486 int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
487 int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
488 int security_locked_down(enum lockdown_reason what);
489 #else /* CONFIG_SECURITY */
491 static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data)
496 static inline int register_blocking_lsm_notifier(struct notifier_block *nb)
501 static inline int unregister_blocking_lsm_notifier(struct notifier_block *nb)
506 static inline void security_free_mnt_opts(void **mnt_opts)
511 * This is the default capabilities functionality. Most of these functions
512 * are just stubbed out, but a few must call the proper capable code.
515 static inline int security_init(void)
520 static inline int early_security_init(void)
525 static inline int security_binder_set_context_mgr(const struct cred *mgr)
530 static inline int security_binder_transaction(const struct cred *from,
531 const struct cred *to)
536 static inline int security_binder_transfer_binder(const struct cred *from,
537 const struct cred *to)
542 static inline int security_binder_transfer_file(const struct cred *from,
543 const struct cred *to,
544 const struct file *file)
549 static inline int security_ptrace_access_check(struct task_struct *child,
552 return cap_ptrace_access_check(child, mode);
555 static inline int security_ptrace_traceme(struct task_struct *parent)
557 return cap_ptrace_traceme(parent);
560 static inline int security_capget(const struct task_struct *target,
561 kernel_cap_t *effective,
562 kernel_cap_t *inheritable,
563 kernel_cap_t *permitted)
565 return cap_capget(target, effective, inheritable, permitted);
568 static inline int security_capset(struct cred *new,
569 const struct cred *old,
570 const kernel_cap_t *effective,
571 const kernel_cap_t *inheritable,
572 const kernel_cap_t *permitted)
574 return cap_capset(new, old, effective, inheritable, permitted);
577 static inline int security_capable(const struct cred *cred,
578 struct user_namespace *ns,
582 return cap_capable(cred, ns, cap, opts);
585 static inline int security_quotactl(int cmds, int type, int id,
586 struct super_block *sb)
591 static inline int security_quota_on(struct dentry *dentry)
596 static inline int security_syslog(int type)
601 static inline int security_settime64(const struct timespec64 *ts,
602 const struct timezone *tz)
604 return cap_settime(ts, tz);
607 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
609 return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages));
612 static inline int security_bprm_creds_for_exec(struct linux_binprm *bprm)
617 static inline int security_bprm_creds_from_file(struct linux_binprm *bprm,
620 return cap_bprm_creds_from_file(bprm, file);
623 static inline int security_bprm_check(struct linux_binprm *bprm)
628 static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
632 static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
636 static inline int security_fs_context_submount(struct fs_context *fc,
637 struct super_block *reference)
641 static inline int security_fs_context_dup(struct fs_context *fc,
642 struct fs_context *src_fc)
646 static inline int security_fs_context_parse_param(struct fs_context *fc,
647 struct fs_parameter *param)
652 static inline int security_sb_alloc(struct super_block *sb)
657 static inline void security_sb_delete(struct super_block *sb)
660 static inline void security_sb_free(struct super_block *sb)
663 static inline int security_sb_eat_lsm_opts(char *options,
669 static inline int security_sb_remount(struct super_block *sb,
675 static inline int security_sb_mnt_opts_compat(struct super_block *sb,
682 static inline int security_sb_kern_mount(struct super_block *sb)
687 static inline int security_sb_show_options(struct seq_file *m,
688 struct super_block *sb)
693 static inline int security_sb_statfs(struct dentry *dentry)
698 static inline int security_sb_mount(const char *dev_name, const struct path *path,
699 const char *type, unsigned long flags,
705 static inline int security_sb_umount(struct vfsmount *mnt, int flags)
710 static inline int security_sb_pivotroot(const struct path *old_path,
711 const struct path *new_path)
716 static inline int security_sb_set_mnt_opts(struct super_block *sb,
718 unsigned long kern_flags,
719 unsigned long *set_kern_flags)
724 static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
725 struct super_block *newsb,
726 unsigned long kern_flags,
727 unsigned long *set_kern_flags)
732 static inline int security_move_mount(const struct path *from_path,
733 const struct path *to_path)
738 static inline int security_path_notify(const struct path *path, u64 mask,
739 unsigned int obj_type)
744 static inline int security_inode_alloc(struct inode *inode)
749 static inline void security_inode_free(struct inode *inode)
752 static inline int security_dentry_init_security(struct dentry *dentry,
754 const struct qstr *name,
755 const char **xattr_name,
762 static inline int security_dentry_create_files_as(struct dentry *dentry,
763 int mode, struct qstr *name,
764 const struct cred *old,
771 static inline int security_inode_init_security(struct inode *inode,
773 const struct qstr *qstr,
774 const initxattrs xattrs,
780 static inline int security_inode_init_security_anon(struct inode *inode,
781 const struct qstr *name,
782 const struct inode *context_inode)
787 static inline int security_inode_create(struct inode *dir,
788 struct dentry *dentry,
794 static inline int security_inode_link(struct dentry *old_dentry,
796 struct dentry *new_dentry)
801 static inline int security_inode_unlink(struct inode *dir,
802 struct dentry *dentry)
807 static inline int security_inode_symlink(struct inode *dir,
808 struct dentry *dentry,
809 const char *old_name)
814 static inline int security_inode_mkdir(struct inode *dir,
815 struct dentry *dentry,
821 static inline int security_inode_rmdir(struct inode *dir,
822 struct dentry *dentry)
827 static inline int security_inode_mknod(struct inode *dir,
828 struct dentry *dentry,
834 static inline int security_inode_rename(struct inode *old_dir,
835 struct dentry *old_dentry,
836 struct inode *new_dir,
837 struct dentry *new_dentry,
843 static inline int security_inode_readlink(struct dentry *dentry)
848 static inline int security_inode_follow_link(struct dentry *dentry,
855 static inline int security_inode_permission(struct inode *inode, int mask)
860 static inline int security_inode_setattr(struct mnt_idmap *idmap,
861 struct dentry *dentry,
867 static inline int security_inode_getattr(const struct path *path)
872 static inline int security_inode_setxattr(struct mnt_idmap *idmap,
873 struct dentry *dentry, const char *name, const void *value,
874 size_t size, int flags)
876 return cap_inode_setxattr(dentry, name, value, size, flags);
879 static inline int security_inode_set_acl(struct mnt_idmap *idmap,
880 struct dentry *dentry,
881 const char *acl_name,
882 struct posix_acl *kacl)
887 static inline int security_inode_get_acl(struct mnt_idmap *idmap,
888 struct dentry *dentry,
889 const char *acl_name)
894 static inline int security_inode_remove_acl(struct mnt_idmap *idmap,
895 struct dentry *dentry,
896 const char *acl_name)
901 static inline void security_inode_post_setxattr(struct dentry *dentry,
902 const char *name, const void *value, size_t size, int flags)
905 static inline int security_inode_getxattr(struct dentry *dentry,
911 static inline int security_inode_listxattr(struct dentry *dentry)
916 static inline int security_inode_removexattr(struct mnt_idmap *idmap,
917 struct dentry *dentry,
920 return cap_inode_removexattr(idmap, dentry, name);
923 static inline int security_inode_need_killpriv(struct dentry *dentry)
925 return cap_inode_need_killpriv(dentry);
928 static inline int security_inode_killpriv(struct mnt_idmap *idmap,
929 struct dentry *dentry)
931 return cap_inode_killpriv(idmap, dentry);
934 static inline int security_inode_getsecurity(struct mnt_idmap *idmap,
936 const char *name, void **buffer,
939 return cap_inode_getsecurity(idmap, inode, name, buffer, alloc);
942 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
947 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
952 static inline void security_inode_getsecid(struct inode *inode, u32 *secid)
957 static inline int security_inode_copy_up(struct dentry *src, struct cred **new)
962 static inline int security_kernfs_init_security(struct kernfs_node *kn_dir,
963 struct kernfs_node *kn)
968 static inline int security_inode_copy_up_xattr(const char *name)
973 static inline int security_file_permission(struct file *file, int mask)
978 static inline int security_file_alloc(struct file *file)
983 static inline void security_file_free(struct file *file)
986 static inline int security_file_ioctl(struct file *file, unsigned int cmd,
992 static inline int security_file_ioctl_compat(struct file *file,
999 static inline int security_mmap_file(struct file *file, unsigned long prot,
1000 unsigned long flags)
1005 static inline int security_mmap_addr(unsigned long addr)
1007 return cap_mmap_addr(addr);
1010 static inline int security_file_mprotect(struct vm_area_struct *vma,
1011 unsigned long reqprot,
1017 static inline int security_file_lock(struct file *file, unsigned int cmd)
1022 static inline int security_file_fcntl(struct file *file, unsigned int cmd,
1028 static inline void security_file_set_fowner(struct file *file)
1033 static inline int security_file_send_sigiotask(struct task_struct *tsk,
1034 struct fown_struct *fown,
1040 static inline int security_file_receive(struct file *file)
1045 static inline int security_file_open(struct file *file)
1050 static inline int security_file_truncate(struct file *file)
1055 static inline int security_task_alloc(struct task_struct *task,
1056 unsigned long clone_flags)
1061 static inline void security_task_free(struct task_struct *task)
1064 static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
1069 static inline void security_cred_free(struct cred *cred)
1072 static inline int security_prepare_creds(struct cred *new,
1073 const struct cred *old,
1079 static inline void security_transfer_creds(struct cred *new,
1080 const struct cred *old)
1084 static inline void security_cred_getsecid(const struct cred *c, u32 *secid)
1089 static inline int security_kernel_act_as(struct cred *cred, u32 secid)
1094 static inline int security_kernel_create_files_as(struct cred *cred,
1095 struct inode *inode)
1100 static inline int security_kernel_module_request(char *kmod_name)
1105 static inline int security_kernel_load_data(enum kernel_load_data_id id, bool contents)
1110 static inline int security_kernel_post_load_data(char *buf, loff_t size,
1111 enum kernel_load_data_id id,
1117 static inline int security_kernel_read_file(struct file *file,
1118 enum kernel_read_file_id id,
1124 static inline int security_kernel_post_read_file(struct file *file,
1125 char *buf, loff_t size,
1126 enum kernel_read_file_id id)
1131 static inline int security_task_fix_setuid(struct cred *new,
1132 const struct cred *old,
1135 return cap_task_fix_setuid(new, old, flags);
1138 static inline int security_task_fix_setgid(struct cred *new,
1139 const struct cred *old,
1145 static inline int security_task_fix_setgroups(struct cred *new,
1146 const struct cred *old)
1151 static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
1156 static inline int security_task_getpgid(struct task_struct *p)
1161 static inline int security_task_getsid(struct task_struct *p)
1166 static inline void security_current_getsecid_subj(u32 *secid)
1171 static inline void security_task_getsecid_obj(struct task_struct *p, u32 *secid)
1176 static inline int security_task_setnice(struct task_struct *p, int nice)
1178 return cap_task_setnice(p, nice);
1181 static inline int security_task_setioprio(struct task_struct *p, int ioprio)
1183 return cap_task_setioprio(p, ioprio);
1186 static inline int security_task_getioprio(struct task_struct *p)
1191 static inline int security_task_prlimit(const struct cred *cred,
1192 const struct cred *tcred,
1198 static inline int security_task_setrlimit(struct task_struct *p,
1199 unsigned int resource,
1200 struct rlimit *new_rlim)
1205 static inline int security_task_setscheduler(struct task_struct *p)
1207 return cap_task_setscheduler(p);
1210 static inline int security_task_getscheduler(struct task_struct *p)
1215 static inline int security_task_movememory(struct task_struct *p)
1220 static inline int security_task_kill(struct task_struct *p,
1221 struct kernel_siginfo *info, int sig,
1222 const struct cred *cred)
1227 static inline int security_task_prctl(int option, unsigned long arg2,
1232 return cap_task_prctl(option, arg2, arg3, arg4, arg5);
1235 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1238 static inline int security_create_user_ns(const struct cred *cred)
1243 static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
1249 static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
1254 static inline int security_msg_msg_alloc(struct msg_msg *msg)
1259 static inline void security_msg_msg_free(struct msg_msg *msg)
1262 static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq)
1267 static inline void security_msg_queue_free(struct kern_ipc_perm *msq)
1270 static inline int security_msg_queue_associate(struct kern_ipc_perm *msq,
1276 static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd)
1281 static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
1282 struct msg_msg *msg, int msqflg)
1287 static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq,
1288 struct msg_msg *msg,
1289 struct task_struct *target,
1290 long type, int mode)
1295 static inline int security_shm_alloc(struct kern_ipc_perm *shp)
1300 static inline void security_shm_free(struct kern_ipc_perm *shp)
1303 static inline int security_shm_associate(struct kern_ipc_perm *shp,
1309 static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd)
1314 static inline int security_shm_shmat(struct kern_ipc_perm *shp,
1315 char __user *shmaddr, int shmflg)
1320 static inline int security_sem_alloc(struct kern_ipc_perm *sma)
1325 static inline void security_sem_free(struct kern_ipc_perm *sma)
1328 static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg)
1333 static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd)
1338 static inline int security_sem_semop(struct kern_ipc_perm *sma,
1339 struct sembuf *sops, unsigned nsops,
1345 static inline void security_d_instantiate(struct dentry *dentry,
1346 struct inode *inode)
1349 static inline int security_getprocattr(struct task_struct *p, const char *lsm,
1350 const char *name, char **value)
1355 static inline int security_setprocattr(const char *lsm, char *name,
1356 void *value, size_t size)
1361 static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
1366 static inline int security_ismaclabel(const char *name)
1371 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
1376 static inline int security_secctx_to_secid(const char *secdata,
1383 static inline void security_release_secctx(char *secdata, u32 seclen)
1387 static inline void security_inode_invalidate_secctx(struct inode *inode)
1391 static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
1395 static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
1399 static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
1403 static inline int security_locked_down(enum lockdown_reason what)
1407 #endif /* CONFIG_SECURITY */
1409 #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
1410 int security_post_notification(const struct cred *w_cred,
1411 const struct cred *cred,
1412 struct watch_notification *n);
1414 static inline int security_post_notification(const struct cred *w_cred,
1415 const struct cred *cred,
1416 struct watch_notification *n)
1422 #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
1423 int security_watch_key(struct key *key);
1425 static inline int security_watch_key(struct key *key)
1431 #ifdef CONFIG_SECURITY_NETWORK
1433 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
1434 int security_unix_may_send(struct socket *sock, struct socket *other);
1435 int security_socket_create(int family, int type, int protocol, int kern);
1436 int security_socket_post_create(struct socket *sock, int family,
1437 int type, int protocol, int kern);
1438 int security_socket_socketpair(struct socket *socka, struct socket *sockb);
1439 int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
1440 int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
1441 int security_socket_listen(struct socket *sock, int backlog);
1442 int security_socket_accept(struct socket *sock, struct socket *newsock);
1443 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
1444 int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
1445 int size, int flags);
1446 int security_socket_getsockname(struct socket *sock);
1447 int security_socket_getpeername(struct socket *sock);
1448 int security_socket_getsockopt(struct socket *sock, int level, int optname);
1449 int security_socket_setsockopt(struct socket *sock, int level, int optname);
1450 int security_socket_shutdown(struct socket *sock, int how);
1451 int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
1452 int security_socket_getpeersec_stream(struct socket *sock, sockptr_t optval,
1453 sockptr_t optlen, unsigned int len);
1454 int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
1455 int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
1456 void security_sk_free(struct sock *sk);
1457 void security_sk_clone(const struct sock *sk, struct sock *newsk);
1458 void security_sk_classify_flow(const struct sock *sk,
1459 struct flowi_common *flic);
1460 void security_req_classify_flow(const struct request_sock *req,
1461 struct flowi_common *flic);
1462 void security_sock_graft(struct sock*sk, struct socket *parent);
1463 int security_inet_conn_request(const struct sock *sk,
1464 struct sk_buff *skb, struct request_sock *req);
1465 void security_inet_csk_clone(struct sock *newsk,
1466 const struct request_sock *req);
1467 void security_inet_conn_established(struct sock *sk,
1468 struct sk_buff *skb);
1469 int security_secmark_relabel_packet(u32 secid);
1470 void security_secmark_refcount_inc(void);
1471 void security_secmark_refcount_dec(void);
1472 int security_tun_dev_alloc_security(void **security);
1473 void security_tun_dev_free_security(void *security);
1474 int security_tun_dev_create(void);
1475 int security_tun_dev_attach_queue(void *security);
1476 int security_tun_dev_attach(struct sock *sk, void *security);
1477 int security_tun_dev_open(void *security);
1478 int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb);
1479 int security_sctp_bind_connect(struct sock *sk, int optname,
1480 struct sockaddr *address, int addrlen);
1481 void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk,
1482 struct sock *newsk);
1483 int security_sctp_assoc_established(struct sctp_association *asoc,
1484 struct sk_buff *skb);
1485 int security_mptcp_add_subflow(struct sock *sk, struct sock *ssk);
1487 #else /* CONFIG_SECURITY_NETWORK */
1488 static inline int security_unix_stream_connect(struct sock *sock,
1495 static inline int security_unix_may_send(struct socket *sock,
1496 struct socket *other)
1501 static inline int security_socket_create(int family, int type,
1502 int protocol, int kern)
1507 static inline int security_socket_post_create(struct socket *sock,
1510 int protocol, int kern)
1515 static inline int security_socket_socketpair(struct socket *socka,
1516 struct socket *sockb)
1521 static inline int security_socket_bind(struct socket *sock,
1522 struct sockaddr *address,
1528 static inline int security_socket_connect(struct socket *sock,
1529 struct sockaddr *address,
1535 static inline int security_socket_listen(struct socket *sock, int backlog)
1540 static inline int security_socket_accept(struct socket *sock,
1541 struct socket *newsock)
1546 static inline int security_socket_sendmsg(struct socket *sock,
1547 struct msghdr *msg, int size)
1552 static inline int security_socket_recvmsg(struct socket *sock,
1553 struct msghdr *msg, int size,
1559 static inline int security_socket_getsockname(struct socket *sock)
1564 static inline int security_socket_getpeername(struct socket *sock)
1569 static inline int security_socket_getsockopt(struct socket *sock,
1570 int level, int optname)
1575 static inline int security_socket_setsockopt(struct socket *sock,
1576 int level, int optname)
1581 static inline int security_socket_shutdown(struct socket *sock, int how)
1585 static inline int security_sock_rcv_skb(struct sock *sk,
1586 struct sk_buff *skb)
1591 static inline int security_socket_getpeersec_stream(struct socket *sock,
1596 return -ENOPROTOOPT;
1599 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
1601 return -ENOPROTOOPT;
1604 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
1609 static inline void security_sk_free(struct sock *sk)
1613 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
1617 static inline void security_sk_classify_flow(const struct sock *sk,
1618 struct flowi_common *flic)
1622 static inline void security_req_classify_flow(const struct request_sock *req,
1623 struct flowi_common *flic)
1627 static inline void security_sock_graft(struct sock *sk, struct socket *parent)
1631 static inline int security_inet_conn_request(const struct sock *sk,
1632 struct sk_buff *skb, struct request_sock *req)
1637 static inline void security_inet_csk_clone(struct sock *newsk,
1638 const struct request_sock *req)
1642 static inline void security_inet_conn_established(struct sock *sk,
1643 struct sk_buff *skb)
1647 static inline int security_secmark_relabel_packet(u32 secid)
1652 static inline void security_secmark_refcount_inc(void)
1656 static inline void security_secmark_refcount_dec(void)
1660 static inline int security_tun_dev_alloc_security(void **security)
1665 static inline void security_tun_dev_free_security(void *security)
1669 static inline int security_tun_dev_create(void)
1674 static inline int security_tun_dev_attach_queue(void *security)
1679 static inline int security_tun_dev_attach(struct sock *sk, void *security)
1684 static inline int security_tun_dev_open(void *security)
1689 static inline int security_sctp_assoc_request(struct sctp_association *asoc,
1690 struct sk_buff *skb)
1695 static inline int security_sctp_bind_connect(struct sock *sk, int optname,
1696 struct sockaddr *address,
1702 static inline void security_sctp_sk_clone(struct sctp_association *asoc,
1708 static inline int security_sctp_assoc_established(struct sctp_association *asoc,
1709 struct sk_buff *skb)
1714 static inline int security_mptcp_add_subflow(struct sock *sk, struct sock *ssk)
1718 #endif /* CONFIG_SECURITY_NETWORK */
1720 #ifdef CONFIG_SECURITY_INFINIBAND
1721 int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey);
1722 int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num);
1723 int security_ib_alloc_security(void **sec);
1724 void security_ib_free_security(void *sec);
1725 #else /* CONFIG_SECURITY_INFINIBAND */
1726 static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey)
1731 static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num)
1736 static inline int security_ib_alloc_security(void **sec)
1741 static inline void security_ib_free_security(void *sec)
1744 #endif /* CONFIG_SECURITY_INFINIBAND */
1746 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1748 int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1749 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
1750 int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
1751 void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
1752 int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
1753 int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1754 int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1755 struct xfrm_sec_ctx *polsec, u32 secid);
1756 int security_xfrm_state_delete(struct xfrm_state *x);
1757 void security_xfrm_state_free(struct xfrm_state *x);
1758 int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid);
1759 int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1760 struct xfrm_policy *xp,
1761 const struct flowi_common *flic);
1762 int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
1763 void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic);
1765 #else /* CONFIG_SECURITY_NETWORK_XFRM */
1767 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1768 struct xfrm_user_sec_ctx *sec_ctx,
1774 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
1779 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
1783 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
1788 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
1789 struct xfrm_user_sec_ctx *sec_ctx)
1794 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1795 struct xfrm_sec_ctx *polsec, u32 secid)
1800 static inline void security_xfrm_state_free(struct xfrm_state *x)
1804 static inline int security_xfrm_state_delete(struct xfrm_state *x)
1809 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
1814 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1815 struct xfrm_policy *xp,
1816 const struct flowi_common *flic)
1821 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
1826 static inline void security_skb_classify_flow(struct sk_buff *skb,
1827 struct flowi_common *flic)
1831 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1833 #ifdef CONFIG_SECURITY_PATH
1834 int security_path_unlink(const struct path *dir, struct dentry *dentry);
1835 int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
1836 int security_path_rmdir(const struct path *dir, struct dentry *dentry);
1837 int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
1839 int security_path_truncate(const struct path *path);
1840 int security_path_symlink(const struct path *dir, struct dentry *dentry,
1841 const char *old_name);
1842 int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
1843 struct dentry *new_dentry);
1844 int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
1845 const struct path *new_dir, struct dentry *new_dentry,
1846 unsigned int flags);
1847 int security_path_chmod(const struct path *path, umode_t mode);
1848 int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
1849 int security_path_chroot(const struct path *path);
1850 #else /* CONFIG_SECURITY_PATH */
1851 static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
1856 static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
1862 static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
1867 static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
1868 umode_t mode, unsigned int dev)
1873 static inline int security_path_truncate(const struct path *path)
1878 static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
1879 const char *old_name)
1884 static inline int security_path_link(struct dentry *old_dentry,
1885 const struct path *new_dir,
1886 struct dentry *new_dentry)
1891 static inline int security_path_rename(const struct path *old_dir,
1892 struct dentry *old_dentry,
1893 const struct path *new_dir,
1894 struct dentry *new_dentry,
1900 static inline int security_path_chmod(const struct path *path, umode_t mode)
1905 static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
1910 static inline int security_path_chroot(const struct path *path)
1914 #endif /* CONFIG_SECURITY_PATH */
1917 #ifdef CONFIG_SECURITY
1919 int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
1920 void security_key_free(struct key *key);
1921 int security_key_permission(key_ref_t key_ref, const struct cred *cred,
1922 enum key_need_perm need_perm);
1923 int security_key_getsecurity(struct key *key, char **_buffer);
1927 static inline int security_key_alloc(struct key *key,
1928 const struct cred *cred,
1929 unsigned long flags)
1934 static inline void security_key_free(struct key *key)
1938 static inline int security_key_permission(key_ref_t key_ref,
1939 const struct cred *cred,
1940 enum key_need_perm need_perm)
1945 static inline int security_key_getsecurity(struct key *key, char **_buffer)
1952 #endif /* CONFIG_KEYS */
1955 #ifdef CONFIG_SECURITY
1956 int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
1957 int security_audit_rule_known(struct audit_krule *krule);
1958 int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule);
1959 void security_audit_rule_free(void *lsmrule);
1963 static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
1969 static inline int security_audit_rule_known(struct audit_krule *krule)
1974 static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
1980 static inline void security_audit_rule_free(void *lsmrule)
1983 #endif /* CONFIG_SECURITY */
1984 #endif /* CONFIG_AUDIT */
1986 #ifdef CONFIG_SECURITYFS
1988 extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
1989 struct dentry *parent, void *data,
1990 const struct file_operations *fops);
1991 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1992 struct dentry *securityfs_create_symlink(const char *name,
1993 struct dentry *parent,
1995 const struct inode_operations *iops);
1996 extern void securityfs_remove(struct dentry *dentry);
1998 #else /* CONFIG_SECURITYFS */
2000 static inline struct dentry *securityfs_create_dir(const char *name,
2001 struct dentry *parent)
2003 return ERR_PTR(-ENODEV);
2006 static inline struct dentry *securityfs_create_file(const char *name,
2008 struct dentry *parent,
2010 const struct file_operations *fops)
2012 return ERR_PTR(-ENODEV);
2015 static inline struct dentry *securityfs_create_symlink(const char *name,
2016 struct dentry *parent,
2018 const struct inode_operations *iops)
2020 return ERR_PTR(-ENODEV);
2023 static inline void securityfs_remove(struct dentry *dentry)
2028 #ifdef CONFIG_BPF_SYSCALL
2032 struct bpf_prog_aux;
2033 #ifdef CONFIG_SECURITY
2034 extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size);
2035 extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
2036 extern int security_bpf_prog(struct bpf_prog *prog);
2037 extern int security_bpf_map_alloc(struct bpf_map *map);
2038 extern void security_bpf_map_free(struct bpf_map *map);
2039 extern int security_bpf_prog_alloc(struct bpf_prog_aux *aux);
2040 extern void security_bpf_prog_free(struct bpf_prog_aux *aux);
2042 static inline int security_bpf(int cmd, union bpf_attr *attr,
2048 static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode)
2053 static inline int security_bpf_prog(struct bpf_prog *prog)
2058 static inline int security_bpf_map_alloc(struct bpf_map *map)
2063 static inline void security_bpf_map_free(struct bpf_map *map)
2066 static inline int security_bpf_prog_alloc(struct bpf_prog_aux *aux)
2071 static inline void security_bpf_prog_free(struct bpf_prog_aux *aux)
2073 #endif /* CONFIG_SECURITY */
2074 #endif /* CONFIG_BPF_SYSCALL */
2076 #ifdef CONFIG_PERF_EVENTS
2077 struct perf_event_attr;
2080 #ifdef CONFIG_SECURITY
2081 extern int security_perf_event_open(struct perf_event_attr *attr, int type);
2082 extern int security_perf_event_alloc(struct perf_event *event);
2083 extern void security_perf_event_free(struct perf_event *event);
2084 extern int security_perf_event_read(struct perf_event *event);
2085 extern int security_perf_event_write(struct perf_event *event);
2087 static inline int security_perf_event_open(struct perf_event_attr *attr,
2093 static inline int security_perf_event_alloc(struct perf_event *event)
2098 static inline void security_perf_event_free(struct perf_event *event)
2102 static inline int security_perf_event_read(struct perf_event *event)
2107 static inline int security_perf_event_write(struct perf_event *event)
2111 #endif /* CONFIG_SECURITY */
2112 #endif /* CONFIG_PERF_EVENTS */
2114 #ifdef CONFIG_IO_URING
2115 #ifdef CONFIG_SECURITY
2116 extern int security_uring_override_creds(const struct cred *new);
2117 extern int security_uring_sqpoll(void);
2118 extern int security_uring_cmd(struct io_uring_cmd *ioucmd);
2120 static inline int security_uring_override_creds(const struct cred *new)
2124 static inline int security_uring_sqpoll(void)
2128 static inline int security_uring_cmd(struct io_uring_cmd *ioucmd)
2132 #endif /* CONFIG_SECURITY */
2133 #endif /* CONFIG_IO_URING */
2135 #endif /* ! __LINUX_SECURITY_H */