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, void **ctx, u32 *ctxlen); 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, void **ctx, u32 *ctxlen) 1595 { 1596 return -EOPNOTSUPP; 1597 } 1598 static inline int security_locked_down(enum lockdown_reason what) 1599 { 1600 return 0; 1601 } 1602 static inline int lsm_fill_user_ctx(struct lsm_ctx __user *uctx, 1603 u32 *uctx_len, void *val, size_t val_len, 1604 u64 id, u64 flags) 1605 { 1606 return -EOPNOTSUPP; 1607 } 1608 1609 static inline int security_bdev_alloc(struct block_device *bdev) 1610 { 1611 return 0; 1612 } 1613 1614 static inline void security_bdev_free(struct block_device *bdev) 1615 { 1616 } 1617 1618 static inline int security_bdev_setintegrity(struct block_device *bdev, 1619 enum lsm_integrity_type type, 1620 const void *value, size_t size) 1621 { 1622 return 0; 1623 } 1624 1625 #endif /* CONFIG_SECURITY */ 1626 1627 #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE) 1628 int security_post_notification(const struct cred *w_cred, 1629 const struct cred *cred, 1630 struct watch_notification *n); 1631 #else 1632 static inline int security_post_notification(const struct cred *w_cred, 1633 const struct cred *cred, 1634 struct watch_notification *n) 1635 { 1636 return 0; 1637 } 1638 #endif 1639 1640 #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS) 1641 int security_watch_key(struct key *key); 1642 #else 1643 static inline int security_watch_key(struct key *key) 1644 { 1645 return 0; 1646 } 1647 #endif 1648 1649 #ifdef CONFIG_SECURITY_NETWORK 1650 1651 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk); 1652 int security_unix_may_send(struct socket *sock, struct socket *other); 1653 int security_socket_create(int family, int type, int protocol, int kern); 1654 int security_socket_post_create(struct socket *sock, int family, 1655 int type, int protocol, int kern); 1656 int security_socket_socketpair(struct socket *socka, struct socket *sockb); 1657 int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen); 1658 int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen); 1659 int security_socket_listen(struct socket *sock, int backlog); 1660 int security_socket_accept(struct socket *sock, struct socket *newsock); 1661 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size); 1662 int security_socket_recvmsg(struct socket *sock, struct msghdr *msg, 1663 int size, int flags); 1664 int security_socket_getsockname(struct socket *sock); 1665 int security_socket_getpeername(struct socket *sock); 1666 int security_socket_getsockopt(struct socket *sock, int level, int optname); 1667 int security_socket_setsockopt(struct socket *sock, int level, int optname); 1668 int security_socket_shutdown(struct socket *sock, int how); 1669 int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb); 1670 int security_socket_getpeersec_stream(struct socket *sock, sockptr_t optval, 1671 sockptr_t optlen, unsigned int len); 1672 int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid); 1673 int security_sk_alloc(struct sock *sk, int family, gfp_t priority); 1674 void security_sk_free(struct sock *sk); 1675 void security_sk_clone(const struct sock *sk, struct sock *newsk); 1676 void security_sk_classify_flow(const struct sock *sk, 1677 struct flowi_common *flic); 1678 void security_req_classify_flow(const struct request_sock *req, 1679 struct flowi_common *flic); 1680 void security_sock_graft(struct sock*sk, struct socket *parent); 1681 int security_inet_conn_request(const struct sock *sk, 1682 struct sk_buff *skb, struct request_sock *req); 1683 void security_inet_csk_clone(struct sock *newsk, 1684 const struct request_sock *req); 1685 void security_inet_conn_established(struct sock *sk, 1686 struct sk_buff *skb); 1687 int security_secmark_relabel_packet(u32 secid); 1688 void security_secmark_refcount_inc(void); 1689 void security_secmark_refcount_dec(void); 1690 int security_tun_dev_alloc_security(void **security); 1691 void security_tun_dev_free_security(void *security); 1692 int security_tun_dev_create(void); 1693 int security_tun_dev_attach_queue(void *security); 1694 int security_tun_dev_attach(struct sock *sk, void *security); 1695 int security_tun_dev_open(void *security); 1696 int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb); 1697 int security_sctp_bind_connect(struct sock *sk, int optname, 1698 struct sockaddr *address, int addrlen); 1699 void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk, 1700 struct sock *newsk); 1701 int security_sctp_assoc_established(struct sctp_association *asoc, 1702 struct sk_buff *skb); 1703 int security_mptcp_add_subflow(struct sock *sk, struct sock *ssk); 1704 1705 #else /* CONFIG_SECURITY_NETWORK */ 1706 static inline int security_unix_stream_connect(struct sock *sock, 1707 struct sock *other, 1708 struct sock *newsk) 1709 { 1710 return 0; 1711 } 1712 1713 static inline int security_unix_may_send(struct socket *sock, 1714 struct socket *other) 1715 { 1716 return 0; 1717 } 1718 1719 static inline int security_socket_create(int family, int type, 1720 int protocol, int kern) 1721 { 1722 return 0; 1723 } 1724 1725 static inline int security_socket_post_create(struct socket *sock, 1726 int family, 1727 int type, 1728 int protocol, int kern) 1729 { 1730 return 0; 1731 } 1732 1733 static inline int security_socket_socketpair(struct socket *socka, 1734 struct socket *sockb) 1735 { 1736 return 0; 1737 } 1738 1739 static inline int security_socket_bind(struct socket *sock, 1740 struct sockaddr *address, 1741 int addrlen) 1742 { 1743 return 0; 1744 } 1745 1746 static inline int security_socket_connect(struct socket *sock, 1747 struct sockaddr *address, 1748 int addrlen) 1749 { 1750 return 0; 1751 } 1752 1753 static inline int security_socket_listen(struct socket *sock, int backlog) 1754 { 1755 return 0; 1756 } 1757 1758 static inline int security_socket_accept(struct socket *sock, 1759 struct socket *newsock) 1760 { 1761 return 0; 1762 } 1763 1764 static inline int security_socket_sendmsg(struct socket *sock, 1765 struct msghdr *msg, int size) 1766 { 1767 return 0; 1768 } 1769 1770 static inline int security_socket_recvmsg(struct socket *sock, 1771 struct msghdr *msg, int size, 1772 int flags) 1773 { 1774 return 0; 1775 } 1776 1777 static inline int security_socket_getsockname(struct socket *sock) 1778 { 1779 return 0; 1780 } 1781 1782 static inline int security_socket_getpeername(struct socket *sock) 1783 { 1784 return 0; 1785 } 1786 1787 static inline int security_socket_getsockopt(struct socket *sock, 1788 int level, int optname) 1789 { 1790 return 0; 1791 } 1792 1793 static inline int security_socket_setsockopt(struct socket *sock, 1794 int level, int optname) 1795 { 1796 return 0; 1797 } 1798 1799 static inline int security_socket_shutdown(struct socket *sock, int how) 1800 { 1801 return 0; 1802 } 1803 static inline int security_sock_rcv_skb(struct sock *sk, 1804 struct sk_buff *skb) 1805 { 1806 return 0; 1807 } 1808 1809 static inline int security_socket_getpeersec_stream(struct socket *sock, 1810 sockptr_t optval, 1811 sockptr_t optlen, 1812 unsigned int len) 1813 { 1814 return -ENOPROTOOPT; 1815 } 1816 1817 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid) 1818 { 1819 return -ENOPROTOOPT; 1820 } 1821 1822 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority) 1823 { 1824 return 0; 1825 } 1826 1827 static inline void security_sk_free(struct sock *sk) 1828 { 1829 } 1830 1831 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk) 1832 { 1833 } 1834 1835 static inline void security_sk_classify_flow(const struct sock *sk, 1836 struct flowi_common *flic) 1837 { 1838 } 1839 1840 static inline void security_req_classify_flow(const struct request_sock *req, 1841 struct flowi_common *flic) 1842 { 1843 } 1844 1845 static inline void security_sock_graft(struct sock *sk, struct socket *parent) 1846 { 1847 } 1848 1849 static inline int security_inet_conn_request(const struct sock *sk, 1850 struct sk_buff *skb, struct request_sock *req) 1851 { 1852 return 0; 1853 } 1854 1855 static inline void security_inet_csk_clone(struct sock *newsk, 1856 const struct request_sock *req) 1857 { 1858 } 1859 1860 static inline void security_inet_conn_established(struct sock *sk, 1861 struct sk_buff *skb) 1862 { 1863 } 1864 1865 static inline int security_secmark_relabel_packet(u32 secid) 1866 { 1867 return 0; 1868 } 1869 1870 static inline void security_secmark_refcount_inc(void) 1871 { 1872 } 1873 1874 static inline void security_secmark_refcount_dec(void) 1875 { 1876 } 1877 1878 static inline int security_tun_dev_alloc_security(void **security) 1879 { 1880 return 0; 1881 } 1882 1883 static inline void security_tun_dev_free_security(void *security) 1884 { 1885 } 1886 1887 static inline int security_tun_dev_create(void) 1888 { 1889 return 0; 1890 } 1891 1892 static inline int security_tun_dev_attach_queue(void *security) 1893 { 1894 return 0; 1895 } 1896 1897 static inline int security_tun_dev_attach(struct sock *sk, void *security) 1898 { 1899 return 0; 1900 } 1901 1902 static inline int security_tun_dev_open(void *security) 1903 { 1904 return 0; 1905 } 1906 1907 static inline int security_sctp_assoc_request(struct sctp_association *asoc, 1908 struct sk_buff *skb) 1909 { 1910 return 0; 1911 } 1912 1913 static inline int security_sctp_bind_connect(struct sock *sk, int optname, 1914 struct sockaddr *address, 1915 int addrlen) 1916 { 1917 return 0; 1918 } 1919 1920 static inline void security_sctp_sk_clone(struct sctp_association *asoc, 1921 struct sock *sk, 1922 struct sock *newsk) 1923 { 1924 } 1925 1926 static inline int security_sctp_assoc_established(struct sctp_association *asoc, 1927 struct sk_buff *skb) 1928 { 1929 return 0; 1930 } 1931 1932 static inline int security_mptcp_add_subflow(struct sock *sk, struct sock *ssk) 1933 { 1934 return 0; 1935 } 1936 #endif /* CONFIG_SECURITY_NETWORK */ 1937 1938 #ifdef CONFIG_SECURITY_INFINIBAND 1939 int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey); 1940 int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num); 1941 int security_ib_alloc_security(void **sec); 1942 void security_ib_free_security(void *sec); 1943 #else /* CONFIG_SECURITY_INFINIBAND */ 1944 static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey) 1945 { 1946 return 0; 1947 } 1948 1949 static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num) 1950 { 1951 return 0; 1952 } 1953 1954 static inline int security_ib_alloc_security(void **sec) 1955 { 1956 return 0; 1957 } 1958 1959 static inline void security_ib_free_security(void *sec) 1960 { 1961 } 1962 #endif /* CONFIG_SECURITY_INFINIBAND */ 1963 1964 #ifdef CONFIG_SECURITY_NETWORK_XFRM 1965 1966 int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, 1967 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp); 1968 int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp); 1969 void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx); 1970 int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx); 1971 int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx); 1972 int security_xfrm_state_alloc_acquire(struct xfrm_state *x, 1973 struct xfrm_sec_ctx *polsec, u32 secid); 1974 int security_xfrm_state_delete(struct xfrm_state *x); 1975 void security_xfrm_state_free(struct xfrm_state *x); 1976 int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid); 1977 int security_xfrm_state_pol_flow_match(struct xfrm_state *x, 1978 struct xfrm_policy *xp, 1979 const struct flowi_common *flic); 1980 int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid); 1981 void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic); 1982 1983 #else /* CONFIG_SECURITY_NETWORK_XFRM */ 1984 1985 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, 1986 struct xfrm_user_sec_ctx *sec_ctx, 1987 gfp_t gfp) 1988 { 1989 return 0; 1990 } 1991 1992 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp) 1993 { 1994 return 0; 1995 } 1996 1997 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx) 1998 { 1999 } 2000 2001 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx) 2002 { 2003 return 0; 2004 } 2005 2006 static inline int security_xfrm_state_alloc(struct xfrm_state *x, 2007 struct xfrm_user_sec_ctx *sec_ctx) 2008 { 2009 return 0; 2010 } 2011 2012 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x, 2013 struct xfrm_sec_ctx *polsec, u32 secid) 2014 { 2015 return 0; 2016 } 2017 2018 static inline void security_xfrm_state_free(struct xfrm_state *x) 2019 { 2020 } 2021 2022 static inline int security_xfrm_state_delete(struct xfrm_state *x) 2023 { 2024 return 0; 2025 } 2026 2027 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid) 2028 { 2029 return 0; 2030 } 2031 2032 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x, 2033 struct xfrm_policy *xp, 2034 const struct flowi_common *flic) 2035 { 2036 return 1; 2037 } 2038 2039 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid) 2040 { 2041 return 0; 2042 } 2043 2044 static inline void security_skb_classify_flow(struct sk_buff *skb, 2045 struct flowi_common *flic) 2046 { 2047 } 2048 2049 #endif /* CONFIG_SECURITY_NETWORK_XFRM */ 2050 2051 #ifdef CONFIG_SECURITY_PATH 2052 int security_path_unlink(const struct path *dir, struct dentry *dentry); 2053 int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode); 2054 int security_path_rmdir(const struct path *dir, struct dentry *dentry); 2055 int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode, 2056 unsigned int dev); 2057 void security_path_post_mknod(struct mnt_idmap *idmap, struct dentry *dentry); 2058 int security_path_truncate(const struct path *path); 2059 int security_path_symlink(const struct path *dir, struct dentry *dentry, 2060 const char *old_name); 2061 int security_path_link(struct dentry *old_dentry, const struct path *new_dir, 2062 struct dentry *new_dentry); 2063 int security_path_rename(const struct path *old_dir, struct dentry *old_dentry, 2064 const struct path *new_dir, struct dentry *new_dentry, 2065 unsigned int flags); 2066 int security_path_chmod(const struct path *path, umode_t mode); 2067 int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid); 2068 int security_path_chroot(const struct path *path); 2069 #else /* CONFIG_SECURITY_PATH */ 2070 static inline int security_path_unlink(const struct path *dir, struct dentry *dentry) 2071 { 2072 return 0; 2073 } 2074 2075 static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry, 2076 umode_t mode) 2077 { 2078 return 0; 2079 } 2080 2081 static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry) 2082 { 2083 return 0; 2084 } 2085 2086 static inline int security_path_mknod(const struct path *dir, struct dentry *dentry, 2087 umode_t mode, unsigned int dev) 2088 { 2089 return 0; 2090 } 2091 2092 static inline void security_path_post_mknod(struct mnt_idmap *idmap, 2093 struct dentry *dentry) 2094 { } 2095 2096 static inline int security_path_truncate(const struct path *path) 2097 { 2098 return 0; 2099 } 2100 2101 static inline int security_path_symlink(const struct path *dir, struct dentry *dentry, 2102 const char *old_name) 2103 { 2104 return 0; 2105 } 2106 2107 static inline int security_path_link(struct dentry *old_dentry, 2108 const struct path *new_dir, 2109 struct dentry *new_dentry) 2110 { 2111 return 0; 2112 } 2113 2114 static inline int security_path_rename(const struct path *old_dir, 2115 struct dentry *old_dentry, 2116 const struct path *new_dir, 2117 struct dentry *new_dentry, 2118 unsigned int flags) 2119 { 2120 return 0; 2121 } 2122 2123 static inline int security_path_chmod(const struct path *path, umode_t mode) 2124 { 2125 return 0; 2126 } 2127 2128 static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid) 2129 { 2130 return 0; 2131 } 2132 2133 static inline int security_path_chroot(const struct path *path) 2134 { 2135 return 0; 2136 } 2137 #endif /* CONFIG_SECURITY_PATH */ 2138 2139 #ifdef CONFIG_KEYS 2140 #ifdef CONFIG_SECURITY 2141 2142 int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags); 2143 void security_key_free(struct key *key); 2144 int security_key_permission(key_ref_t key_ref, const struct cred *cred, 2145 enum key_need_perm need_perm); 2146 int security_key_getsecurity(struct key *key, char **_buffer); 2147 void security_key_post_create_or_update(struct key *keyring, struct key *key, 2148 const void *payload, size_t payload_len, 2149 unsigned long flags, bool create); 2150 2151 #else 2152 2153 static inline int security_key_alloc(struct key *key, 2154 const struct cred *cred, 2155 unsigned long flags) 2156 { 2157 return 0; 2158 } 2159 2160 static inline void security_key_free(struct key *key) 2161 { 2162 } 2163 2164 static inline int security_key_permission(key_ref_t key_ref, 2165 const struct cred *cred, 2166 enum key_need_perm need_perm) 2167 { 2168 return 0; 2169 } 2170 2171 static inline int security_key_getsecurity(struct key *key, char **_buffer) 2172 { 2173 *_buffer = NULL; 2174 return 0; 2175 } 2176 2177 static inline void security_key_post_create_or_update(struct key *keyring, 2178 struct key *key, 2179 const void *payload, 2180 size_t payload_len, 2181 unsigned long flags, 2182 bool create) 2183 { } 2184 2185 #endif 2186 #endif /* CONFIG_KEYS */ 2187 2188 #ifdef CONFIG_AUDIT 2189 #ifdef CONFIG_SECURITY 2190 int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule, 2191 gfp_t gfp); 2192 int security_audit_rule_known(struct audit_krule *krule); 2193 int security_audit_rule_match(struct lsm_prop *prop, u32 field, u32 op, 2194 void *lsmrule); 2195 void security_audit_rule_free(void *lsmrule); 2196 2197 #else 2198 2199 static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr, 2200 void **lsmrule, gfp_t gfp) 2201 { 2202 return 0; 2203 } 2204 2205 static inline int security_audit_rule_known(struct audit_krule *krule) 2206 { 2207 return 0; 2208 } 2209 2210 static inline int security_audit_rule_match(struct lsm_prop *prop, u32 field, 2211 u32 op, void *lsmrule) 2212 { 2213 return 0; 2214 } 2215 2216 static inline void security_audit_rule_free(void *lsmrule) 2217 { } 2218 2219 #endif /* CONFIG_SECURITY */ 2220 #endif /* CONFIG_AUDIT */ 2221 2222 #ifdef CONFIG_SECURITYFS 2223 2224 extern struct dentry *securityfs_create_file(const char *name, umode_t mode, 2225 struct dentry *parent, void *data, 2226 const struct file_operations *fops); 2227 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent); 2228 struct dentry *securityfs_create_symlink(const char *name, 2229 struct dentry *parent, 2230 const char *target, 2231 const struct inode_operations *iops); 2232 extern void securityfs_remove(struct dentry *dentry); 2233 extern void securityfs_recursive_remove(struct dentry *dentry); 2234 2235 #else /* CONFIG_SECURITYFS */ 2236 2237 static inline struct dentry *securityfs_create_dir(const char *name, 2238 struct dentry *parent) 2239 { 2240 return ERR_PTR(-ENODEV); 2241 } 2242 2243 static inline struct dentry *securityfs_create_file(const char *name, 2244 umode_t mode, 2245 struct dentry *parent, 2246 void *data, 2247 const struct file_operations *fops) 2248 { 2249 return ERR_PTR(-ENODEV); 2250 } 2251 2252 static inline struct dentry *securityfs_create_symlink(const char *name, 2253 struct dentry *parent, 2254 const char *target, 2255 const struct inode_operations *iops) 2256 { 2257 return ERR_PTR(-ENODEV); 2258 } 2259 2260 static inline void securityfs_remove(struct dentry *dentry) 2261 {} 2262 2263 #endif 2264 2265 #ifdef CONFIG_BPF_SYSCALL 2266 union bpf_attr; 2267 struct bpf_map; 2268 struct bpf_prog; 2269 struct bpf_token; 2270 #ifdef CONFIG_SECURITY 2271 extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size); 2272 extern int security_bpf_map(struct bpf_map *map, fmode_t fmode); 2273 extern int security_bpf_prog(struct bpf_prog *prog); 2274 extern int security_bpf_map_create(struct bpf_map *map, union bpf_attr *attr, 2275 struct bpf_token *token); 2276 extern void security_bpf_map_free(struct bpf_map *map); 2277 extern int security_bpf_prog_load(struct bpf_prog *prog, union bpf_attr *attr, 2278 struct bpf_token *token); 2279 extern void security_bpf_prog_free(struct bpf_prog *prog); 2280 extern int security_bpf_token_create(struct bpf_token *token, union bpf_attr *attr, 2281 const struct path *path); 2282 extern void security_bpf_token_free(struct bpf_token *token); 2283 extern int security_bpf_token_cmd(const struct bpf_token *token, enum bpf_cmd cmd); 2284 extern int security_bpf_token_capable(const struct bpf_token *token, int cap); 2285 #else 2286 static inline int security_bpf(int cmd, union bpf_attr *attr, 2287 unsigned int size) 2288 { 2289 return 0; 2290 } 2291 2292 static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode) 2293 { 2294 return 0; 2295 } 2296 2297 static inline int security_bpf_prog(struct bpf_prog *prog) 2298 { 2299 return 0; 2300 } 2301 2302 static inline int security_bpf_map_create(struct bpf_map *map, union bpf_attr *attr, 2303 struct bpf_token *token) 2304 { 2305 return 0; 2306 } 2307 2308 static inline void security_bpf_map_free(struct bpf_map *map) 2309 { } 2310 2311 static inline int security_bpf_prog_load(struct bpf_prog *prog, union bpf_attr *attr, 2312 struct bpf_token *token) 2313 { 2314 return 0; 2315 } 2316 2317 static inline void security_bpf_prog_free(struct bpf_prog *prog) 2318 { } 2319 2320 static inline int security_bpf_token_create(struct bpf_token *token, union bpf_attr *attr, 2321 const struct path *path) 2322 { 2323 return 0; 2324 } 2325 2326 static inline void security_bpf_token_free(struct bpf_token *token) 2327 { } 2328 2329 static inline int security_bpf_token_cmd(const struct bpf_token *token, enum bpf_cmd cmd) 2330 { 2331 return 0; 2332 } 2333 2334 static inline int security_bpf_token_capable(const struct bpf_token *token, int cap) 2335 { 2336 return 0; 2337 } 2338 #endif /* CONFIG_SECURITY */ 2339 #endif /* CONFIG_BPF_SYSCALL */ 2340 2341 #ifdef CONFIG_PERF_EVENTS 2342 struct perf_event_attr; 2343 struct perf_event; 2344 2345 #ifdef CONFIG_SECURITY 2346 extern int security_perf_event_open(struct perf_event_attr *attr, int type); 2347 extern int security_perf_event_alloc(struct perf_event *event); 2348 extern void security_perf_event_free(struct perf_event *event); 2349 extern int security_perf_event_read(struct perf_event *event); 2350 extern int security_perf_event_write(struct perf_event *event); 2351 #else 2352 static inline int security_perf_event_open(struct perf_event_attr *attr, 2353 int type) 2354 { 2355 return 0; 2356 } 2357 2358 static inline int security_perf_event_alloc(struct perf_event *event) 2359 { 2360 return 0; 2361 } 2362 2363 static inline void security_perf_event_free(struct perf_event *event) 2364 { 2365 } 2366 2367 static inline int security_perf_event_read(struct perf_event *event) 2368 { 2369 return 0; 2370 } 2371 2372 static inline int security_perf_event_write(struct perf_event *event) 2373 { 2374 return 0; 2375 } 2376 #endif /* CONFIG_SECURITY */ 2377 #endif /* CONFIG_PERF_EVENTS */ 2378 2379 #ifdef CONFIG_IO_URING 2380 #ifdef CONFIG_SECURITY 2381 extern int security_uring_override_creds(const struct cred *new); 2382 extern int security_uring_sqpoll(void); 2383 extern int security_uring_cmd(struct io_uring_cmd *ioucmd); 2384 #else 2385 static inline int security_uring_override_creds(const struct cred *new) 2386 { 2387 return 0; 2388 } 2389 static inline int security_uring_sqpoll(void) 2390 { 2391 return 0; 2392 } 2393 static inline int security_uring_cmd(struct io_uring_cmd *ioucmd) 2394 { 2395 return 0; 2396 } 2397 #endif /* CONFIG_SECURITY */ 2398 #endif /* CONFIG_IO_URING */ 2399 2400 #ifdef CONFIG_SECURITY 2401 extern void security_initramfs_populated(void); 2402 #else 2403 static inline void security_initramfs_populated(void) 2404 { 2405 } 2406 #endif /* CONFIG_SECURITY */ 2407 2408 #endif /* ! __LINUX_SECURITY_H */ 2409