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