1 /* 2 * Linux Security Module interfaces 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) 2015 Intel Corporation. 10 * Copyright (C) 2015 Casey Schaufler <casey@schaufler-ca.com> 11 * Copyright (C) 2016 Mellanox Techonologies 12 * 13 * This program is free software; you can redistribute it and/or modify 14 * it under the terms of the GNU General Public License as published by 15 * the Free Software Foundation; either version 2 of the License, or 16 * (at your option) any later version. 17 * 18 * Due to this file being licensed under the GPL there is controversy over 19 * whether this permits you to write a module that #includes this file 20 * without placing your module under the GPL. Please consult a lawyer for 21 * advice before doing this. 22 * 23 */ 24 25 #ifndef __LINUX_LSM_HOOKS_H 26 #define __LINUX_LSM_HOOKS_H 27 28 #include <linux/security.h> 29 #include <linux/init.h> 30 #include <linux/rculist.h> 31 32 /** 33 * union security_list_options - Linux Security Module hook function list 34 * 35 * Security hooks for program execution operations. 36 * 37 * @bprm_set_creds: 38 * Save security information in the bprm->security field, typically based 39 * on information about the bprm->file, for later use by the apply_creds 40 * hook. This hook may also optionally check permissions (e.g. for 41 * transitions between security domains). 42 * This hook may be called multiple times during a single execve, e.g. for 43 * interpreters. The hook can tell whether it has already been called by 44 * checking to see if @bprm->security is non-NULL. If so, then the hook 45 * may decide either to retain the security information saved earlier or 46 * to replace it. The hook must set @bprm->secureexec to 1 if a "secure 47 * exec" has happened as a result of this hook call. The flag is used to 48 * indicate the need for a sanitized execution environment, and is also 49 * passed in the ELF auxiliary table on the initial stack to indicate 50 * whether libc should enable secure mode. 51 * @bprm contains the linux_binprm structure. 52 * Return 0 if the hook is successful and permission is granted. 53 * @bprm_check_security: 54 * This hook mediates the point when a search for a binary handler will 55 * begin. It allows a check the @bprm->security value which is set in the 56 * preceding set_creds call. The primary difference from set_creds is 57 * that the argv list and envp list are reliably available in @bprm. This 58 * hook may be called multiple times during a single execve; and in each 59 * pass set_creds is called first. 60 * @bprm contains the linux_binprm structure. 61 * Return 0 if the hook is successful and permission is granted. 62 * @bprm_committing_creds: 63 * Prepare to install the new security attributes of a process being 64 * transformed by an execve operation, based on the old credentials 65 * pointed to by @current->cred and the information set in @bprm->cred by 66 * the bprm_set_creds hook. @bprm points to the linux_binprm structure. 67 * This hook is a good place to perform state changes on the process such 68 * as closing open file descriptors to which access will no longer be 69 * granted when the attributes are changed. This is called immediately 70 * before commit_creds(). 71 * @bprm_committed_creds: 72 * Tidy up after the installation of the new security attributes of a 73 * process being transformed by an execve operation. The new credentials 74 * have, by this point, been set to @current->cred. @bprm points to the 75 * linux_binprm structure. This hook is a good place to perform state 76 * changes on the process such as clearing out non-inheritable signal 77 * state. This is called immediately after commit_creds(). 78 * 79 * Security hooks for mount using fs_context. 80 * [See also Documentation/filesystems/mount_api.txt] 81 * 82 * @fs_context_dup: 83 * Allocate and attach a security structure to sc->security. This pointer 84 * is initialised to NULL by the caller. 85 * @fc indicates the new filesystem context. 86 * @src_fc indicates the original filesystem context. 87 * @fs_context_parse_param: 88 * Userspace provided a parameter to configure a superblock. The LSM may 89 * reject it with an error and may use it for itself, in which case it 90 * should return 0; otherwise it should return -ENOPARAM to pass it on to 91 * the filesystem. 92 * @fc indicates the filesystem context. 93 * @param The parameter 94 * 95 * Security hooks for filesystem operations. 96 * 97 * @sb_alloc_security: 98 * Allocate and attach a security structure to the sb->s_security field. 99 * The s_security field is initialized to NULL when the structure is 100 * allocated. 101 * @sb contains the super_block structure to be modified. 102 * Return 0 if operation was successful. 103 * @sb_free_security: 104 * Deallocate and clear the sb->s_security field. 105 * @sb contains the super_block structure to be modified. 106 * @sb_statfs: 107 * Check permission before obtaining filesystem statistics for the @mnt 108 * mountpoint. 109 * @dentry is a handle on the superblock for the filesystem. 110 * Return 0 if permission is granted. 111 * @sb_mount: 112 * Check permission before an object specified by @dev_name is mounted on 113 * the mount point named by @nd. For an ordinary mount, @dev_name 114 * identifies a device if the file system type requires a device. For a 115 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a 116 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the 117 * pathname of the object being mounted. 118 * @dev_name contains the name for object being mounted. 119 * @path contains the path for mount point object. 120 * @type contains the filesystem type. 121 * @flags contains the mount flags. 122 * @data contains the filesystem-specific data. 123 * Return 0 if permission is granted. 124 * @sb_copy_data: 125 * Allow mount option data to be copied prior to parsing by the filesystem, 126 * so that the security module can extract security-specific mount 127 * options cleanly (a filesystem may modify the data e.g. with strsep()). 128 * This also allows the original mount data to be stripped of security- 129 * specific options to avoid having to make filesystems aware of them. 130 * @orig the original mount data copied from userspace. 131 * @copy copied data which will be passed to the security module. 132 * Returns 0 if the copy was successful. 133 * @sb_remount: 134 * Extracts security system specific mount options and verifies no changes 135 * are being made to those options. 136 * @sb superblock being remounted 137 * @data contains the filesystem-specific data. 138 * Return 0 if permission is granted. 139 * @sb_umount: 140 * Check permission before the @mnt file system is unmounted. 141 * @mnt contains the mounted file system. 142 * @flags contains the unmount flags, e.g. MNT_FORCE. 143 * Return 0 if permission is granted. 144 * @sb_pivotroot: 145 * Check permission before pivoting the root filesystem. 146 * @old_path contains the path for the new location of the 147 * current root (put_old). 148 * @new_path contains the path for the new root (new_root). 149 * Return 0 if permission is granted. 150 * @sb_set_mnt_opts: 151 * Set the security relevant mount options used for a superblock 152 * @sb the superblock to set security mount options for 153 * @opts binary data structure containing all lsm mount data 154 * @sb_clone_mnt_opts: 155 * Copy all security options from a given superblock to another 156 * @oldsb old superblock which contain information to clone 157 * @newsb new superblock which needs filled in 158 * @sb_parse_opts_str: 159 * Parse a string of security data filling in the opts structure 160 * @options string containing all mount options known by the LSM 161 * @opts binary data structure usable by the LSM 162 * @move_mount: 163 * Check permission before a mount is moved. 164 * @from_path indicates the mount that is going to be moved. 165 * @to_path indicates the mountpoint that will be mounted upon. 166 * @dentry_init_security: 167 * Compute a context for a dentry as the inode is not yet available 168 * since NFSv4 has no label backed by an EA anyway. 169 * @dentry dentry to use in calculating the context. 170 * @mode mode used to determine resource type. 171 * @name name of the last path component used to create file 172 * @ctx pointer to place the pointer to the resulting context in. 173 * @ctxlen point to place the length of the resulting context. 174 * @dentry_create_files_as: 175 * Compute a context for a dentry as the inode is not yet available 176 * and set that context in passed in creds so that new files are 177 * created using that context. Context is calculated using the 178 * passed in creds and not the creds of the caller. 179 * @dentry dentry to use in calculating the context. 180 * @mode mode used to determine resource type. 181 * @name name of the last path component used to create file 182 * @old creds which should be used for context calculation 183 * @new creds to modify 184 * 185 * 186 * Security hooks for inode operations. 187 * 188 * @inode_alloc_security: 189 * Allocate and attach a security structure to @inode->i_security. The 190 * i_security field is initialized to NULL when the inode structure is 191 * allocated. 192 * @inode contains the inode structure. 193 * Return 0 if operation was successful. 194 * @inode_free_security: 195 * @inode contains the inode structure. 196 * Deallocate the inode security structure and set @inode->i_security to 197 * NULL. 198 * @inode_init_security: 199 * Obtain the security attribute name suffix and value to set on a newly 200 * created inode and set up the incore security field for the new inode. 201 * This hook is called by the fs code as part of the inode creation 202 * transaction and provides for atomic labeling of the inode, unlike 203 * the post_create/mkdir/... hooks called by the VFS. The hook function 204 * is expected to allocate the name and value via kmalloc, with the caller 205 * being responsible for calling kfree after using them. 206 * If the security module does not use security attributes or does 207 * not wish to put a security attribute on this particular inode, 208 * then it should return -EOPNOTSUPP to skip this processing. 209 * @inode contains the inode structure of the newly created inode. 210 * @dir contains the inode structure of the parent directory. 211 * @qstr contains the last path component of the new object 212 * @name will be set to the allocated name suffix (e.g. selinux). 213 * @value will be set to the allocated attribute value. 214 * @len will be set to the length of the value. 215 * Returns 0 if @name and @value have been successfully set, 216 * -EOPNOTSUPP if no security attribute is needed, or 217 * -ENOMEM on memory allocation failure. 218 * @inode_create: 219 * Check permission to create a regular file. 220 * @dir contains inode structure of the parent of the new file. 221 * @dentry contains the dentry structure for the file to be created. 222 * @mode contains the file mode of the file to be created. 223 * Return 0 if permission is granted. 224 * @inode_link: 225 * Check permission before creating a new hard link to a file. 226 * @old_dentry contains the dentry structure for an existing 227 * link to the file. 228 * @dir contains the inode structure of the parent directory 229 * of the new link. 230 * @new_dentry contains the dentry structure for the new link. 231 * Return 0 if permission is granted. 232 * @path_link: 233 * Check permission before creating a new hard link to a file. 234 * @old_dentry contains the dentry structure for an existing link 235 * to the file. 236 * @new_dir contains the path structure of the parent directory of 237 * the new link. 238 * @new_dentry contains the dentry structure for the new link. 239 * Return 0 if permission is granted. 240 * @inode_unlink: 241 * Check the permission to remove a hard link to a file. 242 * @dir contains the inode structure of parent directory of the file. 243 * @dentry contains the dentry structure for file to be unlinked. 244 * Return 0 if permission is granted. 245 * @path_unlink: 246 * Check the permission to remove a hard link to a file. 247 * @dir contains the path structure of parent directory of the file. 248 * @dentry contains the dentry structure for file to be unlinked. 249 * Return 0 if permission is granted. 250 * @inode_symlink: 251 * Check the permission to create a symbolic link to a file. 252 * @dir contains the inode structure of parent directory of 253 * the symbolic link. 254 * @dentry contains the dentry structure of the symbolic link. 255 * @old_name contains the pathname of file. 256 * Return 0 if permission is granted. 257 * @path_symlink: 258 * Check the permission to create a symbolic link to a file. 259 * @dir contains the path structure of parent directory of 260 * the symbolic link. 261 * @dentry contains the dentry structure of the symbolic link. 262 * @old_name contains the pathname of file. 263 * Return 0 if permission is granted. 264 * @inode_mkdir: 265 * Check permissions to create a new directory in the existing directory 266 * associated with inode structure @dir. 267 * @dir contains the inode structure of parent of the directory 268 * to be created. 269 * @dentry contains the dentry structure of new directory. 270 * @mode contains the mode of new directory. 271 * Return 0 if permission is granted. 272 * @path_mkdir: 273 * Check permissions to create a new directory in the existing directory 274 * associated with path structure @path. 275 * @dir contains the path structure of parent of the directory 276 * to be created. 277 * @dentry contains the dentry structure of new directory. 278 * @mode contains the mode of new directory. 279 * Return 0 if permission is granted. 280 * @inode_rmdir: 281 * Check the permission to remove a directory. 282 * @dir contains the inode structure of parent of the directory 283 * to be removed. 284 * @dentry contains the dentry structure of directory to be removed. 285 * Return 0 if permission is granted. 286 * @path_rmdir: 287 * Check the permission to remove a directory. 288 * @dir contains the path structure of parent of the directory to be 289 * removed. 290 * @dentry contains the dentry structure of directory to be removed. 291 * Return 0 if permission is granted. 292 * @inode_mknod: 293 * Check permissions when creating a special file (or a socket or a fifo 294 * file created via the mknod system call). Note that if mknod operation 295 * is being done for a regular file, then the create hook will be called 296 * and not this hook. 297 * @dir contains the inode structure of parent of the new file. 298 * @dentry contains the dentry structure of the new file. 299 * @mode contains the mode of the new file. 300 * @dev contains the device number. 301 * Return 0 if permission is granted. 302 * @path_mknod: 303 * Check permissions when creating a file. Note that this hook is called 304 * even if mknod operation is being done for a regular file. 305 * @dir contains the path structure of parent of the new file. 306 * @dentry contains the dentry structure of the new file. 307 * @mode contains the mode of the new file. 308 * @dev contains the undecoded device number. Use new_decode_dev() to get 309 * the decoded device number. 310 * Return 0 if permission is granted. 311 * @inode_rename: 312 * Check for permission to rename a file or directory. 313 * @old_dir contains the inode structure for parent of the old link. 314 * @old_dentry contains the dentry structure of the old link. 315 * @new_dir contains the inode structure for parent of the new link. 316 * @new_dentry contains the dentry structure of the new link. 317 * Return 0 if permission is granted. 318 * @path_rename: 319 * Check for permission to rename a file or directory. 320 * @old_dir contains the path structure for parent of the old link. 321 * @old_dentry contains the dentry structure of the old link. 322 * @new_dir contains the path structure for parent of the new link. 323 * @new_dentry contains the dentry structure of the new link. 324 * Return 0 if permission is granted. 325 * @path_chmod: 326 * Check for permission to change a mode of the file @path. The new 327 * mode is specified in @mode. 328 * @path contains the path structure of the file to change the mode. 329 * @mode contains the new DAC's permission, which is a bitmask of 330 * constants from <include/uapi/linux/stat.h> 331 * Return 0 if permission is granted. 332 * @path_chown: 333 * Check for permission to change owner/group of a file or directory. 334 * @path contains the path structure. 335 * @uid contains new owner's ID. 336 * @gid contains new group's ID. 337 * Return 0 if permission is granted. 338 * @path_chroot: 339 * Check for permission to change root directory. 340 * @path contains the path structure. 341 * Return 0 if permission is granted. 342 * @path_notify: 343 * Check permissions before setting a watch on events as defined by @mask, 344 * on an object at @path, whose type is defined by @obj_type. 345 * @inode_readlink: 346 * Check the permission to read the symbolic link. 347 * @dentry contains the dentry structure for the file link. 348 * Return 0 if permission is granted. 349 * @inode_follow_link: 350 * Check permission to follow a symbolic link when looking up a pathname. 351 * @dentry contains the dentry structure for the link. 352 * @inode contains the inode, which itself is not stable in RCU-walk 353 * @rcu indicates whether we are in RCU-walk mode. 354 * Return 0 if permission is granted. 355 * @inode_permission: 356 * Check permission before accessing an inode. This hook is called by the 357 * existing Linux permission function, so a security module can use it to 358 * provide additional checking for existing Linux permission checks. 359 * Notice that this hook is called when a file is opened (as well as many 360 * other operations), whereas the file_security_ops permission hook is 361 * called when the actual read/write operations are performed. 362 * @inode contains the inode structure to check. 363 * @mask contains the permission mask. 364 * Return 0 if permission is granted. 365 * @inode_setattr: 366 * Check permission before setting file attributes. Note that the kernel 367 * call to notify_change is performed from several locations, whenever 368 * file attributes change (such as when a file is truncated, chown/chmod 369 * operations, transferring disk quotas, etc). 370 * @dentry contains the dentry structure for the file. 371 * @attr is the iattr structure containing the new file attributes. 372 * Return 0 if permission is granted. 373 * @path_truncate: 374 * Check permission before truncating a file. 375 * @path contains the path structure for the file. 376 * Return 0 if permission is granted. 377 * @inode_getattr: 378 * Check permission before obtaining file attributes. 379 * @path contains the path structure for the file. 380 * Return 0 if permission is granted. 381 * @inode_setxattr: 382 * Check permission before setting the extended attributes 383 * @value identified by @name for @dentry. 384 * Return 0 if permission is granted. 385 * @inode_post_setxattr: 386 * Update inode security field after successful setxattr operation. 387 * @value identified by @name for @dentry. 388 * @inode_getxattr: 389 * Check permission before obtaining the extended attributes 390 * identified by @name for @dentry. 391 * Return 0 if permission is granted. 392 * @inode_listxattr: 393 * Check permission before obtaining the list of extended attribute 394 * names for @dentry. 395 * Return 0 if permission is granted. 396 * @inode_removexattr: 397 * Check permission before removing the extended attribute 398 * identified by @name for @dentry. 399 * Return 0 if permission is granted. 400 * @inode_getsecurity: 401 * Retrieve a copy of the extended attribute representation of the 402 * security label associated with @name for @inode via @buffer. Note that 403 * @name is the remainder of the attribute name after the security prefix 404 * has been removed. @alloc is used to specify of the call should return a 405 * value via the buffer or just the value length Return size of buffer on 406 * success. 407 * @inode_setsecurity: 408 * Set the security label associated with @name for @inode from the 409 * extended attribute value @value. @size indicates the size of the 410 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0. 411 * Note that @name is the remainder of the attribute name after the 412 * security. prefix has been removed. 413 * Return 0 on success. 414 * @inode_listsecurity: 415 * Copy the extended attribute names for the security labels 416 * associated with @inode into @buffer. The maximum size of @buffer 417 * is specified by @buffer_size. @buffer may be NULL to request 418 * the size of the buffer required. 419 * Returns number of bytes used/required on success. 420 * @inode_need_killpriv: 421 * Called when an inode has been changed. 422 * @dentry is the dentry being changed. 423 * Return <0 on error to abort the inode change operation. 424 * Return 0 if inode_killpriv does not need to be called. 425 * Return >0 if inode_killpriv does need to be called. 426 * @inode_killpriv: 427 * The setuid bit is being removed. Remove similar security labels. 428 * Called with the dentry->d_inode->i_mutex held. 429 * @dentry is the dentry being changed. 430 * Return 0 on success. If error is returned, then the operation 431 * causing setuid bit removal is failed. 432 * @inode_getsecid: 433 * Get the secid associated with the node. 434 * @inode contains a pointer to the inode. 435 * @secid contains a pointer to the location where result will be saved. 436 * In case of failure, @secid will be set to zero. 437 * @inode_copy_up: 438 * A file is about to be copied up from lower layer to upper layer of 439 * overlay filesystem. Security module can prepare a set of new creds 440 * and modify as need be and return new creds. Caller will switch to 441 * new creds temporarily to create new file and release newly allocated 442 * creds. 443 * @src indicates the union dentry of file that is being copied up. 444 * @new pointer to pointer to return newly allocated creds. 445 * Returns 0 on success or a negative error code on error. 446 * @inode_copy_up_xattr: 447 * Filter the xattrs being copied up when a unioned file is copied 448 * up from a lower layer to the union/overlay layer. 449 * @name indicates the name of the xattr. 450 * Returns 0 to accept the xattr, 1 to discard the xattr, -EOPNOTSUPP if 451 * security module does not know about attribute or a negative error code 452 * to abort the copy up. Note that the caller is responsible for reading 453 * and writing the xattrs as this hook is merely a filter. 454 * 455 * Security hooks for kernfs node operations 456 * 457 * @kernfs_init_security: 458 * Initialize the security context of a newly created kernfs node based 459 * on its own and its parent's attributes. 460 * 461 * @kn_dir the parent kernfs node 462 * @kn the new child kernfs node 463 * 464 * Security hooks for file operations 465 * 466 * @file_permission: 467 * Check file permissions before accessing an open file. This hook is 468 * called by various operations that read or write files. A security 469 * module can use this hook to perform additional checking on these 470 * operations, e.g. to revalidate permissions on use to support privilege 471 * bracketing or policy changes. Notice that this hook is used when the 472 * actual read/write operations are performed, whereas the 473 * inode_security_ops hook is called when a file is opened (as well as 474 * many other operations). 475 * Caveat: Although this hook can be used to revalidate permissions for 476 * various system call operations that read or write files, it does not 477 * address the revalidation of permissions for memory-mapped files. 478 * Security modules must handle this separately if they need such 479 * revalidation. 480 * @file contains the file structure being accessed. 481 * @mask contains the requested permissions. 482 * Return 0 if permission is granted. 483 * @file_alloc_security: 484 * Allocate and attach a security structure to the file->f_security field. 485 * The security field is initialized to NULL when the structure is first 486 * created. 487 * @file contains the file structure to secure. 488 * Return 0 if the hook is successful and permission is granted. 489 * @file_free_security: 490 * Deallocate and free any security structures stored in file->f_security. 491 * @file contains the file structure being modified. 492 * @file_ioctl: 493 * @file contains the file structure. 494 * @cmd contains the operation to perform. 495 * @arg contains the operational arguments. 496 * Check permission for an ioctl operation on @file. Note that @arg 497 * sometimes represents a user space pointer; in other cases, it may be a 498 * simple integer value. When @arg represents a user space pointer, it 499 * should never be used by the security module. 500 * Return 0 if permission is granted. 501 * @mmap_addr : 502 * Check permissions for a mmap operation at @addr. 503 * @addr contains virtual address that will be used for the operation. 504 * Return 0 if permission is granted. 505 * @mmap_file : 506 * Check permissions for a mmap operation. The @file may be NULL, e.g. 507 * if mapping anonymous memory. 508 * @file contains the file structure for file to map (may be NULL). 509 * @reqprot contains the protection requested by the application. 510 * @prot contains the protection that will be applied by the kernel. 511 * @flags contains the operational flags. 512 * Return 0 if permission is granted. 513 * @file_mprotect: 514 * Check permissions before changing memory access permissions. 515 * @vma contains the memory region to modify. 516 * @reqprot contains the protection requested by the application. 517 * @prot contains the protection that will be applied by the kernel. 518 * Return 0 if permission is granted. 519 * @file_lock: 520 * Check permission before performing file locking operations. 521 * Note the hook mediates both flock and fcntl style locks. 522 * @file contains the file structure. 523 * @cmd contains the posix-translated lock operation to perform 524 * (e.g. F_RDLCK, F_WRLCK). 525 * Return 0 if permission is granted. 526 * @file_fcntl: 527 * Check permission before allowing the file operation specified by @cmd 528 * from being performed on the file @file. Note that @arg sometimes 529 * represents a user space pointer; in other cases, it may be a simple 530 * integer value. When @arg represents a user space pointer, it should 531 * never be used by the security module. 532 * @file contains the file structure. 533 * @cmd contains the operation to be performed. 534 * @arg contains the operational arguments. 535 * Return 0 if permission is granted. 536 * @file_set_fowner: 537 * Save owner security information (typically from current->security) in 538 * file->f_security for later use by the send_sigiotask hook. 539 * @file contains the file structure to update. 540 * Return 0 on success. 541 * @file_send_sigiotask: 542 * Check permission for the file owner @fown to send SIGIO or SIGURG to the 543 * process @tsk. Note that this hook is sometimes called from interrupt. 544 * Note that the fown_struct, @fown, is never outside the context of a 545 * struct file, so the file structure (and associated security information) 546 * can always be obtained: container_of(fown, struct file, f_owner) 547 * @tsk contains the structure of task receiving signal. 548 * @fown contains the file owner information. 549 * @sig is the signal that will be sent. When 0, kernel sends SIGIO. 550 * Return 0 if permission is granted. 551 * @file_receive: 552 * This hook allows security modules to control the ability of a process 553 * to receive an open file descriptor via socket IPC. 554 * @file contains the file structure being received. 555 * Return 0 if permission is granted. 556 * @file_open: 557 * Save open-time permission checking state for later use upon 558 * file_permission, and recheck access if anything has changed 559 * since inode_permission. 560 * 561 * Security hooks for task operations. 562 * 563 * @task_alloc: 564 * @task task being allocated. 565 * @clone_flags contains the flags indicating what should be shared. 566 * Handle allocation of task-related resources. 567 * Returns a zero on success, negative values on failure. 568 * @task_free: 569 * @task task about to be freed. 570 * Handle release of task-related resources. (Note that this can be called 571 * from interrupt context.) 572 * @cred_alloc_blank: 573 * @cred points to the credentials. 574 * @gfp indicates the atomicity of any memory allocations. 575 * Only allocate sufficient memory and attach to @cred such that 576 * cred_transfer() will not get ENOMEM. 577 * @cred_free: 578 * @cred points to the credentials. 579 * Deallocate and clear the cred->security field in a set of credentials. 580 * @cred_prepare: 581 * @new points to the new credentials. 582 * @old points to the original credentials. 583 * @gfp indicates the atomicity of any memory allocations. 584 * Prepare a new set of credentials by copying the data from the old set. 585 * @cred_transfer: 586 * @new points to the new credentials. 587 * @old points to the original credentials. 588 * Transfer data from original creds to new creds 589 * @cred_getsecid: 590 * Retrieve the security identifier of the cred structure @c 591 * @c contains the credentials, secid will be placed into @secid. 592 * In case of failure, @secid will be set to zero. 593 * @kernel_act_as: 594 * Set the credentials for a kernel service to act as (subjective context). 595 * @new points to the credentials to be modified. 596 * @secid specifies the security ID to be set 597 * The current task must be the one that nominated @secid. 598 * Return 0 if successful. 599 * @kernel_create_files_as: 600 * Set the file creation context in a set of credentials to be the same as 601 * the objective context of the specified inode. 602 * @new points to the credentials to be modified. 603 * @inode points to the inode to use as a reference. 604 * The current task must be the one that nominated @inode. 605 * Return 0 if successful. 606 * @kernel_module_request: 607 * Ability to trigger the kernel to automatically upcall to userspace for 608 * userspace to load a kernel module with the given name. 609 * @kmod_name name of the module requested by the kernel 610 * Return 0 if successful. 611 * @kernel_load_data: 612 * Load data provided by userspace. 613 * @id kernel load data identifier 614 * Return 0 if permission is granted. 615 * @kernel_read_file: 616 * Read a file specified by userspace. 617 * @file contains the file structure pointing to the file being read 618 * by the kernel. 619 * @id kernel read file identifier 620 * Return 0 if permission is granted. 621 * @kernel_post_read_file: 622 * Read a file specified by userspace. 623 * @file contains the file structure pointing to the file being read 624 * by the kernel. 625 * @buf pointer to buffer containing the file contents. 626 * @size length of the file contents. 627 * @id kernel read file identifier 628 * Return 0 if permission is granted. 629 * @task_fix_setuid: 630 * Update the module's state after setting one or more of the user 631 * identity attributes of the current process. The @flags parameter 632 * indicates which of the set*uid system calls invoked this hook. If 633 * @new is the set of credentials that will be installed. Modifications 634 * should be made to this rather than to @current->cred. 635 * @old is the set of credentials that are being replaces 636 * @flags contains one of the LSM_SETID_* values. 637 * Return 0 on success. 638 * @task_setpgid: 639 * Check permission before setting the process group identifier of the 640 * process @p to @pgid. 641 * @p contains the task_struct for process being modified. 642 * @pgid contains the new pgid. 643 * Return 0 if permission is granted. 644 * @task_getpgid: 645 * Check permission before getting the process group identifier of the 646 * process @p. 647 * @p contains the task_struct for the process. 648 * Return 0 if permission is granted. 649 * @task_getsid: 650 * Check permission before getting the session identifier of the process 651 * @p. 652 * @p contains the task_struct for the process. 653 * Return 0 if permission is granted. 654 * @task_getsecid: 655 * Retrieve the security identifier of the process @p. 656 * @p contains the task_struct for the process and place is into @secid. 657 * In case of failure, @secid will be set to zero. 658 * 659 * @task_setnice: 660 * Check permission before setting the nice value of @p to @nice. 661 * @p contains the task_struct of process. 662 * @nice contains the new nice value. 663 * Return 0 if permission is granted. 664 * @task_setioprio: 665 * Check permission before setting the ioprio value of @p to @ioprio. 666 * @p contains the task_struct of process. 667 * @ioprio contains the new ioprio value 668 * Return 0 if permission is granted. 669 * @task_getioprio: 670 * Check permission before getting the ioprio value of @p. 671 * @p contains the task_struct of process. 672 * Return 0 if permission is granted. 673 * @task_prlimit: 674 * Check permission before getting and/or setting the resource limits of 675 * another task. 676 * @cred points to the cred structure for the current task. 677 * @tcred points to the cred structure for the target task. 678 * @flags contains the LSM_PRLIMIT_* flag bits indicating whether the 679 * resource limits are being read, modified, or both. 680 * Return 0 if permission is granted. 681 * @task_setrlimit: 682 * Check permission before setting the resource limits of process @p 683 * for @resource to @new_rlim. The old resource limit values can 684 * be examined by dereferencing (p->signal->rlim + resource). 685 * @p points to the task_struct for the target task's group leader. 686 * @resource contains the resource whose limit is being set. 687 * @new_rlim contains the new limits for @resource. 688 * Return 0 if permission is granted. 689 * @task_setscheduler: 690 * Check permission before setting scheduling policy and/or parameters of 691 * process @p. 692 * @p contains the task_struct for process. 693 * Return 0 if permission is granted. 694 * @task_getscheduler: 695 * Check permission before obtaining scheduling information for process 696 * @p. 697 * @p contains the task_struct for process. 698 * Return 0 if permission is granted. 699 * @task_movememory: 700 * Check permission before moving memory owned by process @p. 701 * @p contains the task_struct for process. 702 * Return 0 if permission is granted. 703 * @task_kill: 704 * Check permission before sending signal @sig to @p. @info can be NULL, 705 * the constant 1, or a pointer to a kernel_siginfo structure. If @info is 1 or 706 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming 707 * from the kernel and should typically be permitted. 708 * SIGIO signals are handled separately by the send_sigiotask hook in 709 * file_security_ops. 710 * @p contains the task_struct for process. 711 * @info contains the signal information. 712 * @sig contains the signal value. 713 * @cred contains the cred of the process where the signal originated, or 714 * NULL if the current task is the originator. 715 * Return 0 if permission is granted. 716 * @task_prctl: 717 * Check permission before performing a process control operation on the 718 * current process. 719 * @option contains the operation. 720 * @arg2 contains a argument. 721 * @arg3 contains a argument. 722 * @arg4 contains a argument. 723 * @arg5 contains a argument. 724 * Return -ENOSYS if no-one wanted to handle this op, any other value to 725 * cause prctl() to return immediately with that value. 726 * @task_to_inode: 727 * Set the security attributes for an inode based on an associated task's 728 * security attributes, e.g. for /proc/pid inodes. 729 * @p contains the task_struct for the task. 730 * @inode contains the inode structure for the inode. 731 * 732 * Security hooks for Netlink messaging. 733 * 734 * @netlink_send: 735 * Save security information for a netlink message so that permission 736 * checking can be performed when the message is processed. The security 737 * information can be saved using the eff_cap field of the 738 * netlink_skb_parms structure. Also may be used to provide fine 739 * grained control over message transmission. 740 * @sk associated sock of task sending the message. 741 * @skb contains the sk_buff structure for the netlink message. 742 * Return 0 if the information was successfully saved and message 743 * is allowed to be transmitted. 744 * 745 * Security hooks for Unix domain networking. 746 * 747 * @unix_stream_connect: 748 * Check permissions before establishing a Unix domain stream connection 749 * between @sock and @other. 750 * @sock contains the sock structure. 751 * @other contains the peer sock structure. 752 * @newsk contains the new sock structure. 753 * Return 0 if permission is granted. 754 * @unix_may_send: 755 * Check permissions before connecting or sending datagrams from @sock to 756 * @other. 757 * @sock contains the socket structure. 758 * @other contains the peer socket structure. 759 * Return 0 if permission is granted. 760 * 761 * The @unix_stream_connect and @unix_may_send hooks were necessary because 762 * Linux provides an alternative to the conventional file name space for Unix 763 * domain sockets. Whereas binding and connecting to sockets in the file name 764 * space is mediated by the typical file permissions (and caught by the mknod 765 * and permission hooks in inode_security_ops), binding and connecting to 766 * sockets in the abstract name space is completely unmediated. Sufficient 767 * control of Unix domain sockets in the abstract name space isn't possible 768 * using only the socket layer hooks, since we need to know the actual target 769 * socket, which is not looked up until we are inside the af_unix code. 770 * 771 * Security hooks for socket operations. 772 * 773 * @socket_create: 774 * Check permissions prior to creating a new socket. 775 * @family contains the requested protocol family. 776 * @type contains the requested communications type. 777 * @protocol contains the requested protocol. 778 * @kern set to 1 if a kernel socket. 779 * Return 0 if permission is granted. 780 * @socket_post_create: 781 * This hook allows a module to update or allocate a per-socket security 782 * structure. Note that the security field was not added directly to the 783 * socket structure, but rather, the socket security information is stored 784 * in the associated inode. Typically, the inode alloc_security hook will 785 * allocate and and attach security information to 786 * SOCK_INODE(sock)->i_security. This hook may be used to update the 787 * SOCK_INODE(sock)->i_security field with additional information that 788 * wasn't available when the inode was allocated. 789 * @sock contains the newly created socket structure. 790 * @family contains the requested protocol family. 791 * @type contains the requested communications type. 792 * @protocol contains the requested protocol. 793 * @kern set to 1 if a kernel socket. 794 * @socket_socketpair: 795 * Check permissions before creating a fresh pair of sockets. 796 * @socka contains the first socket structure. 797 * @sockb contains the second socket structure. 798 * Return 0 if permission is granted and the connection was established. 799 * @socket_bind: 800 * Check permission before socket protocol layer bind operation is 801 * performed and the socket @sock is bound to the address specified in the 802 * @address parameter. 803 * @sock contains the socket structure. 804 * @address contains the address to bind to. 805 * @addrlen contains the length of address. 806 * Return 0 if permission is granted. 807 * @socket_connect: 808 * Check permission before socket protocol layer connect operation 809 * attempts to connect socket @sock to a remote address, @address. 810 * @sock contains the socket structure. 811 * @address contains the address of remote endpoint. 812 * @addrlen contains the length of address. 813 * Return 0 if permission is granted. 814 * @socket_listen: 815 * Check permission before socket protocol layer listen operation. 816 * @sock contains the socket structure. 817 * @backlog contains the maximum length for the pending connection queue. 818 * Return 0 if permission is granted. 819 * @socket_accept: 820 * Check permission before accepting a new connection. Note that the new 821 * socket, @newsock, has been created and some information copied to it, 822 * but the accept operation has not actually been performed. 823 * @sock contains the listening socket structure. 824 * @newsock contains the newly created server socket for connection. 825 * Return 0 if permission is granted. 826 * @socket_sendmsg: 827 * Check permission before transmitting a message to another socket. 828 * @sock contains the socket structure. 829 * @msg contains the message to be transmitted. 830 * @size contains the size of message. 831 * Return 0 if permission is granted. 832 * @socket_recvmsg: 833 * Check permission before receiving a message from a socket. 834 * @sock contains the socket structure. 835 * @msg contains the message structure. 836 * @size contains the size of message structure. 837 * @flags contains the operational flags. 838 * Return 0 if permission is granted. 839 * @socket_getsockname: 840 * Check permission before the local address (name) of the socket object 841 * @sock is retrieved. 842 * @sock contains the socket structure. 843 * Return 0 if permission is granted. 844 * @socket_getpeername: 845 * Check permission before the remote address (name) of a socket object 846 * @sock is retrieved. 847 * @sock contains the socket structure. 848 * Return 0 if permission is granted. 849 * @socket_getsockopt: 850 * Check permissions before retrieving the options associated with socket 851 * @sock. 852 * @sock contains the socket structure. 853 * @level contains the protocol level to retrieve option from. 854 * @optname contains the name of option to retrieve. 855 * Return 0 if permission is granted. 856 * @socket_setsockopt: 857 * Check permissions before setting the options associated with socket 858 * @sock. 859 * @sock contains the socket structure. 860 * @level contains the protocol level to set options for. 861 * @optname contains the name of the option to set. 862 * Return 0 if permission is granted. 863 * @socket_shutdown: 864 * Checks permission before all or part of a connection on the socket 865 * @sock is shut down. 866 * @sock contains the socket structure. 867 * @how contains the flag indicating how future sends and receives 868 * are handled. 869 * Return 0 if permission is granted. 870 * @socket_sock_rcv_skb: 871 * Check permissions on incoming network packets. This hook is distinct 872 * from Netfilter's IP input hooks since it is the first time that the 873 * incoming sk_buff @skb has been associated with a particular socket, @sk. 874 * Must not sleep inside this hook because some callers hold spinlocks. 875 * @sk contains the sock (not socket) associated with the incoming sk_buff. 876 * @skb contains the incoming network data. 877 * @socket_getpeersec_stream: 878 * This hook allows the security module to provide peer socket security 879 * state for unix or connected tcp sockets to userspace via getsockopt 880 * SO_GETPEERSEC. For tcp sockets this can be meaningful if the 881 * socket is associated with an ipsec SA. 882 * @sock is the local socket. 883 * @optval userspace memory where the security state is to be copied. 884 * @optlen userspace int where the module should copy the actual length 885 * of the security state. 886 * @len as input is the maximum length to copy to userspace provided 887 * by the caller. 888 * Return 0 if all is well, otherwise, typical getsockopt return 889 * values. 890 * @socket_getpeersec_dgram: 891 * This hook allows the security module to provide peer socket security 892 * state for udp sockets on a per-packet basis to userspace via 893 * getsockopt SO_GETPEERSEC. The application must first have indicated 894 * the IP_PASSSEC option via getsockopt. It can then retrieve the 895 * security state returned by this hook for a packet via the SCM_SECURITY 896 * ancillary message type. 897 * @sock contains the peer socket. May be NULL. 898 * @skb is the sk_buff for the packet being queried. May be NULL. 899 * @secid pointer to store the secid of the packet. 900 * Return 0 on success, error on failure. 901 * @sk_alloc_security: 902 * Allocate and attach a security structure to the sk->sk_security field, 903 * which is used to copy security attributes between local stream sockets. 904 * @sk_free_security: 905 * Deallocate security structure. 906 * @sk_clone_security: 907 * Clone/copy security structure. 908 * @sk_getsecid: 909 * Retrieve the LSM-specific secid for the sock to enable caching 910 * of network authorizations. 911 * @sock_graft: 912 * Sets the socket's isec sid to the sock's sid. 913 * @inet_conn_request: 914 * Sets the openreq's sid to socket's sid with MLS portion taken 915 * from peer sid. 916 * @inet_csk_clone: 917 * Sets the new child socket's sid to the openreq sid. 918 * @inet_conn_established: 919 * Sets the connection's peersid to the secmark on skb. 920 * @secmark_relabel_packet: 921 * check if the process should be allowed to relabel packets to 922 * the given secid 923 * @secmark_refcount_inc: 924 * tells the LSM to increment the number of secmark labeling rules loaded 925 * @secmark_refcount_dec: 926 * tells the LSM to decrement the number of secmark labeling rules loaded 927 * @req_classify_flow: 928 * Sets the flow's sid to the openreq sid. 929 * @tun_dev_alloc_security: 930 * This hook allows a module to allocate a security structure for a TUN 931 * device. 932 * @security pointer to a security structure pointer. 933 * Returns a zero on success, negative values on failure. 934 * @tun_dev_free_security: 935 * This hook allows a module to free the security structure for a TUN 936 * device. 937 * @security pointer to the TUN device's security structure 938 * @tun_dev_create: 939 * Check permissions prior to creating a new TUN device. 940 * @tun_dev_attach_queue: 941 * Check permissions prior to attaching to a TUN device queue. 942 * @security pointer to the TUN device's security structure. 943 * @tun_dev_attach: 944 * This hook can be used by the module to update any security state 945 * associated with the TUN device's sock structure. 946 * @sk contains the existing sock structure. 947 * @security pointer to the TUN device's security structure. 948 * @tun_dev_open: 949 * This hook can be used by the module to update any security state 950 * associated with the TUN device's security structure. 951 * @security pointer to the TUN devices's security structure. 952 * 953 * Security hooks for SCTP 954 * 955 * @sctp_assoc_request: 956 * Passes the @ep and @chunk->skb of the association INIT packet to 957 * the security module. 958 * @ep pointer to sctp endpoint structure. 959 * @skb pointer to skbuff of association packet. 960 * Return 0 on success, error on failure. 961 * @sctp_bind_connect: 962 * Validiate permissions required for each address associated with sock 963 * @sk. Depending on @optname, the addresses will be treated as either 964 * for a connect or bind service. The @addrlen is calculated on each 965 * ipv4 and ipv6 address using sizeof(struct sockaddr_in) or 966 * sizeof(struct sockaddr_in6). 967 * @sk pointer to sock structure. 968 * @optname name of the option to validate. 969 * @address list containing one or more ipv4/ipv6 addresses. 970 * @addrlen total length of address(s). 971 * Return 0 on success, error on failure. 972 * @sctp_sk_clone: 973 * Called whenever a new socket is created by accept(2) (i.e. a TCP 974 * style socket) or when a socket is 'peeled off' e.g userspace 975 * calls sctp_peeloff(3). 976 * @ep pointer to current sctp endpoint structure. 977 * @sk pointer to current sock structure. 978 * @sk pointer to new sock structure. 979 * 980 * Security hooks for Infiniband 981 * 982 * @ib_pkey_access: 983 * Check permission to access a pkey when modifing a QP. 984 * @subnet_prefix the subnet prefix of the port being used. 985 * @pkey the pkey to be accessed. 986 * @sec pointer to a security structure. 987 * @ib_endport_manage_subnet: 988 * Check permissions to send and receive SMPs on a end port. 989 * @dev_name the IB device name (i.e. mlx4_0). 990 * @port_num the port number. 991 * @sec pointer to a security structure. 992 * @ib_alloc_security: 993 * Allocate a security structure for Infiniband objects. 994 * @sec pointer to a security structure pointer. 995 * Returns 0 on success, non-zero on failure 996 * @ib_free_security: 997 * Deallocate an Infiniband security structure. 998 * @sec contains the security structure to be freed. 999 * 1000 * Security hooks for XFRM operations. 1001 * 1002 * @xfrm_policy_alloc_security: 1003 * @ctxp is a pointer to the xfrm_sec_ctx being added to Security Policy 1004 * Database used by the XFRM system. 1005 * @sec_ctx contains the security context information being provided by 1006 * the user-level policy update program (e.g., setkey). 1007 * Allocate a security structure to the xp->security field; the security 1008 * field is initialized to NULL when the xfrm_policy is allocated. 1009 * Return 0 if operation was successful (memory to allocate, legal context) 1010 * @gfp is to specify the context for the allocation 1011 * @xfrm_policy_clone_security: 1012 * @old_ctx contains an existing xfrm_sec_ctx. 1013 * @new_ctxp contains a new xfrm_sec_ctx being cloned from old. 1014 * Allocate a security structure in new_ctxp that contains the 1015 * information from the old_ctx structure. 1016 * Return 0 if operation was successful (memory to allocate). 1017 * @xfrm_policy_free_security: 1018 * @ctx contains the xfrm_sec_ctx 1019 * Deallocate xp->security. 1020 * @xfrm_policy_delete_security: 1021 * @ctx contains the xfrm_sec_ctx. 1022 * Authorize deletion of xp->security. 1023 * @xfrm_state_alloc: 1024 * @x contains the xfrm_state being added to the Security Association 1025 * Database by the XFRM system. 1026 * @sec_ctx contains the security context information being provided by 1027 * the user-level SA generation program (e.g., setkey or racoon). 1028 * Allocate a security structure to the x->security field; the security 1029 * field is initialized to NULL when the xfrm_state is allocated. Set the 1030 * context to correspond to sec_ctx. Return 0 if operation was successful 1031 * (memory to allocate, legal context). 1032 * @xfrm_state_alloc_acquire: 1033 * @x contains the xfrm_state being added to the Security Association 1034 * Database by the XFRM system. 1035 * @polsec contains the policy's security context. 1036 * @secid contains the secid from which to take the mls portion of the 1037 * context. 1038 * Allocate a security structure to the x->security field; the security 1039 * field is initialized to NULL when the xfrm_state is allocated. Set the 1040 * context to correspond to secid. Return 0 if operation was successful 1041 * (memory to allocate, legal context). 1042 * @xfrm_state_free_security: 1043 * @x contains the xfrm_state. 1044 * Deallocate x->security. 1045 * @xfrm_state_delete_security: 1046 * @x contains the xfrm_state. 1047 * Authorize deletion of x->security. 1048 * @xfrm_policy_lookup: 1049 * @ctx contains the xfrm_sec_ctx for which the access control is being 1050 * checked. 1051 * @fl_secid contains the flow security label that is used to authorize 1052 * access to the policy xp. 1053 * @dir contains the direction of the flow (input or output). 1054 * Check permission when a flow selects a xfrm_policy for processing 1055 * XFRMs on a packet. The hook is called when selecting either a 1056 * per-socket policy or a generic xfrm policy. 1057 * Return 0 if permission is granted, -ESRCH otherwise, or -errno 1058 * on other errors. 1059 * @xfrm_state_pol_flow_match: 1060 * @x contains the state to match. 1061 * @xp contains the policy to check for a match. 1062 * @fl contains the flow to check for a match. 1063 * Return 1 if there is a match. 1064 * @xfrm_decode_session: 1065 * @skb points to skb to decode. 1066 * @secid points to the flow key secid to set. 1067 * @ckall says if all xfrms used should be checked for same secid. 1068 * Return 0 if ckall is zero or all xfrms used have the same secid. 1069 * 1070 * Security hooks affecting all Key Management operations 1071 * 1072 * @key_alloc: 1073 * Permit allocation of a key and assign security data. Note that key does 1074 * not have a serial number assigned at this point. 1075 * @key points to the key. 1076 * @flags is the allocation flags 1077 * Return 0 if permission is granted, -ve error otherwise. 1078 * @key_free: 1079 * Notification of destruction; free security data. 1080 * @key points to the key. 1081 * No return value. 1082 * @key_permission: 1083 * See whether a specific operational right is granted to a process on a 1084 * key. 1085 * @key_ref refers to the key (key pointer + possession attribute bit). 1086 * @cred points to the credentials to provide the context against which to 1087 * evaluate the security data on the key. 1088 * @perm describes the combination of permissions required of this key. 1089 * Return 0 if permission is granted, -ve error otherwise. 1090 * @key_getsecurity: 1091 * Get a textual representation of the security context attached to a key 1092 * for the purposes of honouring KEYCTL_GETSECURITY. This function 1093 * allocates the storage for the NUL-terminated string and the caller 1094 * should free it. 1095 * @key points to the key to be queried. 1096 * @_buffer points to a pointer that should be set to point to the 1097 * resulting string (if no label or an error occurs). 1098 * Return the length of the string (including terminating NUL) or -ve if 1099 * an error. 1100 * May also return 0 (and a NULL buffer pointer) if there is no label. 1101 * 1102 * Security hooks affecting all System V IPC operations. 1103 * 1104 * @ipc_permission: 1105 * Check permissions for access to IPC 1106 * @ipcp contains the kernel IPC permission structure 1107 * @flag contains the desired (requested) permission set 1108 * Return 0 if permission is granted. 1109 * @ipc_getsecid: 1110 * Get the secid associated with the ipc object. 1111 * @ipcp contains the kernel IPC permission structure. 1112 * @secid contains a pointer to the location where result will be saved. 1113 * In case of failure, @secid will be set to zero. 1114 * 1115 * Security hooks for individual messages held in System V IPC message queues 1116 * @msg_msg_alloc_security: 1117 * Allocate and attach a security structure to the msg->security field. 1118 * The security field is initialized to NULL when the structure is first 1119 * created. 1120 * @msg contains the message structure to be modified. 1121 * Return 0 if operation was successful and permission is granted. 1122 * @msg_msg_free_security: 1123 * Deallocate the security structure for this message. 1124 * @msg contains the message structure to be modified. 1125 * 1126 * Security hooks for System V IPC Message Queues 1127 * 1128 * @msg_queue_alloc_security: 1129 * Allocate and attach a security structure to the 1130 * @perm->security field. The security field is initialized to 1131 * NULL when the structure is first created. 1132 * @perm contains the IPC permissions of the message queue. 1133 * Return 0 if operation was successful and permission is granted. 1134 * @msg_queue_free_security: 1135 * Deallocate security field @perm->security for the message queue. 1136 * @perm contains the IPC permissions of the message queue. 1137 * @msg_queue_associate: 1138 * Check permission when a message queue is requested through the 1139 * msgget system call. This hook is only called when returning the 1140 * message queue identifier for an existing message queue, not when a 1141 * new message queue is created. 1142 * @perm contains the IPC permissions of the message queue. 1143 * @msqflg contains the operation control flags. 1144 * Return 0 if permission is granted. 1145 * @msg_queue_msgctl: 1146 * Check permission when a message control operation specified by @cmd 1147 * is to be performed on the message queue with permissions @perm. 1148 * The @perm may be NULL, e.g. for IPC_INFO or MSG_INFO. 1149 * @perm contains the IPC permissions of the msg queue. May be NULL. 1150 * @cmd contains the operation to be performed. 1151 * Return 0 if permission is granted. 1152 * @msg_queue_msgsnd: 1153 * Check permission before a message, @msg, is enqueued on the message 1154 * queue with permissions @perm. 1155 * @perm contains the IPC permissions of the message queue. 1156 * @msg contains the message to be enqueued. 1157 * @msqflg contains operational flags. 1158 * Return 0 if permission is granted. 1159 * @msg_queue_msgrcv: 1160 * Check permission before a message, @msg, is removed from the message 1161 * queue. The @target task structure contains a pointer to the 1162 * process that will be receiving the message (not equal to the current 1163 * process when inline receives are being performed). 1164 * @perm contains the IPC permissions of the message queue. 1165 * @msg contains the message destination. 1166 * @target contains the task structure for recipient process. 1167 * @type contains the type of message requested. 1168 * @mode contains the operational flags. 1169 * Return 0 if permission is granted. 1170 * 1171 * Security hooks for System V Shared Memory Segments 1172 * 1173 * @shm_alloc_security: 1174 * Allocate and attach a security structure to the @perm->security 1175 * field. The security field is initialized to NULL when the structure is 1176 * first created. 1177 * @perm contains the IPC permissions of the shared memory structure. 1178 * Return 0 if operation was successful and permission is granted. 1179 * @shm_free_security: 1180 * Deallocate the security structure @perm->security for the memory segment. 1181 * @perm contains the IPC permissions of the shared memory structure. 1182 * @shm_associate: 1183 * Check permission when a shared memory region is requested through the 1184 * shmget system call. This hook is only called when returning the shared 1185 * memory region identifier for an existing region, not when a new shared 1186 * memory region is created. 1187 * @perm contains the IPC permissions of the shared memory structure. 1188 * @shmflg contains the operation control flags. 1189 * Return 0 if permission is granted. 1190 * @shm_shmctl: 1191 * Check permission when a shared memory control operation specified by 1192 * @cmd is to be performed on the shared memory region with permissions @perm. 1193 * The @perm may be NULL, e.g. for IPC_INFO or SHM_INFO. 1194 * @perm contains the IPC permissions of the shared memory structure. 1195 * @cmd contains the operation to be performed. 1196 * Return 0 if permission is granted. 1197 * @shm_shmat: 1198 * Check permissions prior to allowing the shmat system call to attach the 1199 * shared memory segment with permissions @perm to the data segment of the 1200 * calling process. The attaching address is specified by @shmaddr. 1201 * @perm contains the IPC permissions of the shared memory structure. 1202 * @shmaddr contains the address to attach memory region to. 1203 * @shmflg contains the operational flags. 1204 * Return 0 if permission is granted. 1205 * 1206 * Security hooks for System V Semaphores 1207 * 1208 * @sem_alloc_security: 1209 * Allocate and attach a security structure to the @perm->security 1210 * field. The security field is initialized to NULL when the structure is 1211 * first created. 1212 * @perm contains the IPC permissions of the semaphore. 1213 * Return 0 if operation was successful and permission is granted. 1214 * @sem_free_security: 1215 * Deallocate security structure @perm->security for the semaphore. 1216 * @perm contains the IPC permissions of the semaphore. 1217 * @sem_associate: 1218 * Check permission when a semaphore is requested through the semget 1219 * system call. This hook is only called when returning the semaphore 1220 * identifier for an existing semaphore, not when a new one must be 1221 * created. 1222 * @perm contains the IPC permissions of the semaphore. 1223 * @semflg contains the operation control flags. 1224 * Return 0 if permission is granted. 1225 * @sem_semctl: 1226 * Check permission when a semaphore operation specified by @cmd is to be 1227 * performed on the semaphore. The @perm may be NULL, e.g. for 1228 * IPC_INFO or SEM_INFO. 1229 * @perm contains the IPC permissions of the semaphore. May be NULL. 1230 * @cmd contains the operation to be performed. 1231 * Return 0 if permission is granted. 1232 * @sem_semop: 1233 * Check permissions before performing operations on members of the 1234 * semaphore set. If the @alter flag is nonzero, the semaphore set 1235 * may be modified. 1236 * @perm contains the IPC permissions of the semaphore. 1237 * @sops contains the operations to perform. 1238 * @nsops contains the number of operations to perform. 1239 * @alter contains the flag indicating whether changes are to be made. 1240 * Return 0 if permission is granted. 1241 * 1242 * @binder_set_context_mgr: 1243 * Check whether @mgr is allowed to be the binder context manager. 1244 * @mgr contains the task_struct for the task being registered. 1245 * Return 0 if permission is granted. 1246 * @binder_transaction: 1247 * Check whether @from is allowed to invoke a binder transaction call 1248 * to @to. 1249 * @from contains the task_struct for the sending task. 1250 * @to contains the task_struct for the receiving task. 1251 * @binder_transfer_binder: 1252 * Check whether @from is allowed to transfer a binder reference to @to. 1253 * @from contains the task_struct for the sending task. 1254 * @to contains the task_struct for the receiving task. 1255 * @binder_transfer_file: 1256 * Check whether @from is allowed to transfer @file to @to. 1257 * @from contains the task_struct for the sending task. 1258 * @file contains the struct file being transferred. 1259 * @to contains the task_struct for the receiving task. 1260 * 1261 * @ptrace_access_check: 1262 * Check permission before allowing the current process to trace the 1263 * @child process. 1264 * Security modules may also want to perform a process tracing check 1265 * during an execve in the set_security or apply_creds hooks of 1266 * tracing check during an execve in the bprm_set_creds hook of 1267 * binprm_security_ops if the process is being traced and its security 1268 * attributes would be changed by the execve. 1269 * @child contains the task_struct structure for the target process. 1270 * @mode contains the PTRACE_MODE flags indicating the form of access. 1271 * Return 0 if permission is granted. 1272 * @ptrace_traceme: 1273 * Check that the @parent process has sufficient permission to trace the 1274 * current process before allowing the current process to present itself 1275 * to the @parent process for tracing. 1276 * @parent contains the task_struct structure for debugger process. 1277 * Return 0 if permission is granted. 1278 * @capget: 1279 * Get the @effective, @inheritable, and @permitted capability sets for 1280 * the @target process. The hook may also perform permission checking to 1281 * determine if the current process is allowed to see the capability sets 1282 * of the @target process. 1283 * @target contains the task_struct structure for target process. 1284 * @effective contains the effective capability set. 1285 * @inheritable contains the inheritable capability set. 1286 * @permitted contains the permitted capability set. 1287 * Return 0 if the capability sets were successfully obtained. 1288 * @capset: 1289 * Set the @effective, @inheritable, and @permitted capability sets for 1290 * the current process. 1291 * @new contains the new credentials structure for target process. 1292 * @old contains the current credentials structure for target process. 1293 * @effective contains the effective capability set. 1294 * @inheritable contains the inheritable capability set. 1295 * @permitted contains the permitted capability set. 1296 * Return 0 and update @new if permission is granted. 1297 * @capable: 1298 * Check whether the @tsk process has the @cap capability in the indicated 1299 * credentials. 1300 * @cred contains the credentials to use. 1301 * @ns contains the user namespace we want the capability in 1302 * @cap contains the capability <include/linux/capability.h>. 1303 * @opts contains options for the capable check <include/linux/security.h> 1304 * Return 0 if the capability is granted for @tsk. 1305 * @syslog: 1306 * Check permission before accessing the kernel message ring or changing 1307 * logging to the console. 1308 * See the syslog(2) manual page for an explanation of the @type values. 1309 * @type contains the SYSLOG_ACTION_* constant from <include/linux/syslog.h> 1310 * Return 0 if permission is granted. 1311 * @settime: 1312 * Check permission to change the system time. 1313 * struct timespec64 is defined in <include/linux/time64.h> and timezone 1314 * is defined in <include/linux/time.h> 1315 * @ts contains new time 1316 * @tz contains new timezone 1317 * Return 0 if permission is granted. 1318 * @vm_enough_memory: 1319 * Check permissions for allocating a new virtual mapping. 1320 * @mm contains the mm struct it is being added to. 1321 * @pages contains the number of pages. 1322 * Return 0 if permission is granted. 1323 * 1324 * @ismaclabel: 1325 * Check if the extended attribute specified by @name 1326 * represents a MAC label. Returns 1 if name is a MAC 1327 * attribute otherwise returns 0. 1328 * @name full extended attribute name to check against 1329 * LSM as a MAC label. 1330 * 1331 * @secid_to_secctx: 1332 * Convert secid to security context. If secdata is NULL the length of 1333 * the result will be returned in seclen, but no secdata will be returned. 1334 * This does mean that the length could change between calls to check the 1335 * length and the next call which actually allocates and returns the 1336 * secdata. 1337 * @secid contains the security ID. 1338 * @secdata contains the pointer that stores the converted security 1339 * context. 1340 * @seclen pointer which contains the length of the data 1341 * @secctx_to_secid: 1342 * Convert security context to secid. 1343 * @secid contains the pointer to the generated security ID. 1344 * @secdata contains the security context. 1345 * 1346 * @release_secctx: 1347 * Release the security context. 1348 * @secdata contains the security context. 1349 * @seclen contains the length of the security context. 1350 * 1351 * Security hooks for Audit 1352 * 1353 * @audit_rule_init: 1354 * Allocate and initialize an LSM audit rule structure. 1355 * @field contains the required Audit action. 1356 * Fields flags are defined in <include/linux/audit.h> 1357 * @op contains the operator the rule uses. 1358 * @rulestr contains the context where the rule will be applied to. 1359 * @lsmrule contains a pointer to receive the result. 1360 * Return 0 if @lsmrule has been successfully set, 1361 * -EINVAL in case of an invalid rule. 1362 * 1363 * @audit_rule_known: 1364 * Specifies whether given @krule contains any fields related to 1365 * current LSM. 1366 * @krule contains the audit rule of interest. 1367 * Return 1 in case of relation found, 0 otherwise. 1368 * 1369 * @audit_rule_match: 1370 * Determine if given @secid matches a rule previously approved 1371 * by @audit_rule_known. 1372 * @secid contains the security id in question. 1373 * @field contains the field which relates to current LSM. 1374 * @op contains the operator that will be used for matching. 1375 * @lrule points to the audit rule that will be checked against. 1376 * Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure. 1377 * 1378 * @audit_rule_free: 1379 * Deallocate the LSM audit rule structure previously allocated by 1380 * audit_rule_init. 1381 * @lsmrule contains the allocated rule 1382 * 1383 * @inode_invalidate_secctx: 1384 * Notify the security module that it must revalidate the security context 1385 * of an inode. 1386 * 1387 * @inode_notifysecctx: 1388 * Notify the security module of what the security context of an inode 1389 * should be. Initializes the incore security context managed by the 1390 * security module for this inode. Example usage: NFS client invokes 1391 * this hook to initialize the security context in its incore inode to the 1392 * value provided by the server for the file when the server returned the 1393 * file's attributes to the client. 1394 * Must be called with inode->i_mutex locked. 1395 * @inode we wish to set the security context of. 1396 * @ctx contains the string which we wish to set in the inode. 1397 * @ctxlen contains the length of @ctx. 1398 * 1399 * @inode_setsecctx: 1400 * Change the security context of an inode. Updates the 1401 * incore security context managed by the security module and invokes the 1402 * fs code as needed (via __vfs_setxattr_noperm) to update any backing 1403 * xattrs that represent the context. Example usage: NFS server invokes 1404 * this hook to change the security context in its incore inode and on the 1405 * backing filesystem to a value provided by the client on a SETATTR 1406 * operation. 1407 * Must be called with inode->i_mutex locked. 1408 * @dentry contains the inode we wish to set the security context of. 1409 * @ctx contains the string which we wish to set in the inode. 1410 * @ctxlen contains the length of @ctx. 1411 * 1412 * @inode_getsecctx: 1413 * On success, returns 0 and fills out @ctx and @ctxlen with the security 1414 * context for the given @inode. 1415 * @inode we wish to get the security context of. 1416 * @ctx is a pointer in which to place the allocated security context. 1417 * @ctxlen points to the place to put the length of @ctx. 1418 * 1419 * Security hooks for using the eBPF maps and programs functionalities through 1420 * eBPF syscalls. 1421 * 1422 * @bpf: 1423 * Do a initial check for all bpf syscalls after the attribute is copied 1424 * into the kernel. The actual security module can implement their own 1425 * rules to check the specific cmd they need. 1426 * 1427 * @bpf_map: 1428 * Do a check when the kernel generate and return a file descriptor for 1429 * eBPF maps. 1430 * 1431 * @map: bpf map that we want to access 1432 * @mask: the access flags 1433 * 1434 * @bpf_prog: 1435 * Do a check when the kernel generate and return a file descriptor for 1436 * eBPF programs. 1437 * 1438 * @prog: bpf prog that userspace want to use. 1439 * 1440 * @bpf_map_alloc_security: 1441 * Initialize the security field inside bpf map. 1442 * 1443 * @bpf_map_free_security: 1444 * Clean up the security information stored inside bpf map. 1445 * 1446 * @bpf_prog_alloc_security: 1447 * Initialize the security field inside bpf program. 1448 * 1449 * @bpf_prog_free_security: 1450 * Clean up the security information stored inside bpf prog. 1451 * 1452 * @locked_down 1453 * Determine whether a kernel feature that potentially enables arbitrary 1454 * code execution in kernel space should be permitted. 1455 * 1456 * @what: kernel feature being accessed 1457 */ 1458 union security_list_options { 1459 int (*binder_set_context_mgr)(struct task_struct *mgr); 1460 int (*binder_transaction)(struct task_struct *from, 1461 struct task_struct *to); 1462 int (*binder_transfer_binder)(struct task_struct *from, 1463 struct task_struct *to); 1464 int (*binder_transfer_file)(struct task_struct *from, 1465 struct task_struct *to, 1466 struct file *file); 1467 1468 int (*ptrace_access_check)(struct task_struct *child, 1469 unsigned int mode); 1470 int (*ptrace_traceme)(struct task_struct *parent); 1471 int (*capget)(struct task_struct *target, kernel_cap_t *effective, 1472 kernel_cap_t *inheritable, kernel_cap_t *permitted); 1473 int (*capset)(struct cred *new, const struct cred *old, 1474 const kernel_cap_t *effective, 1475 const kernel_cap_t *inheritable, 1476 const kernel_cap_t *permitted); 1477 int (*capable)(const struct cred *cred, 1478 struct user_namespace *ns, 1479 int cap, 1480 unsigned int opts); 1481 int (*quotactl)(int cmds, int type, int id, struct super_block *sb); 1482 int (*quota_on)(struct dentry *dentry); 1483 int (*syslog)(int type); 1484 int (*settime)(const struct timespec64 *ts, const struct timezone *tz); 1485 int (*vm_enough_memory)(struct mm_struct *mm, long pages); 1486 1487 int (*bprm_set_creds)(struct linux_binprm *bprm); 1488 int (*bprm_check_security)(struct linux_binprm *bprm); 1489 void (*bprm_committing_creds)(struct linux_binprm *bprm); 1490 void (*bprm_committed_creds)(struct linux_binprm *bprm); 1491 1492 int (*fs_context_dup)(struct fs_context *fc, struct fs_context *src_sc); 1493 int (*fs_context_parse_param)(struct fs_context *fc, struct fs_parameter *param); 1494 1495 int (*sb_alloc_security)(struct super_block *sb); 1496 void (*sb_free_security)(struct super_block *sb); 1497 void (*sb_free_mnt_opts)(void *mnt_opts); 1498 int (*sb_eat_lsm_opts)(char *orig, void **mnt_opts); 1499 int (*sb_remount)(struct super_block *sb, void *mnt_opts); 1500 int (*sb_kern_mount)(struct super_block *sb); 1501 int (*sb_show_options)(struct seq_file *m, struct super_block *sb); 1502 int (*sb_statfs)(struct dentry *dentry); 1503 int (*sb_mount)(const char *dev_name, const struct path *path, 1504 const char *type, unsigned long flags, void *data); 1505 int (*sb_umount)(struct vfsmount *mnt, int flags); 1506 int (*sb_pivotroot)(const struct path *old_path, const struct path *new_path); 1507 int (*sb_set_mnt_opts)(struct super_block *sb, 1508 void *mnt_opts, 1509 unsigned long kern_flags, 1510 unsigned long *set_kern_flags); 1511 int (*sb_clone_mnt_opts)(const struct super_block *oldsb, 1512 struct super_block *newsb, 1513 unsigned long kern_flags, 1514 unsigned long *set_kern_flags); 1515 int (*sb_add_mnt_opt)(const char *option, const char *val, int len, 1516 void **mnt_opts); 1517 int (*move_mount)(const struct path *from_path, const struct path *to_path); 1518 int (*dentry_init_security)(struct dentry *dentry, int mode, 1519 const struct qstr *name, void **ctx, 1520 u32 *ctxlen); 1521 int (*dentry_create_files_as)(struct dentry *dentry, int mode, 1522 struct qstr *name, 1523 const struct cred *old, 1524 struct cred *new); 1525 1526 1527 #ifdef CONFIG_SECURITY_PATH 1528 int (*path_unlink)(const struct path *dir, struct dentry *dentry); 1529 int (*path_mkdir)(const struct path *dir, struct dentry *dentry, 1530 umode_t mode); 1531 int (*path_rmdir)(const struct path *dir, struct dentry *dentry); 1532 int (*path_mknod)(const struct path *dir, struct dentry *dentry, 1533 umode_t mode, unsigned int dev); 1534 int (*path_truncate)(const struct path *path); 1535 int (*path_symlink)(const struct path *dir, struct dentry *dentry, 1536 const char *old_name); 1537 int (*path_link)(struct dentry *old_dentry, const struct path *new_dir, 1538 struct dentry *new_dentry); 1539 int (*path_rename)(const struct path *old_dir, struct dentry *old_dentry, 1540 const struct path *new_dir, 1541 struct dentry *new_dentry); 1542 int (*path_chmod)(const struct path *path, umode_t mode); 1543 int (*path_chown)(const struct path *path, kuid_t uid, kgid_t gid); 1544 int (*path_chroot)(const struct path *path); 1545 #endif 1546 /* Needed for inode based security check */ 1547 int (*path_notify)(const struct path *path, u64 mask, 1548 unsigned int obj_type); 1549 int (*inode_alloc_security)(struct inode *inode); 1550 void (*inode_free_security)(struct inode *inode); 1551 int (*inode_init_security)(struct inode *inode, struct inode *dir, 1552 const struct qstr *qstr, 1553 const char **name, void **value, 1554 size_t *len); 1555 int (*inode_create)(struct inode *dir, struct dentry *dentry, 1556 umode_t mode); 1557 int (*inode_link)(struct dentry *old_dentry, struct inode *dir, 1558 struct dentry *new_dentry); 1559 int (*inode_unlink)(struct inode *dir, struct dentry *dentry); 1560 int (*inode_symlink)(struct inode *dir, struct dentry *dentry, 1561 const char *old_name); 1562 int (*inode_mkdir)(struct inode *dir, struct dentry *dentry, 1563 umode_t mode); 1564 int (*inode_rmdir)(struct inode *dir, struct dentry *dentry); 1565 int (*inode_mknod)(struct inode *dir, struct dentry *dentry, 1566 umode_t mode, dev_t dev); 1567 int (*inode_rename)(struct inode *old_dir, struct dentry *old_dentry, 1568 struct inode *new_dir, 1569 struct dentry *new_dentry); 1570 int (*inode_readlink)(struct dentry *dentry); 1571 int (*inode_follow_link)(struct dentry *dentry, struct inode *inode, 1572 bool rcu); 1573 int (*inode_permission)(struct inode *inode, int mask); 1574 int (*inode_setattr)(struct dentry *dentry, struct iattr *attr); 1575 int (*inode_getattr)(const struct path *path); 1576 int (*inode_setxattr)(struct dentry *dentry, const char *name, 1577 const void *value, size_t size, int flags); 1578 void (*inode_post_setxattr)(struct dentry *dentry, const char *name, 1579 const void *value, size_t size, 1580 int flags); 1581 int (*inode_getxattr)(struct dentry *dentry, const char *name); 1582 int (*inode_listxattr)(struct dentry *dentry); 1583 int (*inode_removexattr)(struct dentry *dentry, const char *name); 1584 int (*inode_need_killpriv)(struct dentry *dentry); 1585 int (*inode_killpriv)(struct dentry *dentry); 1586 int (*inode_getsecurity)(struct inode *inode, const char *name, 1587 void **buffer, bool alloc); 1588 int (*inode_setsecurity)(struct inode *inode, const char *name, 1589 const void *value, size_t size, 1590 int flags); 1591 int (*inode_listsecurity)(struct inode *inode, char *buffer, 1592 size_t buffer_size); 1593 void (*inode_getsecid)(struct inode *inode, u32 *secid); 1594 int (*inode_copy_up)(struct dentry *src, struct cred **new); 1595 int (*inode_copy_up_xattr)(const char *name); 1596 1597 int (*kernfs_init_security)(struct kernfs_node *kn_dir, 1598 struct kernfs_node *kn); 1599 1600 int (*file_permission)(struct file *file, int mask); 1601 int (*file_alloc_security)(struct file *file); 1602 void (*file_free_security)(struct file *file); 1603 int (*file_ioctl)(struct file *file, unsigned int cmd, 1604 unsigned long arg); 1605 int (*mmap_addr)(unsigned long addr); 1606 int (*mmap_file)(struct file *file, unsigned long reqprot, 1607 unsigned long prot, unsigned long flags); 1608 int (*file_mprotect)(struct vm_area_struct *vma, unsigned long reqprot, 1609 unsigned long prot); 1610 int (*file_lock)(struct file *file, unsigned int cmd); 1611 int (*file_fcntl)(struct file *file, unsigned int cmd, 1612 unsigned long arg); 1613 void (*file_set_fowner)(struct file *file); 1614 int (*file_send_sigiotask)(struct task_struct *tsk, 1615 struct fown_struct *fown, int sig); 1616 int (*file_receive)(struct file *file); 1617 int (*file_open)(struct file *file); 1618 1619 int (*task_alloc)(struct task_struct *task, unsigned long clone_flags); 1620 void (*task_free)(struct task_struct *task); 1621 int (*cred_alloc_blank)(struct cred *cred, gfp_t gfp); 1622 void (*cred_free)(struct cred *cred); 1623 int (*cred_prepare)(struct cred *new, const struct cred *old, 1624 gfp_t gfp); 1625 void (*cred_transfer)(struct cred *new, const struct cred *old); 1626 void (*cred_getsecid)(const struct cred *c, u32 *secid); 1627 int (*kernel_act_as)(struct cred *new, u32 secid); 1628 int (*kernel_create_files_as)(struct cred *new, struct inode *inode); 1629 int (*kernel_module_request)(char *kmod_name); 1630 int (*kernel_load_data)(enum kernel_load_data_id id); 1631 int (*kernel_read_file)(struct file *file, enum kernel_read_file_id id); 1632 int (*kernel_post_read_file)(struct file *file, char *buf, loff_t size, 1633 enum kernel_read_file_id id); 1634 int (*task_fix_setuid)(struct cred *new, const struct cred *old, 1635 int flags); 1636 int (*task_setpgid)(struct task_struct *p, pid_t pgid); 1637 int (*task_getpgid)(struct task_struct *p); 1638 int (*task_getsid)(struct task_struct *p); 1639 void (*task_getsecid)(struct task_struct *p, u32 *secid); 1640 int (*task_setnice)(struct task_struct *p, int nice); 1641 int (*task_setioprio)(struct task_struct *p, int ioprio); 1642 int (*task_getioprio)(struct task_struct *p); 1643 int (*task_prlimit)(const struct cred *cred, const struct cred *tcred, 1644 unsigned int flags); 1645 int (*task_setrlimit)(struct task_struct *p, unsigned int resource, 1646 struct rlimit *new_rlim); 1647 int (*task_setscheduler)(struct task_struct *p); 1648 int (*task_getscheduler)(struct task_struct *p); 1649 int (*task_movememory)(struct task_struct *p); 1650 int (*task_kill)(struct task_struct *p, struct kernel_siginfo *info, 1651 int sig, const struct cred *cred); 1652 int (*task_prctl)(int option, unsigned long arg2, unsigned long arg3, 1653 unsigned long arg4, unsigned long arg5); 1654 void (*task_to_inode)(struct task_struct *p, struct inode *inode); 1655 1656 int (*ipc_permission)(struct kern_ipc_perm *ipcp, short flag); 1657 void (*ipc_getsecid)(struct kern_ipc_perm *ipcp, u32 *secid); 1658 1659 int (*msg_msg_alloc_security)(struct msg_msg *msg); 1660 void (*msg_msg_free_security)(struct msg_msg *msg); 1661 1662 int (*msg_queue_alloc_security)(struct kern_ipc_perm *perm); 1663 void (*msg_queue_free_security)(struct kern_ipc_perm *perm); 1664 int (*msg_queue_associate)(struct kern_ipc_perm *perm, int msqflg); 1665 int (*msg_queue_msgctl)(struct kern_ipc_perm *perm, int cmd); 1666 int (*msg_queue_msgsnd)(struct kern_ipc_perm *perm, struct msg_msg *msg, 1667 int msqflg); 1668 int (*msg_queue_msgrcv)(struct kern_ipc_perm *perm, struct msg_msg *msg, 1669 struct task_struct *target, long type, 1670 int mode); 1671 1672 int (*shm_alloc_security)(struct kern_ipc_perm *perm); 1673 void (*shm_free_security)(struct kern_ipc_perm *perm); 1674 int (*shm_associate)(struct kern_ipc_perm *perm, int shmflg); 1675 int (*shm_shmctl)(struct kern_ipc_perm *perm, int cmd); 1676 int (*shm_shmat)(struct kern_ipc_perm *perm, char __user *shmaddr, 1677 int shmflg); 1678 1679 int (*sem_alloc_security)(struct kern_ipc_perm *perm); 1680 void (*sem_free_security)(struct kern_ipc_perm *perm); 1681 int (*sem_associate)(struct kern_ipc_perm *perm, int semflg); 1682 int (*sem_semctl)(struct kern_ipc_perm *perm, int cmd); 1683 int (*sem_semop)(struct kern_ipc_perm *perm, struct sembuf *sops, 1684 unsigned nsops, int alter); 1685 1686 int (*netlink_send)(struct sock *sk, struct sk_buff *skb); 1687 1688 void (*d_instantiate)(struct dentry *dentry, struct inode *inode); 1689 1690 int (*getprocattr)(struct task_struct *p, char *name, char **value); 1691 int (*setprocattr)(const char *name, void *value, size_t size); 1692 int (*ismaclabel)(const char *name); 1693 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen); 1694 int (*secctx_to_secid)(const char *secdata, u32 seclen, u32 *secid); 1695 void (*release_secctx)(char *secdata, u32 seclen); 1696 1697 void (*inode_invalidate_secctx)(struct inode *inode); 1698 int (*inode_notifysecctx)(struct inode *inode, void *ctx, u32 ctxlen); 1699 int (*inode_setsecctx)(struct dentry *dentry, void *ctx, u32 ctxlen); 1700 int (*inode_getsecctx)(struct inode *inode, void **ctx, u32 *ctxlen); 1701 1702 #ifdef CONFIG_SECURITY_NETWORK 1703 int (*unix_stream_connect)(struct sock *sock, struct sock *other, 1704 struct sock *newsk); 1705 int (*unix_may_send)(struct socket *sock, struct socket *other); 1706 1707 int (*socket_create)(int family, int type, int protocol, int kern); 1708 int (*socket_post_create)(struct socket *sock, int family, int type, 1709 int protocol, int kern); 1710 int (*socket_socketpair)(struct socket *socka, struct socket *sockb); 1711 int (*socket_bind)(struct socket *sock, struct sockaddr *address, 1712 int addrlen); 1713 int (*socket_connect)(struct socket *sock, struct sockaddr *address, 1714 int addrlen); 1715 int (*socket_listen)(struct socket *sock, int backlog); 1716 int (*socket_accept)(struct socket *sock, struct socket *newsock); 1717 int (*socket_sendmsg)(struct socket *sock, struct msghdr *msg, 1718 int size); 1719 int (*socket_recvmsg)(struct socket *sock, struct msghdr *msg, 1720 int size, int flags); 1721 int (*socket_getsockname)(struct socket *sock); 1722 int (*socket_getpeername)(struct socket *sock); 1723 int (*socket_getsockopt)(struct socket *sock, int level, int optname); 1724 int (*socket_setsockopt)(struct socket *sock, int level, int optname); 1725 int (*socket_shutdown)(struct socket *sock, int how); 1726 int (*socket_sock_rcv_skb)(struct sock *sk, struct sk_buff *skb); 1727 int (*socket_getpeersec_stream)(struct socket *sock, 1728 char __user *optval, 1729 int __user *optlen, unsigned len); 1730 int (*socket_getpeersec_dgram)(struct socket *sock, 1731 struct sk_buff *skb, u32 *secid); 1732 int (*sk_alloc_security)(struct sock *sk, int family, gfp_t priority); 1733 void (*sk_free_security)(struct sock *sk); 1734 void (*sk_clone_security)(const struct sock *sk, struct sock *newsk); 1735 void (*sk_getsecid)(struct sock *sk, u32 *secid); 1736 void (*sock_graft)(struct sock *sk, struct socket *parent); 1737 int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb, 1738 struct request_sock *req); 1739 void (*inet_csk_clone)(struct sock *newsk, 1740 const struct request_sock *req); 1741 void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb); 1742 int (*secmark_relabel_packet)(u32 secid); 1743 void (*secmark_refcount_inc)(void); 1744 void (*secmark_refcount_dec)(void); 1745 void (*req_classify_flow)(const struct request_sock *req, 1746 struct flowi *fl); 1747 int (*tun_dev_alloc_security)(void **security); 1748 void (*tun_dev_free_security)(void *security); 1749 int (*tun_dev_create)(void); 1750 int (*tun_dev_attach_queue)(void *security); 1751 int (*tun_dev_attach)(struct sock *sk, void *security); 1752 int (*tun_dev_open)(void *security); 1753 int (*sctp_assoc_request)(struct sctp_endpoint *ep, 1754 struct sk_buff *skb); 1755 int (*sctp_bind_connect)(struct sock *sk, int optname, 1756 struct sockaddr *address, int addrlen); 1757 void (*sctp_sk_clone)(struct sctp_endpoint *ep, struct sock *sk, 1758 struct sock *newsk); 1759 #endif /* CONFIG_SECURITY_NETWORK */ 1760 1761 #ifdef CONFIG_SECURITY_INFINIBAND 1762 int (*ib_pkey_access)(void *sec, u64 subnet_prefix, u16 pkey); 1763 int (*ib_endport_manage_subnet)(void *sec, const char *dev_name, 1764 u8 port_num); 1765 int (*ib_alloc_security)(void **sec); 1766 void (*ib_free_security)(void *sec); 1767 #endif /* CONFIG_SECURITY_INFINIBAND */ 1768 1769 #ifdef CONFIG_SECURITY_NETWORK_XFRM 1770 int (*xfrm_policy_alloc_security)(struct xfrm_sec_ctx **ctxp, 1771 struct xfrm_user_sec_ctx *sec_ctx, 1772 gfp_t gfp); 1773 int (*xfrm_policy_clone_security)(struct xfrm_sec_ctx *old_ctx, 1774 struct xfrm_sec_ctx **new_ctx); 1775 void (*xfrm_policy_free_security)(struct xfrm_sec_ctx *ctx); 1776 int (*xfrm_policy_delete_security)(struct xfrm_sec_ctx *ctx); 1777 int (*xfrm_state_alloc)(struct xfrm_state *x, 1778 struct xfrm_user_sec_ctx *sec_ctx); 1779 int (*xfrm_state_alloc_acquire)(struct xfrm_state *x, 1780 struct xfrm_sec_ctx *polsec, 1781 u32 secid); 1782 void (*xfrm_state_free_security)(struct xfrm_state *x); 1783 int (*xfrm_state_delete_security)(struct xfrm_state *x); 1784 int (*xfrm_policy_lookup)(struct xfrm_sec_ctx *ctx, u32 fl_secid, 1785 u8 dir); 1786 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x, 1787 struct xfrm_policy *xp, 1788 const struct flowi *fl); 1789 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall); 1790 #endif /* CONFIG_SECURITY_NETWORK_XFRM */ 1791 1792 /* key management security hooks */ 1793 #ifdef CONFIG_KEYS 1794 int (*key_alloc)(struct key *key, const struct cred *cred, 1795 unsigned long flags); 1796 void (*key_free)(struct key *key); 1797 int (*key_permission)(key_ref_t key_ref, const struct cred *cred, 1798 unsigned perm); 1799 int (*key_getsecurity)(struct key *key, char **_buffer); 1800 #endif /* CONFIG_KEYS */ 1801 1802 #ifdef CONFIG_AUDIT 1803 int (*audit_rule_init)(u32 field, u32 op, char *rulestr, 1804 void **lsmrule); 1805 int (*audit_rule_known)(struct audit_krule *krule); 1806 int (*audit_rule_match)(u32 secid, u32 field, u32 op, void *lsmrule); 1807 void (*audit_rule_free)(void *lsmrule); 1808 #endif /* CONFIG_AUDIT */ 1809 1810 #ifdef CONFIG_BPF_SYSCALL 1811 int (*bpf)(int cmd, union bpf_attr *attr, 1812 unsigned int size); 1813 int (*bpf_map)(struct bpf_map *map, fmode_t fmode); 1814 int (*bpf_prog)(struct bpf_prog *prog); 1815 int (*bpf_map_alloc_security)(struct bpf_map *map); 1816 void (*bpf_map_free_security)(struct bpf_map *map); 1817 int (*bpf_prog_alloc_security)(struct bpf_prog_aux *aux); 1818 void (*bpf_prog_free_security)(struct bpf_prog_aux *aux); 1819 #endif /* CONFIG_BPF_SYSCALL */ 1820 int (*locked_down)(enum lockdown_reason what); 1821 }; 1822 1823 struct security_hook_heads { 1824 struct hlist_head binder_set_context_mgr; 1825 struct hlist_head binder_transaction; 1826 struct hlist_head binder_transfer_binder; 1827 struct hlist_head binder_transfer_file; 1828 struct hlist_head ptrace_access_check; 1829 struct hlist_head ptrace_traceme; 1830 struct hlist_head capget; 1831 struct hlist_head capset; 1832 struct hlist_head capable; 1833 struct hlist_head quotactl; 1834 struct hlist_head quota_on; 1835 struct hlist_head syslog; 1836 struct hlist_head settime; 1837 struct hlist_head vm_enough_memory; 1838 struct hlist_head bprm_set_creds; 1839 struct hlist_head bprm_check_security; 1840 struct hlist_head bprm_committing_creds; 1841 struct hlist_head bprm_committed_creds; 1842 struct hlist_head fs_context_dup; 1843 struct hlist_head fs_context_parse_param; 1844 struct hlist_head sb_alloc_security; 1845 struct hlist_head sb_free_security; 1846 struct hlist_head sb_free_mnt_opts; 1847 struct hlist_head sb_eat_lsm_opts; 1848 struct hlist_head sb_remount; 1849 struct hlist_head sb_kern_mount; 1850 struct hlist_head sb_show_options; 1851 struct hlist_head sb_statfs; 1852 struct hlist_head sb_mount; 1853 struct hlist_head sb_umount; 1854 struct hlist_head sb_pivotroot; 1855 struct hlist_head sb_set_mnt_opts; 1856 struct hlist_head sb_clone_mnt_opts; 1857 struct hlist_head sb_add_mnt_opt; 1858 struct hlist_head move_mount; 1859 struct hlist_head dentry_init_security; 1860 struct hlist_head dentry_create_files_as; 1861 #ifdef CONFIG_SECURITY_PATH 1862 struct hlist_head path_unlink; 1863 struct hlist_head path_mkdir; 1864 struct hlist_head path_rmdir; 1865 struct hlist_head path_mknod; 1866 struct hlist_head path_truncate; 1867 struct hlist_head path_symlink; 1868 struct hlist_head path_link; 1869 struct hlist_head path_rename; 1870 struct hlist_head path_chmod; 1871 struct hlist_head path_chown; 1872 struct hlist_head path_chroot; 1873 #endif 1874 /* Needed for inode based modules as well */ 1875 struct hlist_head path_notify; 1876 struct hlist_head inode_alloc_security; 1877 struct hlist_head inode_free_security; 1878 struct hlist_head inode_init_security; 1879 struct hlist_head inode_create; 1880 struct hlist_head inode_link; 1881 struct hlist_head inode_unlink; 1882 struct hlist_head inode_symlink; 1883 struct hlist_head inode_mkdir; 1884 struct hlist_head inode_rmdir; 1885 struct hlist_head inode_mknod; 1886 struct hlist_head inode_rename; 1887 struct hlist_head inode_readlink; 1888 struct hlist_head inode_follow_link; 1889 struct hlist_head inode_permission; 1890 struct hlist_head inode_setattr; 1891 struct hlist_head inode_getattr; 1892 struct hlist_head inode_setxattr; 1893 struct hlist_head inode_post_setxattr; 1894 struct hlist_head inode_getxattr; 1895 struct hlist_head inode_listxattr; 1896 struct hlist_head inode_removexattr; 1897 struct hlist_head inode_need_killpriv; 1898 struct hlist_head inode_killpriv; 1899 struct hlist_head inode_getsecurity; 1900 struct hlist_head inode_setsecurity; 1901 struct hlist_head inode_listsecurity; 1902 struct hlist_head inode_getsecid; 1903 struct hlist_head inode_copy_up; 1904 struct hlist_head inode_copy_up_xattr; 1905 struct hlist_head kernfs_init_security; 1906 struct hlist_head file_permission; 1907 struct hlist_head file_alloc_security; 1908 struct hlist_head file_free_security; 1909 struct hlist_head file_ioctl; 1910 struct hlist_head mmap_addr; 1911 struct hlist_head mmap_file; 1912 struct hlist_head file_mprotect; 1913 struct hlist_head file_lock; 1914 struct hlist_head file_fcntl; 1915 struct hlist_head file_set_fowner; 1916 struct hlist_head file_send_sigiotask; 1917 struct hlist_head file_receive; 1918 struct hlist_head file_open; 1919 struct hlist_head task_alloc; 1920 struct hlist_head task_free; 1921 struct hlist_head cred_alloc_blank; 1922 struct hlist_head cred_free; 1923 struct hlist_head cred_prepare; 1924 struct hlist_head cred_transfer; 1925 struct hlist_head cred_getsecid; 1926 struct hlist_head kernel_act_as; 1927 struct hlist_head kernel_create_files_as; 1928 struct hlist_head kernel_load_data; 1929 struct hlist_head kernel_read_file; 1930 struct hlist_head kernel_post_read_file; 1931 struct hlist_head kernel_module_request; 1932 struct hlist_head task_fix_setuid; 1933 struct hlist_head task_setpgid; 1934 struct hlist_head task_getpgid; 1935 struct hlist_head task_getsid; 1936 struct hlist_head task_getsecid; 1937 struct hlist_head task_setnice; 1938 struct hlist_head task_setioprio; 1939 struct hlist_head task_getioprio; 1940 struct hlist_head task_prlimit; 1941 struct hlist_head task_setrlimit; 1942 struct hlist_head task_setscheduler; 1943 struct hlist_head task_getscheduler; 1944 struct hlist_head task_movememory; 1945 struct hlist_head task_kill; 1946 struct hlist_head task_prctl; 1947 struct hlist_head task_to_inode; 1948 struct hlist_head ipc_permission; 1949 struct hlist_head ipc_getsecid; 1950 struct hlist_head msg_msg_alloc_security; 1951 struct hlist_head msg_msg_free_security; 1952 struct hlist_head msg_queue_alloc_security; 1953 struct hlist_head msg_queue_free_security; 1954 struct hlist_head msg_queue_associate; 1955 struct hlist_head msg_queue_msgctl; 1956 struct hlist_head msg_queue_msgsnd; 1957 struct hlist_head msg_queue_msgrcv; 1958 struct hlist_head shm_alloc_security; 1959 struct hlist_head shm_free_security; 1960 struct hlist_head shm_associate; 1961 struct hlist_head shm_shmctl; 1962 struct hlist_head shm_shmat; 1963 struct hlist_head sem_alloc_security; 1964 struct hlist_head sem_free_security; 1965 struct hlist_head sem_associate; 1966 struct hlist_head sem_semctl; 1967 struct hlist_head sem_semop; 1968 struct hlist_head netlink_send; 1969 struct hlist_head d_instantiate; 1970 struct hlist_head getprocattr; 1971 struct hlist_head setprocattr; 1972 struct hlist_head ismaclabel; 1973 struct hlist_head secid_to_secctx; 1974 struct hlist_head secctx_to_secid; 1975 struct hlist_head release_secctx; 1976 struct hlist_head inode_invalidate_secctx; 1977 struct hlist_head inode_notifysecctx; 1978 struct hlist_head inode_setsecctx; 1979 struct hlist_head inode_getsecctx; 1980 #ifdef CONFIG_SECURITY_NETWORK 1981 struct hlist_head unix_stream_connect; 1982 struct hlist_head unix_may_send; 1983 struct hlist_head socket_create; 1984 struct hlist_head socket_post_create; 1985 struct hlist_head socket_socketpair; 1986 struct hlist_head socket_bind; 1987 struct hlist_head socket_connect; 1988 struct hlist_head socket_listen; 1989 struct hlist_head socket_accept; 1990 struct hlist_head socket_sendmsg; 1991 struct hlist_head socket_recvmsg; 1992 struct hlist_head socket_getsockname; 1993 struct hlist_head socket_getpeername; 1994 struct hlist_head socket_getsockopt; 1995 struct hlist_head socket_setsockopt; 1996 struct hlist_head socket_shutdown; 1997 struct hlist_head socket_sock_rcv_skb; 1998 struct hlist_head socket_getpeersec_stream; 1999 struct hlist_head socket_getpeersec_dgram; 2000 struct hlist_head sk_alloc_security; 2001 struct hlist_head sk_free_security; 2002 struct hlist_head sk_clone_security; 2003 struct hlist_head sk_getsecid; 2004 struct hlist_head sock_graft; 2005 struct hlist_head inet_conn_request; 2006 struct hlist_head inet_csk_clone; 2007 struct hlist_head inet_conn_established; 2008 struct hlist_head secmark_relabel_packet; 2009 struct hlist_head secmark_refcount_inc; 2010 struct hlist_head secmark_refcount_dec; 2011 struct hlist_head req_classify_flow; 2012 struct hlist_head tun_dev_alloc_security; 2013 struct hlist_head tun_dev_free_security; 2014 struct hlist_head tun_dev_create; 2015 struct hlist_head tun_dev_attach_queue; 2016 struct hlist_head tun_dev_attach; 2017 struct hlist_head tun_dev_open; 2018 struct hlist_head sctp_assoc_request; 2019 struct hlist_head sctp_bind_connect; 2020 struct hlist_head sctp_sk_clone; 2021 #endif /* CONFIG_SECURITY_NETWORK */ 2022 #ifdef CONFIG_SECURITY_INFINIBAND 2023 struct hlist_head ib_pkey_access; 2024 struct hlist_head ib_endport_manage_subnet; 2025 struct hlist_head ib_alloc_security; 2026 struct hlist_head ib_free_security; 2027 #endif /* CONFIG_SECURITY_INFINIBAND */ 2028 #ifdef CONFIG_SECURITY_NETWORK_XFRM 2029 struct hlist_head xfrm_policy_alloc_security; 2030 struct hlist_head xfrm_policy_clone_security; 2031 struct hlist_head xfrm_policy_free_security; 2032 struct hlist_head xfrm_policy_delete_security; 2033 struct hlist_head xfrm_state_alloc; 2034 struct hlist_head xfrm_state_alloc_acquire; 2035 struct hlist_head xfrm_state_free_security; 2036 struct hlist_head xfrm_state_delete_security; 2037 struct hlist_head xfrm_policy_lookup; 2038 struct hlist_head xfrm_state_pol_flow_match; 2039 struct hlist_head xfrm_decode_session; 2040 #endif /* CONFIG_SECURITY_NETWORK_XFRM */ 2041 #ifdef CONFIG_KEYS 2042 struct hlist_head key_alloc; 2043 struct hlist_head key_free; 2044 struct hlist_head key_permission; 2045 struct hlist_head key_getsecurity; 2046 #endif /* CONFIG_KEYS */ 2047 #ifdef CONFIG_AUDIT 2048 struct hlist_head audit_rule_init; 2049 struct hlist_head audit_rule_known; 2050 struct hlist_head audit_rule_match; 2051 struct hlist_head audit_rule_free; 2052 #endif /* CONFIG_AUDIT */ 2053 #ifdef CONFIG_BPF_SYSCALL 2054 struct hlist_head bpf; 2055 struct hlist_head bpf_map; 2056 struct hlist_head bpf_prog; 2057 struct hlist_head bpf_map_alloc_security; 2058 struct hlist_head bpf_map_free_security; 2059 struct hlist_head bpf_prog_alloc_security; 2060 struct hlist_head bpf_prog_free_security; 2061 #endif /* CONFIG_BPF_SYSCALL */ 2062 struct hlist_head locked_down; 2063 } __randomize_layout; 2064 2065 /* 2066 * Security module hook list structure. 2067 * For use with generic list macros for common operations. 2068 */ 2069 struct security_hook_list { 2070 struct hlist_node list; 2071 struct hlist_head *head; 2072 union security_list_options hook; 2073 char *lsm; 2074 } __randomize_layout; 2075 2076 /* 2077 * Security blob size or offset data. 2078 */ 2079 struct lsm_blob_sizes { 2080 int lbs_cred; 2081 int lbs_file; 2082 int lbs_inode; 2083 int lbs_ipc; 2084 int lbs_msg_msg; 2085 int lbs_task; 2086 }; 2087 2088 /* 2089 * Initializing a security_hook_list structure takes 2090 * up a lot of space in a source file. This macro takes 2091 * care of the common case and reduces the amount of 2092 * text involved. 2093 */ 2094 #define LSM_HOOK_INIT(HEAD, HOOK) \ 2095 { .head = &security_hook_heads.HEAD, .hook = { .HEAD = HOOK } } 2096 2097 extern struct security_hook_heads security_hook_heads; 2098 extern char *lsm_names; 2099 2100 extern void security_add_hooks(struct security_hook_list *hooks, int count, 2101 char *lsm); 2102 2103 #define LSM_FLAG_LEGACY_MAJOR BIT(0) 2104 #define LSM_FLAG_EXCLUSIVE BIT(1) 2105 2106 enum lsm_order { 2107 LSM_ORDER_FIRST = -1, /* This is only for capabilities. */ 2108 LSM_ORDER_MUTABLE = 0, 2109 }; 2110 2111 struct lsm_info { 2112 const char *name; /* Required. */ 2113 enum lsm_order order; /* Optional: default is LSM_ORDER_MUTABLE */ 2114 unsigned long flags; /* Optional: flags describing LSM */ 2115 int *enabled; /* Optional: controlled by CONFIG_LSM */ 2116 int (*init)(void); /* Required. */ 2117 struct lsm_blob_sizes *blobs; /* Optional: for blob sharing. */ 2118 }; 2119 2120 extern struct lsm_info __start_lsm_info[], __end_lsm_info[]; 2121 extern struct lsm_info __start_early_lsm_info[], __end_early_lsm_info[]; 2122 2123 #define DEFINE_LSM(lsm) \ 2124 static struct lsm_info __lsm_##lsm \ 2125 __used __section(.lsm_info.init) \ 2126 __aligned(sizeof(unsigned long)) 2127 2128 #define DEFINE_EARLY_LSM(lsm) \ 2129 static struct lsm_info __early_lsm_##lsm \ 2130 __used __section(.early_lsm_info.init) \ 2131 __aligned(sizeof(unsigned long)) 2132 2133 #ifdef CONFIG_SECURITY_SELINUX_DISABLE 2134 /* 2135 * Assuring the safety of deleting a security module is up to 2136 * the security module involved. This may entail ordering the 2137 * module's hook list in a particular way, refusing to disable 2138 * the module once a policy is loaded or any number of other 2139 * actions better imagined than described. 2140 * 2141 * The name of the configuration option reflects the only module 2142 * that currently uses the mechanism. Any developer who thinks 2143 * disabling their module is a good idea needs to be at least as 2144 * careful as the SELinux team. 2145 */ 2146 static inline void security_delete_hooks(struct security_hook_list *hooks, 2147 int count) 2148 { 2149 int i; 2150 2151 for (i = 0; i < count; i++) 2152 hlist_del_rcu(&hooks[i].list); 2153 } 2154 #endif /* CONFIG_SECURITY_SELINUX_DISABLE */ 2155 2156 /* Currently required to handle SELinux runtime hook disable. */ 2157 #ifdef CONFIG_SECURITY_WRITABLE_HOOKS 2158 #define __lsm_ro_after_init 2159 #else 2160 #define __lsm_ro_after_init __ro_after_init 2161 #endif /* CONFIG_SECURITY_WRITABLE_HOOKS */ 2162 2163 extern int lsm_inode_alloc(struct inode *inode); 2164 2165 #endif /* ! __LINUX_LSM_HOOKS_H */