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