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 fs_context::lsm_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(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
149 extern int cap_capset(struct cred *new, const struct cred *old,
150 const kernel_cap_t *effective,
151 const kernel_cap_t *inheritable,
152 const kernel_cap_t *permitted);
153 extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
154 int cap_inode_setxattr(struct dentry *dentry, const char *name,
155 const void *value, size_t size, int flags);
156 int cap_inode_removexattr(struct user_namespace *mnt_userns,
157 struct dentry *dentry, const char *name);
158 int cap_inode_need_killpriv(struct dentry *dentry);
159 int cap_inode_killpriv(struct user_namespace *mnt_userns,
160 struct dentry *dentry);
161 int cap_inode_getsecurity(struct user_namespace *mnt_userns,
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, 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(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_dup(struct fs_context *fc, struct fs_context *src_fc);
298 int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
299 int security_sb_alloc(struct super_block *sb);
300 void security_sb_delete(struct super_block *sb);
301 void security_sb_free(struct super_block *sb);
302 void security_free_mnt_opts(void **mnt_opts);
303 int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
304 int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
305 int security_sb_remount(struct super_block *sb, void *mnt_opts);
306 int security_sb_kern_mount(struct super_block *sb);
307 int security_sb_show_options(struct seq_file *m, struct super_block *sb);
308 int security_sb_statfs(struct dentry *dentry);
309 int security_sb_mount(const char *dev_name, const struct path *path,
310 const char *type, unsigned long flags, void *data);
311 int security_sb_umount(struct vfsmount *mnt, int flags);
312 int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
313 int security_sb_set_mnt_opts(struct super_block *sb,
315 unsigned long kern_flags,
316 unsigned long *set_kern_flags);
317 int security_sb_clone_mnt_opts(const struct super_block *oldsb,
318 struct super_block *newsb,
319 unsigned long kern_flags,
320 unsigned long *set_kern_flags);
321 int security_move_mount(const struct path *from_path, const struct path *to_path);
322 int security_dentry_init_security(struct dentry *dentry, int mode,
323 const struct qstr *name,
324 const char **xattr_name, void **ctx,
326 int security_dentry_create_files_as(struct dentry *dentry, int mode,
328 const struct cred *old,
330 int security_path_notify(const struct path *path, u64 mask,
331 unsigned int obj_type);
332 int security_inode_alloc(struct inode *inode);
333 void security_inode_free(struct inode *inode);
334 int security_inode_init_security(struct inode *inode, struct inode *dir,
335 const struct qstr *qstr,
336 initxattrs initxattrs, void *fs_data);
337 int security_inode_init_security_anon(struct inode *inode,
338 const struct qstr *name,
339 const struct inode *context_inode);
340 int security_old_inode_init_security(struct inode *inode, struct inode *dir,
341 const struct qstr *qstr, const char **name,
342 void **value, size_t *len);
343 int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
344 int security_inode_link(struct dentry *old_dentry, struct inode *dir,
345 struct dentry *new_dentry);
346 int security_inode_unlink(struct inode *dir, struct dentry *dentry);
347 int security_inode_symlink(struct inode *dir, struct dentry *dentry,
348 const char *old_name);
349 int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
350 int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
351 int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
352 int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
353 struct inode *new_dir, struct dentry *new_dentry,
355 int security_inode_readlink(struct dentry *dentry);
356 int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
358 int security_inode_permission(struct inode *inode, int mask);
359 int security_inode_setattr(struct user_namespace *mnt_userns,
360 struct dentry *dentry, struct iattr *attr);
361 int security_inode_getattr(const struct path *path);
362 int security_inode_setxattr(struct user_namespace *mnt_userns,
363 struct dentry *dentry, const char *name,
364 const void *value, size_t size, int flags);
365 int security_inode_set_acl(struct user_namespace *mnt_userns,
366 struct dentry *dentry, const char *acl_name,
367 struct posix_acl *kacl);
368 int security_inode_get_acl(struct user_namespace *mnt_userns,
369 struct dentry *dentry, const char *acl_name);
370 int security_inode_remove_acl(struct user_namespace *mnt_userns,
371 struct dentry *dentry, const char *acl_name);
372 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
373 const void *value, size_t size, int flags);
374 int security_inode_getxattr(struct dentry *dentry, const char *name);
375 int security_inode_listxattr(struct dentry *dentry);
376 int security_inode_removexattr(struct user_namespace *mnt_userns,
377 struct dentry *dentry, const char *name);
378 int security_inode_need_killpriv(struct dentry *dentry);
379 int security_inode_killpriv(struct user_namespace *mnt_userns,
380 struct dentry *dentry);
381 int security_inode_getsecurity(struct user_namespace *mnt_userns,
382 struct inode *inode, const char *name,
383 void **buffer, bool alloc);
384 int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
385 int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
386 void security_inode_getsecid(struct inode *inode, u32 *secid);
387 int security_inode_copy_up(struct dentry *src, struct cred **new);
388 int security_inode_copy_up_xattr(const char *name);
389 int security_kernfs_init_security(struct kernfs_node *kn_dir,
390 struct kernfs_node *kn);
391 int security_file_permission(struct file *file, int mask);
392 int security_file_alloc(struct file *file);
393 void security_file_free(struct file *file);
394 int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
395 int security_mmap_file(struct file *file, unsigned long prot,
396 unsigned long flags);
397 int security_mmap_addr(unsigned long addr);
398 int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
400 int security_file_lock(struct file *file, unsigned int cmd);
401 int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
402 void security_file_set_fowner(struct file *file);
403 int security_file_send_sigiotask(struct task_struct *tsk,
404 struct fown_struct *fown, int sig);
405 int security_file_receive(struct file *file);
406 int security_file_open(struct file *file);
407 int security_file_truncate(struct file *file);
408 int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
409 void security_task_free(struct task_struct *task);
410 int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
411 void security_cred_free(struct cred *cred);
412 int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
413 void security_transfer_creds(struct cred *new, const struct cred *old);
414 void security_cred_getsecid(const struct cred *c, u32 *secid);
415 int security_kernel_act_as(struct cred *new, u32 secid);
416 int security_kernel_create_files_as(struct cred *new, struct inode *inode);
417 int security_kernel_module_request(char *kmod_name);
418 int security_kernel_load_data(enum kernel_load_data_id id, bool contents);
419 int security_kernel_post_load_data(char *buf, loff_t size,
420 enum kernel_load_data_id id,
422 int security_kernel_read_file(struct file *file, enum kernel_read_file_id id,
424 int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
425 enum kernel_read_file_id id);
426 int security_task_fix_setuid(struct cred *new, const struct cred *old,
428 int security_task_fix_setgid(struct cred *new, const struct cred *old,
430 int security_task_fix_setgroups(struct cred *new, const struct cred *old);
431 int security_task_setpgid(struct task_struct *p, pid_t pgid);
432 int security_task_getpgid(struct task_struct *p);
433 int security_task_getsid(struct task_struct *p);
434 void security_current_getsecid_subj(u32 *secid);
435 void security_task_getsecid_obj(struct task_struct *p, u32 *secid);
436 int security_task_setnice(struct task_struct *p, int nice);
437 int security_task_setioprio(struct task_struct *p, int ioprio);
438 int security_task_getioprio(struct task_struct *p);
439 int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
441 int security_task_setrlimit(struct task_struct *p, unsigned int resource,
442 struct rlimit *new_rlim);
443 int security_task_setscheduler(struct task_struct *p);
444 int security_task_getscheduler(struct task_struct *p);
445 int security_task_movememory(struct task_struct *p);
446 int security_task_kill(struct task_struct *p, struct kernel_siginfo *info,
447 int sig, const struct cred *cred);
448 int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
449 unsigned long arg4, unsigned long arg5);
450 void security_task_to_inode(struct task_struct *p, struct inode *inode);
451 int security_create_user_ns(const struct cred *cred);
452 int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
453 void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
454 int security_msg_msg_alloc(struct msg_msg *msg);
455 void security_msg_msg_free(struct msg_msg *msg);
456 int security_msg_queue_alloc(struct kern_ipc_perm *msq);
457 void security_msg_queue_free(struct kern_ipc_perm *msq);
458 int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg);
459 int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd);
460 int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
461 struct msg_msg *msg, int msqflg);
462 int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg,
463 struct task_struct *target, long type, int mode);
464 int security_shm_alloc(struct kern_ipc_perm *shp);
465 void security_shm_free(struct kern_ipc_perm *shp);
466 int security_shm_associate(struct kern_ipc_perm *shp, int shmflg);
467 int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd);
468 int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg);
469 int security_sem_alloc(struct kern_ipc_perm *sma);
470 void security_sem_free(struct kern_ipc_perm *sma);
471 int security_sem_associate(struct kern_ipc_perm *sma, int semflg);
472 int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
473 int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
474 unsigned nsops, int alter);
475 void security_d_instantiate(struct dentry *dentry, struct inode *inode);
476 int security_getprocattr(struct task_struct *p, const char *lsm, const char *name,
478 int security_setprocattr(const char *lsm, const char *name, void *value,
480 int security_netlink_send(struct sock *sk, struct sk_buff *skb);
481 int security_ismaclabel(const char *name);
482 int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
483 int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
484 void security_release_secctx(char *secdata, u32 seclen);
485 void security_inode_invalidate_secctx(struct inode *inode);
486 int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
487 int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
488 int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
489 int security_locked_down(enum lockdown_reason what);
490 #else /* CONFIG_SECURITY */
492 static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data)
497 static inline int register_blocking_lsm_notifier(struct notifier_block *nb)
502 static inline int unregister_blocking_lsm_notifier(struct notifier_block *nb)
507 static inline void security_free_mnt_opts(void **mnt_opts)
512 * This is the default capabilities functionality. Most of these functions
513 * are just stubbed out, but a few must call the proper capable code.
516 static inline int security_init(void)
521 static inline int early_security_init(void)
526 static inline int security_binder_set_context_mgr(const struct cred *mgr)
531 static inline int security_binder_transaction(const struct cred *from,
532 const struct cred *to)
537 static inline int security_binder_transfer_binder(const struct cred *from,
538 const struct cred *to)
543 static inline int security_binder_transfer_file(const struct cred *from,
544 const struct cred *to,
550 static inline int security_ptrace_access_check(struct task_struct *child,
553 return cap_ptrace_access_check(child, mode);
556 static inline int security_ptrace_traceme(struct task_struct *parent)
558 return cap_ptrace_traceme(parent);
561 static inline int security_capget(struct task_struct *target,
562 kernel_cap_t *effective,
563 kernel_cap_t *inheritable,
564 kernel_cap_t *permitted)
566 return cap_capget(target, effective, inheritable, permitted);
569 static inline int security_capset(struct cred *new,
570 const struct cred *old,
571 const kernel_cap_t *effective,
572 const kernel_cap_t *inheritable,
573 const kernel_cap_t *permitted)
575 return cap_capset(new, old, effective, inheritable, permitted);
578 static inline int security_capable(const struct cred *cred,
579 struct user_namespace *ns,
583 return cap_capable(cred, ns, cap, opts);
586 static inline int security_quotactl(int cmds, int type, int id,
587 struct super_block *sb)
592 static inline int security_quota_on(struct dentry *dentry)
597 static inline int security_syslog(int type)
602 static inline int security_settime64(const struct timespec64 *ts,
603 const struct timezone *tz)
605 return cap_settime(ts, tz);
608 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
610 return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages));
613 static inline int security_bprm_creds_for_exec(struct linux_binprm *bprm)
618 static inline int security_bprm_creds_from_file(struct linux_binprm *bprm,
621 return cap_bprm_creds_from_file(bprm, file);
624 static inline int security_bprm_check(struct linux_binprm *bprm)
629 static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
633 static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
637 static inline int security_fs_context_dup(struct fs_context *fc,
638 struct fs_context *src_fc)
642 static inline int security_fs_context_parse_param(struct fs_context *fc,
643 struct fs_parameter *param)
648 static inline int security_sb_alloc(struct super_block *sb)
653 static inline void security_sb_delete(struct super_block *sb)
656 static inline void security_sb_free(struct super_block *sb)
659 static inline int security_sb_eat_lsm_opts(char *options,
665 static inline int security_sb_remount(struct super_block *sb,
671 static inline int security_sb_mnt_opts_compat(struct super_block *sb,
678 static inline int security_sb_kern_mount(struct super_block *sb)
683 static inline int security_sb_show_options(struct seq_file *m,
684 struct super_block *sb)
689 static inline int security_sb_statfs(struct dentry *dentry)
694 static inline int security_sb_mount(const char *dev_name, const struct path *path,
695 const char *type, unsigned long flags,
701 static inline int security_sb_umount(struct vfsmount *mnt, int flags)
706 static inline int security_sb_pivotroot(const struct path *old_path,
707 const struct path *new_path)
712 static inline int security_sb_set_mnt_opts(struct super_block *sb,
714 unsigned long kern_flags,
715 unsigned long *set_kern_flags)
720 static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
721 struct super_block *newsb,
722 unsigned long kern_flags,
723 unsigned long *set_kern_flags)
728 static inline int security_move_mount(const struct path *from_path,
729 const struct path *to_path)
734 static inline int security_path_notify(const struct path *path, u64 mask,
735 unsigned int obj_type)
740 static inline int security_inode_alloc(struct inode *inode)
745 static inline void security_inode_free(struct inode *inode)
748 static inline int security_dentry_init_security(struct dentry *dentry,
750 const struct qstr *name,
751 const char **xattr_name,
758 static inline int security_dentry_create_files_as(struct dentry *dentry,
759 int mode, struct qstr *name,
760 const struct cred *old,
767 static inline int security_inode_init_security(struct inode *inode,
769 const struct qstr *qstr,
770 const initxattrs xattrs,
776 static inline int security_inode_init_security_anon(struct inode *inode,
777 const struct qstr *name,
778 const struct inode *context_inode)
783 static inline int security_old_inode_init_security(struct inode *inode,
785 const struct qstr *qstr,
787 void **value, size_t *len)
792 static inline int security_inode_create(struct inode *dir,
793 struct dentry *dentry,
799 static inline int security_inode_link(struct dentry *old_dentry,
801 struct dentry *new_dentry)
806 static inline int security_inode_unlink(struct inode *dir,
807 struct dentry *dentry)
812 static inline int security_inode_symlink(struct inode *dir,
813 struct dentry *dentry,
814 const char *old_name)
819 static inline int security_inode_mkdir(struct inode *dir,
820 struct dentry *dentry,
826 static inline int security_inode_rmdir(struct inode *dir,
827 struct dentry *dentry)
832 static inline int security_inode_mknod(struct inode *dir,
833 struct dentry *dentry,
839 static inline int security_inode_rename(struct inode *old_dir,
840 struct dentry *old_dentry,
841 struct inode *new_dir,
842 struct dentry *new_dentry,
848 static inline int security_inode_readlink(struct dentry *dentry)
853 static inline int security_inode_follow_link(struct dentry *dentry,
860 static inline int security_inode_permission(struct inode *inode, int mask)
865 static inline int security_inode_setattr(struct user_namespace *mnt_userns,
866 struct dentry *dentry,
872 static inline int security_inode_getattr(const struct path *path)
877 static inline int security_inode_setxattr(struct user_namespace *mnt_userns,
878 struct dentry *dentry, const char *name, const void *value,
879 size_t size, int flags)
881 return cap_inode_setxattr(dentry, name, value, size, flags);
884 static inline int security_inode_set_acl(struct user_namespace *mnt_userns,
885 struct dentry *dentry,
886 const char *acl_name,
887 struct posix_acl *kacl)
892 static inline int security_inode_get_acl(struct user_namespace *mnt_userns,
893 struct dentry *dentry,
894 const char *acl_name)
899 static inline int security_inode_remove_acl(struct user_namespace *mnt_userns,
900 struct dentry *dentry,
901 const char *acl_name)
906 static inline void security_inode_post_setxattr(struct dentry *dentry,
907 const char *name, const void *value, size_t size, int flags)
910 static inline int security_inode_getxattr(struct dentry *dentry,
916 static inline int security_inode_listxattr(struct dentry *dentry)
921 static inline int security_inode_removexattr(struct user_namespace *mnt_userns,
922 struct dentry *dentry,
925 return cap_inode_removexattr(mnt_userns, dentry, name);
928 static inline int security_inode_need_killpriv(struct dentry *dentry)
930 return cap_inode_need_killpriv(dentry);
933 static inline int security_inode_killpriv(struct user_namespace *mnt_userns,
934 struct dentry *dentry)
936 return cap_inode_killpriv(mnt_userns, dentry);
939 static inline int security_inode_getsecurity(struct user_namespace *mnt_userns,
941 const char *name, void **buffer,
944 return cap_inode_getsecurity(mnt_userns, inode, name, buffer, alloc);
947 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
952 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
957 static inline void security_inode_getsecid(struct inode *inode, u32 *secid)
962 static inline int security_inode_copy_up(struct dentry *src, struct cred **new)
967 static inline int security_kernfs_init_security(struct kernfs_node *kn_dir,
968 struct kernfs_node *kn)
973 static inline int security_inode_copy_up_xattr(const char *name)
978 static inline int security_file_permission(struct file *file, int mask)
983 static inline int security_file_alloc(struct file *file)
988 static inline void security_file_free(struct file *file)
991 static inline int security_file_ioctl(struct file *file, unsigned int cmd,
997 static inline int security_mmap_file(struct file *file, unsigned long prot,
1003 static inline int security_mmap_addr(unsigned long addr)
1005 return cap_mmap_addr(addr);
1008 static inline int security_file_mprotect(struct vm_area_struct *vma,
1009 unsigned long reqprot,
1015 static inline int security_file_lock(struct file *file, unsigned int cmd)
1020 static inline int security_file_fcntl(struct file *file, unsigned int cmd,
1026 static inline void security_file_set_fowner(struct file *file)
1031 static inline int security_file_send_sigiotask(struct task_struct *tsk,
1032 struct fown_struct *fown,
1038 static inline int security_file_receive(struct file *file)
1043 static inline int security_file_open(struct file *file)
1048 static inline int security_file_truncate(struct file *file)
1053 static inline int security_task_alloc(struct task_struct *task,
1054 unsigned long clone_flags)
1059 static inline void security_task_free(struct task_struct *task)
1062 static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
1067 static inline void security_cred_free(struct cred *cred)
1070 static inline int security_prepare_creds(struct cred *new,
1071 const struct cred *old,
1077 static inline void security_transfer_creds(struct cred *new,
1078 const struct cred *old)
1082 static inline void security_cred_getsecid(const struct cred *c, u32 *secid)
1087 static inline int security_kernel_act_as(struct cred *cred, u32 secid)
1092 static inline int security_kernel_create_files_as(struct cred *cred,
1093 struct inode *inode)
1098 static inline int security_kernel_module_request(char *kmod_name)
1103 static inline int security_kernel_load_data(enum kernel_load_data_id id, bool contents)
1108 static inline int security_kernel_post_load_data(char *buf, loff_t size,
1109 enum kernel_load_data_id id,
1115 static inline int security_kernel_read_file(struct file *file,
1116 enum kernel_read_file_id id,
1122 static inline int security_kernel_post_read_file(struct file *file,
1123 char *buf, loff_t size,
1124 enum kernel_read_file_id id)
1129 static inline int security_task_fix_setuid(struct cred *new,
1130 const struct cred *old,
1133 return cap_task_fix_setuid(new, old, flags);
1136 static inline int security_task_fix_setgid(struct cred *new,
1137 const struct cred *old,
1143 static inline int security_task_fix_setgroups(struct cred *new,
1144 const struct cred *old)
1149 static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
1154 static inline int security_task_getpgid(struct task_struct *p)
1159 static inline int security_task_getsid(struct task_struct *p)
1164 static inline void security_current_getsecid_subj(u32 *secid)
1169 static inline void security_task_getsecid_obj(struct task_struct *p, u32 *secid)
1174 static inline int security_task_setnice(struct task_struct *p, int nice)
1176 return cap_task_setnice(p, nice);
1179 static inline int security_task_setioprio(struct task_struct *p, int ioprio)
1181 return cap_task_setioprio(p, ioprio);
1184 static inline int security_task_getioprio(struct task_struct *p)
1189 static inline int security_task_prlimit(const struct cred *cred,
1190 const struct cred *tcred,
1196 static inline int security_task_setrlimit(struct task_struct *p,
1197 unsigned int resource,
1198 struct rlimit *new_rlim)
1203 static inline int security_task_setscheduler(struct task_struct *p)
1205 return cap_task_setscheduler(p);
1208 static inline int security_task_getscheduler(struct task_struct *p)
1213 static inline int security_task_movememory(struct task_struct *p)
1218 static inline int security_task_kill(struct task_struct *p,
1219 struct kernel_siginfo *info, int sig,
1220 const struct cred *cred)
1225 static inline int security_task_prctl(int option, unsigned long arg2,
1230 return cap_task_prctl(option, arg2, arg3, arg4, arg5);
1233 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1236 static inline int security_create_user_ns(const struct cred *cred)
1241 static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
1247 static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
1252 static inline int security_msg_msg_alloc(struct msg_msg *msg)
1257 static inline void security_msg_msg_free(struct msg_msg *msg)
1260 static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq)
1265 static inline void security_msg_queue_free(struct kern_ipc_perm *msq)
1268 static inline int security_msg_queue_associate(struct kern_ipc_perm *msq,
1274 static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd)
1279 static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
1280 struct msg_msg *msg, int msqflg)
1285 static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq,
1286 struct msg_msg *msg,
1287 struct task_struct *target,
1288 long type, int mode)
1293 static inline int security_shm_alloc(struct kern_ipc_perm *shp)
1298 static inline void security_shm_free(struct kern_ipc_perm *shp)
1301 static inline int security_shm_associate(struct kern_ipc_perm *shp,
1307 static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd)
1312 static inline int security_shm_shmat(struct kern_ipc_perm *shp,
1313 char __user *shmaddr, int shmflg)
1318 static inline int security_sem_alloc(struct kern_ipc_perm *sma)
1323 static inline void security_sem_free(struct kern_ipc_perm *sma)
1326 static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg)
1331 static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd)
1336 static inline int security_sem_semop(struct kern_ipc_perm *sma,
1337 struct sembuf *sops, unsigned nsops,
1343 static inline void security_d_instantiate(struct dentry *dentry,
1344 struct inode *inode)
1347 static inline int security_getprocattr(struct task_struct *p, const char *lsm,
1348 const char *name, char **value)
1353 static inline int security_setprocattr(const char *lsm, char *name,
1354 void *value, size_t size)
1359 static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
1364 static inline int security_ismaclabel(const char *name)
1369 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
1374 static inline int security_secctx_to_secid(const char *secdata,
1381 static inline void security_release_secctx(char *secdata, u32 seclen)
1385 static inline void security_inode_invalidate_secctx(struct inode *inode)
1389 static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
1393 static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
1397 static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
1401 static inline int security_locked_down(enum lockdown_reason what)
1405 #endif /* CONFIG_SECURITY */
1407 #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
1408 int security_post_notification(const struct cred *w_cred,
1409 const struct cred *cred,
1410 struct watch_notification *n);
1412 static inline int security_post_notification(const struct cred *w_cred,
1413 const struct cred *cred,
1414 struct watch_notification *n)
1420 #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
1421 int security_watch_key(struct key *key);
1423 static inline int security_watch_key(struct key *key)
1429 #ifdef CONFIG_SECURITY_NETWORK
1431 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
1432 int security_unix_may_send(struct socket *sock, struct socket *other);
1433 int security_socket_create(int family, int type, int protocol, int kern);
1434 int security_socket_post_create(struct socket *sock, int family,
1435 int type, int protocol, int kern);
1436 int security_socket_socketpair(struct socket *socka, struct socket *sockb);
1437 int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
1438 int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
1439 int security_socket_listen(struct socket *sock, int backlog);
1440 int security_socket_accept(struct socket *sock, struct socket *newsock);
1441 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
1442 int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
1443 int size, int flags);
1444 int security_socket_getsockname(struct socket *sock);
1445 int security_socket_getpeername(struct socket *sock);
1446 int security_socket_getsockopt(struct socket *sock, int level, int optname);
1447 int security_socket_setsockopt(struct socket *sock, int level, int optname);
1448 int security_socket_shutdown(struct socket *sock, int how);
1449 int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
1450 int security_socket_getpeersec_stream(struct socket *sock, sockptr_t optval,
1451 sockptr_t optlen, unsigned int len);
1452 int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
1453 int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
1454 void security_sk_free(struct sock *sk);
1455 void security_sk_clone(const struct sock *sk, struct sock *newsk);
1456 void security_sk_classify_flow(struct sock *sk, struct flowi_common *flic);
1457 void security_req_classify_flow(const struct request_sock *req,
1458 struct flowi_common *flic);
1459 void security_sock_graft(struct sock*sk, struct socket *parent);
1460 int security_inet_conn_request(const struct sock *sk,
1461 struct sk_buff *skb, struct request_sock *req);
1462 void security_inet_csk_clone(struct sock *newsk,
1463 const struct request_sock *req);
1464 void security_inet_conn_established(struct sock *sk,
1465 struct sk_buff *skb);
1466 int security_secmark_relabel_packet(u32 secid);
1467 void security_secmark_refcount_inc(void);
1468 void security_secmark_refcount_dec(void);
1469 int security_tun_dev_alloc_security(void **security);
1470 void security_tun_dev_free_security(void *security);
1471 int security_tun_dev_create(void);
1472 int security_tun_dev_attach_queue(void *security);
1473 int security_tun_dev_attach(struct sock *sk, void *security);
1474 int security_tun_dev_open(void *security);
1475 int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb);
1476 int security_sctp_bind_connect(struct sock *sk, int optname,
1477 struct sockaddr *address, int addrlen);
1478 void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk,
1479 struct sock *newsk);
1480 int security_sctp_assoc_established(struct sctp_association *asoc,
1481 struct sk_buff *skb);
1483 #else /* CONFIG_SECURITY_NETWORK */
1484 static inline int security_unix_stream_connect(struct sock *sock,
1491 static inline int security_unix_may_send(struct socket *sock,
1492 struct socket *other)
1497 static inline int security_socket_create(int family, int type,
1498 int protocol, int kern)
1503 static inline int security_socket_post_create(struct socket *sock,
1506 int protocol, int kern)
1511 static inline int security_socket_socketpair(struct socket *socka,
1512 struct socket *sockb)
1517 static inline int security_socket_bind(struct socket *sock,
1518 struct sockaddr *address,
1524 static inline int security_socket_connect(struct socket *sock,
1525 struct sockaddr *address,
1531 static inline int security_socket_listen(struct socket *sock, int backlog)
1536 static inline int security_socket_accept(struct socket *sock,
1537 struct socket *newsock)
1542 static inline int security_socket_sendmsg(struct socket *sock,
1543 struct msghdr *msg, int size)
1548 static inline int security_socket_recvmsg(struct socket *sock,
1549 struct msghdr *msg, int size,
1555 static inline int security_socket_getsockname(struct socket *sock)
1560 static inline int security_socket_getpeername(struct socket *sock)
1565 static inline int security_socket_getsockopt(struct socket *sock,
1566 int level, int optname)
1571 static inline int security_socket_setsockopt(struct socket *sock,
1572 int level, int optname)
1577 static inline int security_socket_shutdown(struct socket *sock, int how)
1581 static inline int security_sock_rcv_skb(struct sock *sk,
1582 struct sk_buff *skb)
1587 static inline int security_socket_getpeersec_stream(struct socket *sock,
1592 return -ENOPROTOOPT;
1595 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
1597 return -ENOPROTOOPT;
1600 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
1605 static inline void security_sk_free(struct sock *sk)
1609 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
1613 static inline void security_sk_classify_flow(struct sock *sk,
1614 struct flowi_common *flic)
1618 static inline void security_req_classify_flow(const struct request_sock *req,
1619 struct flowi_common *flic)
1623 static inline void security_sock_graft(struct sock *sk, struct socket *parent)
1627 static inline int security_inet_conn_request(const struct sock *sk,
1628 struct sk_buff *skb, struct request_sock *req)
1633 static inline void security_inet_csk_clone(struct sock *newsk,
1634 const struct request_sock *req)
1638 static inline void security_inet_conn_established(struct sock *sk,
1639 struct sk_buff *skb)
1643 static inline int security_secmark_relabel_packet(u32 secid)
1648 static inline void security_secmark_refcount_inc(void)
1652 static inline void security_secmark_refcount_dec(void)
1656 static inline int security_tun_dev_alloc_security(void **security)
1661 static inline void security_tun_dev_free_security(void *security)
1665 static inline int security_tun_dev_create(void)
1670 static inline int security_tun_dev_attach_queue(void *security)
1675 static inline int security_tun_dev_attach(struct sock *sk, void *security)
1680 static inline int security_tun_dev_open(void *security)
1685 static inline int security_sctp_assoc_request(struct sctp_association *asoc,
1686 struct sk_buff *skb)
1691 static inline int security_sctp_bind_connect(struct sock *sk, int optname,
1692 struct sockaddr *address,
1698 static inline void security_sctp_sk_clone(struct sctp_association *asoc,
1704 static inline int security_sctp_assoc_established(struct sctp_association *asoc,
1705 struct sk_buff *skb)
1709 #endif /* CONFIG_SECURITY_NETWORK */
1711 #ifdef CONFIG_SECURITY_INFINIBAND
1712 int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey);
1713 int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num);
1714 int security_ib_alloc_security(void **sec);
1715 void security_ib_free_security(void *sec);
1716 #else /* CONFIG_SECURITY_INFINIBAND */
1717 static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey)
1722 static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num)
1727 static inline int security_ib_alloc_security(void **sec)
1732 static inline void security_ib_free_security(void *sec)
1735 #endif /* CONFIG_SECURITY_INFINIBAND */
1737 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1739 int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1740 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
1741 int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
1742 void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
1743 int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
1744 int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1745 int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1746 struct xfrm_sec_ctx *polsec, u32 secid);
1747 int security_xfrm_state_delete(struct xfrm_state *x);
1748 void security_xfrm_state_free(struct xfrm_state *x);
1749 int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid);
1750 int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1751 struct xfrm_policy *xp,
1752 const struct flowi_common *flic);
1753 int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
1754 void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic);
1756 #else /* CONFIG_SECURITY_NETWORK_XFRM */
1758 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1759 struct xfrm_user_sec_ctx *sec_ctx,
1765 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
1770 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
1774 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
1779 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
1780 struct xfrm_user_sec_ctx *sec_ctx)
1785 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1786 struct xfrm_sec_ctx *polsec, u32 secid)
1791 static inline void security_xfrm_state_free(struct xfrm_state *x)
1795 static inline int security_xfrm_state_delete(struct xfrm_state *x)
1800 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
1805 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1806 struct xfrm_policy *xp,
1807 const struct flowi_common *flic)
1812 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
1817 static inline void security_skb_classify_flow(struct sk_buff *skb,
1818 struct flowi_common *flic)
1822 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1824 #ifdef CONFIG_SECURITY_PATH
1825 int security_path_unlink(const struct path *dir, struct dentry *dentry);
1826 int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
1827 int security_path_rmdir(const struct path *dir, struct dentry *dentry);
1828 int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
1830 int security_path_truncate(const struct path *path);
1831 int security_path_symlink(const struct path *dir, struct dentry *dentry,
1832 const char *old_name);
1833 int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
1834 struct dentry *new_dentry);
1835 int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
1836 const struct path *new_dir, struct dentry *new_dentry,
1837 unsigned int flags);
1838 int security_path_chmod(const struct path *path, umode_t mode);
1839 int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
1840 int security_path_chroot(const struct path *path);
1841 #else /* CONFIG_SECURITY_PATH */
1842 static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
1847 static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
1853 static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
1858 static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
1859 umode_t mode, unsigned int dev)
1864 static inline int security_path_truncate(const struct path *path)
1869 static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
1870 const char *old_name)
1875 static inline int security_path_link(struct dentry *old_dentry,
1876 const struct path *new_dir,
1877 struct dentry *new_dentry)
1882 static inline int security_path_rename(const struct path *old_dir,
1883 struct dentry *old_dentry,
1884 const struct path *new_dir,
1885 struct dentry *new_dentry,
1891 static inline int security_path_chmod(const struct path *path, umode_t mode)
1896 static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
1901 static inline int security_path_chroot(const struct path *path)
1905 #endif /* CONFIG_SECURITY_PATH */
1908 #ifdef CONFIG_SECURITY
1910 int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
1911 void security_key_free(struct key *key);
1912 int security_key_permission(key_ref_t key_ref, const struct cred *cred,
1913 enum key_need_perm need_perm);
1914 int security_key_getsecurity(struct key *key, char **_buffer);
1918 static inline int security_key_alloc(struct key *key,
1919 const struct cred *cred,
1920 unsigned long flags)
1925 static inline void security_key_free(struct key *key)
1929 static inline int security_key_permission(key_ref_t key_ref,
1930 const struct cred *cred,
1931 enum key_need_perm need_perm)
1936 static inline int security_key_getsecurity(struct key *key, char **_buffer)
1943 #endif /* CONFIG_KEYS */
1946 #ifdef CONFIG_SECURITY
1947 int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
1948 int security_audit_rule_known(struct audit_krule *krule);
1949 int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule);
1950 void security_audit_rule_free(void *lsmrule);
1954 static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
1960 static inline int security_audit_rule_known(struct audit_krule *krule)
1965 static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
1971 static inline void security_audit_rule_free(void *lsmrule)
1974 #endif /* CONFIG_SECURITY */
1975 #endif /* CONFIG_AUDIT */
1977 #ifdef CONFIG_SECURITYFS
1979 extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
1980 struct dentry *parent, void *data,
1981 const struct file_operations *fops);
1982 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1983 struct dentry *securityfs_create_symlink(const char *name,
1984 struct dentry *parent,
1986 const struct inode_operations *iops);
1987 extern void securityfs_remove(struct dentry *dentry);
1989 #else /* CONFIG_SECURITYFS */
1991 static inline struct dentry *securityfs_create_dir(const char *name,
1992 struct dentry *parent)
1994 return ERR_PTR(-ENODEV);
1997 static inline struct dentry *securityfs_create_file(const char *name,
1999 struct dentry *parent,
2001 const struct file_operations *fops)
2003 return ERR_PTR(-ENODEV);
2006 static inline struct dentry *securityfs_create_symlink(const char *name,
2007 struct dentry *parent,
2009 const struct inode_operations *iops)
2011 return ERR_PTR(-ENODEV);
2014 static inline void securityfs_remove(struct dentry *dentry)
2019 #ifdef CONFIG_BPF_SYSCALL
2023 struct bpf_prog_aux;
2024 #ifdef CONFIG_SECURITY
2025 extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size);
2026 extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
2027 extern int security_bpf_prog(struct bpf_prog *prog);
2028 extern int security_bpf_map_alloc(struct bpf_map *map);
2029 extern void security_bpf_map_free(struct bpf_map *map);
2030 extern int security_bpf_prog_alloc(struct bpf_prog_aux *aux);
2031 extern void security_bpf_prog_free(struct bpf_prog_aux *aux);
2033 static inline int security_bpf(int cmd, union bpf_attr *attr,
2039 static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode)
2044 static inline int security_bpf_prog(struct bpf_prog *prog)
2049 static inline int security_bpf_map_alloc(struct bpf_map *map)
2054 static inline void security_bpf_map_free(struct bpf_map *map)
2057 static inline int security_bpf_prog_alloc(struct bpf_prog_aux *aux)
2062 static inline void security_bpf_prog_free(struct bpf_prog_aux *aux)
2064 #endif /* CONFIG_SECURITY */
2065 #endif /* CONFIG_BPF_SYSCALL */
2067 #ifdef CONFIG_PERF_EVENTS
2068 struct perf_event_attr;
2071 #ifdef CONFIG_SECURITY
2072 extern int security_perf_event_open(struct perf_event_attr *attr, int type);
2073 extern int security_perf_event_alloc(struct perf_event *event);
2074 extern void security_perf_event_free(struct perf_event *event);
2075 extern int security_perf_event_read(struct perf_event *event);
2076 extern int security_perf_event_write(struct perf_event *event);
2078 static inline int security_perf_event_open(struct perf_event_attr *attr,
2084 static inline int security_perf_event_alloc(struct perf_event *event)
2089 static inline void security_perf_event_free(struct perf_event *event)
2093 static inline int security_perf_event_read(struct perf_event *event)
2098 static inline int security_perf_event_write(struct perf_event *event)
2102 #endif /* CONFIG_SECURITY */
2103 #endif /* CONFIG_PERF_EVENTS */
2105 #ifdef CONFIG_IO_URING
2106 #ifdef CONFIG_SECURITY
2107 extern int security_uring_override_creds(const struct cred *new);
2108 extern int security_uring_sqpoll(void);
2109 extern int security_uring_cmd(struct io_uring_cmd *ioucmd);
2111 static inline int security_uring_override_creds(const struct cred *new)
2115 static inline int security_uring_sqpoll(void)
2119 static inline int security_uring_cmd(struct io_uring_cmd *ioucmd)
2123 #endif /* CONFIG_SECURITY */
2124 #endif /* CONFIG_IO_URING */
2126 #endif /* ! __LINUX_SECURITY_H */