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>
35 #include <linux/bpf.h>
36 #include <uapi/linux/lsm.h>
41 struct kernel_siginfo;
54 struct file_operations;
64 struct watch_notification;
67 /* Default (no) options for the capable function */
68 #define CAP_OPT_NONE 0x0
69 /* If capable should audit the security request */
70 #define CAP_OPT_NOAUDIT BIT(1)
71 /* If capable is being called by a setid function */
72 #define CAP_OPT_INSETID BIT(2)
74 /* LSM Agnostic defines for security_sb_set_mnt_opts() flags */
75 #define SECURITY_LSM_NATIVE_LABELS 1
79 struct user_namespace;
87 * These are reasons that can be passed to the security_locked_down()
88 * LSM hook. Lockdown reasons that protect kernel integrity (ie, the
89 * ability for userland to modify kernel code) are placed before
90 * LOCKDOWN_INTEGRITY_MAX. Lockdown reasons that protect kernel
91 * confidentiality (ie, the ability for userland to extract
92 * information from the running kernel that would otherwise be
93 * restricted) are placed before LOCKDOWN_CONFIDENTIALITY_MAX.
95 * LSM authors should note that the semantics of any given lockdown
96 * reason are not guaranteed to be stable - the same reason may block
97 * one set of features in one kernel release, and a slightly different
98 * set of features in a later kernel release. LSMs that seek to expose
99 * lockdown policy at any level of granularity other than "none",
100 * "integrity" or "confidentiality" are responsible for either
101 * ensuring that they expose a consistent level of functionality to
102 * userland, or ensuring that userland is aware that this is
103 * potentially a moving target. It is easy to misuse this information
104 * in a way that could break userspace. Please be careful not to do
107 * If you add to this, remember to extend lockdown_reasons in
108 * security/lockdown/lockdown.c.
110 enum lockdown_reason {
112 LOCKDOWN_MODULE_SIGNATURE,
116 LOCKDOWN_HIBERNATION,
120 LOCKDOWN_ACPI_TABLES,
121 LOCKDOWN_DEVICE_TREE,
123 LOCKDOWN_TIOCSSERIAL,
124 LOCKDOWN_MODULE_PARAMETERS,
128 LOCKDOWN_BPF_WRITE_USER,
129 LOCKDOWN_DBG_WRITE_KERNEL,
130 LOCKDOWN_RTAS_ERROR_INJECTION,
131 LOCKDOWN_INTEGRITY_MAX,
134 LOCKDOWN_BPF_READ_KERNEL,
135 LOCKDOWN_DBG_READ_KERNEL,
139 LOCKDOWN_XFRM_SECRET,
140 LOCKDOWN_CONFIDENTIALITY_MAX,
143 extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
144 extern u32 lsm_active_cnt;
145 extern const struct lsm_id *lsm_idlist[];
147 /* These functions are in security/commoncap.c */
148 extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
149 int cap, unsigned int opts);
150 extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
151 extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
152 extern int cap_ptrace_traceme(struct task_struct *parent);
153 extern int cap_capget(const struct task_struct *target, kernel_cap_t *effective,
154 kernel_cap_t *inheritable, kernel_cap_t *permitted);
155 extern int cap_capset(struct cred *new, const struct cred *old,
156 const kernel_cap_t *effective,
157 const kernel_cap_t *inheritable,
158 const kernel_cap_t *permitted);
159 extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file);
160 int cap_inode_setxattr(struct dentry *dentry, const char *name,
161 const void *value, size_t size, int flags);
162 int cap_inode_removexattr(struct mnt_idmap *idmap,
163 struct dentry *dentry, const char *name);
164 int cap_inode_need_killpriv(struct dentry *dentry);
165 int cap_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
166 int cap_inode_getsecurity(struct mnt_idmap *idmap,
167 struct inode *inode, const char *name, void **buffer,
169 extern int cap_mmap_addr(unsigned long addr);
170 extern int cap_mmap_file(struct file *file, unsigned long reqprot,
171 unsigned long prot, unsigned long flags);
172 extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
173 extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
174 unsigned long arg4, unsigned long arg5);
175 extern int cap_task_setscheduler(struct task_struct *p);
176 extern int cap_task_setioprio(struct task_struct *p, int ioprio);
177 extern int cap_task_setnice(struct task_struct *p, int nice);
178 extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
187 struct xfrm_selector;
190 struct xfrm_user_sec_ctx;
192 struct sctp_association;
195 extern unsigned long mmap_min_addr;
196 extern unsigned long dac_mmap_min_addr;
198 #define mmap_min_addr 0UL
199 #define dac_mmap_min_addr 0UL
203 * Values used in the task_security_ops calls
205 /* setuid or setgid, id0 == uid or gid */
206 #define LSM_SETID_ID 1
208 /* setreuid or setregid, id0 == real, id1 == eff */
209 #define LSM_SETID_RE 2
211 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
212 #define LSM_SETID_RES 4
214 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
215 #define LSM_SETID_FS 8
217 /* Flags for security_task_prlimit(). */
218 #define LSM_PRLIMIT_READ 1
219 #define LSM_PRLIMIT_WRITE 2
221 /* forward declares to avoid warnings */
225 /* bprm->unsafe reasons */
226 #define LSM_UNSAFE_SHARE 1
227 #define LSM_UNSAFE_PTRACE 2
228 #define LSM_UNSAFE_NO_NEW_PRIVS 4
231 extern int mmap_min_addr_handler(const struct ctl_table *table, int write,
232 void *buffer, size_t *lenp, loff_t *ppos);
235 /* security_inode_init_security callback function to write xattrs */
236 typedef int (*initxattrs) (struct inode *inode,
237 const struct xattr *xattr_array, void *fs_data);
240 /* Keep the kernel_load_data_id enum in sync with kernel_read_file_id */
241 #define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM,
242 #define __data_id_stringify(dummy, str) #str,
244 enum kernel_load_data_id {
245 __kernel_read_file_id(__data_id_enumify)
248 static const char * const kernel_load_data_str[] = {
249 __kernel_read_file_id(__data_id_stringify)
252 static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
254 if ((unsigned)id >= LOADING_MAX_ID)
255 return kernel_load_data_str[LOADING_UNKNOWN];
257 return kernel_load_data_str[id];
260 #ifdef CONFIG_SECURITY
262 int call_blocking_lsm_notifier(enum lsm_event event, void *data);
263 int register_blocking_lsm_notifier(struct notifier_block *nb);
264 int unregister_blocking_lsm_notifier(struct notifier_block *nb);
267 extern int security_init(void);
268 extern int early_security_init(void);
269 extern u64 lsm_name_to_attr(const char *name);
271 /* Security operations */
272 int security_binder_set_context_mgr(const struct cred *mgr);
273 int security_binder_transaction(const struct cred *from,
274 const struct cred *to);
275 int security_binder_transfer_binder(const struct cred *from,
276 const struct cred *to);
277 int security_binder_transfer_file(const struct cred *from,
278 const struct cred *to, const struct file *file);
279 int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
280 int security_ptrace_traceme(struct task_struct *parent);
281 int security_capget(const struct task_struct *target,
282 kernel_cap_t *effective,
283 kernel_cap_t *inheritable,
284 kernel_cap_t *permitted);
285 int security_capset(struct cred *new, const struct cred *old,
286 const kernel_cap_t *effective,
287 const kernel_cap_t *inheritable,
288 const kernel_cap_t *permitted);
289 int security_capable(const struct cred *cred,
290 struct user_namespace *ns,
293 int security_quotactl(int cmds, int type, int id, const struct super_block *sb);
294 int security_quota_on(struct dentry *dentry);
295 int security_syslog(int type);
296 int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
297 int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
298 int security_bprm_creds_for_exec(struct linux_binprm *bprm);
299 int security_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file);
300 int security_bprm_check(struct linux_binprm *bprm);
301 void security_bprm_committing_creds(const struct linux_binprm *bprm);
302 void security_bprm_committed_creds(const struct linux_binprm *bprm);
303 int security_fs_context_submount(struct fs_context *fc, struct super_block *reference);
304 int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc);
305 int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
306 int security_sb_alloc(struct super_block *sb);
307 void security_sb_delete(struct super_block *sb);
308 void security_sb_free(struct super_block *sb);
309 void security_free_mnt_opts(void **mnt_opts);
310 int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
311 int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
312 int security_sb_remount(struct super_block *sb, void *mnt_opts);
313 int security_sb_kern_mount(const struct super_block *sb);
314 int security_sb_show_options(struct seq_file *m, struct super_block *sb);
315 int security_sb_statfs(struct dentry *dentry);
316 int security_sb_mount(const char *dev_name, const struct path *path,
317 const char *type, unsigned long flags, void *data);
318 int security_sb_umount(struct vfsmount *mnt, int flags);
319 int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
320 int security_sb_set_mnt_opts(struct super_block *sb,
322 unsigned long kern_flags,
323 unsigned long *set_kern_flags);
324 int security_sb_clone_mnt_opts(const struct super_block *oldsb,
325 struct super_block *newsb,
326 unsigned long kern_flags,
327 unsigned long *set_kern_flags);
328 int security_move_mount(const struct path *from_path, const struct path *to_path);
329 int security_dentry_init_security(struct dentry *dentry, int mode,
330 const struct qstr *name,
331 const char **xattr_name, void **ctx,
333 int security_dentry_create_files_as(struct dentry *dentry, int mode,
335 const struct cred *old,
337 int security_path_notify(const struct path *path, u64 mask,
338 unsigned int obj_type);
339 int security_inode_alloc(struct inode *inode);
340 void security_inode_free(struct inode *inode);
341 int security_inode_init_security(struct inode *inode, struct inode *dir,
342 const struct qstr *qstr,
343 initxattrs initxattrs, void *fs_data);
344 int security_inode_init_security_anon(struct inode *inode,
345 const struct qstr *name,
346 const struct inode *context_inode);
347 int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
348 void security_inode_post_create_tmpfile(struct mnt_idmap *idmap,
349 struct inode *inode);
350 int security_inode_link(struct dentry *old_dentry, struct inode *dir,
351 struct dentry *new_dentry);
352 int security_inode_unlink(struct inode *dir, struct dentry *dentry);
353 int security_inode_symlink(struct inode *dir, struct dentry *dentry,
354 const char *old_name);
355 int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
356 int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
357 int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
358 int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
359 struct inode *new_dir, struct dentry *new_dentry,
361 int security_inode_readlink(struct dentry *dentry);
362 int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
364 int security_inode_permission(struct inode *inode, int mask);
365 int security_inode_setattr(struct mnt_idmap *idmap,
366 struct dentry *dentry, struct iattr *attr);
367 void security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
369 int security_inode_getattr(const struct path *path);
370 int security_inode_setxattr(struct mnt_idmap *idmap,
371 struct dentry *dentry, const char *name,
372 const void *value, size_t size, int flags);
373 int security_inode_set_acl(struct mnt_idmap *idmap,
374 struct dentry *dentry, const char *acl_name,
375 struct posix_acl *kacl);
376 void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,
377 struct posix_acl *kacl);
378 int security_inode_get_acl(struct mnt_idmap *idmap,
379 struct dentry *dentry, const char *acl_name);
380 int security_inode_remove_acl(struct mnt_idmap *idmap,
381 struct dentry *dentry, const char *acl_name);
382 void security_inode_post_remove_acl(struct mnt_idmap *idmap,
383 struct dentry *dentry,
384 const char *acl_name);
385 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
386 const void *value, size_t size, int flags);
387 int security_inode_getxattr(struct dentry *dentry, const char *name);
388 int security_inode_listxattr(struct dentry *dentry);
389 int security_inode_removexattr(struct mnt_idmap *idmap,
390 struct dentry *dentry, const char *name);
391 void security_inode_post_removexattr(struct dentry *dentry, const char *name);
392 int security_inode_need_killpriv(struct dentry *dentry);
393 int security_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
394 int security_inode_getsecurity(struct mnt_idmap *idmap,
395 struct inode *inode, const char *name,
396 void **buffer, bool alloc);
397 int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
398 int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
399 void security_inode_getsecid(struct inode *inode, u32 *secid);
400 int security_inode_copy_up(struct dentry *src, struct cred **new);
401 int security_inode_copy_up_xattr(struct dentry *src, const char *name);
402 int security_kernfs_init_security(struct kernfs_node *kn_dir,
403 struct kernfs_node *kn);
404 int security_file_permission(struct file *file, int mask);
405 int security_file_alloc(struct file *file);
406 void security_file_release(struct file *file);
407 void security_file_free(struct file *file);
408 int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
409 int security_file_ioctl_compat(struct file *file, unsigned int cmd,
411 int security_mmap_file(struct file *file, unsigned long prot,
412 unsigned long flags);
413 int security_mmap_addr(unsigned long addr);
414 int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
416 int security_file_lock(struct file *file, unsigned int cmd);
417 int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
418 void security_file_set_fowner(struct file *file);
419 int security_file_send_sigiotask(struct task_struct *tsk,
420 struct fown_struct *fown, int sig);
421 int security_file_receive(struct file *file);
422 int security_file_open(struct file *file);
423 int security_file_post_open(struct file *file, int mask);
424 int security_file_truncate(struct file *file);
425 int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
426 void security_task_free(struct task_struct *task);
427 int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
428 void security_cred_free(struct cred *cred);
429 int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
430 void security_transfer_creds(struct cred *new, const struct cred *old);
431 void security_cred_getsecid(const struct cred *c, u32 *secid);
432 int security_kernel_act_as(struct cred *new, u32 secid);
433 int security_kernel_create_files_as(struct cred *new, struct inode *inode);
434 int security_kernel_module_request(char *kmod_name);
435 int security_kernel_load_data(enum kernel_load_data_id id, bool contents);
436 int security_kernel_post_load_data(char *buf, loff_t size,
437 enum kernel_load_data_id id,
439 int security_kernel_read_file(struct file *file, enum kernel_read_file_id id,
441 int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
442 enum kernel_read_file_id id);
443 int security_task_fix_setuid(struct cred *new, const struct cred *old,
445 int security_task_fix_setgid(struct cred *new, const struct cred *old,
447 int security_task_fix_setgroups(struct cred *new, const struct cred *old);
448 int security_task_setpgid(struct task_struct *p, pid_t pgid);
449 int security_task_getpgid(struct task_struct *p);
450 int security_task_getsid(struct task_struct *p);
451 void security_current_getsecid_subj(u32 *secid);
452 void security_task_getsecid_obj(struct task_struct *p, u32 *secid);
453 int security_task_setnice(struct task_struct *p, int nice);
454 int security_task_setioprio(struct task_struct *p, int ioprio);
455 int security_task_getioprio(struct task_struct *p);
456 int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
458 int security_task_setrlimit(struct task_struct *p, unsigned int resource,
459 struct rlimit *new_rlim);
460 int security_task_setscheduler(struct task_struct *p);
461 int security_task_getscheduler(struct task_struct *p);
462 int security_task_movememory(struct task_struct *p);
463 int security_task_kill(struct task_struct *p, struct kernel_siginfo *info,
464 int sig, const struct cred *cred);
465 int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
466 unsigned long arg4, unsigned long arg5);
467 void security_task_to_inode(struct task_struct *p, struct inode *inode);
468 int security_create_user_ns(const struct cred *cred);
469 int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
470 void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
471 int security_msg_msg_alloc(struct msg_msg *msg);
472 void security_msg_msg_free(struct msg_msg *msg);
473 int security_msg_queue_alloc(struct kern_ipc_perm *msq);
474 void security_msg_queue_free(struct kern_ipc_perm *msq);
475 int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg);
476 int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd);
477 int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
478 struct msg_msg *msg, int msqflg);
479 int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg,
480 struct task_struct *target, long type, int mode);
481 int security_shm_alloc(struct kern_ipc_perm *shp);
482 void security_shm_free(struct kern_ipc_perm *shp);
483 int security_shm_associate(struct kern_ipc_perm *shp, int shmflg);
484 int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd);
485 int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg);
486 int security_sem_alloc(struct kern_ipc_perm *sma);
487 void security_sem_free(struct kern_ipc_perm *sma);
488 int security_sem_associate(struct kern_ipc_perm *sma, int semflg);
489 int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
490 int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
491 unsigned nsops, int alter);
492 void security_d_instantiate(struct dentry *dentry, struct inode *inode);
493 int security_getselfattr(unsigned int attr, struct lsm_ctx __user *ctx,
494 u32 __user *size, u32 flags);
495 int security_setselfattr(unsigned int attr, struct lsm_ctx __user *ctx,
496 u32 size, u32 flags);
497 int security_getprocattr(struct task_struct *p, int lsmid, const char *name,
499 int security_setprocattr(int lsmid, const char *name, void *value, size_t size);
500 int security_netlink_send(struct sock *sk, struct sk_buff *skb);
501 int security_ismaclabel(const char *name);
502 int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
503 int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
504 void security_release_secctx(char *secdata, u32 seclen);
505 void security_inode_invalidate_secctx(struct inode *inode);
506 int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
507 int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
508 int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
509 int security_locked_down(enum lockdown_reason what);
510 int lsm_fill_user_ctx(struct lsm_ctx __user *uctx, u32 *uctx_len,
511 void *val, size_t val_len, u64 id, u64 flags);
512 #else /* CONFIG_SECURITY */
514 static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data)
519 static inline int register_blocking_lsm_notifier(struct notifier_block *nb)
524 static inline int unregister_blocking_lsm_notifier(struct notifier_block *nb)
529 static inline u64 lsm_name_to_attr(const char *name)
531 return LSM_ATTR_UNDEF;
534 static inline void security_free_mnt_opts(void **mnt_opts)
539 * This is the default capabilities functionality. Most of these functions
540 * are just stubbed out, but a few must call the proper capable code.
543 static inline int security_init(void)
548 static inline int early_security_init(void)
553 static inline int security_binder_set_context_mgr(const struct cred *mgr)
558 static inline int security_binder_transaction(const struct cred *from,
559 const struct cred *to)
564 static inline int security_binder_transfer_binder(const struct cred *from,
565 const struct cred *to)
570 static inline int security_binder_transfer_file(const struct cred *from,
571 const struct cred *to,
572 const struct file *file)
577 static inline int security_ptrace_access_check(struct task_struct *child,
580 return cap_ptrace_access_check(child, mode);
583 static inline int security_ptrace_traceme(struct task_struct *parent)
585 return cap_ptrace_traceme(parent);
588 static inline int security_capget(const struct task_struct *target,
589 kernel_cap_t *effective,
590 kernel_cap_t *inheritable,
591 kernel_cap_t *permitted)
593 return cap_capget(target, effective, inheritable, permitted);
596 static inline int security_capset(struct cred *new,
597 const struct cred *old,
598 const kernel_cap_t *effective,
599 const kernel_cap_t *inheritable,
600 const kernel_cap_t *permitted)
602 return cap_capset(new, old, effective, inheritable, permitted);
605 static inline int security_capable(const struct cred *cred,
606 struct user_namespace *ns,
610 return cap_capable(cred, ns, cap, opts);
613 static inline int security_quotactl(int cmds, int type, int id,
614 const struct super_block *sb)
619 static inline int security_quota_on(struct dentry *dentry)
624 static inline int security_syslog(int type)
629 static inline int security_settime64(const struct timespec64 *ts,
630 const struct timezone *tz)
632 return cap_settime(ts, tz);
635 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
637 return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages));
640 static inline int security_bprm_creds_for_exec(struct linux_binprm *bprm)
645 static inline int security_bprm_creds_from_file(struct linux_binprm *bprm,
646 const struct file *file)
648 return cap_bprm_creds_from_file(bprm, file);
651 static inline int security_bprm_check(struct linux_binprm *bprm)
656 static inline void security_bprm_committing_creds(const struct linux_binprm *bprm)
660 static inline void security_bprm_committed_creds(const struct linux_binprm *bprm)
664 static inline int security_fs_context_submount(struct fs_context *fc,
665 struct super_block *reference)
669 static inline int security_fs_context_dup(struct fs_context *fc,
670 struct fs_context *src_fc)
674 static inline int security_fs_context_parse_param(struct fs_context *fc,
675 struct fs_parameter *param)
680 static inline int security_sb_alloc(struct super_block *sb)
685 static inline void security_sb_delete(struct super_block *sb)
688 static inline void security_sb_free(struct super_block *sb)
691 static inline int security_sb_eat_lsm_opts(char *options,
697 static inline int security_sb_remount(struct super_block *sb,
703 static inline int security_sb_mnt_opts_compat(struct super_block *sb,
710 static inline int security_sb_kern_mount(struct super_block *sb)
715 static inline int security_sb_show_options(struct seq_file *m,
716 struct super_block *sb)
721 static inline int security_sb_statfs(struct dentry *dentry)
726 static inline int security_sb_mount(const char *dev_name, const struct path *path,
727 const char *type, unsigned long flags,
733 static inline int security_sb_umount(struct vfsmount *mnt, int flags)
738 static inline int security_sb_pivotroot(const struct path *old_path,
739 const struct path *new_path)
744 static inline int security_sb_set_mnt_opts(struct super_block *sb,
746 unsigned long kern_flags,
747 unsigned long *set_kern_flags)
752 static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
753 struct super_block *newsb,
754 unsigned long kern_flags,
755 unsigned long *set_kern_flags)
760 static inline int security_move_mount(const struct path *from_path,
761 const struct path *to_path)
766 static inline int security_path_notify(const struct path *path, u64 mask,
767 unsigned int obj_type)
772 static inline int security_inode_alloc(struct inode *inode)
777 static inline void security_inode_free(struct inode *inode)
780 static inline int security_dentry_init_security(struct dentry *dentry,
782 const struct qstr *name,
783 const char **xattr_name,
790 static inline int security_dentry_create_files_as(struct dentry *dentry,
791 int mode, struct qstr *name,
792 const struct cred *old,
799 static inline int security_inode_init_security(struct inode *inode,
801 const struct qstr *qstr,
802 const initxattrs xattrs,
808 static inline int security_inode_init_security_anon(struct inode *inode,
809 const struct qstr *name,
810 const struct inode *context_inode)
815 static inline int security_inode_create(struct inode *dir,
816 struct dentry *dentry,
823 security_inode_post_create_tmpfile(struct mnt_idmap *idmap, struct inode *inode)
826 static inline int security_inode_link(struct dentry *old_dentry,
828 struct dentry *new_dentry)
833 static inline int security_inode_unlink(struct inode *dir,
834 struct dentry *dentry)
839 static inline int security_inode_symlink(struct inode *dir,
840 struct dentry *dentry,
841 const char *old_name)
846 static inline int security_inode_mkdir(struct inode *dir,
847 struct dentry *dentry,
853 static inline int security_inode_rmdir(struct inode *dir,
854 struct dentry *dentry)
859 static inline int security_inode_mknod(struct inode *dir,
860 struct dentry *dentry,
866 static inline int security_inode_rename(struct inode *old_dir,
867 struct dentry *old_dentry,
868 struct inode *new_dir,
869 struct dentry *new_dentry,
875 static inline int security_inode_readlink(struct dentry *dentry)
880 static inline int security_inode_follow_link(struct dentry *dentry,
887 static inline int security_inode_permission(struct inode *inode, int mask)
892 static inline int security_inode_setattr(struct mnt_idmap *idmap,
893 struct dentry *dentry,
900 security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
904 static inline int security_inode_getattr(const struct path *path)
909 static inline int security_inode_setxattr(struct mnt_idmap *idmap,
910 struct dentry *dentry, const char *name, const void *value,
911 size_t size, int flags)
913 return cap_inode_setxattr(dentry, name, value, size, flags);
916 static inline int security_inode_set_acl(struct mnt_idmap *idmap,
917 struct dentry *dentry,
918 const char *acl_name,
919 struct posix_acl *kacl)
924 static inline void security_inode_post_set_acl(struct dentry *dentry,
925 const char *acl_name,
926 struct posix_acl *kacl)
929 static inline int security_inode_get_acl(struct mnt_idmap *idmap,
930 struct dentry *dentry,
931 const char *acl_name)
936 static inline int security_inode_remove_acl(struct mnt_idmap *idmap,
937 struct dentry *dentry,
938 const char *acl_name)
943 static inline void security_inode_post_remove_acl(struct mnt_idmap *idmap,
944 struct dentry *dentry,
945 const char *acl_name)
948 static inline void security_inode_post_setxattr(struct dentry *dentry,
949 const char *name, const void *value, size_t size, int flags)
952 static inline int security_inode_getxattr(struct dentry *dentry,
958 static inline int security_inode_listxattr(struct dentry *dentry)
963 static inline int security_inode_removexattr(struct mnt_idmap *idmap,
964 struct dentry *dentry,
967 return cap_inode_removexattr(idmap, dentry, name);
970 static inline void security_inode_post_removexattr(struct dentry *dentry,
974 static inline int security_inode_need_killpriv(struct dentry *dentry)
976 return cap_inode_need_killpriv(dentry);
979 static inline int security_inode_killpriv(struct mnt_idmap *idmap,
980 struct dentry *dentry)
982 return cap_inode_killpriv(idmap, dentry);
985 static inline int security_inode_getsecurity(struct mnt_idmap *idmap,
987 const char *name, void **buffer,
990 return cap_inode_getsecurity(idmap, inode, name, buffer, alloc);
993 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
998 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1003 static inline void security_inode_getsecid(struct inode *inode, u32 *secid)
1008 static inline int security_inode_copy_up(struct dentry *src, struct cred **new)
1013 static inline int security_kernfs_init_security(struct kernfs_node *kn_dir,
1014 struct kernfs_node *kn)
1019 static inline int security_inode_copy_up_xattr(struct dentry *src, const char *name)
1024 static inline int security_file_permission(struct file *file, int mask)
1029 static inline int security_file_alloc(struct file *file)
1034 static inline void security_file_release(struct file *file)
1037 static inline void security_file_free(struct file *file)
1040 static inline int security_file_ioctl(struct file *file, unsigned int cmd,
1046 static inline int security_file_ioctl_compat(struct file *file,
1053 static inline int security_mmap_file(struct file *file, unsigned long prot,
1054 unsigned long flags)
1059 static inline int security_mmap_addr(unsigned long addr)
1061 return cap_mmap_addr(addr);
1064 static inline int security_file_mprotect(struct vm_area_struct *vma,
1065 unsigned long reqprot,
1071 static inline int security_file_lock(struct file *file, unsigned int cmd)
1076 static inline int security_file_fcntl(struct file *file, unsigned int cmd,
1082 static inline void security_file_set_fowner(struct file *file)
1087 static inline int security_file_send_sigiotask(struct task_struct *tsk,
1088 struct fown_struct *fown,
1094 static inline int security_file_receive(struct file *file)
1099 static inline int security_file_open(struct file *file)
1104 static inline int security_file_post_open(struct file *file, int mask)
1109 static inline int security_file_truncate(struct file *file)
1114 static inline int security_task_alloc(struct task_struct *task,
1115 unsigned long clone_flags)
1120 static inline void security_task_free(struct task_struct *task)
1123 static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
1128 static inline void security_cred_free(struct cred *cred)
1131 static inline int security_prepare_creds(struct cred *new,
1132 const struct cred *old,
1138 static inline void security_transfer_creds(struct cred *new,
1139 const struct cred *old)
1143 static inline void security_cred_getsecid(const struct cred *c, u32 *secid)
1148 static inline int security_kernel_act_as(struct cred *cred, u32 secid)
1153 static inline int security_kernel_create_files_as(struct cred *cred,
1154 struct inode *inode)
1159 static inline int security_kernel_module_request(char *kmod_name)
1164 static inline int security_kernel_load_data(enum kernel_load_data_id id, bool contents)
1169 static inline int security_kernel_post_load_data(char *buf, loff_t size,
1170 enum kernel_load_data_id id,
1176 static inline int security_kernel_read_file(struct file *file,
1177 enum kernel_read_file_id id,
1183 static inline int security_kernel_post_read_file(struct file *file,
1184 char *buf, loff_t size,
1185 enum kernel_read_file_id id)
1190 static inline int security_task_fix_setuid(struct cred *new,
1191 const struct cred *old,
1194 return cap_task_fix_setuid(new, old, flags);
1197 static inline int security_task_fix_setgid(struct cred *new,
1198 const struct cred *old,
1204 static inline int security_task_fix_setgroups(struct cred *new,
1205 const struct cred *old)
1210 static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
1215 static inline int security_task_getpgid(struct task_struct *p)
1220 static inline int security_task_getsid(struct task_struct *p)
1225 static inline void security_current_getsecid_subj(u32 *secid)
1230 static inline void security_task_getsecid_obj(struct task_struct *p, u32 *secid)
1235 static inline int security_task_setnice(struct task_struct *p, int nice)
1237 return cap_task_setnice(p, nice);
1240 static inline int security_task_setioprio(struct task_struct *p, int ioprio)
1242 return cap_task_setioprio(p, ioprio);
1245 static inline int security_task_getioprio(struct task_struct *p)
1250 static inline int security_task_prlimit(const struct cred *cred,
1251 const struct cred *tcred,
1257 static inline int security_task_setrlimit(struct task_struct *p,
1258 unsigned int resource,
1259 struct rlimit *new_rlim)
1264 static inline int security_task_setscheduler(struct task_struct *p)
1266 return cap_task_setscheduler(p);
1269 static inline int security_task_getscheduler(struct task_struct *p)
1274 static inline int security_task_movememory(struct task_struct *p)
1279 static inline int security_task_kill(struct task_struct *p,
1280 struct kernel_siginfo *info, int sig,
1281 const struct cred *cred)
1286 static inline int security_task_prctl(int option, unsigned long arg2,
1291 return cap_task_prctl(option, arg2, arg3, arg4, arg5);
1294 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1297 static inline int security_create_user_ns(const struct cred *cred)
1302 static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
1308 static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
1313 static inline int security_msg_msg_alloc(struct msg_msg *msg)
1318 static inline void security_msg_msg_free(struct msg_msg *msg)
1321 static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq)
1326 static inline void security_msg_queue_free(struct kern_ipc_perm *msq)
1329 static inline int security_msg_queue_associate(struct kern_ipc_perm *msq,
1335 static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd)
1340 static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
1341 struct msg_msg *msg, int msqflg)
1346 static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq,
1347 struct msg_msg *msg,
1348 struct task_struct *target,
1349 long type, int mode)
1354 static inline int security_shm_alloc(struct kern_ipc_perm *shp)
1359 static inline void security_shm_free(struct kern_ipc_perm *shp)
1362 static inline int security_shm_associate(struct kern_ipc_perm *shp,
1368 static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd)
1373 static inline int security_shm_shmat(struct kern_ipc_perm *shp,
1374 char __user *shmaddr, int shmflg)
1379 static inline int security_sem_alloc(struct kern_ipc_perm *sma)
1384 static inline void security_sem_free(struct kern_ipc_perm *sma)
1387 static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg)
1392 static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd)
1397 static inline int security_sem_semop(struct kern_ipc_perm *sma,
1398 struct sembuf *sops, unsigned nsops,
1404 static inline void security_d_instantiate(struct dentry *dentry,
1405 struct inode *inode)
1408 static inline int security_getselfattr(unsigned int attr,
1409 struct lsm_ctx __user *ctx,
1410 size_t __user *size, u32 flags)
1415 static inline int security_setselfattr(unsigned int attr,
1416 struct lsm_ctx __user *ctx,
1417 size_t size, u32 flags)
1422 static inline int security_getprocattr(struct task_struct *p, int lsmid,
1423 const char *name, char **value)
1428 static inline int security_setprocattr(int lsmid, char *name, void *value,
1434 static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
1439 static inline int security_ismaclabel(const char *name)
1444 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
1449 static inline int security_secctx_to_secid(const char *secdata,
1456 static inline void security_release_secctx(char *secdata, u32 seclen)
1460 static inline void security_inode_invalidate_secctx(struct inode *inode)
1464 static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
1468 static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
1472 static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
1476 static inline int security_locked_down(enum lockdown_reason what)
1480 static inline int lsm_fill_user_ctx(struct lsm_ctx __user *uctx,
1481 u32 *uctx_len, void *val, size_t val_len,
1486 #endif /* CONFIG_SECURITY */
1488 #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
1489 int security_post_notification(const struct cred *w_cred,
1490 const struct cred *cred,
1491 struct watch_notification *n);
1493 static inline int security_post_notification(const struct cred *w_cred,
1494 const struct cred *cred,
1495 struct watch_notification *n)
1501 #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
1502 int security_watch_key(struct key *key);
1504 static inline int security_watch_key(struct key *key)
1510 #ifdef CONFIG_SECURITY_NETWORK
1512 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
1513 int security_unix_may_send(struct socket *sock, struct socket *other);
1514 int security_socket_create(int family, int type, int protocol, int kern);
1515 int security_socket_post_create(struct socket *sock, int family,
1516 int type, int protocol, int kern);
1517 int security_socket_socketpair(struct socket *socka, struct socket *sockb);
1518 int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
1519 int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
1520 int security_socket_listen(struct socket *sock, int backlog);
1521 int security_socket_accept(struct socket *sock, struct socket *newsock);
1522 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
1523 int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
1524 int size, int flags);
1525 int security_socket_getsockname(struct socket *sock);
1526 int security_socket_getpeername(struct socket *sock);
1527 int security_socket_getsockopt(struct socket *sock, int level, int optname);
1528 int security_socket_setsockopt(struct socket *sock, int level, int optname);
1529 int security_socket_shutdown(struct socket *sock, int how);
1530 int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
1531 int security_socket_getpeersec_stream(struct socket *sock, sockptr_t optval,
1532 sockptr_t optlen, unsigned int len);
1533 int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
1534 int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
1535 void security_sk_free(struct sock *sk);
1536 void security_sk_clone(const struct sock *sk, struct sock *newsk);
1537 void security_sk_classify_flow(const struct sock *sk,
1538 struct flowi_common *flic);
1539 void security_req_classify_flow(const struct request_sock *req,
1540 struct flowi_common *flic);
1541 void security_sock_graft(struct sock*sk, struct socket *parent);
1542 int security_inet_conn_request(const struct sock *sk,
1543 struct sk_buff *skb, struct request_sock *req);
1544 void security_inet_csk_clone(struct sock *newsk,
1545 const struct request_sock *req);
1546 void security_inet_conn_established(struct sock *sk,
1547 struct sk_buff *skb);
1548 int security_secmark_relabel_packet(u32 secid);
1549 void security_secmark_refcount_inc(void);
1550 void security_secmark_refcount_dec(void);
1551 int security_tun_dev_alloc_security(void **security);
1552 void security_tun_dev_free_security(void *security);
1553 int security_tun_dev_create(void);
1554 int security_tun_dev_attach_queue(void *security);
1555 int security_tun_dev_attach(struct sock *sk, void *security);
1556 int security_tun_dev_open(void *security);
1557 int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb);
1558 int security_sctp_bind_connect(struct sock *sk, int optname,
1559 struct sockaddr *address, int addrlen);
1560 void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk,
1561 struct sock *newsk);
1562 int security_sctp_assoc_established(struct sctp_association *asoc,
1563 struct sk_buff *skb);
1564 int security_mptcp_add_subflow(struct sock *sk, struct sock *ssk);
1566 #else /* CONFIG_SECURITY_NETWORK */
1567 static inline int security_unix_stream_connect(struct sock *sock,
1574 static inline int security_unix_may_send(struct socket *sock,
1575 struct socket *other)
1580 static inline int security_socket_create(int family, int type,
1581 int protocol, int kern)
1586 static inline int security_socket_post_create(struct socket *sock,
1589 int protocol, int kern)
1594 static inline int security_socket_socketpair(struct socket *socka,
1595 struct socket *sockb)
1600 static inline int security_socket_bind(struct socket *sock,
1601 struct sockaddr *address,
1607 static inline int security_socket_connect(struct socket *sock,
1608 struct sockaddr *address,
1614 static inline int security_socket_listen(struct socket *sock, int backlog)
1619 static inline int security_socket_accept(struct socket *sock,
1620 struct socket *newsock)
1625 static inline int security_socket_sendmsg(struct socket *sock,
1626 struct msghdr *msg, int size)
1631 static inline int security_socket_recvmsg(struct socket *sock,
1632 struct msghdr *msg, int size,
1638 static inline int security_socket_getsockname(struct socket *sock)
1643 static inline int security_socket_getpeername(struct socket *sock)
1648 static inline int security_socket_getsockopt(struct socket *sock,
1649 int level, int optname)
1654 static inline int security_socket_setsockopt(struct socket *sock,
1655 int level, int optname)
1660 static inline int security_socket_shutdown(struct socket *sock, int how)
1664 static inline int security_sock_rcv_skb(struct sock *sk,
1665 struct sk_buff *skb)
1670 static inline int security_socket_getpeersec_stream(struct socket *sock,
1675 return -ENOPROTOOPT;
1678 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
1680 return -ENOPROTOOPT;
1683 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
1688 static inline void security_sk_free(struct sock *sk)
1692 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
1696 static inline void security_sk_classify_flow(const struct sock *sk,
1697 struct flowi_common *flic)
1701 static inline void security_req_classify_flow(const struct request_sock *req,
1702 struct flowi_common *flic)
1706 static inline void security_sock_graft(struct sock *sk, struct socket *parent)
1710 static inline int security_inet_conn_request(const struct sock *sk,
1711 struct sk_buff *skb, struct request_sock *req)
1716 static inline void security_inet_csk_clone(struct sock *newsk,
1717 const struct request_sock *req)
1721 static inline void security_inet_conn_established(struct sock *sk,
1722 struct sk_buff *skb)
1726 static inline int security_secmark_relabel_packet(u32 secid)
1731 static inline void security_secmark_refcount_inc(void)
1735 static inline void security_secmark_refcount_dec(void)
1739 static inline int security_tun_dev_alloc_security(void **security)
1744 static inline void security_tun_dev_free_security(void *security)
1748 static inline int security_tun_dev_create(void)
1753 static inline int security_tun_dev_attach_queue(void *security)
1758 static inline int security_tun_dev_attach(struct sock *sk, void *security)
1763 static inline int security_tun_dev_open(void *security)
1768 static inline int security_sctp_assoc_request(struct sctp_association *asoc,
1769 struct sk_buff *skb)
1774 static inline int security_sctp_bind_connect(struct sock *sk, int optname,
1775 struct sockaddr *address,
1781 static inline void security_sctp_sk_clone(struct sctp_association *asoc,
1787 static inline int security_sctp_assoc_established(struct sctp_association *asoc,
1788 struct sk_buff *skb)
1793 static inline int security_mptcp_add_subflow(struct sock *sk, struct sock *ssk)
1797 #endif /* CONFIG_SECURITY_NETWORK */
1799 #ifdef CONFIG_SECURITY_INFINIBAND
1800 int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey);
1801 int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num);
1802 int security_ib_alloc_security(void **sec);
1803 void security_ib_free_security(void *sec);
1804 #else /* CONFIG_SECURITY_INFINIBAND */
1805 static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey)
1810 static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num)
1815 static inline int security_ib_alloc_security(void **sec)
1820 static inline void security_ib_free_security(void *sec)
1823 #endif /* CONFIG_SECURITY_INFINIBAND */
1825 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1827 int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1828 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
1829 int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
1830 void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
1831 int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
1832 int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1833 int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1834 struct xfrm_sec_ctx *polsec, u32 secid);
1835 int security_xfrm_state_delete(struct xfrm_state *x);
1836 void security_xfrm_state_free(struct xfrm_state *x);
1837 int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid);
1838 int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1839 struct xfrm_policy *xp,
1840 const struct flowi_common *flic);
1841 int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
1842 void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic);
1844 #else /* CONFIG_SECURITY_NETWORK_XFRM */
1846 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1847 struct xfrm_user_sec_ctx *sec_ctx,
1853 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
1858 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
1862 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
1867 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
1868 struct xfrm_user_sec_ctx *sec_ctx)
1873 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1874 struct xfrm_sec_ctx *polsec, u32 secid)
1879 static inline void security_xfrm_state_free(struct xfrm_state *x)
1883 static inline int security_xfrm_state_delete(struct xfrm_state *x)
1888 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
1893 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1894 struct xfrm_policy *xp,
1895 const struct flowi_common *flic)
1900 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
1905 static inline void security_skb_classify_flow(struct sk_buff *skb,
1906 struct flowi_common *flic)
1910 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1912 #ifdef CONFIG_SECURITY_PATH
1913 int security_path_unlink(const struct path *dir, struct dentry *dentry);
1914 int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
1915 int security_path_rmdir(const struct path *dir, struct dentry *dentry);
1916 int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
1918 void security_path_post_mknod(struct mnt_idmap *idmap, struct dentry *dentry);
1919 int security_path_truncate(const struct path *path);
1920 int security_path_symlink(const struct path *dir, struct dentry *dentry,
1921 const char *old_name);
1922 int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
1923 struct dentry *new_dentry);
1924 int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
1925 const struct path *new_dir, struct dentry *new_dentry,
1926 unsigned int flags);
1927 int security_path_chmod(const struct path *path, umode_t mode);
1928 int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
1929 int security_path_chroot(const struct path *path);
1930 #else /* CONFIG_SECURITY_PATH */
1931 static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
1936 static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
1942 static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
1947 static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
1948 umode_t mode, unsigned int dev)
1953 static inline void security_path_post_mknod(struct mnt_idmap *idmap,
1954 struct dentry *dentry)
1957 static inline int security_path_truncate(const struct path *path)
1962 static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
1963 const char *old_name)
1968 static inline int security_path_link(struct dentry *old_dentry,
1969 const struct path *new_dir,
1970 struct dentry *new_dentry)
1975 static inline int security_path_rename(const struct path *old_dir,
1976 struct dentry *old_dentry,
1977 const struct path *new_dir,
1978 struct dentry *new_dentry,
1984 static inline int security_path_chmod(const struct path *path, umode_t mode)
1989 static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
1994 static inline int security_path_chroot(const struct path *path)
1998 #endif /* CONFIG_SECURITY_PATH */
2001 #ifdef CONFIG_SECURITY
2003 int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
2004 void security_key_free(struct key *key);
2005 int security_key_permission(key_ref_t key_ref, const struct cred *cred,
2006 enum key_need_perm need_perm);
2007 int security_key_getsecurity(struct key *key, char **_buffer);
2008 void security_key_post_create_or_update(struct key *keyring, struct key *key,
2009 const void *payload, size_t payload_len,
2010 unsigned long flags, bool create);
2014 static inline int security_key_alloc(struct key *key,
2015 const struct cred *cred,
2016 unsigned long flags)
2021 static inline void security_key_free(struct key *key)
2025 static inline int security_key_permission(key_ref_t key_ref,
2026 const struct cred *cred,
2027 enum key_need_perm need_perm)
2032 static inline int security_key_getsecurity(struct key *key, char **_buffer)
2038 static inline void security_key_post_create_or_update(struct key *keyring,
2040 const void *payload,
2042 unsigned long flags,
2047 #endif /* CONFIG_KEYS */
2050 #ifdef CONFIG_SECURITY
2051 int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule,
2053 int security_audit_rule_known(struct audit_krule *krule);
2054 int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule);
2055 void security_audit_rule_free(void *lsmrule);
2059 static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
2060 void **lsmrule, gfp_t gfp)
2065 static inline int security_audit_rule_known(struct audit_krule *krule)
2070 static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
2076 static inline void security_audit_rule_free(void *lsmrule)
2079 #endif /* CONFIG_SECURITY */
2080 #endif /* CONFIG_AUDIT */
2082 #ifdef CONFIG_SECURITYFS
2084 extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
2085 struct dentry *parent, void *data,
2086 const struct file_operations *fops);
2087 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2088 struct dentry *securityfs_create_symlink(const char *name,
2089 struct dentry *parent,
2091 const struct inode_operations *iops);
2092 extern void securityfs_remove(struct dentry *dentry);
2094 #else /* CONFIG_SECURITYFS */
2096 static inline struct dentry *securityfs_create_dir(const char *name,
2097 struct dentry *parent)
2099 return ERR_PTR(-ENODEV);
2102 static inline struct dentry *securityfs_create_file(const char *name,
2104 struct dentry *parent,
2106 const struct file_operations *fops)
2108 return ERR_PTR(-ENODEV);
2111 static inline struct dentry *securityfs_create_symlink(const char *name,
2112 struct dentry *parent,
2114 const struct inode_operations *iops)
2116 return ERR_PTR(-ENODEV);
2119 static inline void securityfs_remove(struct dentry *dentry)
2124 #ifdef CONFIG_BPF_SYSCALL
2129 #ifdef CONFIG_SECURITY
2130 extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size);
2131 extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
2132 extern int security_bpf_prog(struct bpf_prog *prog);
2133 extern int security_bpf_map_create(struct bpf_map *map, union bpf_attr *attr,
2134 struct bpf_token *token);
2135 extern void security_bpf_map_free(struct bpf_map *map);
2136 extern int security_bpf_prog_load(struct bpf_prog *prog, union bpf_attr *attr,
2137 struct bpf_token *token);
2138 extern void security_bpf_prog_free(struct bpf_prog *prog);
2139 extern int security_bpf_token_create(struct bpf_token *token, union bpf_attr *attr,
2140 const struct path *path);
2141 extern void security_bpf_token_free(struct bpf_token *token);
2142 extern int security_bpf_token_cmd(const struct bpf_token *token, enum bpf_cmd cmd);
2143 extern int security_bpf_token_capable(const struct bpf_token *token, int cap);
2145 static inline int security_bpf(int cmd, union bpf_attr *attr,
2151 static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode)
2156 static inline int security_bpf_prog(struct bpf_prog *prog)
2161 static inline int security_bpf_map_create(struct bpf_map *map, union bpf_attr *attr,
2162 struct bpf_token *token)
2167 static inline void security_bpf_map_free(struct bpf_map *map)
2170 static inline int security_bpf_prog_load(struct bpf_prog *prog, union bpf_attr *attr,
2171 struct bpf_token *token)
2176 static inline void security_bpf_prog_free(struct bpf_prog *prog)
2179 static inline int security_bpf_token_create(struct bpf_token *token, union bpf_attr *attr,
2180 const struct path *path)
2185 static inline void security_bpf_token_free(struct bpf_token *token)
2188 static inline int security_bpf_token_cmd(const struct bpf_token *token, enum bpf_cmd cmd)
2193 static inline int security_bpf_token_capable(const struct bpf_token *token, int cap)
2197 #endif /* CONFIG_SECURITY */
2198 #endif /* CONFIG_BPF_SYSCALL */
2200 #ifdef CONFIG_PERF_EVENTS
2201 struct perf_event_attr;
2204 #ifdef CONFIG_SECURITY
2205 extern int security_perf_event_open(struct perf_event_attr *attr, int type);
2206 extern int security_perf_event_alloc(struct perf_event *event);
2207 extern void security_perf_event_free(struct perf_event *event);
2208 extern int security_perf_event_read(struct perf_event *event);
2209 extern int security_perf_event_write(struct perf_event *event);
2211 static inline int security_perf_event_open(struct perf_event_attr *attr,
2217 static inline int security_perf_event_alloc(struct perf_event *event)
2222 static inline void security_perf_event_free(struct perf_event *event)
2226 static inline int security_perf_event_read(struct perf_event *event)
2231 static inline int security_perf_event_write(struct perf_event *event)
2235 #endif /* CONFIG_SECURITY */
2236 #endif /* CONFIG_PERF_EVENTS */
2238 #ifdef CONFIG_IO_URING
2239 #ifdef CONFIG_SECURITY
2240 extern int security_uring_override_creds(const struct cred *new);
2241 extern int security_uring_sqpoll(void);
2242 extern int security_uring_cmd(struct io_uring_cmd *ioucmd);
2244 static inline int security_uring_override_creds(const struct cred *new)
2248 static inline int security_uring_sqpoll(void)
2252 static inline int security_uring_cmd(struct io_uring_cmd *ioucmd)
2256 #endif /* CONFIG_SECURITY */
2257 #endif /* CONFIG_IO_URING */
2259 #endif /* ! __LINUX_SECURITY_H */