at v6.1-rc7 57 kB view raw
1/* 2 * Linux Security plug 3 * 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 10 * 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. 15 * 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. 20 * 21 */ 22 23#ifndef __LINUX_SECURITY_H 24#define __LINUX_SECURITY_H 25 26#include <linux/kernel_read_file.h> 27#include <linux/key.h> 28#include <linux/capability.h> 29#include <linux/fs.h> 30#include <linux/slab.h> 31#include <linux/err.h> 32#include <linux/string.h> 33#include <linux/mm.h> 34 35struct linux_binprm; 36struct cred; 37struct rlimit; 38struct kernel_siginfo; 39struct sembuf; 40struct kern_ipc_perm; 41struct audit_context; 42struct super_block; 43struct inode; 44struct dentry; 45struct file; 46struct vfsmount; 47struct path; 48struct qstr; 49struct iattr; 50struct fown_struct; 51struct file_operations; 52struct msg_msg; 53struct xattr; 54struct kernfs_node; 55struct xfrm_sec_ctx; 56struct mm_struct; 57struct fs_context; 58struct fs_parameter; 59enum fs_value_type; 60struct watch; 61struct watch_notification; 62 63/* Default (no) options for the capable function */ 64#define CAP_OPT_NONE 0x0 65/* If capable should audit the security request */ 66#define CAP_OPT_NOAUDIT BIT(1) 67/* If capable is being called by a setid function */ 68#define CAP_OPT_INSETID BIT(2) 69 70/* LSM Agnostic defines for fs_context::lsm_flags */ 71#define SECURITY_LSM_NATIVE_LABELS 1 72 73struct ctl_table; 74struct audit_krule; 75struct user_namespace; 76struct timezone; 77 78enum lsm_event { 79 LSM_POLICY_CHANGE, 80}; 81 82/* 83 * These are reasons that can be passed to the security_locked_down() 84 * LSM hook. Lockdown reasons that protect kernel integrity (ie, the 85 * ability for userland to modify kernel code) are placed before 86 * LOCKDOWN_INTEGRITY_MAX. Lockdown reasons that protect kernel 87 * confidentiality (ie, the ability for userland to extract 88 * information from the running kernel that would otherwise be 89 * restricted) are placed before LOCKDOWN_CONFIDENTIALITY_MAX. 90 * 91 * LSM authors should note that the semantics of any given lockdown 92 * reason are not guaranteed to be stable - the same reason may block 93 * one set of features in one kernel release, and a slightly different 94 * set of features in a later kernel release. LSMs that seek to expose 95 * lockdown policy at any level of granularity other than "none", 96 * "integrity" or "confidentiality" are responsible for either 97 * ensuring that they expose a consistent level of functionality to 98 * userland, or ensuring that userland is aware that this is 99 * potentially a moving target. It is easy to misuse this information 100 * in a way that could break userspace. Please be careful not to do 101 * so. 102 * 103 * If you add to this, remember to extend lockdown_reasons in 104 * security/lockdown/lockdown.c. 105 */ 106enum lockdown_reason { 107 LOCKDOWN_NONE, 108 LOCKDOWN_MODULE_SIGNATURE, 109 LOCKDOWN_DEV_MEM, 110 LOCKDOWN_EFI_TEST, 111 LOCKDOWN_KEXEC, 112 LOCKDOWN_HIBERNATION, 113 LOCKDOWN_PCI_ACCESS, 114 LOCKDOWN_IOPORT, 115 LOCKDOWN_MSR, 116 LOCKDOWN_ACPI_TABLES, 117 LOCKDOWN_DEVICE_TREE, 118 LOCKDOWN_PCMCIA_CIS, 119 LOCKDOWN_TIOCSSERIAL, 120 LOCKDOWN_MODULE_PARAMETERS, 121 LOCKDOWN_MMIOTRACE, 122 LOCKDOWN_DEBUGFS, 123 LOCKDOWN_XMON_WR, 124 LOCKDOWN_BPF_WRITE_USER, 125 LOCKDOWN_DBG_WRITE_KERNEL, 126 LOCKDOWN_RTAS_ERROR_INJECTION, 127 LOCKDOWN_INTEGRITY_MAX, 128 LOCKDOWN_KCORE, 129 LOCKDOWN_KPROBES, 130 LOCKDOWN_BPF_READ_KERNEL, 131 LOCKDOWN_DBG_READ_KERNEL, 132 LOCKDOWN_PERF, 133 LOCKDOWN_TRACEFS, 134 LOCKDOWN_XMON_RW, 135 LOCKDOWN_XFRM_SECRET, 136 LOCKDOWN_CONFIDENTIALITY_MAX, 137}; 138 139extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1]; 140 141/* These functions are in security/commoncap.c */ 142extern int cap_capable(const struct cred *cred, struct user_namespace *ns, 143 int cap, unsigned int opts); 144extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz); 145extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode); 146extern int cap_ptrace_traceme(struct task_struct *parent); 147extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); 148extern int cap_capset(struct cred *new, const struct cred *old, 149 const kernel_cap_t *effective, 150 const kernel_cap_t *inheritable, 151 const kernel_cap_t *permitted); 152extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file); 153int cap_inode_setxattr(struct dentry *dentry, const char *name, 154 const void *value, size_t size, int flags); 155int cap_inode_removexattr(struct user_namespace *mnt_userns, 156 struct dentry *dentry, const char *name); 157int cap_inode_need_killpriv(struct dentry *dentry); 158int cap_inode_killpriv(struct user_namespace *mnt_userns, 159 struct dentry *dentry); 160int cap_inode_getsecurity(struct user_namespace *mnt_userns, 161 struct inode *inode, const char *name, void **buffer, 162 bool alloc); 163extern int cap_mmap_addr(unsigned long addr); 164extern int cap_mmap_file(struct file *file, unsigned long reqprot, 165 unsigned long prot, unsigned long flags); 166extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags); 167extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, 168 unsigned long arg4, unsigned long arg5); 169extern int cap_task_setscheduler(struct task_struct *p); 170extern int cap_task_setioprio(struct task_struct *p, int ioprio); 171extern int cap_task_setnice(struct task_struct *p, int nice); 172extern int cap_vm_enough_memory(struct mm_struct *mm, long pages); 173 174struct msghdr; 175struct sk_buff; 176struct sock; 177struct sockaddr; 178struct socket; 179struct flowi_common; 180struct dst_entry; 181struct xfrm_selector; 182struct xfrm_policy; 183struct xfrm_state; 184struct xfrm_user_sec_ctx; 185struct seq_file; 186struct sctp_association; 187 188#ifdef CONFIG_MMU 189extern unsigned long mmap_min_addr; 190extern unsigned long dac_mmap_min_addr; 191#else 192#define mmap_min_addr 0UL 193#define dac_mmap_min_addr 0UL 194#endif 195 196/* 197 * Values used in the task_security_ops calls 198 */ 199/* setuid or setgid, id0 == uid or gid */ 200#define LSM_SETID_ID 1 201 202/* setreuid or setregid, id0 == real, id1 == eff */ 203#define LSM_SETID_RE 2 204 205/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */ 206#define LSM_SETID_RES 4 207 208/* setfsuid or setfsgid, id0 == fsuid or fsgid */ 209#define LSM_SETID_FS 8 210 211/* Flags for security_task_prlimit(). */ 212#define LSM_PRLIMIT_READ 1 213#define LSM_PRLIMIT_WRITE 2 214 215/* forward declares to avoid warnings */ 216struct sched_param; 217struct request_sock; 218 219/* bprm->unsafe reasons */ 220#define LSM_UNSAFE_SHARE 1 221#define LSM_UNSAFE_PTRACE 2 222#define LSM_UNSAFE_NO_NEW_PRIVS 4 223 224#ifdef CONFIG_MMU 225extern int mmap_min_addr_handler(struct ctl_table *table, int write, 226 void *buffer, size_t *lenp, loff_t *ppos); 227#endif 228 229/* security_inode_init_security callback function to write xattrs */ 230typedef int (*initxattrs) (struct inode *inode, 231 const struct xattr *xattr_array, void *fs_data); 232 233 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, 237 238enum kernel_load_data_id { 239 __kernel_read_file_id(__data_id_enumify) 240}; 241 242static const char * const kernel_load_data_str[] = { 243 __kernel_read_file_id(__data_id_stringify) 244}; 245 246static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id) 247{ 248 if ((unsigned)id >= LOADING_MAX_ID) 249 return kernel_load_data_str[LOADING_UNKNOWN]; 250 251 return kernel_load_data_str[id]; 252} 253 254#ifdef CONFIG_SECURITY 255 256int call_blocking_lsm_notifier(enum lsm_event event, void *data); 257int register_blocking_lsm_notifier(struct notifier_block *nb); 258int unregister_blocking_lsm_notifier(struct notifier_block *nb); 259 260/* prototypes */ 261extern int security_init(void); 262extern int early_security_init(void); 263 264/* Security operations */ 265int security_binder_set_context_mgr(const struct cred *mgr); 266int security_binder_transaction(const struct cred *from, 267 const struct cred *to); 268int security_binder_transfer_binder(const struct cred *from, 269 const struct cred *to); 270int security_binder_transfer_file(const struct cred *from, 271 const struct cred *to, struct file *file); 272int security_ptrace_access_check(struct task_struct *child, unsigned int mode); 273int security_ptrace_traceme(struct task_struct *parent); 274int security_capget(struct task_struct *target, 275 kernel_cap_t *effective, 276 kernel_cap_t *inheritable, 277 kernel_cap_t *permitted); 278int 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); 282int security_capable(const struct cred *cred, 283 struct user_namespace *ns, 284 int cap, 285 unsigned int opts); 286int security_quotactl(int cmds, int type, int id, struct super_block *sb); 287int security_quota_on(struct dentry *dentry); 288int security_syslog(int type); 289int security_settime64(const struct timespec64 *ts, const struct timezone *tz); 290int security_vm_enough_memory_mm(struct mm_struct *mm, long pages); 291int security_bprm_creds_for_exec(struct linux_binprm *bprm); 292int security_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file); 293int security_bprm_check(struct linux_binprm *bprm); 294void security_bprm_committing_creds(struct linux_binprm *bprm); 295void security_bprm_committed_creds(struct linux_binprm *bprm); 296int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc); 297int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param); 298int security_sb_alloc(struct super_block *sb); 299void security_sb_delete(struct super_block *sb); 300void security_sb_free(struct super_block *sb); 301void security_free_mnt_opts(void **mnt_opts); 302int security_sb_eat_lsm_opts(char *options, void **mnt_opts); 303int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts); 304int security_sb_remount(struct super_block *sb, void *mnt_opts); 305int security_sb_kern_mount(struct super_block *sb); 306int security_sb_show_options(struct seq_file *m, struct super_block *sb); 307int security_sb_statfs(struct dentry *dentry); 308int security_sb_mount(const char *dev_name, const struct path *path, 309 const char *type, unsigned long flags, void *data); 310int security_sb_umount(struct vfsmount *mnt, int flags); 311int security_sb_pivotroot(const struct path *old_path, const struct path *new_path); 312int security_sb_set_mnt_opts(struct super_block *sb, 313 void *mnt_opts, 314 unsigned long kern_flags, 315 unsigned long *set_kern_flags); 316int 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); 320int security_move_mount(const struct path *from_path, const struct path *to_path); 321int security_dentry_init_security(struct dentry *dentry, int mode, 322 const struct qstr *name, 323 const char **xattr_name, void **ctx, 324 u32 *ctxlen); 325int security_dentry_create_files_as(struct dentry *dentry, int mode, 326 struct qstr *name, 327 const struct cred *old, 328 struct cred *new); 329int security_path_notify(const struct path *path, u64 mask, 330 unsigned int obj_type); 331int security_inode_alloc(struct inode *inode); 332void security_inode_free(struct inode *inode); 333int security_inode_init_security(struct inode *inode, struct inode *dir, 334 const struct qstr *qstr, 335 initxattrs initxattrs, void *fs_data); 336int security_inode_init_security_anon(struct inode *inode, 337 const struct qstr *name, 338 const struct inode *context_inode); 339int security_old_inode_init_security(struct inode *inode, struct inode *dir, 340 const struct qstr *qstr, const char **name, 341 void **value, size_t *len); 342int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode); 343int security_inode_link(struct dentry *old_dentry, struct inode *dir, 344 struct dentry *new_dentry); 345int security_inode_unlink(struct inode *dir, struct dentry *dentry); 346int security_inode_symlink(struct inode *dir, struct dentry *dentry, 347 const char *old_name); 348int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); 349int security_inode_rmdir(struct inode *dir, struct dentry *dentry); 350int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev); 351int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry, 352 struct inode *new_dir, struct dentry *new_dentry, 353 unsigned int flags); 354int security_inode_readlink(struct dentry *dentry); 355int security_inode_follow_link(struct dentry *dentry, struct inode *inode, 356 bool rcu); 357int security_inode_permission(struct inode *inode, int mask); 358int security_inode_setattr(struct user_namespace *mnt_userns, 359 struct dentry *dentry, struct iattr *attr); 360int security_inode_getattr(const struct path *path); 361int security_inode_setxattr(struct user_namespace *mnt_userns, 362 struct dentry *dentry, const char *name, 363 const void *value, size_t size, int flags); 364void security_inode_post_setxattr(struct dentry *dentry, const char *name, 365 const void *value, size_t size, int flags); 366int security_inode_getxattr(struct dentry *dentry, const char *name); 367int security_inode_listxattr(struct dentry *dentry); 368int security_inode_removexattr(struct user_namespace *mnt_userns, 369 struct dentry *dentry, const char *name); 370int security_inode_need_killpriv(struct dentry *dentry); 371int security_inode_killpriv(struct user_namespace *mnt_userns, 372 struct dentry *dentry); 373int security_inode_getsecurity(struct user_namespace *mnt_userns, 374 struct inode *inode, const char *name, 375 void **buffer, bool alloc); 376int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags); 377int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size); 378void security_inode_getsecid(struct inode *inode, u32 *secid); 379int security_inode_copy_up(struct dentry *src, struct cred **new); 380int security_inode_copy_up_xattr(const char *name); 381int security_kernfs_init_security(struct kernfs_node *kn_dir, 382 struct kernfs_node *kn); 383int security_file_permission(struct file *file, int mask); 384int security_file_alloc(struct file *file); 385void security_file_free(struct file *file); 386int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 387int security_mmap_file(struct file *file, unsigned long prot, 388 unsigned long flags); 389int security_mmap_addr(unsigned long addr); 390int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, 391 unsigned long prot); 392int security_file_lock(struct file *file, unsigned int cmd); 393int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg); 394void security_file_set_fowner(struct file *file); 395int security_file_send_sigiotask(struct task_struct *tsk, 396 struct fown_struct *fown, int sig); 397int security_file_receive(struct file *file); 398int security_file_open(struct file *file); 399int security_task_alloc(struct task_struct *task, unsigned long clone_flags); 400void security_task_free(struct task_struct *task); 401int security_cred_alloc_blank(struct cred *cred, gfp_t gfp); 402void security_cred_free(struct cred *cred); 403int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp); 404void security_transfer_creds(struct cred *new, const struct cred *old); 405void security_cred_getsecid(const struct cred *c, u32 *secid); 406int security_kernel_act_as(struct cred *new, u32 secid); 407int security_kernel_create_files_as(struct cred *new, struct inode *inode); 408int security_kernel_module_request(char *kmod_name); 409int security_kernel_load_data(enum kernel_load_data_id id, bool contents); 410int security_kernel_post_load_data(char *buf, loff_t size, 411 enum kernel_load_data_id id, 412 char *description); 413int security_kernel_read_file(struct file *file, enum kernel_read_file_id id, 414 bool contents); 415int security_kernel_post_read_file(struct file *file, char *buf, loff_t size, 416 enum kernel_read_file_id id); 417int security_task_fix_setuid(struct cred *new, const struct cred *old, 418 int flags); 419int security_task_fix_setgid(struct cred *new, const struct cred *old, 420 int flags); 421int security_task_fix_setgroups(struct cred *new, const struct cred *old); 422int security_task_setpgid(struct task_struct *p, pid_t pgid); 423int security_task_getpgid(struct task_struct *p); 424int security_task_getsid(struct task_struct *p); 425void security_current_getsecid_subj(u32 *secid); 426void security_task_getsecid_obj(struct task_struct *p, u32 *secid); 427int security_task_setnice(struct task_struct *p, int nice); 428int security_task_setioprio(struct task_struct *p, int ioprio); 429int security_task_getioprio(struct task_struct *p); 430int security_task_prlimit(const struct cred *cred, const struct cred *tcred, 431 unsigned int flags); 432int security_task_setrlimit(struct task_struct *p, unsigned int resource, 433 struct rlimit *new_rlim); 434int security_task_setscheduler(struct task_struct *p); 435int security_task_getscheduler(struct task_struct *p); 436int security_task_movememory(struct task_struct *p); 437int security_task_kill(struct task_struct *p, struct kernel_siginfo *info, 438 int sig, const struct cred *cred); 439int security_task_prctl(int option, unsigned long arg2, unsigned long arg3, 440 unsigned long arg4, unsigned long arg5); 441void security_task_to_inode(struct task_struct *p, struct inode *inode); 442int security_create_user_ns(const struct cred *cred); 443int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag); 444void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid); 445int security_msg_msg_alloc(struct msg_msg *msg); 446void security_msg_msg_free(struct msg_msg *msg); 447int security_msg_queue_alloc(struct kern_ipc_perm *msq); 448void security_msg_queue_free(struct kern_ipc_perm *msq); 449int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg); 450int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd); 451int security_msg_queue_msgsnd(struct kern_ipc_perm *msq, 452 struct msg_msg *msg, int msqflg); 453int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg, 454 struct task_struct *target, long type, int mode); 455int security_shm_alloc(struct kern_ipc_perm *shp); 456void security_shm_free(struct kern_ipc_perm *shp); 457int security_shm_associate(struct kern_ipc_perm *shp, int shmflg); 458int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd); 459int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg); 460int security_sem_alloc(struct kern_ipc_perm *sma); 461void security_sem_free(struct kern_ipc_perm *sma); 462int security_sem_associate(struct kern_ipc_perm *sma, int semflg); 463int security_sem_semctl(struct kern_ipc_perm *sma, int cmd); 464int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops, 465 unsigned nsops, int alter); 466void security_d_instantiate(struct dentry *dentry, struct inode *inode); 467int security_getprocattr(struct task_struct *p, const char *lsm, const char *name, 468 char **value); 469int security_setprocattr(const char *lsm, const char *name, void *value, 470 size_t size); 471int security_netlink_send(struct sock *sk, struct sk_buff *skb); 472int security_ismaclabel(const char *name); 473int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen); 474int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid); 475void security_release_secctx(char *secdata, u32 seclen); 476void security_inode_invalidate_secctx(struct inode *inode); 477int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen); 478int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen); 479int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen); 480int security_locked_down(enum lockdown_reason what); 481#else /* CONFIG_SECURITY */ 482 483static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data) 484{ 485 return 0; 486} 487 488static inline int register_blocking_lsm_notifier(struct notifier_block *nb) 489{ 490 return 0; 491} 492 493static inline int unregister_blocking_lsm_notifier(struct notifier_block *nb) 494{ 495 return 0; 496} 497 498static inline void security_free_mnt_opts(void **mnt_opts) 499{ 500} 501 502/* 503 * This is the default capabilities functionality. Most of these functions 504 * are just stubbed out, but a few must call the proper capable code. 505 */ 506 507static inline int security_init(void) 508{ 509 return 0; 510} 511 512static inline int early_security_init(void) 513{ 514 return 0; 515} 516 517static inline int security_binder_set_context_mgr(const struct cred *mgr) 518{ 519 return 0; 520} 521 522static inline int security_binder_transaction(const struct cred *from, 523 const struct cred *to) 524{ 525 return 0; 526} 527 528static inline int security_binder_transfer_binder(const struct cred *from, 529 const struct cred *to) 530{ 531 return 0; 532} 533 534static inline int security_binder_transfer_file(const struct cred *from, 535 const struct cred *to, 536 struct file *file) 537{ 538 return 0; 539} 540 541static inline int security_ptrace_access_check(struct task_struct *child, 542 unsigned int mode) 543{ 544 return cap_ptrace_access_check(child, mode); 545} 546 547static inline int security_ptrace_traceme(struct task_struct *parent) 548{ 549 return cap_ptrace_traceme(parent); 550} 551 552static inline int security_capget(struct task_struct *target, 553 kernel_cap_t *effective, 554 kernel_cap_t *inheritable, 555 kernel_cap_t *permitted) 556{ 557 return cap_capget(target, effective, inheritable, permitted); 558} 559 560static inline int security_capset(struct cred *new, 561 const struct cred *old, 562 const kernel_cap_t *effective, 563 const kernel_cap_t *inheritable, 564 const kernel_cap_t *permitted) 565{ 566 return cap_capset(new, old, effective, inheritable, permitted); 567} 568 569static inline int security_capable(const struct cred *cred, 570 struct user_namespace *ns, 571 int cap, 572 unsigned int opts) 573{ 574 return cap_capable(cred, ns, cap, opts); 575} 576 577static inline int security_quotactl(int cmds, int type, int id, 578 struct super_block *sb) 579{ 580 return 0; 581} 582 583static inline int security_quota_on(struct dentry *dentry) 584{ 585 return 0; 586} 587 588static inline int security_syslog(int type) 589{ 590 return 0; 591} 592 593static inline int security_settime64(const struct timespec64 *ts, 594 const struct timezone *tz) 595{ 596 return cap_settime(ts, tz); 597} 598 599static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages) 600{ 601 return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages)); 602} 603 604static inline int security_bprm_creds_for_exec(struct linux_binprm *bprm) 605{ 606 return 0; 607} 608 609static inline int security_bprm_creds_from_file(struct linux_binprm *bprm, 610 struct file *file) 611{ 612 return cap_bprm_creds_from_file(bprm, file); 613} 614 615static inline int security_bprm_check(struct linux_binprm *bprm) 616{ 617 return 0; 618} 619 620static inline void security_bprm_committing_creds(struct linux_binprm *bprm) 621{ 622} 623 624static inline void security_bprm_committed_creds(struct linux_binprm *bprm) 625{ 626} 627 628static inline int security_fs_context_dup(struct fs_context *fc, 629 struct fs_context *src_fc) 630{ 631 return 0; 632} 633static inline int security_fs_context_parse_param(struct fs_context *fc, 634 struct fs_parameter *param) 635{ 636 return -ENOPARAM; 637} 638 639static inline int security_sb_alloc(struct super_block *sb) 640{ 641 return 0; 642} 643 644static inline void security_sb_delete(struct super_block *sb) 645{ } 646 647static inline void security_sb_free(struct super_block *sb) 648{ } 649 650static inline int security_sb_eat_lsm_opts(char *options, 651 void **mnt_opts) 652{ 653 return 0; 654} 655 656static inline int security_sb_remount(struct super_block *sb, 657 void *mnt_opts) 658{ 659 return 0; 660} 661 662static inline int security_sb_mnt_opts_compat(struct super_block *sb, 663 void *mnt_opts) 664{ 665 return 0; 666} 667 668 669static inline int security_sb_kern_mount(struct super_block *sb) 670{ 671 return 0; 672} 673 674static inline int security_sb_show_options(struct seq_file *m, 675 struct super_block *sb) 676{ 677 return 0; 678} 679 680static inline int security_sb_statfs(struct dentry *dentry) 681{ 682 return 0; 683} 684 685static inline int security_sb_mount(const char *dev_name, const struct path *path, 686 const char *type, unsigned long flags, 687 void *data) 688{ 689 return 0; 690} 691 692static inline int security_sb_umount(struct vfsmount *mnt, int flags) 693{ 694 return 0; 695} 696 697static inline int security_sb_pivotroot(const struct path *old_path, 698 const struct path *new_path) 699{ 700 return 0; 701} 702 703static inline int security_sb_set_mnt_opts(struct super_block *sb, 704 void *mnt_opts, 705 unsigned long kern_flags, 706 unsigned long *set_kern_flags) 707{ 708 return 0; 709} 710 711static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb, 712 struct super_block *newsb, 713 unsigned long kern_flags, 714 unsigned long *set_kern_flags) 715{ 716 return 0; 717} 718 719static inline int security_move_mount(const struct path *from_path, 720 const struct path *to_path) 721{ 722 return 0; 723} 724 725static inline int security_path_notify(const struct path *path, u64 mask, 726 unsigned int obj_type) 727{ 728 return 0; 729} 730 731static inline int security_inode_alloc(struct inode *inode) 732{ 733 return 0; 734} 735 736static inline void security_inode_free(struct inode *inode) 737{ } 738 739static inline int security_dentry_init_security(struct dentry *dentry, 740 int mode, 741 const struct qstr *name, 742 const char **xattr_name, 743 void **ctx, 744 u32 *ctxlen) 745{ 746 return -EOPNOTSUPP; 747} 748 749static inline int security_dentry_create_files_as(struct dentry *dentry, 750 int mode, struct qstr *name, 751 const struct cred *old, 752 struct cred *new) 753{ 754 return 0; 755} 756 757 758static inline int security_inode_init_security(struct inode *inode, 759 struct inode *dir, 760 const struct qstr *qstr, 761 const initxattrs xattrs, 762 void *fs_data) 763{ 764 return 0; 765} 766 767static inline int security_inode_init_security_anon(struct inode *inode, 768 const struct qstr *name, 769 const struct inode *context_inode) 770{ 771 return 0; 772} 773 774static inline int security_old_inode_init_security(struct inode *inode, 775 struct inode *dir, 776 const struct qstr *qstr, 777 const char **name, 778 void **value, size_t *len) 779{ 780 return -EOPNOTSUPP; 781} 782 783static inline int security_inode_create(struct inode *dir, 784 struct dentry *dentry, 785 umode_t mode) 786{ 787 return 0; 788} 789 790static inline int security_inode_link(struct dentry *old_dentry, 791 struct inode *dir, 792 struct dentry *new_dentry) 793{ 794 return 0; 795} 796 797static inline int security_inode_unlink(struct inode *dir, 798 struct dentry *dentry) 799{ 800 return 0; 801} 802 803static inline int security_inode_symlink(struct inode *dir, 804 struct dentry *dentry, 805 const char *old_name) 806{ 807 return 0; 808} 809 810static inline int security_inode_mkdir(struct inode *dir, 811 struct dentry *dentry, 812 int mode) 813{ 814 return 0; 815} 816 817static inline int security_inode_rmdir(struct inode *dir, 818 struct dentry *dentry) 819{ 820 return 0; 821} 822 823static inline int security_inode_mknod(struct inode *dir, 824 struct dentry *dentry, 825 int mode, dev_t dev) 826{ 827 return 0; 828} 829 830static inline int security_inode_rename(struct inode *old_dir, 831 struct dentry *old_dentry, 832 struct inode *new_dir, 833 struct dentry *new_dentry, 834 unsigned int flags) 835{ 836 return 0; 837} 838 839static inline int security_inode_readlink(struct dentry *dentry) 840{ 841 return 0; 842} 843 844static inline int security_inode_follow_link(struct dentry *dentry, 845 struct inode *inode, 846 bool rcu) 847{ 848 return 0; 849} 850 851static inline int security_inode_permission(struct inode *inode, int mask) 852{ 853 return 0; 854} 855 856static inline int security_inode_setattr(struct user_namespace *mnt_userns, 857 struct dentry *dentry, 858 struct iattr *attr) 859{ 860 return 0; 861} 862 863static inline int security_inode_getattr(const struct path *path) 864{ 865 return 0; 866} 867 868static inline int security_inode_setxattr(struct user_namespace *mnt_userns, 869 struct dentry *dentry, const char *name, const void *value, 870 size_t size, int flags) 871{ 872 return cap_inode_setxattr(dentry, name, value, size, flags); 873} 874 875static inline void security_inode_post_setxattr(struct dentry *dentry, 876 const char *name, const void *value, size_t size, int flags) 877{ } 878 879static inline int security_inode_getxattr(struct dentry *dentry, 880 const char *name) 881{ 882 return 0; 883} 884 885static inline int security_inode_listxattr(struct dentry *dentry) 886{ 887 return 0; 888} 889 890static inline int security_inode_removexattr(struct user_namespace *mnt_userns, 891 struct dentry *dentry, 892 const char *name) 893{ 894 return cap_inode_removexattr(mnt_userns, dentry, name); 895} 896 897static inline int security_inode_need_killpriv(struct dentry *dentry) 898{ 899 return cap_inode_need_killpriv(dentry); 900} 901 902static inline int security_inode_killpriv(struct user_namespace *mnt_userns, 903 struct dentry *dentry) 904{ 905 return cap_inode_killpriv(mnt_userns, dentry); 906} 907 908static inline int security_inode_getsecurity(struct user_namespace *mnt_userns, 909 struct inode *inode, 910 const char *name, void **buffer, 911 bool alloc) 912{ 913 return cap_inode_getsecurity(mnt_userns, inode, name, buffer, alloc); 914} 915 916static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags) 917{ 918 return -EOPNOTSUPP; 919} 920 921static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size) 922{ 923 return 0; 924} 925 926static inline void security_inode_getsecid(struct inode *inode, u32 *secid) 927{ 928 *secid = 0; 929} 930 931static inline int security_inode_copy_up(struct dentry *src, struct cred **new) 932{ 933 return 0; 934} 935 936static inline int security_kernfs_init_security(struct kernfs_node *kn_dir, 937 struct kernfs_node *kn) 938{ 939 return 0; 940} 941 942static inline int security_inode_copy_up_xattr(const char *name) 943{ 944 return -EOPNOTSUPP; 945} 946 947static inline int security_file_permission(struct file *file, int mask) 948{ 949 return 0; 950} 951 952static inline int security_file_alloc(struct file *file) 953{ 954 return 0; 955} 956 957static inline void security_file_free(struct file *file) 958{ } 959 960static inline int security_file_ioctl(struct file *file, unsigned int cmd, 961 unsigned long arg) 962{ 963 return 0; 964} 965 966static inline int security_mmap_file(struct file *file, unsigned long prot, 967 unsigned long flags) 968{ 969 return 0; 970} 971 972static inline int security_mmap_addr(unsigned long addr) 973{ 974 return cap_mmap_addr(addr); 975} 976 977static inline int security_file_mprotect(struct vm_area_struct *vma, 978 unsigned long reqprot, 979 unsigned long prot) 980{ 981 return 0; 982} 983 984static inline int security_file_lock(struct file *file, unsigned int cmd) 985{ 986 return 0; 987} 988 989static inline int security_file_fcntl(struct file *file, unsigned int cmd, 990 unsigned long arg) 991{ 992 return 0; 993} 994 995static inline void security_file_set_fowner(struct file *file) 996{ 997 return; 998} 999 1000static inline int security_file_send_sigiotask(struct task_struct *tsk, 1001 struct fown_struct *fown, 1002 int sig) 1003{ 1004 return 0; 1005} 1006 1007static inline int security_file_receive(struct file *file) 1008{ 1009 return 0; 1010} 1011 1012static inline int security_file_open(struct file *file) 1013{ 1014 return 0; 1015} 1016 1017static inline int security_task_alloc(struct task_struct *task, 1018 unsigned long clone_flags) 1019{ 1020 return 0; 1021} 1022 1023static inline void security_task_free(struct task_struct *task) 1024{ } 1025 1026static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp) 1027{ 1028 return 0; 1029} 1030 1031static inline void security_cred_free(struct cred *cred) 1032{ } 1033 1034static inline int security_prepare_creds(struct cred *new, 1035 const struct cred *old, 1036 gfp_t gfp) 1037{ 1038 return 0; 1039} 1040 1041static inline void security_transfer_creds(struct cred *new, 1042 const struct cred *old) 1043{ 1044} 1045 1046static inline void security_cred_getsecid(const struct cred *c, u32 *secid) 1047{ 1048 *secid = 0; 1049} 1050 1051static inline int security_kernel_act_as(struct cred *cred, u32 secid) 1052{ 1053 return 0; 1054} 1055 1056static inline int security_kernel_create_files_as(struct cred *cred, 1057 struct inode *inode) 1058{ 1059 return 0; 1060} 1061 1062static inline int security_kernel_module_request(char *kmod_name) 1063{ 1064 return 0; 1065} 1066 1067static inline int security_kernel_load_data(enum kernel_load_data_id id, bool contents) 1068{ 1069 return 0; 1070} 1071 1072static inline int security_kernel_post_load_data(char *buf, loff_t size, 1073 enum kernel_load_data_id id, 1074 char *description) 1075{ 1076 return 0; 1077} 1078 1079static inline int security_kernel_read_file(struct file *file, 1080 enum kernel_read_file_id id, 1081 bool contents) 1082{ 1083 return 0; 1084} 1085 1086static inline int security_kernel_post_read_file(struct file *file, 1087 char *buf, loff_t size, 1088 enum kernel_read_file_id id) 1089{ 1090 return 0; 1091} 1092 1093static inline int security_task_fix_setuid(struct cred *new, 1094 const struct cred *old, 1095 int flags) 1096{ 1097 return cap_task_fix_setuid(new, old, flags); 1098} 1099 1100static inline int security_task_fix_setgid(struct cred *new, 1101 const struct cred *old, 1102 int flags) 1103{ 1104 return 0; 1105} 1106 1107static inline int security_task_fix_setgroups(struct cred *new, 1108 const struct cred *old) 1109{ 1110 return 0; 1111} 1112 1113static inline int security_task_setpgid(struct task_struct *p, pid_t pgid) 1114{ 1115 return 0; 1116} 1117 1118static inline int security_task_getpgid(struct task_struct *p) 1119{ 1120 return 0; 1121} 1122 1123static inline int security_task_getsid(struct task_struct *p) 1124{ 1125 return 0; 1126} 1127 1128static inline void security_current_getsecid_subj(u32 *secid) 1129{ 1130 *secid = 0; 1131} 1132 1133static inline void security_task_getsecid_obj(struct task_struct *p, u32 *secid) 1134{ 1135 *secid = 0; 1136} 1137 1138static inline int security_task_setnice(struct task_struct *p, int nice) 1139{ 1140 return cap_task_setnice(p, nice); 1141} 1142 1143static inline int security_task_setioprio(struct task_struct *p, int ioprio) 1144{ 1145 return cap_task_setioprio(p, ioprio); 1146} 1147 1148static inline int security_task_getioprio(struct task_struct *p) 1149{ 1150 return 0; 1151} 1152 1153static inline int security_task_prlimit(const struct cred *cred, 1154 const struct cred *tcred, 1155 unsigned int flags) 1156{ 1157 return 0; 1158} 1159 1160static inline int security_task_setrlimit(struct task_struct *p, 1161 unsigned int resource, 1162 struct rlimit *new_rlim) 1163{ 1164 return 0; 1165} 1166 1167static inline int security_task_setscheduler(struct task_struct *p) 1168{ 1169 return cap_task_setscheduler(p); 1170} 1171 1172static inline int security_task_getscheduler(struct task_struct *p) 1173{ 1174 return 0; 1175} 1176 1177static inline int security_task_movememory(struct task_struct *p) 1178{ 1179 return 0; 1180} 1181 1182static inline int security_task_kill(struct task_struct *p, 1183 struct kernel_siginfo *info, int sig, 1184 const struct cred *cred) 1185{ 1186 return 0; 1187} 1188 1189static inline int security_task_prctl(int option, unsigned long arg2, 1190 unsigned long arg3, 1191 unsigned long arg4, 1192 unsigned long arg5) 1193{ 1194 return cap_task_prctl(option, arg2, arg3, arg4, arg5); 1195} 1196 1197static inline void security_task_to_inode(struct task_struct *p, struct inode *inode) 1198{ } 1199 1200static inline int security_create_user_ns(const struct cred *cred) 1201{ 1202 return 0; 1203} 1204 1205static inline int security_ipc_permission(struct kern_ipc_perm *ipcp, 1206 short flag) 1207{ 1208 return 0; 1209} 1210 1211static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid) 1212{ 1213 *secid = 0; 1214} 1215 1216static inline int security_msg_msg_alloc(struct msg_msg *msg) 1217{ 1218 return 0; 1219} 1220 1221static inline void security_msg_msg_free(struct msg_msg *msg) 1222{ } 1223 1224static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq) 1225{ 1226 return 0; 1227} 1228 1229static inline void security_msg_queue_free(struct kern_ipc_perm *msq) 1230{ } 1231 1232static inline int security_msg_queue_associate(struct kern_ipc_perm *msq, 1233 int msqflg) 1234{ 1235 return 0; 1236} 1237 1238static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd) 1239{ 1240 return 0; 1241} 1242 1243static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq, 1244 struct msg_msg *msg, int msqflg) 1245{ 1246 return 0; 1247} 1248 1249static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, 1250 struct msg_msg *msg, 1251 struct task_struct *target, 1252 long type, int mode) 1253{ 1254 return 0; 1255} 1256 1257static inline int security_shm_alloc(struct kern_ipc_perm *shp) 1258{ 1259 return 0; 1260} 1261 1262static inline void security_shm_free(struct kern_ipc_perm *shp) 1263{ } 1264 1265static inline int security_shm_associate(struct kern_ipc_perm *shp, 1266 int shmflg) 1267{ 1268 return 0; 1269} 1270 1271static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd) 1272{ 1273 return 0; 1274} 1275 1276static inline int security_shm_shmat(struct kern_ipc_perm *shp, 1277 char __user *shmaddr, int shmflg) 1278{ 1279 return 0; 1280} 1281 1282static inline int security_sem_alloc(struct kern_ipc_perm *sma) 1283{ 1284 return 0; 1285} 1286 1287static inline void security_sem_free(struct kern_ipc_perm *sma) 1288{ } 1289 1290static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg) 1291{ 1292 return 0; 1293} 1294 1295static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd) 1296{ 1297 return 0; 1298} 1299 1300static inline int security_sem_semop(struct kern_ipc_perm *sma, 1301 struct sembuf *sops, unsigned nsops, 1302 int alter) 1303{ 1304 return 0; 1305} 1306 1307static inline void security_d_instantiate(struct dentry *dentry, 1308 struct inode *inode) 1309{ } 1310 1311static inline int security_getprocattr(struct task_struct *p, const char *lsm, 1312 const char *name, char **value) 1313{ 1314 return -EINVAL; 1315} 1316 1317static inline int security_setprocattr(const char *lsm, char *name, 1318 void *value, size_t size) 1319{ 1320 return -EINVAL; 1321} 1322 1323static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb) 1324{ 1325 return 0; 1326} 1327 1328static inline int security_ismaclabel(const char *name) 1329{ 1330 return 0; 1331} 1332 1333static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) 1334{ 1335 return -EOPNOTSUPP; 1336} 1337 1338static inline int security_secctx_to_secid(const char *secdata, 1339 u32 seclen, 1340 u32 *secid) 1341{ 1342 return -EOPNOTSUPP; 1343} 1344 1345static inline void security_release_secctx(char *secdata, u32 seclen) 1346{ 1347} 1348 1349static inline void security_inode_invalidate_secctx(struct inode *inode) 1350{ 1351} 1352 1353static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen) 1354{ 1355 return -EOPNOTSUPP; 1356} 1357static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen) 1358{ 1359 return -EOPNOTSUPP; 1360} 1361static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen) 1362{ 1363 return -EOPNOTSUPP; 1364} 1365static inline int security_locked_down(enum lockdown_reason what) 1366{ 1367 return 0; 1368} 1369#endif /* CONFIG_SECURITY */ 1370 1371#if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE) 1372int security_post_notification(const struct cred *w_cred, 1373 const struct cred *cred, 1374 struct watch_notification *n); 1375#else 1376static inline int security_post_notification(const struct cred *w_cred, 1377 const struct cred *cred, 1378 struct watch_notification *n) 1379{ 1380 return 0; 1381} 1382#endif 1383 1384#if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS) 1385int security_watch_key(struct key *key); 1386#else 1387static inline int security_watch_key(struct key *key) 1388{ 1389 return 0; 1390} 1391#endif 1392 1393#ifdef CONFIG_SECURITY_NETWORK 1394 1395int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk); 1396int security_unix_may_send(struct socket *sock, struct socket *other); 1397int security_socket_create(int family, int type, int protocol, int kern); 1398int security_socket_post_create(struct socket *sock, int family, 1399 int type, int protocol, int kern); 1400int security_socket_socketpair(struct socket *socka, struct socket *sockb); 1401int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen); 1402int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen); 1403int security_socket_listen(struct socket *sock, int backlog); 1404int security_socket_accept(struct socket *sock, struct socket *newsock); 1405int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size); 1406int security_socket_recvmsg(struct socket *sock, struct msghdr *msg, 1407 int size, int flags); 1408int security_socket_getsockname(struct socket *sock); 1409int security_socket_getpeername(struct socket *sock); 1410int security_socket_getsockopt(struct socket *sock, int level, int optname); 1411int security_socket_setsockopt(struct socket *sock, int level, int optname); 1412int security_socket_shutdown(struct socket *sock, int how); 1413int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb); 1414int security_socket_getpeersec_stream(struct socket *sock, char __user *optval, 1415 int __user *optlen, unsigned len); 1416int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid); 1417int security_sk_alloc(struct sock *sk, int family, gfp_t priority); 1418void security_sk_free(struct sock *sk); 1419void security_sk_clone(const struct sock *sk, struct sock *newsk); 1420void security_sk_classify_flow(struct sock *sk, struct flowi_common *flic); 1421void security_req_classify_flow(const struct request_sock *req, 1422 struct flowi_common *flic); 1423void security_sock_graft(struct sock*sk, struct socket *parent); 1424int security_inet_conn_request(const struct sock *sk, 1425 struct sk_buff *skb, struct request_sock *req); 1426void security_inet_csk_clone(struct sock *newsk, 1427 const struct request_sock *req); 1428void security_inet_conn_established(struct sock *sk, 1429 struct sk_buff *skb); 1430int security_secmark_relabel_packet(u32 secid); 1431void security_secmark_refcount_inc(void); 1432void security_secmark_refcount_dec(void); 1433int security_tun_dev_alloc_security(void **security); 1434void security_tun_dev_free_security(void *security); 1435int security_tun_dev_create(void); 1436int security_tun_dev_attach_queue(void *security); 1437int security_tun_dev_attach(struct sock *sk, void *security); 1438int security_tun_dev_open(void *security); 1439int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb); 1440int security_sctp_bind_connect(struct sock *sk, int optname, 1441 struct sockaddr *address, int addrlen); 1442void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk, 1443 struct sock *newsk); 1444int security_sctp_assoc_established(struct sctp_association *asoc, 1445 struct sk_buff *skb); 1446 1447#else /* CONFIG_SECURITY_NETWORK */ 1448static inline int security_unix_stream_connect(struct sock *sock, 1449 struct sock *other, 1450 struct sock *newsk) 1451{ 1452 return 0; 1453} 1454 1455static inline int security_unix_may_send(struct socket *sock, 1456 struct socket *other) 1457{ 1458 return 0; 1459} 1460 1461static inline int security_socket_create(int family, int type, 1462 int protocol, int kern) 1463{ 1464 return 0; 1465} 1466 1467static inline int security_socket_post_create(struct socket *sock, 1468 int family, 1469 int type, 1470 int protocol, int kern) 1471{ 1472 return 0; 1473} 1474 1475static inline int security_socket_socketpair(struct socket *socka, 1476 struct socket *sockb) 1477{ 1478 return 0; 1479} 1480 1481static inline int security_socket_bind(struct socket *sock, 1482 struct sockaddr *address, 1483 int addrlen) 1484{ 1485 return 0; 1486} 1487 1488static inline int security_socket_connect(struct socket *sock, 1489 struct sockaddr *address, 1490 int addrlen) 1491{ 1492 return 0; 1493} 1494 1495static inline int security_socket_listen(struct socket *sock, int backlog) 1496{ 1497 return 0; 1498} 1499 1500static inline int security_socket_accept(struct socket *sock, 1501 struct socket *newsock) 1502{ 1503 return 0; 1504} 1505 1506static inline int security_socket_sendmsg(struct socket *sock, 1507 struct msghdr *msg, int size) 1508{ 1509 return 0; 1510} 1511 1512static inline int security_socket_recvmsg(struct socket *sock, 1513 struct msghdr *msg, int size, 1514 int flags) 1515{ 1516 return 0; 1517} 1518 1519static inline int security_socket_getsockname(struct socket *sock) 1520{ 1521 return 0; 1522} 1523 1524static inline int security_socket_getpeername(struct socket *sock) 1525{ 1526 return 0; 1527} 1528 1529static inline int security_socket_getsockopt(struct socket *sock, 1530 int level, int optname) 1531{ 1532 return 0; 1533} 1534 1535static inline int security_socket_setsockopt(struct socket *sock, 1536 int level, int optname) 1537{ 1538 return 0; 1539} 1540 1541static inline int security_socket_shutdown(struct socket *sock, int how) 1542{ 1543 return 0; 1544} 1545static inline int security_sock_rcv_skb(struct sock *sk, 1546 struct sk_buff *skb) 1547{ 1548 return 0; 1549} 1550 1551static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval, 1552 int __user *optlen, unsigned len) 1553{ 1554 return -ENOPROTOOPT; 1555} 1556 1557static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid) 1558{ 1559 return -ENOPROTOOPT; 1560} 1561 1562static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority) 1563{ 1564 return 0; 1565} 1566 1567static inline void security_sk_free(struct sock *sk) 1568{ 1569} 1570 1571static inline void security_sk_clone(const struct sock *sk, struct sock *newsk) 1572{ 1573} 1574 1575static inline void security_sk_classify_flow(struct sock *sk, 1576 struct flowi_common *flic) 1577{ 1578} 1579 1580static inline void security_req_classify_flow(const struct request_sock *req, 1581 struct flowi_common *flic) 1582{ 1583} 1584 1585static inline void security_sock_graft(struct sock *sk, struct socket *parent) 1586{ 1587} 1588 1589static inline int security_inet_conn_request(const struct sock *sk, 1590 struct sk_buff *skb, struct request_sock *req) 1591{ 1592 return 0; 1593} 1594 1595static inline void security_inet_csk_clone(struct sock *newsk, 1596 const struct request_sock *req) 1597{ 1598} 1599 1600static inline void security_inet_conn_established(struct sock *sk, 1601 struct sk_buff *skb) 1602{ 1603} 1604 1605static inline int security_secmark_relabel_packet(u32 secid) 1606{ 1607 return 0; 1608} 1609 1610static inline void security_secmark_refcount_inc(void) 1611{ 1612} 1613 1614static inline void security_secmark_refcount_dec(void) 1615{ 1616} 1617 1618static inline int security_tun_dev_alloc_security(void **security) 1619{ 1620 return 0; 1621} 1622 1623static inline void security_tun_dev_free_security(void *security) 1624{ 1625} 1626 1627static inline int security_tun_dev_create(void) 1628{ 1629 return 0; 1630} 1631 1632static inline int security_tun_dev_attach_queue(void *security) 1633{ 1634 return 0; 1635} 1636 1637static inline int security_tun_dev_attach(struct sock *sk, void *security) 1638{ 1639 return 0; 1640} 1641 1642static inline int security_tun_dev_open(void *security) 1643{ 1644 return 0; 1645} 1646 1647static inline int security_sctp_assoc_request(struct sctp_association *asoc, 1648 struct sk_buff *skb) 1649{ 1650 return 0; 1651} 1652 1653static inline int security_sctp_bind_connect(struct sock *sk, int optname, 1654 struct sockaddr *address, 1655 int addrlen) 1656{ 1657 return 0; 1658} 1659 1660static inline void security_sctp_sk_clone(struct sctp_association *asoc, 1661 struct sock *sk, 1662 struct sock *newsk) 1663{ 1664} 1665 1666static inline int security_sctp_assoc_established(struct sctp_association *asoc, 1667 struct sk_buff *skb) 1668{ 1669 return 0; 1670} 1671#endif /* CONFIG_SECURITY_NETWORK */ 1672 1673#ifdef CONFIG_SECURITY_INFINIBAND 1674int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey); 1675int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num); 1676int security_ib_alloc_security(void **sec); 1677void security_ib_free_security(void *sec); 1678#else /* CONFIG_SECURITY_INFINIBAND */ 1679static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey) 1680{ 1681 return 0; 1682} 1683 1684static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num) 1685{ 1686 return 0; 1687} 1688 1689static inline int security_ib_alloc_security(void **sec) 1690{ 1691 return 0; 1692} 1693 1694static inline void security_ib_free_security(void *sec) 1695{ 1696} 1697#endif /* CONFIG_SECURITY_INFINIBAND */ 1698 1699#ifdef CONFIG_SECURITY_NETWORK_XFRM 1700 1701int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, 1702 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp); 1703int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp); 1704void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx); 1705int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx); 1706int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx); 1707int security_xfrm_state_alloc_acquire(struct xfrm_state *x, 1708 struct xfrm_sec_ctx *polsec, u32 secid); 1709int security_xfrm_state_delete(struct xfrm_state *x); 1710void security_xfrm_state_free(struct xfrm_state *x); 1711int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid); 1712int security_xfrm_state_pol_flow_match(struct xfrm_state *x, 1713 struct xfrm_policy *xp, 1714 const struct flowi_common *flic); 1715int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid); 1716void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic); 1717 1718#else /* CONFIG_SECURITY_NETWORK_XFRM */ 1719 1720static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, 1721 struct xfrm_user_sec_ctx *sec_ctx, 1722 gfp_t gfp) 1723{ 1724 return 0; 1725} 1726 1727static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp) 1728{ 1729 return 0; 1730} 1731 1732static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx) 1733{ 1734} 1735 1736static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx) 1737{ 1738 return 0; 1739} 1740 1741static inline int security_xfrm_state_alloc(struct xfrm_state *x, 1742 struct xfrm_user_sec_ctx *sec_ctx) 1743{ 1744 return 0; 1745} 1746 1747static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x, 1748 struct xfrm_sec_ctx *polsec, u32 secid) 1749{ 1750 return 0; 1751} 1752 1753static inline void security_xfrm_state_free(struct xfrm_state *x) 1754{ 1755} 1756 1757static inline int security_xfrm_state_delete(struct xfrm_state *x) 1758{ 1759 return 0; 1760} 1761 1762static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid) 1763{ 1764 return 0; 1765} 1766 1767static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x, 1768 struct xfrm_policy *xp, 1769 const struct flowi_common *flic) 1770{ 1771 return 1; 1772} 1773 1774static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid) 1775{ 1776 return 0; 1777} 1778 1779static inline void security_skb_classify_flow(struct sk_buff *skb, 1780 struct flowi_common *flic) 1781{ 1782} 1783 1784#endif /* CONFIG_SECURITY_NETWORK_XFRM */ 1785 1786#ifdef CONFIG_SECURITY_PATH 1787int security_path_unlink(const struct path *dir, struct dentry *dentry); 1788int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode); 1789int security_path_rmdir(const struct path *dir, struct dentry *dentry); 1790int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode, 1791 unsigned int dev); 1792int security_path_truncate(const struct path *path); 1793int security_path_symlink(const struct path *dir, struct dentry *dentry, 1794 const char *old_name); 1795int security_path_link(struct dentry *old_dentry, const struct path *new_dir, 1796 struct dentry *new_dentry); 1797int security_path_rename(const struct path *old_dir, struct dentry *old_dentry, 1798 const struct path *new_dir, struct dentry *new_dentry, 1799 unsigned int flags); 1800int security_path_chmod(const struct path *path, umode_t mode); 1801int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid); 1802int security_path_chroot(const struct path *path); 1803#else /* CONFIG_SECURITY_PATH */ 1804static inline int security_path_unlink(const struct path *dir, struct dentry *dentry) 1805{ 1806 return 0; 1807} 1808 1809static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry, 1810 umode_t mode) 1811{ 1812 return 0; 1813} 1814 1815static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry) 1816{ 1817 return 0; 1818} 1819 1820static inline int security_path_mknod(const struct path *dir, struct dentry *dentry, 1821 umode_t mode, unsigned int dev) 1822{ 1823 return 0; 1824} 1825 1826static inline int security_path_truncate(const struct path *path) 1827{ 1828 return 0; 1829} 1830 1831static inline int security_path_symlink(const struct path *dir, struct dentry *dentry, 1832 const char *old_name) 1833{ 1834 return 0; 1835} 1836 1837static inline int security_path_link(struct dentry *old_dentry, 1838 const struct path *new_dir, 1839 struct dentry *new_dentry) 1840{ 1841 return 0; 1842} 1843 1844static inline int security_path_rename(const struct path *old_dir, 1845 struct dentry *old_dentry, 1846 const struct path *new_dir, 1847 struct dentry *new_dentry, 1848 unsigned int flags) 1849{ 1850 return 0; 1851} 1852 1853static inline int security_path_chmod(const struct path *path, umode_t mode) 1854{ 1855 return 0; 1856} 1857 1858static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid) 1859{ 1860 return 0; 1861} 1862 1863static inline int security_path_chroot(const struct path *path) 1864{ 1865 return 0; 1866} 1867#endif /* CONFIG_SECURITY_PATH */ 1868 1869#ifdef CONFIG_KEYS 1870#ifdef CONFIG_SECURITY 1871 1872int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags); 1873void security_key_free(struct key *key); 1874int security_key_permission(key_ref_t key_ref, const struct cred *cred, 1875 enum key_need_perm need_perm); 1876int security_key_getsecurity(struct key *key, char **_buffer); 1877 1878#else 1879 1880static inline int security_key_alloc(struct key *key, 1881 const struct cred *cred, 1882 unsigned long flags) 1883{ 1884 return 0; 1885} 1886 1887static inline void security_key_free(struct key *key) 1888{ 1889} 1890 1891static inline int security_key_permission(key_ref_t key_ref, 1892 const struct cred *cred, 1893 enum key_need_perm need_perm) 1894{ 1895 return 0; 1896} 1897 1898static inline int security_key_getsecurity(struct key *key, char **_buffer) 1899{ 1900 *_buffer = NULL; 1901 return 0; 1902} 1903 1904#endif 1905#endif /* CONFIG_KEYS */ 1906 1907#ifdef CONFIG_AUDIT 1908#ifdef CONFIG_SECURITY 1909int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule); 1910int security_audit_rule_known(struct audit_krule *krule); 1911int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule); 1912void security_audit_rule_free(void *lsmrule); 1913 1914#else 1915 1916static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr, 1917 void **lsmrule) 1918{ 1919 return 0; 1920} 1921 1922static inline int security_audit_rule_known(struct audit_krule *krule) 1923{ 1924 return 0; 1925} 1926 1927static inline int security_audit_rule_match(u32 secid, u32 field, u32 op, 1928 void *lsmrule) 1929{ 1930 return 0; 1931} 1932 1933static inline void security_audit_rule_free(void *lsmrule) 1934{ } 1935 1936#endif /* CONFIG_SECURITY */ 1937#endif /* CONFIG_AUDIT */ 1938 1939#ifdef CONFIG_SECURITYFS 1940 1941extern struct dentry *securityfs_create_file(const char *name, umode_t mode, 1942 struct dentry *parent, void *data, 1943 const struct file_operations *fops); 1944extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent); 1945struct dentry *securityfs_create_symlink(const char *name, 1946 struct dentry *parent, 1947 const char *target, 1948 const struct inode_operations *iops); 1949extern void securityfs_remove(struct dentry *dentry); 1950 1951#else /* CONFIG_SECURITYFS */ 1952 1953static inline struct dentry *securityfs_create_dir(const char *name, 1954 struct dentry *parent) 1955{ 1956 return ERR_PTR(-ENODEV); 1957} 1958 1959static inline struct dentry *securityfs_create_file(const char *name, 1960 umode_t mode, 1961 struct dentry *parent, 1962 void *data, 1963 const struct file_operations *fops) 1964{ 1965 return ERR_PTR(-ENODEV); 1966} 1967 1968static inline struct dentry *securityfs_create_symlink(const char *name, 1969 struct dentry *parent, 1970 const char *target, 1971 const struct inode_operations *iops) 1972{ 1973 return ERR_PTR(-ENODEV); 1974} 1975 1976static inline void securityfs_remove(struct dentry *dentry) 1977{} 1978 1979#endif 1980 1981#ifdef CONFIG_BPF_SYSCALL 1982union bpf_attr; 1983struct bpf_map; 1984struct bpf_prog; 1985struct bpf_prog_aux; 1986#ifdef CONFIG_SECURITY 1987extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size); 1988extern int security_bpf_map(struct bpf_map *map, fmode_t fmode); 1989extern int security_bpf_prog(struct bpf_prog *prog); 1990extern int security_bpf_map_alloc(struct bpf_map *map); 1991extern void security_bpf_map_free(struct bpf_map *map); 1992extern int security_bpf_prog_alloc(struct bpf_prog_aux *aux); 1993extern void security_bpf_prog_free(struct bpf_prog_aux *aux); 1994#else 1995static inline int security_bpf(int cmd, union bpf_attr *attr, 1996 unsigned int size) 1997{ 1998 return 0; 1999} 2000 2001static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode) 2002{ 2003 return 0; 2004} 2005 2006static inline int security_bpf_prog(struct bpf_prog *prog) 2007{ 2008 return 0; 2009} 2010 2011static inline int security_bpf_map_alloc(struct bpf_map *map) 2012{ 2013 return 0; 2014} 2015 2016static inline void security_bpf_map_free(struct bpf_map *map) 2017{ } 2018 2019static inline int security_bpf_prog_alloc(struct bpf_prog_aux *aux) 2020{ 2021 return 0; 2022} 2023 2024static inline void security_bpf_prog_free(struct bpf_prog_aux *aux) 2025{ } 2026#endif /* CONFIG_SECURITY */ 2027#endif /* CONFIG_BPF_SYSCALL */ 2028 2029#ifdef CONFIG_PERF_EVENTS 2030struct perf_event_attr; 2031struct perf_event; 2032 2033#ifdef CONFIG_SECURITY 2034extern int security_perf_event_open(struct perf_event_attr *attr, int type); 2035extern int security_perf_event_alloc(struct perf_event *event); 2036extern void security_perf_event_free(struct perf_event *event); 2037extern int security_perf_event_read(struct perf_event *event); 2038extern int security_perf_event_write(struct perf_event *event); 2039#else 2040static inline int security_perf_event_open(struct perf_event_attr *attr, 2041 int type) 2042{ 2043 return 0; 2044} 2045 2046static inline int security_perf_event_alloc(struct perf_event *event) 2047{ 2048 return 0; 2049} 2050 2051static inline void security_perf_event_free(struct perf_event *event) 2052{ 2053} 2054 2055static inline int security_perf_event_read(struct perf_event *event) 2056{ 2057 return 0; 2058} 2059 2060static inline int security_perf_event_write(struct perf_event *event) 2061{ 2062 return 0; 2063} 2064#endif /* CONFIG_SECURITY */ 2065#endif /* CONFIG_PERF_EVENTS */ 2066 2067#ifdef CONFIG_IO_URING 2068#ifdef CONFIG_SECURITY 2069extern int security_uring_override_creds(const struct cred *new); 2070extern int security_uring_sqpoll(void); 2071extern int security_uring_cmd(struct io_uring_cmd *ioucmd); 2072#else 2073static inline int security_uring_override_creds(const struct cred *new) 2074{ 2075 return 0; 2076} 2077static inline int security_uring_sqpoll(void) 2078{ 2079 return 0; 2080} 2081static inline int security_uring_cmd(struct io_uring_cmd *ioucmd) 2082{ 2083 return 0; 2084} 2085#endif /* CONFIG_SECURITY */ 2086#endif /* CONFIG_IO_URING */ 2087 2088#endif /* ! __LINUX_SECURITY_H */