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