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