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