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