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(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 mnt_idmap *idmap,
157 struct dentry *dentry, const char *name);
158 int cap_inode_need_killpriv(struct dentry *dentry);
159 int cap_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
160 int cap_inode_getsecurity(struct mnt_idmap *idmap,
161 struct inode *inode, const char *name, void **buffer,
163 extern int cap_mmap_addr(unsigned long addr);
164 extern int cap_mmap_file(struct file *file, unsigned long reqprot,
165 unsigned long prot, unsigned long flags);
166 extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
167 extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
168 unsigned long arg4, unsigned long arg5);
169 extern int cap_task_setscheduler(struct task_struct *p);
170 extern int cap_task_setioprio(struct task_struct *p, int ioprio);
171 extern int cap_task_setnice(struct task_struct *p, int nice);
172 extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
181 struct xfrm_selector;
184 struct xfrm_user_sec_ctx;
186 struct sctp_association;
189 extern unsigned long mmap_min_addr;
190 extern unsigned long dac_mmap_min_addr;
192 #define mmap_min_addr 0UL
193 #define dac_mmap_min_addr 0UL
197 * Values used in the task_security_ops calls
199 /* setuid or setgid, id0 == uid or gid */
200 #define LSM_SETID_ID 1
202 /* setreuid or setregid, id0 == real, id1 == eff */
203 #define LSM_SETID_RE 2
205 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
206 #define LSM_SETID_RES 4
208 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
209 #define LSM_SETID_FS 8
211 /* Flags for security_task_prlimit(). */
212 #define LSM_PRLIMIT_READ 1
213 #define LSM_PRLIMIT_WRITE 2
215 /* forward declares to avoid warnings */
219 /* bprm->unsafe reasons */
220 #define LSM_UNSAFE_SHARE 1
221 #define LSM_UNSAFE_PTRACE 2
222 #define LSM_UNSAFE_NO_NEW_PRIVS 4
225 extern int mmap_min_addr_handler(struct ctl_table *table, int write,
226 void *buffer, size_t *lenp, loff_t *ppos);
229 /* security_inode_init_security callback function to write xattrs */
230 typedef int (*initxattrs) (struct inode *inode,
231 const struct xattr *xattr_array, void *fs_data);
234 /* Keep the kernel_load_data_id enum in sync with kernel_read_file_id */
235 #define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM,
236 #define __data_id_stringify(dummy, str) #str,
238 enum kernel_load_data_id {
239 __kernel_read_file_id(__data_id_enumify)
242 static const char * const kernel_load_data_str[] = {
243 __kernel_read_file_id(__data_id_stringify)
246 static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
248 if ((unsigned)id >= LOADING_MAX_ID)
249 return kernel_load_data_str[LOADING_UNKNOWN];
251 return kernel_load_data_str[id];
254 #ifdef CONFIG_SECURITY
256 int call_blocking_lsm_notifier(enum lsm_event event, void *data);
257 int register_blocking_lsm_notifier(struct notifier_block *nb);
258 int unregister_blocking_lsm_notifier(struct notifier_block *nb);
261 extern int security_init(void);
262 extern int early_security_init(void);
264 /* Security operations */
265 int security_binder_set_context_mgr(const struct cred *mgr);
266 int security_binder_transaction(const struct cred *from,
267 const struct cred *to);
268 int security_binder_transfer_binder(const struct cred *from,
269 const struct cred *to);
270 int security_binder_transfer_file(const struct cred *from,
271 const struct cred *to, struct file *file);
272 int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
273 int security_ptrace_traceme(struct task_struct *parent);
274 int security_capget(struct task_struct *target,
275 kernel_cap_t *effective,
276 kernel_cap_t *inheritable,
277 kernel_cap_t *permitted);
278 int security_capset(struct cred *new, const struct cred *old,
279 const kernel_cap_t *effective,
280 const kernel_cap_t *inheritable,
281 const kernel_cap_t *permitted);
282 int security_capable(const struct cred *cred,
283 struct user_namespace *ns,
286 int security_quotactl(int cmds, int type, int id, struct super_block *sb);
287 int security_quota_on(struct dentry *dentry);
288 int security_syslog(int type);
289 int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
290 int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
291 int security_bprm_creds_for_exec(struct linux_binprm *bprm);
292 int security_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
293 int security_bprm_check(struct linux_binprm *bprm);
294 void security_bprm_committing_creds(struct linux_binprm *bprm);
295 void security_bprm_committed_creds(struct linux_binprm *bprm);
296 int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc);
297 int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
298 int security_sb_alloc(struct super_block *sb);
299 void security_sb_delete(struct super_block *sb);
300 void security_sb_free(struct super_block *sb);
301 void security_free_mnt_opts(void **mnt_opts);
302 int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
303 int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
304 int security_sb_remount(struct super_block *sb, void *mnt_opts);
305 int security_sb_kern_mount(struct super_block *sb);
306 int security_sb_show_options(struct seq_file *m, struct super_block *sb);
307 int security_sb_statfs(struct dentry *dentry);
308 int security_sb_mount(const char *dev_name, const struct path *path,
309 const char *type, unsigned long flags, void *data);
310 int security_sb_umount(struct vfsmount *mnt, int flags);
311 int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
312 int security_sb_set_mnt_opts(struct super_block *sb,
314 unsigned long kern_flags,
315 unsigned long *set_kern_flags);
316 int security_sb_clone_mnt_opts(const struct super_block *oldsb,
317 struct super_block *newsb,
318 unsigned long kern_flags,
319 unsigned long *set_kern_flags);
320 int security_move_mount(const struct path *from_path, const struct path *to_path);
321 int security_dentry_init_security(struct dentry *dentry, int mode,
322 const struct qstr *name,
323 const char **xattr_name, void **ctx,
325 int security_dentry_create_files_as(struct dentry *dentry, int mode,
327 const struct cred *old,
329 int security_path_notify(const struct path *path, u64 mask,
330 unsigned int obj_type);
331 int security_inode_alloc(struct inode *inode);
332 void security_inode_free(struct inode *inode);
333 int security_inode_init_security(struct inode *inode, struct inode *dir,
334 const struct qstr *qstr,
335 initxattrs initxattrs, void *fs_data);
336 int security_inode_init_security_anon(struct inode *inode,
337 const struct qstr *name,
338 const struct inode *context_inode);
339 int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
340 int security_inode_link(struct dentry *old_dentry, struct inode *dir,
341 struct dentry *new_dentry);
342 int security_inode_unlink(struct inode *dir, struct dentry *dentry);
343 int security_inode_symlink(struct inode *dir, struct dentry *dentry,
344 const char *old_name);
345 int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
346 int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
347 int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
348 int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
349 struct inode *new_dir, struct dentry *new_dentry,
351 int security_inode_readlink(struct dentry *dentry);
352 int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
354 int security_inode_permission(struct inode *inode, int mask);
355 int security_inode_setattr(struct mnt_idmap *idmap,
356 struct dentry *dentry, struct iattr *attr);
357 int security_inode_getattr(const struct path *path);
358 int security_inode_setxattr(struct mnt_idmap *idmap,
359 struct dentry *dentry, const char *name,
360 const void *value, size_t size, int flags);
361 int security_inode_set_acl(struct mnt_idmap *idmap,
362 struct dentry *dentry, const char *acl_name,
363 struct posix_acl *kacl);
364 int security_inode_get_acl(struct mnt_idmap *idmap,
365 struct dentry *dentry, const char *acl_name);
366 int security_inode_remove_acl(struct mnt_idmap *idmap,
367 struct dentry *dentry, const char *acl_name);
368 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
369 const void *value, size_t size, int flags);
370 int security_inode_getxattr(struct dentry *dentry, const char *name);
371 int security_inode_listxattr(struct dentry *dentry);
372 int security_inode_removexattr(struct mnt_idmap *idmap,
373 struct dentry *dentry, const char *name);
374 int security_inode_need_killpriv(struct dentry *dentry);
375 int security_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
376 int security_inode_getsecurity(struct mnt_idmap *idmap,
377 struct inode *inode, const char *name,
378 void **buffer, bool alloc);
379 int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
380 int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
381 void security_inode_getsecid(struct inode *inode, u32 *secid);
382 int security_inode_copy_up(struct dentry *src, struct cred **new);
383 int security_inode_copy_up_xattr(const char *name);
384 int security_kernfs_init_security(struct kernfs_node *kn_dir,
385 struct kernfs_node *kn);
386 int security_file_permission(struct file *file, int mask);
387 int security_file_alloc(struct file *file);
388 void security_file_free(struct file *file);
389 int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
390 int security_mmap_file(struct file *file, unsigned long prot,
391 unsigned long flags);
392 int security_mmap_addr(unsigned long addr);
393 int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
395 int security_file_lock(struct file *file, unsigned int cmd);
396 int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
397 void security_file_set_fowner(struct file *file);
398 int security_file_send_sigiotask(struct task_struct *tsk,
399 struct fown_struct *fown, int sig);
400 int security_file_receive(struct file *file);
401 int security_file_open(struct file *file);
402 int security_file_truncate(struct file *file);
403 int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
404 void security_task_free(struct task_struct *task);
405 int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
406 void security_cred_free(struct cred *cred);
407 int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
408 void security_transfer_creds(struct cred *new, const struct cred *old);
409 void security_cred_getsecid(const struct cred *c, u32 *secid);
410 int security_kernel_act_as(struct cred *new, u32 secid);
411 int security_kernel_create_files_as(struct cred *new, struct inode *inode);
412 int security_kernel_module_request(char *kmod_name);
413 int security_kernel_load_data(enum kernel_load_data_id id, bool contents);
414 int security_kernel_post_load_data(char *buf, loff_t size,
415 enum kernel_load_data_id id,
417 int security_kernel_read_file(struct file *file, enum kernel_read_file_id id,
419 int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
420 enum kernel_read_file_id id);
421 int security_task_fix_setuid(struct cred *new, const struct cred *old,
423 int security_task_fix_setgid(struct cred *new, const struct cred *old,
425 int security_task_fix_setgroups(struct cred *new, const struct cred *old);
426 int security_task_setpgid(struct task_struct *p, pid_t pgid);
427 int security_task_getpgid(struct task_struct *p);
428 int security_task_getsid(struct task_struct *p);
429 void security_current_getsecid_subj(u32 *secid);
430 void security_task_getsecid_obj(struct task_struct *p, u32 *secid);
431 int security_task_setnice(struct task_struct *p, int nice);
432 int security_task_setioprio(struct task_struct *p, int ioprio);
433 int security_task_getioprio(struct task_struct *p);
434 int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
436 int security_task_setrlimit(struct task_struct *p, unsigned int resource,
437 struct rlimit *new_rlim);
438 int security_task_setscheduler(struct task_struct *p);
439 int security_task_getscheduler(struct task_struct *p);
440 int security_task_movememory(struct task_struct *p);
441 int security_task_kill(struct task_struct *p, struct kernel_siginfo *info,
442 int sig, const struct cred *cred);
443 int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
444 unsigned long arg4, unsigned long arg5);
445 void security_task_to_inode(struct task_struct *p, struct inode *inode);
446 int security_create_user_ns(const struct cred *cred);
447 int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
448 void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
449 int security_msg_msg_alloc(struct msg_msg *msg);
450 void security_msg_msg_free(struct msg_msg *msg);
451 int security_msg_queue_alloc(struct kern_ipc_perm *msq);
452 void security_msg_queue_free(struct kern_ipc_perm *msq);
453 int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg);
454 int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd);
455 int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
456 struct msg_msg *msg, int msqflg);
457 int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg,
458 struct task_struct *target, long type, int mode);
459 int security_shm_alloc(struct kern_ipc_perm *shp);
460 void security_shm_free(struct kern_ipc_perm *shp);
461 int security_shm_associate(struct kern_ipc_perm *shp, int shmflg);
462 int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd);
463 int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg);
464 int security_sem_alloc(struct kern_ipc_perm *sma);
465 void security_sem_free(struct kern_ipc_perm *sma);
466 int security_sem_associate(struct kern_ipc_perm *sma, int semflg);
467 int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
468 int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
469 unsigned nsops, int alter);
470 void security_d_instantiate(struct dentry *dentry, struct inode *inode);
471 int security_getprocattr(struct task_struct *p, const char *lsm, const char *name,
473 int security_setprocattr(const char *lsm, const char *name, void *value,
475 int security_netlink_send(struct sock *sk, struct sk_buff *skb);
476 int security_ismaclabel(const char *name);
477 int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
478 int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
479 void security_release_secctx(char *secdata, u32 seclen);
480 void security_inode_invalidate_secctx(struct inode *inode);
481 int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
482 int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
483 int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
484 int security_locked_down(enum lockdown_reason what);
485 #else /* CONFIG_SECURITY */
487 static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data)
492 static inline int register_blocking_lsm_notifier(struct notifier_block *nb)
497 static inline int unregister_blocking_lsm_notifier(struct notifier_block *nb)
502 static inline void security_free_mnt_opts(void **mnt_opts)
507 * This is the default capabilities functionality. Most of these functions
508 * are just stubbed out, but a few must call the proper capable code.
511 static inline int security_init(void)
516 static inline int early_security_init(void)
521 static inline int security_binder_set_context_mgr(const struct cred *mgr)
526 static inline int security_binder_transaction(const struct cred *from,
527 const struct cred *to)
532 static inline int security_binder_transfer_binder(const struct cred *from,
533 const struct cred *to)
538 static inline int security_binder_transfer_file(const struct cred *from,
539 const struct cred *to,
545 static inline int security_ptrace_access_check(struct task_struct *child,
548 return cap_ptrace_access_check(child, mode);
551 static inline int security_ptrace_traceme(struct task_struct *parent)
553 return cap_ptrace_traceme(parent);
556 static inline int security_capget(struct task_struct *target,
557 kernel_cap_t *effective,
558 kernel_cap_t *inheritable,
559 kernel_cap_t *permitted)
561 return cap_capget(target, effective, inheritable, permitted);
564 static inline int security_capset(struct cred *new,
565 const struct cred *old,
566 const kernel_cap_t *effective,
567 const kernel_cap_t *inheritable,
568 const kernel_cap_t *permitted)
570 return cap_capset(new, old, effective, inheritable, permitted);
573 static inline int security_capable(const struct cred *cred,
574 struct user_namespace *ns,
578 return cap_capable(cred, ns, cap, opts);
581 static inline int security_quotactl(int cmds, int type, int id,
582 struct super_block *sb)
587 static inline int security_quota_on(struct dentry *dentry)
592 static inline int security_syslog(int type)
597 static inline int security_settime64(const struct timespec64 *ts,
598 const struct timezone *tz)
600 return cap_settime(ts, tz);
603 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
605 return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages));
608 static inline int security_bprm_creds_for_exec(struct linux_binprm *bprm)
613 static inline int security_bprm_creds_from_file(struct linux_binprm *bprm,
616 return cap_bprm_creds_from_file(bprm, file);
619 static inline int security_bprm_check(struct linux_binprm *bprm)
624 static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
628 static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
632 static inline int security_fs_context_dup(struct fs_context *fc,
633 struct fs_context *src_fc)
637 static inline int security_fs_context_parse_param(struct fs_context *fc,
638 struct fs_parameter *param)
643 static inline int security_sb_alloc(struct super_block *sb)
648 static inline void security_sb_delete(struct super_block *sb)
651 static inline void security_sb_free(struct super_block *sb)
654 static inline int security_sb_eat_lsm_opts(char *options,
660 static inline int security_sb_remount(struct super_block *sb,
666 static inline int security_sb_mnt_opts_compat(struct super_block *sb,
673 static inline int security_sb_kern_mount(struct super_block *sb)
678 static inline int security_sb_show_options(struct seq_file *m,
679 struct super_block *sb)
684 static inline int security_sb_statfs(struct dentry *dentry)
689 static inline int security_sb_mount(const char *dev_name, const struct path *path,
690 const char *type, unsigned long flags,
696 static inline int security_sb_umount(struct vfsmount *mnt, int flags)
701 static inline int security_sb_pivotroot(const struct path *old_path,
702 const struct path *new_path)
707 static inline int security_sb_set_mnt_opts(struct super_block *sb,
709 unsigned long kern_flags,
710 unsigned long *set_kern_flags)
715 static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
716 struct super_block *newsb,
717 unsigned long kern_flags,
718 unsigned long *set_kern_flags)
723 static inline int security_move_mount(const struct path *from_path,
724 const struct path *to_path)
729 static inline int security_path_notify(const struct path *path, u64 mask,
730 unsigned int obj_type)
735 static inline int security_inode_alloc(struct inode *inode)
740 static inline void security_inode_free(struct inode *inode)
743 static inline int security_dentry_init_security(struct dentry *dentry,
745 const struct qstr *name,
746 const char **xattr_name,
753 static inline int security_dentry_create_files_as(struct dentry *dentry,
754 int mode, struct qstr *name,
755 const struct cred *old,
762 static inline int security_inode_init_security(struct inode *inode,
764 const struct qstr *qstr,
765 const initxattrs xattrs,
771 static inline int security_inode_init_security_anon(struct inode *inode,
772 const struct qstr *name,
773 const struct inode *context_inode)
778 static inline int security_inode_create(struct inode *dir,
779 struct dentry *dentry,
785 static inline int security_inode_link(struct dentry *old_dentry,
787 struct dentry *new_dentry)
792 static inline int security_inode_unlink(struct inode *dir,
793 struct dentry *dentry)
798 static inline int security_inode_symlink(struct inode *dir,
799 struct dentry *dentry,
800 const char *old_name)
805 static inline int security_inode_mkdir(struct inode *dir,
806 struct dentry *dentry,
812 static inline int security_inode_rmdir(struct inode *dir,
813 struct dentry *dentry)
818 static inline int security_inode_mknod(struct inode *dir,
819 struct dentry *dentry,
825 static inline int security_inode_rename(struct inode *old_dir,
826 struct dentry *old_dentry,
827 struct inode *new_dir,
828 struct dentry *new_dentry,
834 static inline int security_inode_readlink(struct dentry *dentry)
839 static inline int security_inode_follow_link(struct dentry *dentry,
846 static inline int security_inode_permission(struct inode *inode, int mask)
851 static inline int security_inode_setattr(struct mnt_idmap *idmap,
852 struct dentry *dentry,
858 static inline int security_inode_getattr(const struct path *path)
863 static inline int security_inode_setxattr(struct mnt_idmap *idmap,
864 struct dentry *dentry, const char *name, const void *value,
865 size_t size, int flags)
867 return cap_inode_setxattr(dentry, name, value, size, flags);
870 static inline int security_inode_set_acl(struct mnt_idmap *idmap,
871 struct dentry *dentry,
872 const char *acl_name,
873 struct posix_acl *kacl)
878 static inline int security_inode_get_acl(struct mnt_idmap *idmap,
879 struct dentry *dentry,
880 const char *acl_name)
885 static inline int security_inode_remove_acl(struct mnt_idmap *idmap,
886 struct dentry *dentry,
887 const char *acl_name)
892 static inline void security_inode_post_setxattr(struct dentry *dentry,
893 const char *name, const void *value, size_t size, int flags)
896 static inline int security_inode_getxattr(struct dentry *dentry,
902 static inline int security_inode_listxattr(struct dentry *dentry)
907 static inline int security_inode_removexattr(struct mnt_idmap *idmap,
908 struct dentry *dentry,
911 return cap_inode_removexattr(idmap, dentry, name);
914 static inline int security_inode_need_killpriv(struct dentry *dentry)
916 return cap_inode_need_killpriv(dentry);
919 static inline int security_inode_killpriv(struct mnt_idmap *idmap,
920 struct dentry *dentry)
922 return cap_inode_killpriv(idmap, dentry);
925 static inline int security_inode_getsecurity(struct mnt_idmap *idmap,
927 const char *name, void **buffer,
930 return cap_inode_getsecurity(idmap, inode, name, buffer, alloc);
933 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
938 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
943 static inline void security_inode_getsecid(struct inode *inode, u32 *secid)
948 static inline int security_inode_copy_up(struct dentry *src, struct cred **new)
953 static inline int security_kernfs_init_security(struct kernfs_node *kn_dir,
954 struct kernfs_node *kn)
959 static inline int security_inode_copy_up_xattr(const char *name)
964 static inline int security_file_permission(struct file *file, int mask)
969 static inline int security_file_alloc(struct file *file)
974 static inline void security_file_free(struct file *file)
977 static inline int security_file_ioctl(struct file *file, unsigned int cmd,
983 static inline int security_mmap_file(struct file *file, unsigned long prot,
989 static inline int security_mmap_addr(unsigned long addr)
991 return cap_mmap_addr(addr);
994 static inline int security_file_mprotect(struct vm_area_struct *vma,
995 unsigned long reqprot,
1001 static inline int security_file_lock(struct file *file, unsigned int cmd)
1006 static inline int security_file_fcntl(struct file *file, unsigned int cmd,
1012 static inline void security_file_set_fowner(struct file *file)
1017 static inline int security_file_send_sigiotask(struct task_struct *tsk,
1018 struct fown_struct *fown,
1024 static inline int security_file_receive(struct file *file)
1029 static inline int security_file_open(struct file *file)
1034 static inline int security_file_truncate(struct file *file)
1039 static inline int security_task_alloc(struct task_struct *task,
1040 unsigned long clone_flags)
1045 static inline void security_task_free(struct task_struct *task)
1048 static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
1053 static inline void security_cred_free(struct cred *cred)
1056 static inline int security_prepare_creds(struct cred *new,
1057 const struct cred *old,
1063 static inline void security_transfer_creds(struct cred *new,
1064 const struct cred *old)
1068 static inline void security_cred_getsecid(const struct cred *c, u32 *secid)
1073 static inline int security_kernel_act_as(struct cred *cred, u32 secid)
1078 static inline int security_kernel_create_files_as(struct cred *cred,
1079 struct inode *inode)
1084 static inline int security_kernel_module_request(char *kmod_name)
1089 static inline int security_kernel_load_data(enum kernel_load_data_id id, bool contents)
1094 static inline int security_kernel_post_load_data(char *buf, loff_t size,
1095 enum kernel_load_data_id id,
1101 static inline int security_kernel_read_file(struct file *file,
1102 enum kernel_read_file_id id,
1108 static inline int security_kernel_post_read_file(struct file *file,
1109 char *buf, loff_t size,
1110 enum kernel_read_file_id id)
1115 static inline int security_task_fix_setuid(struct cred *new,
1116 const struct cred *old,
1119 return cap_task_fix_setuid(new, old, flags);
1122 static inline int security_task_fix_setgid(struct cred *new,
1123 const struct cred *old,
1129 static inline int security_task_fix_setgroups(struct cred *new,
1130 const struct cred *old)
1135 static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
1140 static inline int security_task_getpgid(struct task_struct *p)
1145 static inline int security_task_getsid(struct task_struct *p)
1150 static inline void security_current_getsecid_subj(u32 *secid)
1155 static inline void security_task_getsecid_obj(struct task_struct *p, u32 *secid)
1160 static inline int security_task_setnice(struct task_struct *p, int nice)
1162 return cap_task_setnice(p, nice);
1165 static inline int security_task_setioprio(struct task_struct *p, int ioprio)
1167 return cap_task_setioprio(p, ioprio);
1170 static inline int security_task_getioprio(struct task_struct *p)
1175 static inline int security_task_prlimit(const struct cred *cred,
1176 const struct cred *tcred,
1182 static inline int security_task_setrlimit(struct task_struct *p,
1183 unsigned int resource,
1184 struct rlimit *new_rlim)
1189 static inline int security_task_setscheduler(struct task_struct *p)
1191 return cap_task_setscheduler(p);
1194 static inline int security_task_getscheduler(struct task_struct *p)
1199 static inline int security_task_movememory(struct task_struct *p)
1204 static inline int security_task_kill(struct task_struct *p,
1205 struct kernel_siginfo *info, int sig,
1206 const struct cred *cred)
1211 static inline int security_task_prctl(int option, unsigned long arg2,
1216 return cap_task_prctl(option, arg2, arg3, arg4, arg5);
1219 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1222 static inline int security_create_user_ns(const struct cred *cred)
1227 static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
1233 static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
1238 static inline int security_msg_msg_alloc(struct msg_msg *msg)
1243 static inline void security_msg_msg_free(struct msg_msg *msg)
1246 static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq)
1251 static inline void security_msg_queue_free(struct kern_ipc_perm *msq)
1254 static inline int security_msg_queue_associate(struct kern_ipc_perm *msq,
1260 static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd)
1265 static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
1266 struct msg_msg *msg, int msqflg)
1271 static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq,
1272 struct msg_msg *msg,
1273 struct task_struct *target,
1274 long type, int mode)
1279 static inline int security_shm_alloc(struct kern_ipc_perm *shp)
1284 static inline void security_shm_free(struct kern_ipc_perm *shp)
1287 static inline int security_shm_associate(struct kern_ipc_perm *shp,
1293 static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd)
1298 static inline int security_shm_shmat(struct kern_ipc_perm *shp,
1299 char __user *shmaddr, int shmflg)
1304 static inline int security_sem_alloc(struct kern_ipc_perm *sma)
1309 static inline void security_sem_free(struct kern_ipc_perm *sma)
1312 static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg)
1317 static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd)
1322 static inline int security_sem_semop(struct kern_ipc_perm *sma,
1323 struct sembuf *sops, unsigned nsops,
1329 static inline void security_d_instantiate(struct dentry *dentry,
1330 struct inode *inode)
1333 static inline int security_getprocattr(struct task_struct *p, const char *lsm,
1334 const char *name, char **value)
1339 static inline int security_setprocattr(const char *lsm, char *name,
1340 void *value, size_t size)
1345 static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
1350 static inline int security_ismaclabel(const char *name)
1355 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
1360 static inline int security_secctx_to_secid(const char *secdata,
1367 static inline void security_release_secctx(char *secdata, u32 seclen)
1371 static inline void security_inode_invalidate_secctx(struct inode *inode)
1375 static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
1379 static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
1383 static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
1387 static inline int security_locked_down(enum lockdown_reason what)
1391 #endif /* CONFIG_SECURITY */
1393 #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
1394 int security_post_notification(const struct cred *w_cred,
1395 const struct cred *cred,
1396 struct watch_notification *n);
1398 static inline int security_post_notification(const struct cred *w_cred,
1399 const struct cred *cred,
1400 struct watch_notification *n)
1406 #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
1407 int security_watch_key(struct key *key);
1409 static inline int security_watch_key(struct key *key)
1415 #ifdef CONFIG_SECURITY_NETWORK
1417 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
1418 int security_unix_may_send(struct socket *sock, struct socket *other);
1419 int security_socket_create(int family, int type, int protocol, int kern);
1420 int security_socket_post_create(struct socket *sock, int family,
1421 int type, int protocol, int kern);
1422 int security_socket_socketpair(struct socket *socka, struct socket *sockb);
1423 int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
1424 int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
1425 int security_socket_listen(struct socket *sock, int backlog);
1426 int security_socket_accept(struct socket *sock, struct socket *newsock);
1427 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
1428 int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
1429 int size, int flags);
1430 int security_socket_getsockname(struct socket *sock);
1431 int security_socket_getpeername(struct socket *sock);
1432 int security_socket_getsockopt(struct socket *sock, int level, int optname);
1433 int security_socket_setsockopt(struct socket *sock, int level, int optname);
1434 int security_socket_shutdown(struct socket *sock, int how);
1435 int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
1436 int security_socket_getpeersec_stream(struct socket *sock, sockptr_t optval,
1437 sockptr_t optlen, unsigned int len);
1438 int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
1439 int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
1440 void security_sk_free(struct sock *sk);
1441 void security_sk_clone(const struct sock *sk, struct sock *newsk);
1442 void security_sk_classify_flow(const struct sock *sk,
1443 struct flowi_common *flic);
1444 void security_req_classify_flow(const struct request_sock *req,
1445 struct flowi_common *flic);
1446 void security_sock_graft(struct sock*sk, struct socket *parent);
1447 int security_inet_conn_request(const struct sock *sk,
1448 struct sk_buff *skb, struct request_sock *req);
1449 void security_inet_csk_clone(struct sock *newsk,
1450 const struct request_sock *req);
1451 void security_inet_conn_established(struct sock *sk,
1452 struct sk_buff *skb);
1453 int security_secmark_relabel_packet(u32 secid);
1454 void security_secmark_refcount_inc(void);
1455 void security_secmark_refcount_dec(void);
1456 int security_tun_dev_alloc_security(void **security);
1457 void security_tun_dev_free_security(void *security);
1458 int security_tun_dev_create(void);
1459 int security_tun_dev_attach_queue(void *security);
1460 int security_tun_dev_attach(struct sock *sk, void *security);
1461 int security_tun_dev_open(void *security);
1462 int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb);
1463 int security_sctp_bind_connect(struct sock *sk, int optname,
1464 struct sockaddr *address, int addrlen);
1465 void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk,
1466 struct sock *newsk);
1467 int security_sctp_assoc_established(struct sctp_association *asoc,
1468 struct sk_buff *skb);
1469 int security_mptcp_add_subflow(struct sock *sk, struct sock *ssk);
1471 #else /* CONFIG_SECURITY_NETWORK */
1472 static inline int security_unix_stream_connect(struct sock *sock,
1479 static inline int security_unix_may_send(struct socket *sock,
1480 struct socket *other)
1485 static inline int security_socket_create(int family, int type,
1486 int protocol, int kern)
1491 static inline int security_socket_post_create(struct socket *sock,
1494 int protocol, int kern)
1499 static inline int security_socket_socketpair(struct socket *socka,
1500 struct socket *sockb)
1505 static inline int security_socket_bind(struct socket *sock,
1506 struct sockaddr *address,
1512 static inline int security_socket_connect(struct socket *sock,
1513 struct sockaddr *address,
1519 static inline int security_socket_listen(struct socket *sock, int backlog)
1524 static inline int security_socket_accept(struct socket *sock,
1525 struct socket *newsock)
1530 static inline int security_socket_sendmsg(struct socket *sock,
1531 struct msghdr *msg, int size)
1536 static inline int security_socket_recvmsg(struct socket *sock,
1537 struct msghdr *msg, int size,
1543 static inline int security_socket_getsockname(struct socket *sock)
1548 static inline int security_socket_getpeername(struct socket *sock)
1553 static inline int security_socket_getsockopt(struct socket *sock,
1554 int level, int optname)
1559 static inline int security_socket_setsockopt(struct socket *sock,
1560 int level, int optname)
1565 static inline int security_socket_shutdown(struct socket *sock, int how)
1569 static inline int security_sock_rcv_skb(struct sock *sk,
1570 struct sk_buff *skb)
1575 static inline int security_socket_getpeersec_stream(struct socket *sock,
1580 return -ENOPROTOOPT;
1583 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
1585 return -ENOPROTOOPT;
1588 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
1593 static inline void security_sk_free(struct sock *sk)
1597 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
1601 static inline void security_sk_classify_flow(const struct sock *sk,
1602 struct flowi_common *flic)
1606 static inline void security_req_classify_flow(const struct request_sock *req,
1607 struct flowi_common *flic)
1611 static inline void security_sock_graft(struct sock *sk, struct socket *parent)
1615 static inline int security_inet_conn_request(const struct sock *sk,
1616 struct sk_buff *skb, struct request_sock *req)
1621 static inline void security_inet_csk_clone(struct sock *newsk,
1622 const struct request_sock *req)
1626 static inline void security_inet_conn_established(struct sock *sk,
1627 struct sk_buff *skb)
1631 static inline int security_secmark_relabel_packet(u32 secid)
1636 static inline void security_secmark_refcount_inc(void)
1640 static inline void security_secmark_refcount_dec(void)
1644 static inline int security_tun_dev_alloc_security(void **security)
1649 static inline void security_tun_dev_free_security(void *security)
1653 static inline int security_tun_dev_create(void)
1658 static inline int security_tun_dev_attach_queue(void *security)
1663 static inline int security_tun_dev_attach(struct sock *sk, void *security)
1668 static inline int security_tun_dev_open(void *security)
1673 static inline int security_sctp_assoc_request(struct sctp_association *asoc,
1674 struct sk_buff *skb)
1679 static inline int security_sctp_bind_connect(struct sock *sk, int optname,
1680 struct sockaddr *address,
1686 static inline void security_sctp_sk_clone(struct sctp_association *asoc,
1692 static inline int security_sctp_assoc_established(struct sctp_association *asoc,
1693 struct sk_buff *skb)
1698 static inline int security_mptcp_add_subflow(struct sock *sk, struct sock *ssk)
1702 #endif /* CONFIG_SECURITY_NETWORK */
1704 #ifdef CONFIG_SECURITY_INFINIBAND
1705 int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey);
1706 int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num);
1707 int security_ib_alloc_security(void **sec);
1708 void security_ib_free_security(void *sec);
1709 #else /* CONFIG_SECURITY_INFINIBAND */
1710 static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey)
1715 static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num)
1720 static inline int security_ib_alloc_security(void **sec)
1725 static inline void security_ib_free_security(void *sec)
1728 #endif /* CONFIG_SECURITY_INFINIBAND */
1730 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1732 int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1733 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
1734 int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
1735 void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
1736 int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
1737 int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1738 int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1739 struct xfrm_sec_ctx *polsec, u32 secid);
1740 int security_xfrm_state_delete(struct xfrm_state *x);
1741 void security_xfrm_state_free(struct xfrm_state *x);
1742 int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid);
1743 int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1744 struct xfrm_policy *xp,
1745 const struct flowi_common *flic);
1746 int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
1747 void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic);
1749 #else /* CONFIG_SECURITY_NETWORK_XFRM */
1751 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1752 struct xfrm_user_sec_ctx *sec_ctx,
1758 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
1763 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
1767 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
1772 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
1773 struct xfrm_user_sec_ctx *sec_ctx)
1778 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1779 struct xfrm_sec_ctx *polsec, u32 secid)
1784 static inline void security_xfrm_state_free(struct xfrm_state *x)
1788 static inline int security_xfrm_state_delete(struct xfrm_state *x)
1793 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
1798 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1799 struct xfrm_policy *xp,
1800 const struct flowi_common *flic)
1805 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
1810 static inline void security_skb_classify_flow(struct sk_buff *skb,
1811 struct flowi_common *flic)
1815 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1817 #ifdef CONFIG_SECURITY_PATH
1818 int security_path_unlink(const struct path *dir, struct dentry *dentry);
1819 int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
1820 int security_path_rmdir(const struct path *dir, struct dentry *dentry);
1821 int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
1823 int security_path_truncate(const struct path *path);
1824 int security_path_symlink(const struct path *dir, struct dentry *dentry,
1825 const char *old_name);
1826 int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
1827 struct dentry *new_dentry);
1828 int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
1829 const struct path *new_dir, struct dentry *new_dentry,
1830 unsigned int flags);
1831 int security_path_chmod(const struct path *path, umode_t mode);
1832 int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
1833 int security_path_chroot(const struct path *path);
1834 #else /* CONFIG_SECURITY_PATH */
1835 static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
1840 static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
1846 static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
1851 static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
1852 umode_t mode, unsigned int dev)
1857 static inline int security_path_truncate(const struct path *path)
1862 static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
1863 const char *old_name)
1868 static inline int security_path_link(struct dentry *old_dentry,
1869 const struct path *new_dir,
1870 struct dentry *new_dentry)
1875 static inline int security_path_rename(const struct path *old_dir,
1876 struct dentry *old_dentry,
1877 const struct path *new_dir,
1878 struct dentry *new_dentry,
1884 static inline int security_path_chmod(const struct path *path, umode_t mode)
1889 static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
1894 static inline int security_path_chroot(const struct path *path)
1898 #endif /* CONFIG_SECURITY_PATH */
1901 #ifdef CONFIG_SECURITY
1903 int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
1904 void security_key_free(struct key *key);
1905 int security_key_permission(key_ref_t key_ref, const struct cred *cred,
1906 enum key_need_perm need_perm);
1907 int security_key_getsecurity(struct key *key, char **_buffer);
1911 static inline int security_key_alloc(struct key *key,
1912 const struct cred *cred,
1913 unsigned long flags)
1918 static inline void security_key_free(struct key *key)
1922 static inline int security_key_permission(key_ref_t key_ref,
1923 const struct cred *cred,
1924 enum key_need_perm need_perm)
1929 static inline int security_key_getsecurity(struct key *key, char **_buffer)
1936 #endif /* CONFIG_KEYS */
1939 #ifdef CONFIG_SECURITY
1940 int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
1941 int security_audit_rule_known(struct audit_krule *krule);
1942 int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule);
1943 void security_audit_rule_free(void *lsmrule);
1947 static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
1953 static inline int security_audit_rule_known(struct audit_krule *krule)
1958 static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
1964 static inline void security_audit_rule_free(void *lsmrule)
1967 #endif /* CONFIG_SECURITY */
1968 #endif /* CONFIG_AUDIT */
1970 #ifdef CONFIG_SECURITYFS
1972 extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
1973 struct dentry *parent, void *data,
1974 const struct file_operations *fops);
1975 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1976 struct dentry *securityfs_create_symlink(const char *name,
1977 struct dentry *parent,
1979 const struct inode_operations *iops);
1980 extern void securityfs_remove(struct dentry *dentry);
1982 #else /* CONFIG_SECURITYFS */
1984 static inline struct dentry *securityfs_create_dir(const char *name,
1985 struct dentry *parent)
1987 return ERR_PTR(-ENODEV);
1990 static inline struct dentry *securityfs_create_file(const char *name,
1992 struct dentry *parent,
1994 const struct file_operations *fops)
1996 return ERR_PTR(-ENODEV);
1999 static inline struct dentry *securityfs_create_symlink(const char *name,
2000 struct dentry *parent,
2002 const struct inode_operations *iops)
2004 return ERR_PTR(-ENODEV);
2007 static inline void securityfs_remove(struct dentry *dentry)
2012 #ifdef CONFIG_BPF_SYSCALL
2016 struct bpf_prog_aux;
2017 #ifdef CONFIG_SECURITY
2018 extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size);
2019 extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
2020 extern int security_bpf_prog(struct bpf_prog *prog);
2021 extern int security_bpf_map_alloc(struct bpf_map *map);
2022 extern void security_bpf_map_free(struct bpf_map *map);
2023 extern int security_bpf_prog_alloc(struct bpf_prog_aux *aux);
2024 extern void security_bpf_prog_free(struct bpf_prog_aux *aux);
2026 static inline int security_bpf(int cmd, union bpf_attr *attr,
2032 static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode)
2037 static inline int security_bpf_prog(struct bpf_prog *prog)
2042 static inline int security_bpf_map_alloc(struct bpf_map *map)
2047 static inline void security_bpf_map_free(struct bpf_map *map)
2050 static inline int security_bpf_prog_alloc(struct bpf_prog_aux *aux)
2055 static inline void security_bpf_prog_free(struct bpf_prog_aux *aux)
2057 #endif /* CONFIG_SECURITY */
2058 #endif /* CONFIG_BPF_SYSCALL */
2060 #ifdef CONFIG_PERF_EVENTS
2061 struct perf_event_attr;
2064 #ifdef CONFIG_SECURITY
2065 extern int security_perf_event_open(struct perf_event_attr *attr, int type);
2066 extern int security_perf_event_alloc(struct perf_event *event);
2067 extern void security_perf_event_free(struct perf_event *event);
2068 extern int security_perf_event_read(struct perf_event *event);
2069 extern int security_perf_event_write(struct perf_event *event);
2071 static inline int security_perf_event_open(struct perf_event_attr *attr,
2077 static inline int security_perf_event_alloc(struct perf_event *event)
2082 static inline void security_perf_event_free(struct perf_event *event)
2086 static inline int security_perf_event_read(struct perf_event *event)
2091 static inline int security_perf_event_write(struct perf_event *event)
2095 #endif /* CONFIG_SECURITY */
2096 #endif /* CONFIG_PERF_EVENTS */
2098 #ifdef CONFIG_IO_URING
2099 #ifdef CONFIG_SECURITY
2100 extern int security_uring_override_creds(const struct cred *new);
2101 extern int security_uring_sqpoll(void);
2102 extern int security_uring_cmd(struct io_uring_cmd *ioucmd);
2104 static inline int security_uring_override_creds(const struct cred *new)
2108 static inline int security_uring_sqpoll(void)
2112 static inline int security_uring_cmd(struct io_uring_cmd *ioucmd)
2116 #endif /* CONFIG_SECURITY */
2117 #endif /* CONFIG_IO_URING */
2119 #endif /* ! __LINUX_SECURITY_H */