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