![]() |
|
|||
0001 /* 0002 * Linux Security Module interfaces 0003 * 0004 * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com> 0005 * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com> 0006 * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com> 0007 * Copyright (C) 2001 James Morris <jmorris@intercode.com.au> 0008 * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group) 0009 * Copyright (C) 2015 Intel Corporation. 0010 * Copyright (C) 2015 Casey Schaufler <casey@schaufler-ca.com> 0011 * Copyright (C) 2016 Mellanox Techonologies 0012 * 0013 * This program is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Due to this file being licensed under the GPL there is controversy over 0019 * whether this permits you to write a module that #includes this file 0020 * without placing your module under the GPL. Please consult a lawyer for 0021 * advice before doing this. 0022 * 0023 */ 0024 0025 #ifndef __LINUX_LSM_HOOKS_H 0026 #define __LINUX_LSM_HOOKS_H 0027 0028 #include <linux/security.h> 0029 #include <linux/init.h> 0030 #include <linux/rculist.h> 0031 0032 /** 0033 * union security_list_options - Linux Security Module hook function list 0034 * 0035 * Security hooks for program execution operations. 0036 * 0037 * @bprm_creds_for_exec: 0038 * If the setup in prepare_exec_creds did not setup @bprm->cred->security 0039 * properly for executing @bprm->file, update the LSM's portion of 0040 * @bprm->cred->security to be what commit_creds needs to install for the 0041 * new program. This hook may also optionally check permissions 0042 * (e.g. for transitions between security domains). 0043 * The hook must set @bprm->secureexec to 1 if AT_SECURE should be set to 0044 * request libc enable secure mode. 0045 * @bprm contains the linux_binprm structure. 0046 * Return 0 if the hook is successful and permission is granted. 0047 * @bprm_creds_from_file: 0048 * If @file is setpcap, suid, sgid or otherwise marked to change 0049 * privilege upon exec, update @bprm->cred to reflect that change. 0050 * This is called after finding the binary that will be executed. 0051 * without an interpreter. This ensures that the credentials will not 0052 * be derived from a script that the binary will need to reopen, which 0053 * when reopend may end up being a completely different file. This 0054 * hook may also optionally check permissions (e.g. for transitions 0055 * between security domains). 0056 * The hook must set @bprm->secureexec to 1 if AT_SECURE should be set to 0057 * request libc enable secure mode. 0058 * The hook must add to @bprm->per_clear any personality flags that 0059 * should be cleared from current->personality. 0060 * @bprm contains the linux_binprm structure. 0061 * Return 0 if the hook is successful and permission is granted. 0062 * @bprm_check_security: 0063 * This hook mediates the point when a search for a binary handler will 0064 * begin. It allows a check against the @bprm->cred->security value 0065 * which was set in the preceding creds_for_exec call. The argv list and 0066 * envp list are reliably available in @bprm. This hook may be called 0067 * multiple times during a single execve. 0068 * @bprm contains the linux_binprm structure. 0069 * Return 0 if the hook is successful and permission is granted. 0070 * @bprm_committing_creds: 0071 * Prepare to install the new security attributes of a process being 0072 * transformed by an execve operation, based on the old credentials 0073 * pointed to by @current->cred and the information set in @bprm->cred by 0074 * the bprm_creds_for_exec hook. @bprm points to the linux_binprm 0075 * structure. This hook is a good place to perform state changes on the 0076 * process such as closing open file descriptors to which access will no 0077 * longer be granted when the attributes are changed. This is called 0078 * immediately before commit_creds(). 0079 * @bprm_committed_creds: 0080 * Tidy up after the installation of the new security attributes of a 0081 * process being transformed by an execve operation. The new credentials 0082 * have, by this point, been set to @current->cred. @bprm points to the 0083 * linux_binprm structure. This hook is a good place to perform state 0084 * changes on the process such as clearing out non-inheritable signal 0085 * state. This is called immediately after commit_creds(). 0086 * 0087 * Security hooks for mount using fs_context. 0088 * [See also Documentation/filesystems/mount_api.rst] 0089 * 0090 * @fs_context_dup: 0091 * Allocate and attach a security structure to sc->security. This pointer 0092 * is initialised to NULL by the caller. 0093 * @fc indicates the new filesystem context. 0094 * @src_fc indicates the original filesystem context. 0095 * @fs_context_parse_param: 0096 * Userspace provided a parameter to configure a superblock. The LSM may 0097 * reject it with an error and may use it for itself, in which case it 0098 * should return 0; otherwise it should return -ENOPARAM to pass it on to 0099 * the filesystem. 0100 * @fc indicates the filesystem context. 0101 * @param The parameter 0102 * 0103 * Security hooks for filesystem operations. 0104 * 0105 * @sb_alloc_security: 0106 * Allocate and attach a security structure to the sb->s_security field. 0107 * The s_security field is initialized to NULL when the structure is 0108 * allocated. 0109 * @sb contains the super_block structure to be modified. 0110 * Return 0 if operation was successful. 0111 * @sb_delete: 0112 * Release objects tied to a superblock (e.g. inodes). 0113 * @sb contains the super_block structure being released. 0114 * @sb_free_security: 0115 * Deallocate and clear the sb->s_security field. 0116 * @sb contains the super_block structure to be modified. 0117 * @sb_free_mnt_opts: 0118 * Free memory associated with @mnt_ops. 0119 * @sb_eat_lsm_opts: 0120 * Eat (scan @orig options) and save them in @mnt_opts. 0121 * @sb_statfs: 0122 * Check permission before obtaining filesystem statistics for the @mnt 0123 * mountpoint. 0124 * @dentry is a handle on the superblock for the filesystem. 0125 * Return 0 if permission is granted. 0126 * @sb_mount: 0127 * Check permission before an object specified by @dev_name is mounted on 0128 * the mount point named by @nd. For an ordinary mount, @dev_name 0129 * identifies a device if the file system type requires a device. For a 0130 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a 0131 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the 0132 * pathname of the object being mounted. 0133 * @dev_name contains the name for object being mounted. 0134 * @path contains the path for mount point object. 0135 * @type contains the filesystem type. 0136 * @flags contains the mount flags. 0137 * @data contains the filesystem-specific data. 0138 * Return 0 if permission is granted. 0139 * @sb_copy_data: 0140 * Allow mount option data to be copied prior to parsing by the filesystem, 0141 * so that the security module can extract security-specific mount 0142 * options cleanly (a filesystem may modify the data e.g. with strsep()). 0143 * This also allows the original mount data to be stripped of security- 0144 * specific options to avoid having to make filesystems aware of them. 0145 * @orig the original mount data copied from userspace. 0146 * @copy copied data which will be passed to the security module. 0147 * Returns 0 if the copy was successful. 0148 * @sb_mnt_opts_compat: 0149 * Determine if the new mount options in @mnt_opts are allowed given 0150 * the existing mounted filesystem at @sb. 0151 * @sb superblock being compared 0152 * @mnt_opts new mount options 0153 * Return 0 if options are compatible. 0154 * @sb_remount: 0155 * Extracts security system specific mount options and verifies no changes 0156 * are being made to those options. 0157 * @sb superblock being remounted 0158 * @data contains the filesystem-specific data. 0159 * Return 0 if permission is granted. 0160 * @sb_kern_mount: 0161 * Mount this @sb if allowed by permissions. 0162 * @sb_show_options: 0163 * Show (print on @m) mount options for this @sb. 0164 * @sb_umount: 0165 * Check permission before the @mnt file system is unmounted. 0166 * @mnt contains the mounted file system. 0167 * @flags contains the unmount flags, e.g. MNT_FORCE. 0168 * Return 0 if permission is granted. 0169 * @sb_pivotroot: 0170 * Check permission before pivoting the root filesystem. 0171 * @old_path contains the path for the new location of the 0172 * current root (put_old). 0173 * @new_path contains the path for the new root (new_root). 0174 * Return 0 if permission is granted. 0175 * @sb_set_mnt_opts: 0176 * Set the security relevant mount options used for a superblock 0177 * @sb the superblock to set security mount options for 0178 * @opts binary data structure containing all lsm mount data 0179 * @sb_clone_mnt_opts: 0180 * Copy all security options from a given superblock to another 0181 * @oldsb old superblock which contain information to clone 0182 * @newsb new superblock which needs filled in 0183 * @sb_parse_opts_str: 0184 * Parse a string of security data filling in the opts structure 0185 * @options string containing all mount options known by the LSM 0186 * @opts binary data structure usable by the LSM 0187 * @move_mount: 0188 * Check permission before a mount is moved. 0189 * @from_path indicates the mount that is going to be moved. 0190 * @to_path indicates the mountpoint that will be mounted upon. 0191 * @dentry_init_security: 0192 * Compute a context for a dentry as the inode is not yet available 0193 * since NFSv4 has no label backed by an EA anyway. 0194 * @dentry dentry to use in calculating the context. 0195 * @mode mode used to determine resource type. 0196 * @name name of the last path component used to create file 0197 * @xattr_name pointer to place the pointer to security xattr name. 0198 * Caller does not have to free the resulting pointer. Its 0199 * a pointer to static string. 0200 * @ctx pointer to place the pointer to the resulting context in. 0201 * @ctxlen point to place the length of the resulting context. 0202 * @dentry_create_files_as: 0203 * Compute a context for a dentry as the inode is not yet available 0204 * and set that context in passed in creds so that new files are 0205 * created using that context. Context is calculated using the 0206 * passed in creds and not the creds of the caller. 0207 * @dentry dentry to use in calculating the context. 0208 * @mode mode used to determine resource type. 0209 * @name name of the last path component used to create file 0210 * @old creds which should be used for context calculation 0211 * @new creds to modify 0212 * 0213 * 0214 * Security hooks for inode operations. 0215 * 0216 * @inode_alloc_security: 0217 * Allocate and attach a security structure to @inode->i_security. The 0218 * i_security field is initialized to NULL when the inode structure is 0219 * allocated. 0220 * @inode contains the inode structure. 0221 * Return 0 if operation was successful. 0222 * @inode_free_security: 0223 * @inode contains the inode structure. 0224 * Deallocate the inode security structure and set @inode->i_security to 0225 * NULL. 0226 * @inode_init_security: 0227 * Obtain the security attribute name suffix and value to set on a newly 0228 * created inode and set up the incore security field for the new inode. 0229 * This hook is called by the fs code as part of the inode creation 0230 * transaction and provides for atomic labeling of the inode, unlike 0231 * the post_create/mkdir/... hooks called by the VFS. The hook function 0232 * is expected to allocate the name and value via kmalloc, with the caller 0233 * being responsible for calling kfree after using them. 0234 * If the security module does not use security attributes or does 0235 * not wish to put a security attribute on this particular inode, 0236 * then it should return -EOPNOTSUPP to skip this processing. 0237 * @inode contains the inode structure of the newly created inode. 0238 * @dir contains the inode structure of the parent directory. 0239 * @qstr contains the last path component of the new object 0240 * @name will be set to the allocated name suffix (e.g. selinux). 0241 * @value will be set to the allocated attribute value. 0242 * @len will be set to the length of the value. 0243 * Returns 0 if @name and @value have been successfully set, 0244 * -EOPNOTSUPP if no security attribute is needed, or 0245 * -ENOMEM on memory allocation failure. 0246 * @inode_init_security_anon: 0247 * Set up the incore security field for the new anonymous inode 0248 * and return whether the inode creation is permitted by the security 0249 * module or not. 0250 * @inode contains the inode structure 0251 * @name name of the anonymous inode class 0252 * @context_inode optional related inode 0253 * Returns 0 on success, -EACCES if the security module denies the 0254 * creation of this inode, or another -errno upon other errors. 0255 * @inode_create: 0256 * Check permission to create a regular file. 0257 * @dir contains inode structure of the parent of the new file. 0258 * @dentry contains the dentry structure for the file to be created. 0259 * @mode contains the file mode of the file to be created. 0260 * Return 0 if permission is granted. 0261 * @inode_link: 0262 * Check permission before creating a new hard link to a file. 0263 * @old_dentry contains the dentry structure for an existing 0264 * link to the file. 0265 * @dir contains the inode structure of the parent directory 0266 * of the new link. 0267 * @new_dentry contains the dentry structure for the new link. 0268 * Return 0 if permission is granted. 0269 * @path_link: 0270 * Check permission before creating a new hard link to a file. 0271 * @old_dentry contains the dentry structure for an existing link 0272 * to the file. 0273 * @new_dir contains the path structure of the parent directory of 0274 * the new link. 0275 * @new_dentry contains the dentry structure for the new link. 0276 * Return 0 if permission is granted. 0277 * @inode_unlink: 0278 * Check the permission to remove a hard link to a file. 0279 * @dir contains the inode structure of parent directory of the file. 0280 * @dentry contains the dentry structure for file to be unlinked. 0281 * Return 0 if permission is granted. 0282 * @path_unlink: 0283 * Check the permission to remove a hard link to a file. 0284 * @dir contains the path structure of parent directory of the file. 0285 * @dentry contains the dentry structure for file to be unlinked. 0286 * Return 0 if permission is granted. 0287 * @inode_symlink: 0288 * Check the permission to create a symbolic link to a file. 0289 * @dir contains the inode structure of parent directory of 0290 * the symbolic link. 0291 * @dentry contains the dentry structure of the symbolic link. 0292 * @old_name contains the pathname of file. 0293 * Return 0 if permission is granted. 0294 * @path_symlink: 0295 * Check the permission to create a symbolic link to a file. 0296 * @dir contains the path structure of parent directory of 0297 * the symbolic link. 0298 * @dentry contains the dentry structure of the symbolic link. 0299 * @old_name contains the pathname of file. 0300 * Return 0 if permission is granted. 0301 * @inode_mkdir: 0302 * Check permissions to create a new directory in the existing directory 0303 * associated with inode structure @dir. 0304 * @dir contains the inode structure of parent of the directory 0305 * to be created. 0306 * @dentry contains the dentry structure of new directory. 0307 * @mode contains the mode of new directory. 0308 * Return 0 if permission is granted. 0309 * @path_mkdir: 0310 * Check permissions to create a new directory in the existing directory 0311 * associated with path structure @path. 0312 * @dir contains the path structure of parent of the directory 0313 * to be created. 0314 * @dentry contains the dentry structure of new directory. 0315 * @mode contains the mode of new directory. 0316 * Return 0 if permission is granted. 0317 * @inode_rmdir: 0318 * Check the permission to remove a directory. 0319 * @dir contains the inode structure of parent of the directory 0320 * to be removed. 0321 * @dentry contains the dentry structure of directory to be removed. 0322 * Return 0 if permission is granted. 0323 * @path_rmdir: 0324 * Check the permission to remove a directory. 0325 * @dir contains the path structure of parent of the directory to be 0326 * removed. 0327 * @dentry contains the dentry structure of directory to be removed. 0328 * Return 0 if permission is granted. 0329 * @inode_mknod: 0330 * Check permissions when creating a special file (or a socket or a fifo 0331 * file created via the mknod system call). Note that if mknod operation 0332 * is being done for a regular file, then the create hook will be called 0333 * and not this hook. 0334 * @dir contains the inode structure of parent of the new file. 0335 * @dentry contains the dentry structure of the new file. 0336 * @mode contains the mode of the new file. 0337 * @dev contains the device number. 0338 * Return 0 if permission is granted. 0339 * @path_mknod: 0340 * Check permissions when creating a file. Note that this hook is called 0341 * even if mknod operation is being done for a regular file. 0342 * @dir contains the path structure of parent of the new file. 0343 * @dentry contains the dentry structure of the new file. 0344 * @mode contains the mode of the new file. 0345 * @dev contains the undecoded device number. Use new_decode_dev() to get 0346 * the decoded device number. 0347 * Return 0 if permission is granted. 0348 * @inode_rename: 0349 * Check for permission to rename a file or directory. 0350 * @old_dir contains the inode structure for parent of the old link. 0351 * @old_dentry contains the dentry structure of the old link. 0352 * @new_dir contains the inode structure for parent of the new link. 0353 * @new_dentry contains the dentry structure of the new link. 0354 * Return 0 if permission is granted. 0355 * @path_rename: 0356 * Check for permission to rename a file or directory. 0357 * @old_dir contains the path structure for parent of the old link. 0358 * @old_dentry contains the dentry structure of the old link. 0359 * @new_dir contains the path structure for parent of the new link. 0360 * @new_dentry contains the dentry structure of the new link. 0361 * @flags may contain rename options such as RENAME_EXCHANGE. 0362 * Return 0 if permission is granted. 0363 * @path_chmod: 0364 * Check for permission to change a mode of the file @path. The new 0365 * mode is specified in @mode. 0366 * @path contains the path structure of the file to change the mode. 0367 * @mode contains the new DAC's permission, which is a bitmask of 0368 * constants from <include/uapi/linux/stat.h> 0369 * Return 0 if permission is granted. 0370 * @path_chown: 0371 * Check for permission to change owner/group of a file or directory. 0372 * @path contains the path structure. 0373 * @uid contains new owner's ID. 0374 * @gid contains new group's ID. 0375 * Return 0 if permission is granted. 0376 * @path_chroot: 0377 * Check for permission to change root directory. 0378 * @path contains the path structure. 0379 * Return 0 if permission is granted. 0380 * @path_notify: 0381 * Check permissions before setting a watch on events as defined by @mask, 0382 * on an object at @path, whose type is defined by @obj_type. 0383 * @inode_readlink: 0384 * Check the permission to read the symbolic link. 0385 * @dentry contains the dentry structure for the file link. 0386 * Return 0 if permission is granted. 0387 * @inode_follow_link: 0388 * Check permission to follow a symbolic link when looking up a pathname. 0389 * @dentry contains the dentry structure for the link. 0390 * @inode contains the inode, which itself is not stable in RCU-walk 0391 * @rcu indicates whether we are in RCU-walk mode. 0392 * Return 0 if permission is granted. 0393 * @inode_permission: 0394 * Check permission before accessing an inode. This hook is called by the 0395 * existing Linux permission function, so a security module can use it to 0396 * provide additional checking for existing Linux permission checks. 0397 * Notice that this hook is called when a file is opened (as well as many 0398 * other operations), whereas the file_security_ops permission hook is 0399 * called when the actual read/write operations are performed. 0400 * @inode contains the inode structure to check. 0401 * @mask contains the permission mask. 0402 * Return 0 if permission is granted. 0403 * @inode_setattr: 0404 * Check permission before setting file attributes. Note that the kernel 0405 * call to notify_change is performed from several locations, whenever 0406 * file attributes change (such as when a file is truncated, chown/chmod 0407 * operations, transferring disk quotas, etc). 0408 * @dentry contains the dentry structure for the file. 0409 * @attr is the iattr structure containing the new file attributes. 0410 * Return 0 if permission is granted. 0411 * @path_truncate: 0412 * Check permission before truncating a file. 0413 * @path contains the path structure for the file. 0414 * Return 0 if permission is granted. 0415 * @inode_getattr: 0416 * Check permission before obtaining file attributes. 0417 * @path contains the path structure for the file. 0418 * Return 0 if permission is granted. 0419 * @inode_setxattr: 0420 * Check permission before setting the extended attributes 0421 * @value identified by @name for @dentry. 0422 * Return 0 if permission is granted. 0423 * @inode_post_setxattr: 0424 * Update inode security field after successful setxattr operation. 0425 * @value identified by @name for @dentry. 0426 * @inode_getxattr: 0427 * Check permission before obtaining the extended attributes 0428 * identified by @name for @dentry. 0429 * Return 0 if permission is granted. 0430 * @inode_listxattr: 0431 * Check permission before obtaining the list of extended attribute 0432 * names for @dentry. 0433 * Return 0 if permission is granted. 0434 * @inode_removexattr: 0435 * Check permission before removing the extended attribute 0436 * identified by @name for @dentry. 0437 * Return 0 if permission is granted. 0438 * @inode_getsecurity: 0439 * Retrieve a copy of the extended attribute representation of the 0440 * security label associated with @name for @inode via @buffer. Note that 0441 * @name is the remainder of the attribute name after the security prefix 0442 * has been removed. @alloc is used to specify of the call should return a 0443 * value via the buffer or just the value length Return size of buffer on 0444 * success. 0445 * @inode_setsecurity: 0446 * Set the security label associated with @name for @inode from the 0447 * extended attribute value @value. @size indicates the size of the 0448 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0. 0449 * Note that @name is the remainder of the attribute name after the 0450 * security. prefix has been removed. 0451 * Return 0 on success. 0452 * @inode_listsecurity: 0453 * Copy the extended attribute names for the security labels 0454 * associated with @inode into @buffer. The maximum size of @buffer 0455 * is specified by @buffer_size. @buffer may be NULL to request 0456 * the size of the buffer required. 0457 * Returns number of bytes used/required on success. 0458 * @inode_need_killpriv: 0459 * Called when an inode has been changed. 0460 * @dentry is the dentry being changed. 0461 * Return <0 on error to abort the inode change operation. 0462 * Return 0 if inode_killpriv does not need to be called. 0463 * Return >0 if inode_killpriv does need to be called. 0464 * @inode_killpriv: 0465 * The setuid bit is being removed. Remove similar security labels. 0466 * Called with the dentry->d_inode->i_mutex held. 0467 * @mnt_userns: user namespace of the mount 0468 * @dentry is the dentry being changed. 0469 * Return 0 on success. If error is returned, then the operation 0470 * causing setuid bit removal is failed. 0471 * @inode_getsecid: 0472 * Get the secid associated with the node. 0473 * @inode contains a pointer to the inode. 0474 * @secid contains a pointer to the location where result will be saved. 0475 * In case of failure, @secid will be set to zero. 0476 * @inode_copy_up: 0477 * A file is about to be copied up from lower layer to upper layer of 0478 * overlay filesystem. Security module can prepare a set of new creds 0479 * and modify as need be and return new creds. Caller will switch to 0480 * new creds temporarily to create new file and release newly allocated 0481 * creds. 0482 * @src indicates the union dentry of file that is being copied up. 0483 * @new pointer to pointer to return newly allocated creds. 0484 * Returns 0 on success or a negative error code on error. 0485 * @inode_copy_up_xattr: 0486 * Filter the xattrs being copied up when a unioned file is copied 0487 * up from a lower layer to the union/overlay layer. 0488 * @name indicates the name of the xattr. 0489 * Returns 0 to accept the xattr, 1 to discard the xattr, -EOPNOTSUPP if 0490 * security module does not know about attribute or a negative error code 0491 * to abort the copy up. Note that the caller is responsible for reading 0492 * and writing the xattrs as this hook is merely a filter. 0493 * @d_instantiate: 0494 * Fill in @inode security information for a @dentry if allowed. 0495 * @getprocattr: 0496 * Read attribute @name for process @p and store it into @value if allowed. 0497 * @setprocattr: 0498 * Write (set) attribute @name to @value, size @size if allowed. 0499 * 0500 * Security hooks for kernfs node operations 0501 * 0502 * @kernfs_init_security: 0503 * Initialize the security context of a newly created kernfs node based 0504 * on its own and its parent's attributes. 0505 * 0506 * @kn_dir the parent kernfs node 0507 * @kn the new child kernfs node 0508 * 0509 * Security hooks for file operations 0510 * 0511 * @file_permission: 0512 * Check file permissions before accessing an open file. This hook is 0513 * called by various operations that read or write files. A security 0514 * module can use this hook to perform additional checking on these 0515 * operations, e.g. to revalidate permissions on use to support privilege 0516 * bracketing or policy changes. Notice that this hook is used when the 0517 * actual read/write operations are performed, whereas the 0518 * inode_security_ops hook is called when a file is opened (as well as 0519 * many other operations). 0520 * Caveat: Although this hook can be used to revalidate permissions for 0521 * various system call operations that read or write files, it does not 0522 * address the revalidation of permissions for memory-mapped files. 0523 * Security modules must handle this separately if they need such 0524 * revalidation. 0525 * @file contains the file structure being accessed. 0526 * @mask contains the requested permissions. 0527 * Return 0 if permission is granted. 0528 * @file_alloc_security: 0529 * Allocate and attach a security structure to the file->f_security field. 0530 * The security field is initialized to NULL when the structure is first 0531 * created. 0532 * @file contains the file structure to secure. 0533 * Return 0 if the hook is successful and permission is granted. 0534 * @file_free_security: 0535 * Deallocate and free any security structures stored in file->f_security. 0536 * @file contains the file structure being modified. 0537 * @file_ioctl: 0538 * @file contains the file structure. 0539 * @cmd contains the operation to perform. 0540 * @arg contains the operational arguments. 0541 * Check permission for an ioctl operation on @file. Note that @arg 0542 * sometimes represents a user space pointer; in other cases, it may be a 0543 * simple integer value. When @arg represents a user space pointer, it 0544 * should never be used by the security module. 0545 * Return 0 if permission is granted. 0546 * @mmap_addr : 0547 * Check permissions for a mmap operation at @addr. 0548 * @addr contains virtual address that will be used for the operation. 0549 * Return 0 if permission is granted. 0550 * @mmap_file : 0551 * Check permissions for a mmap operation. The @file may be NULL, e.g. 0552 * if mapping anonymous memory. 0553 * @file contains the file structure for file to map (may be NULL). 0554 * @reqprot contains the protection requested by the application. 0555 * @prot contains the protection that will be applied by the kernel. 0556 * @flags contains the operational flags. 0557 * Return 0 if permission is granted. 0558 * @file_mprotect: 0559 * Check permissions before changing memory access permissions. 0560 * @vma contains the memory region to modify. 0561 * @reqprot contains the protection requested by the application. 0562 * @prot contains the protection that will be applied by the kernel. 0563 * Return 0 if permission is granted. 0564 * @file_lock: 0565 * Check permission before performing file locking operations. 0566 * Note the hook mediates both flock and fcntl style locks. 0567 * @file contains the file structure. 0568 * @cmd contains the posix-translated lock operation to perform 0569 * (e.g. F_RDLCK, F_WRLCK). 0570 * Return 0 if permission is granted. 0571 * @file_fcntl: 0572 * Check permission before allowing the file operation specified by @cmd 0573 * from being performed on the file @file. Note that @arg sometimes 0574 * represents a user space pointer; in other cases, it may be a simple 0575 * integer value. When @arg represents a user space pointer, it should 0576 * never be used by the security module. 0577 * @file contains the file structure. 0578 * @cmd contains the operation to be performed. 0579 * @arg contains the operational arguments. 0580 * Return 0 if permission is granted. 0581 * @file_set_fowner: 0582 * Save owner security information (typically from current->security) in 0583 * file->f_security for later use by the send_sigiotask hook. 0584 * @file contains the file structure to update. 0585 * Return 0 on success. 0586 * @file_send_sigiotask: 0587 * Check permission for the file owner @fown to send SIGIO or SIGURG to the 0588 * process @tsk. Note that this hook is sometimes called from interrupt. 0589 * Note that the fown_struct, @fown, is never outside the context of a 0590 * struct file, so the file structure (and associated security information) 0591 * can always be obtained: container_of(fown, struct file, f_owner) 0592 * @tsk contains the structure of task receiving signal. 0593 * @fown contains the file owner information. 0594 * @sig is the signal that will be sent. When 0, kernel sends SIGIO. 0595 * Return 0 if permission is granted. 0596 * @file_receive: 0597 * This hook allows security modules to control the ability of a process 0598 * to receive an open file descriptor via socket IPC. 0599 * @file contains the file structure being received. 0600 * Return 0 if permission is granted. 0601 * @file_open: 0602 * Save open-time permission checking state for later use upon 0603 * file_permission, and recheck access if anything has changed 0604 * since inode_permission. 0605 * 0606 * Security hooks for task operations. 0607 * 0608 * @task_alloc: 0609 * @task task being allocated. 0610 * @clone_flags contains the flags indicating what should be shared. 0611 * Handle allocation of task-related resources. 0612 * Returns a zero on success, negative values on failure. 0613 * @task_free: 0614 * @task task about to be freed. 0615 * Handle release of task-related resources. (Note that this can be called 0616 * from interrupt context.) 0617 * @cred_alloc_blank: 0618 * @cred points to the credentials. 0619 * @gfp indicates the atomicity of any memory allocations. 0620 * Only allocate sufficient memory and attach to @cred such that 0621 * cred_transfer() will not get ENOMEM. 0622 * @cred_free: 0623 * @cred points to the credentials. 0624 * Deallocate and clear the cred->security field in a set of credentials. 0625 * @cred_prepare: 0626 * @new points to the new credentials. 0627 * @old points to the original credentials. 0628 * @gfp indicates the atomicity of any memory allocations. 0629 * Prepare a new set of credentials by copying the data from the old set. 0630 * @cred_transfer: 0631 * @new points to the new credentials. 0632 * @old points to the original credentials. 0633 * Transfer data from original creds to new creds 0634 * @cred_getsecid: 0635 * Retrieve the security identifier of the cred structure @c 0636 * @c contains the credentials, secid will be placed into @secid. 0637 * In case of failure, @secid will be set to zero. 0638 * @kernel_act_as: 0639 * Set the credentials for a kernel service to act as (subjective context). 0640 * @new points to the credentials to be modified. 0641 * @secid specifies the security ID to be set 0642 * The current task must be the one that nominated @secid. 0643 * Return 0 if successful. 0644 * @kernel_create_files_as: 0645 * Set the file creation context in a set of credentials to be the same as 0646 * the objective context of the specified inode. 0647 * @new points to the credentials to be modified. 0648 * @inode points to the inode to use as a reference. 0649 * The current task must be the one that nominated @inode. 0650 * Return 0 if successful. 0651 * @kernel_module_request: 0652 * Ability to trigger the kernel to automatically upcall to userspace for 0653 * userspace to load a kernel module with the given name. 0654 * @kmod_name name of the module requested by the kernel 0655 * Return 0 if successful. 0656 * @kernel_load_data: 0657 * Load data provided by userspace. 0658 * @id kernel load data identifier 0659 * @contents if a subsequent @kernel_post_load_data will be called. 0660 * Return 0 if permission is granted. 0661 * @kernel_post_load_data: 0662 * Load data provided by a non-file source (usually userspace buffer). 0663 * @buf pointer to buffer containing the data contents. 0664 * @size length of the data contents. 0665 * @id kernel load data identifier 0666 * @description a text description of what was loaded, @id-specific 0667 * Return 0 if permission is granted. 0668 * This must be paired with a prior @kernel_load_data call that had 0669 * @contents set to true. 0670 * @kernel_read_file: 0671 * Read a file specified by userspace. 0672 * @file contains the file structure pointing to the file being read 0673 * by the kernel. 0674 * @id kernel read file identifier 0675 * @contents if a subsequent @kernel_post_read_file will be called. 0676 * Return 0 if permission is granted. 0677 * @kernel_post_read_file: 0678 * Read a file specified by userspace. 0679 * @file contains the file structure pointing to the file being read 0680 * by the kernel. 0681 * @buf pointer to buffer containing the file contents. 0682 * @size length of the file contents. 0683 * @id kernel read file identifier 0684 * This must be paired with a prior @kernel_read_file call that had 0685 * @contents set to true. 0686 * Return 0 if permission is granted. 0687 * @task_fix_setuid: 0688 * Update the module's state after setting one or more of the user 0689 * identity attributes of the current process. The @flags parameter 0690 * indicates which of the set*uid system calls invoked this hook. If 0691 * @new is the set of credentials that will be installed. Modifications 0692 * should be made to this rather than to @current->cred. 0693 * @old is the set of credentials that are being replaces 0694 * @flags contains one of the LSM_SETID_* values. 0695 * Return 0 on success. 0696 * @task_fix_setgid: 0697 * Update the module's state after setting one or more of the group 0698 * identity attributes of the current process. The @flags parameter 0699 * indicates which of the set*gid system calls invoked this hook. 0700 * @new is the set of credentials that will be installed. Modifications 0701 * should be made to this rather than to @current->cred. 0702 * @old is the set of credentials that are being replaced. 0703 * @flags contains one of the LSM_SETID_* values. 0704 * Return 0 on success. 0705 * @task_fix_setgroups: 0706 * Update the module's state after setting the supplementary group 0707 * identity attributes of the current process. 0708 * @new is the set of credentials that will be installed. Modifications 0709 * should be made to this rather than to @current->cred. 0710 * @old is the set of credentials that are being replaced. 0711 * Return 0 on success. 0712 * @task_setpgid: 0713 * Check permission before setting the process group identifier of the 0714 * process @p to @pgid. 0715 * @p contains the task_struct for process being modified. 0716 * @pgid contains the new pgid. 0717 * Return 0 if permission is granted. 0718 * @task_getpgid: 0719 * Check permission before getting the process group identifier of the 0720 * process @p. 0721 * @p contains the task_struct for the process. 0722 * Return 0 if permission is granted. 0723 * @task_getsid: 0724 * Check permission before getting the session identifier of the process 0725 * @p. 0726 * @p contains the task_struct for the process. 0727 * Return 0 if permission is granted. 0728 * @current_getsecid_subj: 0729 * Retrieve the subjective security identifier of the current task and 0730 * return it in @secid. 0731 * In case of failure, @secid will be set to zero. 0732 * @task_getsecid_obj: 0733 * Retrieve the objective security identifier of the task_struct in @p 0734 * and return it in @secid. 0735 * In case of failure, @secid will be set to zero. 0736 * 0737 * @task_setnice: 0738 * Check permission before setting the nice value of @p to @nice. 0739 * @p contains the task_struct of process. 0740 * @nice contains the new nice value. 0741 * Return 0 if permission is granted. 0742 * @task_setioprio: 0743 * Check permission before setting the ioprio value of @p to @ioprio. 0744 * @p contains the task_struct of process. 0745 * @ioprio contains the new ioprio value 0746 * Return 0 if permission is granted. 0747 * @task_getioprio: 0748 * Check permission before getting the ioprio value of @p. 0749 * @p contains the task_struct of process. 0750 * Return 0 if permission is granted. 0751 * @task_prlimit: 0752 * Check permission before getting and/or setting the resource limits of 0753 * another task. 0754 * @cred points to the cred structure for the current task. 0755 * @tcred points to the cred structure for the target task. 0756 * @flags contains the LSM_PRLIMIT_* flag bits indicating whether the 0757 * resource limits are being read, modified, or both. 0758 * Return 0 if permission is granted. 0759 * @task_setrlimit: 0760 * Check permission before setting the resource limits of process @p 0761 * for @resource to @new_rlim. The old resource limit values can 0762 * be examined by dereferencing (p->signal->rlim + resource). 0763 * @p points to the task_struct for the target task's group leader. 0764 * @resource contains the resource whose limit is being set. 0765 * @new_rlim contains the new limits for @resource. 0766 * Return 0 if permission is granted. 0767 * @task_setscheduler: 0768 * Check permission before setting scheduling policy and/or parameters of 0769 * process @p. 0770 * @p contains the task_struct for process. 0771 * Return 0 if permission is granted. 0772 * @task_getscheduler: 0773 * Check permission before obtaining scheduling information for process 0774 * @p. 0775 * @p contains the task_struct for process. 0776 * Return 0 if permission is granted. 0777 * @task_movememory: 0778 * Check permission before moving memory owned by process @p. 0779 * @p contains the task_struct for process. 0780 * Return 0 if permission is granted. 0781 * @task_kill: 0782 * Check permission before sending signal @sig to @p. @info can be NULL, 0783 * the constant 1, or a pointer to a kernel_siginfo structure. If @info is 1 or 0784 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming 0785 * from the kernel and should typically be permitted. 0786 * SIGIO signals are handled separately by the send_sigiotask hook in 0787 * file_security_ops. 0788 * @p contains the task_struct for process. 0789 * @info contains the signal information. 0790 * @sig contains the signal value. 0791 * @cred contains the cred of the process where the signal originated, or 0792 * NULL if the current task is the originator. 0793 * Return 0 if permission is granted. 0794 * @task_prctl: 0795 * Check permission before performing a process control operation on the 0796 * current process. 0797 * @option contains the operation. 0798 * @arg2 contains a argument. 0799 * @arg3 contains a argument. 0800 * @arg4 contains a argument. 0801 * @arg5 contains a argument. 0802 * Return -ENOSYS if no-one wanted to handle this op, any other value to 0803 * cause prctl() to return immediately with that value. 0804 * @task_to_inode: 0805 * Set the security attributes for an inode based on an associated task's 0806 * security attributes, e.g. for /proc/pid inodes. 0807 * @p contains the task_struct for the task. 0808 * @inode contains the inode structure for the inode. 0809 * 0810 * Security hooks for Netlink messaging. 0811 * 0812 * @netlink_send: 0813 * Save security information for a netlink message so that permission 0814 * checking can be performed when the message is processed. The security 0815 * information can be saved using the eff_cap field of the 0816 * netlink_skb_parms structure. Also may be used to provide fine 0817 * grained control over message transmission. 0818 * @sk associated sock of task sending the message. 0819 * @skb contains the sk_buff structure for the netlink message. 0820 * Return 0 if the information was successfully saved and message 0821 * is allowed to be transmitted. 0822 * 0823 * Security hooks for Unix domain networking. 0824 * 0825 * @unix_stream_connect: 0826 * Check permissions before establishing a Unix domain stream connection 0827 * between @sock and @other. 0828 * @sock contains the sock structure. 0829 * @other contains the peer sock structure. 0830 * @newsk contains the new sock structure. 0831 * Return 0 if permission is granted. 0832 * @unix_may_send: 0833 * Check permissions before connecting or sending datagrams from @sock to 0834 * @other. 0835 * @sock contains the socket structure. 0836 * @other contains the peer socket structure. 0837 * Return 0 if permission is granted. 0838 * 0839 * The @unix_stream_connect and @unix_may_send hooks were necessary because 0840 * Linux provides an alternative to the conventional file name space for Unix 0841 * domain sockets. Whereas binding and connecting to sockets in the file name 0842 * space is mediated by the typical file permissions (and caught by the mknod 0843 * and permission hooks in inode_security_ops), binding and connecting to 0844 * sockets in the abstract name space is completely unmediated. Sufficient 0845 * control of Unix domain sockets in the abstract name space isn't possible 0846 * using only the socket layer hooks, since we need to know the actual target 0847 * socket, which is not looked up until we are inside the af_unix code. 0848 * 0849 * Security hooks for socket operations. 0850 * 0851 * @socket_create: 0852 * Check permissions prior to creating a new socket. 0853 * @family contains the requested protocol family. 0854 * @type contains the requested communications type. 0855 * @protocol contains the requested protocol. 0856 * @kern set to 1 if a kernel socket. 0857 * Return 0 if permission is granted. 0858 * @socket_post_create: 0859 * This hook allows a module to update or allocate a per-socket security 0860 * structure. Note that the security field was not added directly to the 0861 * socket structure, but rather, the socket security information is stored 0862 * in the associated inode. Typically, the inode alloc_security hook will 0863 * allocate and attach security information to 0864 * SOCK_INODE(sock)->i_security. This hook may be used to update the 0865 * SOCK_INODE(sock)->i_security field with additional information that 0866 * wasn't available when the inode was allocated. 0867 * @sock contains the newly created socket structure. 0868 * @family contains the requested protocol family. 0869 * @type contains the requested communications type. 0870 * @protocol contains the requested protocol. 0871 * @kern set to 1 if a kernel socket. 0872 * @socket_socketpair: 0873 * Check permissions before creating a fresh pair of sockets. 0874 * @socka contains the first socket structure. 0875 * @sockb contains the second socket structure. 0876 * Return 0 if permission is granted and the connection was established. 0877 * @socket_bind: 0878 * Check permission before socket protocol layer bind operation is 0879 * performed and the socket @sock is bound to the address specified in the 0880 * @address parameter. 0881 * @sock contains the socket structure. 0882 * @address contains the address to bind to. 0883 * @addrlen contains the length of address. 0884 * Return 0 if permission is granted. 0885 * @socket_connect: 0886 * Check permission before socket protocol layer connect operation 0887 * attempts to connect socket @sock to a remote address, @address. 0888 * @sock contains the socket structure. 0889 * @address contains the address of remote endpoint. 0890 * @addrlen contains the length of address. 0891 * Return 0 if permission is granted. 0892 * @socket_listen: 0893 * Check permission before socket protocol layer listen operation. 0894 * @sock contains the socket structure. 0895 * @backlog contains the maximum length for the pending connection queue. 0896 * Return 0 if permission is granted. 0897 * @socket_accept: 0898 * Check permission before accepting a new connection. Note that the new 0899 * socket, @newsock, has been created and some information copied to it, 0900 * but the accept operation has not actually been performed. 0901 * @sock contains the listening socket structure. 0902 * @newsock contains the newly created server socket for connection. 0903 * Return 0 if permission is granted. 0904 * @socket_sendmsg: 0905 * Check permission before transmitting a message to another socket. 0906 * @sock contains the socket structure. 0907 * @msg contains the message to be transmitted. 0908 * @size contains the size of message. 0909 * Return 0 if permission is granted. 0910 * @socket_recvmsg: 0911 * Check permission before receiving a message from a socket. 0912 * @sock contains the socket structure. 0913 * @msg contains the message structure. 0914 * @size contains the size of message structure. 0915 * @flags contains the operational flags. 0916 * Return 0 if permission is granted. 0917 * @socket_getsockname: 0918 * Check permission before the local address (name) of the socket object 0919 * @sock is retrieved. 0920 * @sock contains the socket structure. 0921 * Return 0 if permission is granted. 0922 * @socket_getpeername: 0923 * Check permission before the remote address (name) of a socket object 0924 * @sock is retrieved. 0925 * @sock contains the socket structure. 0926 * Return 0 if permission is granted. 0927 * @socket_getsockopt: 0928 * Check permissions before retrieving the options associated with socket 0929 * @sock. 0930 * @sock contains the socket structure. 0931 * @level contains the protocol level to retrieve option from. 0932 * @optname contains the name of option to retrieve. 0933 * Return 0 if permission is granted. 0934 * @socket_setsockopt: 0935 * Check permissions before setting the options associated with socket 0936 * @sock. 0937 * @sock contains the socket structure. 0938 * @level contains the protocol level to set options for. 0939 * @optname contains the name of the option to set. 0940 * Return 0 if permission is granted. 0941 * @socket_shutdown: 0942 * Checks permission before all or part of a connection on the socket 0943 * @sock is shut down. 0944 * @sock contains the socket structure. 0945 * @how contains the flag indicating how future sends and receives 0946 * are handled. 0947 * Return 0 if permission is granted. 0948 * @socket_sock_rcv_skb: 0949 * Check permissions on incoming network packets. This hook is distinct 0950 * from Netfilter's IP input hooks since it is the first time that the 0951 * incoming sk_buff @skb has been associated with a particular socket, @sk. 0952 * Must not sleep inside this hook because some callers hold spinlocks. 0953 * @sk contains the sock (not socket) associated with the incoming sk_buff. 0954 * @skb contains the incoming network data. 0955 * @socket_getpeersec_stream: 0956 * This hook allows the security module to provide peer socket security 0957 * state for unix or connected tcp sockets to userspace via getsockopt 0958 * SO_GETPEERSEC. For tcp sockets this can be meaningful if the 0959 * socket is associated with an ipsec SA. 0960 * @sock is the local socket. 0961 * @optval userspace memory where the security state is to be copied. 0962 * @optlen userspace int where the module should copy the actual length 0963 * of the security state. 0964 * @len as input is the maximum length to copy to userspace provided 0965 * by the caller. 0966 * Return 0 if all is well, otherwise, typical getsockopt return 0967 * values. 0968 * @socket_getpeersec_dgram: 0969 * This hook allows the security module to provide peer socket security 0970 * state for udp sockets on a per-packet basis to userspace via 0971 * getsockopt SO_GETPEERSEC. The application must first have indicated 0972 * the IP_PASSSEC option via getsockopt. It can then retrieve the 0973 * security state returned by this hook for a packet via the SCM_SECURITY 0974 * ancillary message type. 0975 * @sock contains the peer socket. May be NULL. 0976 * @skb is the sk_buff for the packet being queried. May be NULL. 0977 * @secid pointer to store the secid of the packet. 0978 * Return 0 on success, error on failure. 0979 * @sk_alloc_security: 0980 * Allocate and attach a security structure to the sk->sk_security field, 0981 * which is used to copy security attributes between local stream sockets. 0982 * @sk_free_security: 0983 * Deallocate security structure. 0984 * @sk_clone_security: 0985 * Clone/copy security structure. 0986 * @sk_getsecid: 0987 * Retrieve the LSM-specific secid for the sock to enable caching 0988 * of network authorizations. 0989 * @sock_graft: 0990 * Sets the socket's isec sid to the sock's sid. 0991 * @inet_conn_request: 0992 * Sets the openreq's sid to socket's sid with MLS portion taken 0993 * from peer sid. 0994 * @inet_csk_clone: 0995 * Sets the new child socket's sid to the openreq sid. 0996 * @inet_conn_established: 0997 * Sets the connection's peersid to the secmark on skb. 0998 * @secmark_relabel_packet: 0999 * check if the process should be allowed to relabel packets to 1000 * the given secid 1001 * @secmark_refcount_inc: 1002 * tells the LSM to increment the number of secmark labeling rules loaded 1003 * @secmark_refcount_dec: 1004 * tells the LSM to decrement the number of secmark labeling rules loaded 1005 * @req_classify_flow: 1006 * Sets the flow's sid to the openreq sid. 1007 * @tun_dev_alloc_security: 1008 * This hook allows a module to allocate a security structure for a TUN 1009 * device. 1010 * @security pointer to a security structure pointer. 1011 * Returns a zero on success, negative values on failure. 1012 * @tun_dev_free_security: 1013 * This hook allows a module to free the security structure for a TUN 1014 * device. 1015 * @security pointer to the TUN device's security structure 1016 * @tun_dev_create: 1017 * Check permissions prior to creating a new TUN device. 1018 * @tun_dev_attach_queue: 1019 * Check permissions prior to attaching to a TUN device queue. 1020 * @security pointer to the TUN device's security structure. 1021 * @tun_dev_attach: 1022 * This hook can be used by the module to update any security state 1023 * associated with the TUN device's sock structure. 1024 * @sk contains the existing sock structure. 1025 * @security pointer to the TUN device's security structure. 1026 * @tun_dev_open: 1027 * This hook can be used by the module to update any security state 1028 * associated with the TUN device's security structure. 1029 * @security pointer to the TUN devices's security structure. 1030 * 1031 * Security hooks for SCTP 1032 * 1033 * @sctp_assoc_request: 1034 * Passes the @asoc and @chunk->skb of the association INIT packet to 1035 * the security module. 1036 * @asoc pointer to sctp association structure. 1037 * @skb pointer to skbuff of association packet. 1038 * Return 0 on success, error on failure. 1039 * @sctp_bind_connect: 1040 * Validiate permissions required for each address associated with sock 1041 * @sk. Depending on @optname, the addresses will be treated as either 1042 * for a connect or bind service. The @addrlen is calculated on each 1043 * ipv4 and ipv6 address using sizeof(struct sockaddr_in) or 1044 * sizeof(struct sockaddr_in6). 1045 * @sk pointer to sock structure. 1046 * @optname name of the option to validate. 1047 * @address list containing one or more ipv4/ipv6 addresses. 1048 * @addrlen total length of address(s). 1049 * Return 0 on success, error on failure. 1050 * @sctp_sk_clone: 1051 * Called whenever a new socket is created by accept(2) (i.e. a TCP 1052 * style socket) or when a socket is 'peeled off' e.g userspace 1053 * calls sctp_peeloff(3). 1054 * @asoc pointer to current sctp association structure. 1055 * @sk pointer to current sock structure. 1056 * @newsk pointer to new sock structure. 1057 * @sctp_assoc_established: 1058 * Passes the @asoc and @chunk->skb of the association COOKIE_ACK packet 1059 * to the security module. 1060 * @asoc pointer to sctp association structure. 1061 * @skb pointer to skbuff of association packet. 1062 * 1063 * Security hooks for Infiniband 1064 * 1065 * @ib_pkey_access: 1066 * Check permission to access a pkey when modifing a QP. 1067 * @subnet_prefix the subnet prefix of the port being used. 1068 * @pkey the pkey to be accessed. 1069 * @sec pointer to a security structure. 1070 * @ib_endport_manage_subnet: 1071 * Check permissions to send and receive SMPs on a end port. 1072 * @dev_name the IB device name (i.e. mlx4_0). 1073 * @port_num the port number. 1074 * @sec pointer to a security structure. 1075 * @ib_alloc_security: 1076 * Allocate a security structure for Infiniband objects. 1077 * @sec pointer to a security structure pointer. 1078 * Returns 0 on success, non-zero on failure 1079 * @ib_free_security: 1080 * Deallocate an Infiniband security structure. 1081 * @sec contains the security structure to be freed. 1082 * 1083 * Security hooks for XFRM operations. 1084 * 1085 * @xfrm_policy_alloc_security: 1086 * @ctxp is a pointer to the xfrm_sec_ctx being added to Security Policy 1087 * Database used by the XFRM system. 1088 * @sec_ctx contains the security context information being provided by 1089 * the user-level policy update program (e.g., setkey). 1090 * Allocate a security structure to the xp->security field; the security 1091 * field is initialized to NULL when the xfrm_policy is allocated. 1092 * Return 0 if operation was successful (memory to allocate, legal context) 1093 * @gfp is to specify the context for the allocation 1094 * @xfrm_policy_clone_security: 1095 * @old_ctx contains an existing xfrm_sec_ctx. 1096 * @new_ctxp contains a new xfrm_sec_ctx being cloned from old. 1097 * Allocate a security structure in new_ctxp that contains the 1098 * information from the old_ctx structure. 1099 * Return 0 if operation was successful (memory to allocate). 1100 * @xfrm_policy_free_security: 1101 * @ctx contains the xfrm_sec_ctx 1102 * Deallocate xp->security. 1103 * @xfrm_policy_delete_security: 1104 * @ctx contains the xfrm_sec_ctx. 1105 * Authorize deletion of xp->security. 1106 * @xfrm_state_alloc: 1107 * @x contains the xfrm_state being added to the Security Association 1108 * Database by the XFRM system. 1109 * @sec_ctx contains the security context information being provided by 1110 * the user-level SA generation program (e.g., setkey or racoon). 1111 * Allocate a security structure to the x->security field; the security 1112 * field is initialized to NULL when the xfrm_state is allocated. Set the 1113 * context to correspond to sec_ctx. Return 0 if operation was successful 1114 * (memory to allocate, legal context). 1115 * @xfrm_state_alloc_acquire: 1116 * @x contains the xfrm_state being added to the Security Association 1117 * Database by the XFRM system. 1118 * @polsec contains the policy's security context. 1119 * @secid contains the secid from which to take the mls portion of the 1120 * context. 1121 * Allocate a security structure to the x->security field; the security 1122 * field is initialized to NULL when the xfrm_state is allocated. Set the 1123 * context to correspond to secid. Return 0 if operation was successful 1124 * (memory to allocate, legal context). 1125 * @xfrm_state_free_security: 1126 * @x contains the xfrm_state. 1127 * Deallocate x->security. 1128 * @xfrm_state_delete_security: 1129 * @x contains the xfrm_state. 1130 * Authorize deletion of x->security. 1131 * @xfrm_policy_lookup: 1132 * @ctx contains the xfrm_sec_ctx for which the access control is being 1133 * checked. 1134 * @fl_secid contains the flow security label that is used to authorize 1135 * access to the policy xp. 1136 * @dir contains the direction of the flow (input or output). 1137 * Check permission when a flow selects a xfrm_policy for processing 1138 * XFRMs on a packet. The hook is called when selecting either a 1139 * per-socket policy or a generic xfrm policy. 1140 * Return 0 if permission is granted, -ESRCH otherwise, or -errno 1141 * on other errors. 1142 * @xfrm_state_pol_flow_match: 1143 * @x contains the state to match. 1144 * @xp contains the policy to check for a match. 1145 * @flic contains the flowi_common struct to check for a match. 1146 * Return 1 if there is a match. 1147 * @xfrm_decode_session: 1148 * @skb points to skb to decode. 1149 * @secid points to the flow key secid to set. 1150 * @ckall says if all xfrms used should be checked for same secid. 1151 * Return 0 if ckall is zero or all xfrms used have the same secid. 1152 * 1153 * Security hooks affecting all Key Management operations 1154 * 1155 * @key_alloc: 1156 * Permit allocation of a key and assign security data. Note that key does 1157 * not have a serial number assigned at this point. 1158 * @key points to the key. 1159 * @flags is the allocation flags 1160 * Return 0 if permission is granted, -ve error otherwise. 1161 * @key_free: 1162 * Notification of destruction; free security data. 1163 * @key points to the key. 1164 * No return value. 1165 * @key_permission: 1166 * See whether a specific operational right is granted to a process on a 1167 * key. 1168 * @key_ref refers to the key (key pointer + possession attribute bit). 1169 * @cred points to the credentials to provide the context against which to 1170 * evaluate the security data on the key. 1171 * @perm describes the combination of permissions required of this key. 1172 * Return 0 if permission is granted, -ve error otherwise. 1173 * @key_getsecurity: 1174 * Get a textual representation of the security context attached to a key 1175 * for the purposes of honouring KEYCTL_GETSECURITY. This function 1176 * allocates the storage for the NUL-terminated string and the caller 1177 * should free it. 1178 * @key points to the key to be queried. 1179 * @_buffer points to a pointer that should be set to point to the 1180 * resulting string (if no label or an error occurs). 1181 * Return the length of the string (including terminating NUL) or -ve if 1182 * an error. 1183 * May also return 0 (and a NULL buffer pointer) if there is no label. 1184 * 1185 * Security hooks affecting all System V IPC operations. 1186 * 1187 * @ipc_permission: 1188 * Check permissions for access to IPC 1189 * @ipcp contains the kernel IPC permission structure 1190 * @flag contains the desired (requested) permission set 1191 * Return 0 if permission is granted. 1192 * @ipc_getsecid: 1193 * Get the secid associated with the ipc object. 1194 * @ipcp contains the kernel IPC permission structure. 1195 * @secid contains a pointer to the location where result will be saved. 1196 * In case of failure, @secid will be set to zero. 1197 * 1198 * Security hooks for individual messages held in System V IPC message queues 1199 * 1200 * @msg_msg_alloc_security: 1201 * Allocate and attach a security structure to the msg->security field. 1202 * The security field is initialized to NULL when the structure is first 1203 * created. 1204 * @msg contains the message structure to be modified. 1205 * Return 0 if operation was successful and permission is granted. 1206 * @msg_msg_free_security: 1207 * Deallocate the security structure for this message. 1208 * @msg contains the message structure to be modified. 1209 * 1210 * Security hooks for System V IPC Message Queues 1211 * 1212 * @msg_queue_alloc_security: 1213 * Allocate and attach a security structure to the 1214 * @perm->security field. The security field is initialized to 1215 * NULL when the structure is first created. 1216 * @perm contains the IPC permissions of the message queue. 1217 * Return 0 if operation was successful and permission is granted. 1218 * @msg_queue_free_security: 1219 * Deallocate security field @perm->security for the message queue. 1220 * @perm contains the IPC permissions of the message queue. 1221 * @msg_queue_associate: 1222 * Check permission when a message queue is requested through the 1223 * msgget system call. This hook is only called when returning the 1224 * message queue identifier for an existing message queue, not when a 1225 * new message queue is created. 1226 * @perm contains the IPC permissions of the message queue. 1227 * @msqflg contains the operation control flags. 1228 * Return 0 if permission is granted. 1229 * @msg_queue_msgctl: 1230 * Check permission when a message control operation specified by @cmd 1231 * is to be performed on the message queue with permissions @perm. 1232 * The @perm may be NULL, e.g. for IPC_INFO or MSG_INFO. 1233 * @perm contains the IPC permissions of the msg queue. May be NULL. 1234 * @cmd contains the operation to be performed. 1235 * Return 0 if permission is granted. 1236 * @msg_queue_msgsnd: 1237 * Check permission before a message, @msg, is enqueued on the message 1238 * queue with permissions @perm. 1239 * @perm contains the IPC permissions of the message queue. 1240 * @msg contains the message to be enqueued. 1241 * @msqflg contains operational flags. 1242 * Return 0 if permission is granted. 1243 * @msg_queue_msgrcv: 1244 * Check permission before a message, @msg, is removed from the message 1245 * queue. The @target task structure contains a pointer to the 1246 * process that will be receiving the message (not equal to the current 1247 * process when inline receives are being performed). 1248 * @perm contains the IPC permissions of the message queue. 1249 * @msg contains the message destination. 1250 * @target contains the task structure for recipient process. 1251 * @type contains the type of message requested. 1252 * @mode contains the operational flags. 1253 * Return 0 if permission is granted. 1254 * 1255 * Security hooks for System V Shared Memory Segments 1256 * 1257 * @shm_alloc_security: 1258 * Allocate and attach a security structure to the @perm->security 1259 * field. The security field is initialized to NULL when the structure is 1260 * first created. 1261 * @perm contains the IPC permissions of the shared memory structure. 1262 * Return 0 if operation was successful and permission is granted. 1263 * @shm_free_security: 1264 * Deallocate the security structure @perm->security for the memory segment. 1265 * @perm contains the IPC permissions of the shared memory structure. 1266 * @shm_associate: 1267 * Check permission when a shared memory region is requested through the 1268 * shmget system call. This hook is only called when returning the shared 1269 * memory region identifier for an existing region, not when a new shared 1270 * memory region is created. 1271 * @perm contains the IPC permissions of the shared memory structure. 1272 * @shmflg contains the operation control flags. 1273 * Return 0 if permission is granted. 1274 * @shm_shmctl: 1275 * Check permission when a shared memory control operation specified by 1276 * @cmd is to be performed on the shared memory region with permissions @perm. 1277 * The @perm may be NULL, e.g. for IPC_INFO or SHM_INFO. 1278 * @perm contains the IPC permissions of the shared memory structure. 1279 * @cmd contains the operation to be performed. 1280 * Return 0 if permission is granted. 1281 * @shm_shmat: 1282 * Check permissions prior to allowing the shmat system call to attach the 1283 * shared memory segment with permissions @perm to the data segment of the 1284 * calling process. The attaching address is specified by @shmaddr. 1285 * @perm contains the IPC permissions of the shared memory structure. 1286 * @shmaddr contains the address to attach memory region to. 1287 * @shmflg contains the operational flags. 1288 * Return 0 if permission is granted. 1289 * 1290 * Security hooks for System V Semaphores 1291 * 1292 * @sem_alloc_security: 1293 * Allocate and attach a security structure to the @perm->security 1294 * field. The security field is initialized to NULL when the structure is 1295 * first created. 1296 * @perm contains the IPC permissions of the semaphore. 1297 * Return 0 if operation was successful and permission is granted. 1298 * @sem_free_security: 1299 * Deallocate security structure @perm->security for the semaphore. 1300 * @perm contains the IPC permissions of the semaphore. 1301 * @sem_associate: 1302 * Check permission when a semaphore is requested through the semget 1303 * system call. This hook is only called when returning the semaphore 1304 * identifier for an existing semaphore, not when a new one must be 1305 * created. 1306 * @perm contains the IPC permissions of the semaphore. 1307 * @semflg contains the operation control flags. 1308 * Return 0 if permission is granted. 1309 * @sem_semctl: 1310 * Check permission when a semaphore operation specified by @cmd is to be 1311 * performed on the semaphore. The @perm may be NULL, e.g. for 1312 * IPC_INFO or SEM_INFO. 1313 * @perm contains the IPC permissions of the semaphore. May be NULL. 1314 * @cmd contains the operation to be performed. 1315 * Return 0 if permission is granted. 1316 * @sem_semop: 1317 * Check permissions before performing operations on members of the 1318 * semaphore set. If the @alter flag is nonzero, the semaphore set 1319 * may be modified. 1320 * @perm contains the IPC permissions of the semaphore. 1321 * @sops contains the operations to perform. 1322 * @nsops contains the number of operations to perform. 1323 * @alter contains the flag indicating whether changes are to be made. 1324 * Return 0 if permission is granted. 1325 * 1326 * @binder_set_context_mgr: 1327 * Check whether @mgr is allowed to be the binder context manager. 1328 * @mgr contains the struct cred for the current binder process. 1329 * Return 0 if permission is granted. 1330 * @binder_transaction: 1331 * Check whether @from is allowed to invoke a binder transaction call 1332 * to @to. 1333 * @from contains the struct cred for the sending process. 1334 * @to contains the struct cred for the receiving process. 1335 * @binder_transfer_binder: 1336 * Check whether @from is allowed to transfer a binder reference to @to. 1337 * @from contains the struct cred for the sending process. 1338 * @to contains the struct cred for the receiving process. 1339 * @binder_transfer_file: 1340 * Check whether @from is allowed to transfer @file to @to. 1341 * @from contains the struct cred for the sending process. 1342 * @file contains the struct file being transferred. 1343 * @to contains the struct cred for the receiving process. 1344 * 1345 * @ptrace_access_check: 1346 * Check permission before allowing the current process to trace the 1347 * @child process. 1348 * Security modules may also want to perform a process tracing check 1349 * during an execve in the set_security or apply_creds hooks of 1350 * tracing check during an execve in the bprm_set_creds hook of 1351 * binprm_security_ops if the process is being traced and its security 1352 * attributes would be changed by the execve. 1353 * @child contains the task_struct structure for the target process. 1354 * @mode contains the PTRACE_MODE flags indicating the form of access. 1355 * Return 0 if permission is granted. 1356 * @ptrace_traceme: 1357 * Check that the @parent process has sufficient permission to trace the 1358 * current process before allowing the current process to present itself 1359 * to the @parent process for tracing. 1360 * @parent contains the task_struct structure for debugger process. 1361 * Return 0 if permission is granted. 1362 * @capget: 1363 * Get the @effective, @inheritable, and @permitted capability sets for 1364 * the @target process. The hook may also perform permission checking to 1365 * determine if the current process is allowed to see the capability sets 1366 * of the @target process. 1367 * @target contains the task_struct structure for target process. 1368 * @effective contains the effective capability set. 1369 * @inheritable contains the inheritable capability set. 1370 * @permitted contains the permitted capability set. 1371 * Return 0 if the capability sets were successfully obtained. 1372 * @capset: 1373 * Set the @effective, @inheritable, and @permitted capability sets for 1374 * the current process. 1375 * @new contains the new credentials structure for target process. 1376 * @old contains the current credentials structure for target process. 1377 * @effective contains the effective capability set. 1378 * @inheritable contains the inheritable capability set. 1379 * @permitted contains the permitted capability set. 1380 * Return 0 and update @new if permission is granted. 1381 * @capable: 1382 * Check whether the @tsk process has the @cap capability in the indicated 1383 * credentials. 1384 * @cred contains the credentials to use. 1385 * @ns contains the user namespace we want the capability in 1386 * @cap contains the capability <include/linux/capability.h>. 1387 * @opts contains options for the capable check <include/linux/security.h> 1388 * Return 0 if the capability is granted for @tsk. 1389 * @quotactl: 1390 * Check whether the quotactl syscall is allowed for this @sb. 1391 * @quota_on: 1392 * Check whether QUOTAON is allowed for this @dentry. 1393 * @syslog: 1394 * Check permission before accessing the kernel message ring or changing 1395 * logging to the console. 1396 * See the syslog(2) manual page for an explanation of the @type values. 1397 * @type contains the SYSLOG_ACTION_* constant from <include/linux/syslog.h> 1398 * Return 0 if permission is granted. 1399 * @settime: 1400 * Check permission to change the system time. 1401 * struct timespec64 is defined in <include/linux/time64.h> and timezone 1402 * is defined in <include/linux/time.h> 1403 * @ts contains new time 1404 * @tz contains new timezone 1405 * Return 0 if permission is granted. 1406 * @vm_enough_memory: 1407 * Check permissions for allocating a new virtual mapping. 1408 * @mm contains the mm struct it is being added to. 1409 * @pages contains the number of pages. 1410 * Return 0 if permission is granted. 1411 * 1412 * @ismaclabel: 1413 * Check if the extended attribute specified by @name 1414 * represents a MAC label. Returns 1 if name is a MAC 1415 * attribute otherwise returns 0. 1416 * @name full extended attribute name to check against 1417 * LSM as a MAC label. 1418 * 1419 * @secid_to_secctx: 1420 * Convert secid to security context. If secdata is NULL the length of 1421 * the result will be returned in seclen, but no secdata will be returned. 1422 * This does mean that the length could change between calls to check the 1423 * length and the next call which actually allocates and returns the 1424 * secdata. 1425 * @secid contains the security ID. 1426 * @secdata contains the pointer that stores the converted security 1427 * context. 1428 * @seclen pointer which contains the length of the data 1429 * @secctx_to_secid: 1430 * Convert security context to secid. 1431 * @secid contains the pointer to the generated security ID. 1432 * @secdata contains the security context. 1433 * 1434 * @release_secctx: 1435 * Release the security context. 1436 * @secdata contains the security context. 1437 * @seclen contains the length of the security context. 1438 * 1439 * Security hooks for Audit 1440 * 1441 * @audit_rule_init: 1442 * Allocate and initialize an LSM audit rule structure. 1443 * @field contains the required Audit action. 1444 * Fields flags are defined in <include/linux/audit.h> 1445 * @op contains the operator the rule uses. 1446 * @rulestr contains the context where the rule will be applied to. 1447 * @lsmrule contains a pointer to receive the result. 1448 * Return 0 if @lsmrule has been successfully set, 1449 * -EINVAL in case of an invalid rule. 1450 * 1451 * @audit_rule_known: 1452 * Specifies whether given @krule contains any fields related to 1453 * current LSM. 1454 * @krule contains the audit rule of interest. 1455 * Return 1 in case of relation found, 0 otherwise. 1456 * 1457 * @audit_rule_match: 1458 * Determine if given @secid matches a rule previously approved 1459 * by @audit_rule_known. 1460 * @secid contains the security id in question. 1461 * @field contains the field which relates to current LSM. 1462 * @op contains the operator that will be used for matching. 1463 * @lrule points to the audit rule that will be checked against. 1464 * Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure. 1465 * 1466 * @audit_rule_free: 1467 * Deallocate the LSM audit rule structure previously allocated by 1468 * audit_rule_init. 1469 * @lsmrule contains the allocated rule 1470 * 1471 * @inode_invalidate_secctx: 1472 * Notify the security module that it must revalidate the security context 1473 * of an inode. 1474 * 1475 * @inode_notifysecctx: 1476 * Notify the security module of what the security context of an inode 1477 * should be. Initializes the incore security context managed by the 1478 * security module for this inode. Example usage: NFS client invokes 1479 * this hook to initialize the security context in its incore inode to the 1480 * value provided by the server for the file when the server returned the 1481 * file's attributes to the client. 1482 * Must be called with inode->i_mutex locked. 1483 * @inode we wish to set the security context of. 1484 * @ctx contains the string which we wish to set in the inode. 1485 * @ctxlen contains the length of @ctx. 1486 * 1487 * @inode_setsecctx: 1488 * Change the security context of an inode. Updates the 1489 * incore security context managed by the security module and invokes the 1490 * fs code as needed (via __vfs_setxattr_noperm) to update any backing 1491 * xattrs that represent the context. Example usage: NFS server invokes 1492 * this hook to change the security context in its incore inode and on the 1493 * backing filesystem to a value provided by the client on a SETATTR 1494 * operation. 1495 * Must be called with inode->i_mutex locked. 1496 * @dentry contains the inode we wish to set the security context of. 1497 * @ctx contains the string which we wish to set in the inode. 1498 * @ctxlen contains the length of @ctx. 1499 * 1500 * @inode_getsecctx: 1501 * On success, returns 0 and fills out @ctx and @ctxlen with the security 1502 * context for the given @inode. 1503 * @inode we wish to get the security context of. 1504 * @ctx is a pointer in which to place the allocated security context. 1505 * @ctxlen points to the place to put the length of @ctx. 1506 * 1507 * Security hooks for the general notification queue: 1508 * 1509 * @post_notification: 1510 * Check to see if a watch notification can be posted to a particular 1511 * queue. 1512 * @w_cred: The credentials of the whoever set the watch. 1513 * @cred: The event-triggerer's credentials 1514 * @n: The notification being posted 1515 * 1516 * @watch_key: 1517 * Check to see if a process is allowed to watch for event notifications 1518 * from a key or keyring. 1519 * @key: The key to watch. 1520 * 1521 * Security hooks for using the eBPF maps and programs functionalities through 1522 * eBPF syscalls. 1523 * 1524 * @bpf: 1525 * Do a initial check for all bpf syscalls after the attribute is copied 1526 * into the kernel. The actual security module can implement their own 1527 * rules to check the specific cmd they need. 1528 * 1529 * @bpf_map: 1530 * Do a check when the kernel generate and return a file descriptor for 1531 * eBPF maps. 1532 * 1533 * @map: bpf map that we want to access 1534 * @mask: the access flags 1535 * 1536 * @bpf_prog: 1537 * Do a check when the kernel generate and return a file descriptor for 1538 * eBPF programs. 1539 * 1540 * @prog: bpf prog that userspace want to use. 1541 * 1542 * @bpf_map_alloc_security: 1543 * Initialize the security field inside bpf map. 1544 * 1545 * @bpf_map_free_security: 1546 * Clean up the security information stored inside bpf map. 1547 * 1548 * @bpf_prog_alloc_security: 1549 * Initialize the security field inside bpf program. 1550 * 1551 * @bpf_prog_free_security: 1552 * Clean up the security information stored inside bpf prog. 1553 * 1554 * @locked_down: 1555 * Determine whether a kernel feature that potentially enables arbitrary 1556 * code execution in kernel space should be permitted. 1557 * 1558 * @what: kernel feature being accessed 1559 * 1560 * Security hooks for perf events 1561 * 1562 * @perf_event_open: 1563 * Check whether the @type of perf_event_open syscall is allowed. 1564 * @perf_event_alloc: 1565 * Allocate and save perf_event security info. 1566 * @perf_event_free: 1567 * Release (free) perf_event security info. 1568 * @perf_event_read: 1569 * Read perf_event security info if allowed. 1570 * @perf_event_write: 1571 * Write perf_event security info if allowed. 1572 * 1573 * Security hooks for io_uring 1574 * 1575 * @uring_override_creds: 1576 * Check if the current task, executing an io_uring operation, is allowed 1577 * to override it's credentials with @new. 1578 * 1579 * @new: the new creds to use 1580 * 1581 * @uring_sqpoll: 1582 * Check whether the current task is allowed to spawn a io_uring polling 1583 * thread (IORING_SETUP_SQPOLL). 1584 * 1585 * @uring_cmd: 1586 * Check whether the file_operations uring_cmd is allowed to run. 1587 * 1588 */ 1589 union security_list_options { 1590 #define LSM_HOOK(RET, DEFAULT, NAME, ...) RET (*NAME)(__VA_ARGS__); 1591 #include "lsm_hook_defs.h" 1592 #undef LSM_HOOK 1593 }; 1594 1595 struct security_hook_heads { 1596 #define LSM_HOOK(RET, DEFAULT, NAME, ...) struct hlist_head NAME; 1597 #include "lsm_hook_defs.h" 1598 #undef LSM_HOOK 1599 } __randomize_layout; 1600 1601 /* 1602 * Security module hook list structure. 1603 * For use with generic list macros for common operations. 1604 */ 1605 struct security_hook_list { 1606 struct hlist_node list; 1607 struct hlist_head *head; 1608 union security_list_options hook; 1609 const char *lsm; 1610 } __randomize_layout; 1611 1612 /* 1613 * Security blob size or offset data. 1614 */ 1615 struct lsm_blob_sizes { 1616 int lbs_cred; 1617 int lbs_file; 1618 int lbs_inode; 1619 int lbs_superblock; 1620 int lbs_ipc; 1621 int lbs_msg_msg; 1622 int lbs_task; 1623 }; 1624 1625 /* 1626 * LSM_RET_VOID is used as the default value in LSM_HOOK definitions for void 1627 * LSM hooks (in include/linux/lsm_hook_defs.h). 1628 */ 1629 #define LSM_RET_VOID ((void) 0) 1630 1631 /* 1632 * Initializing a security_hook_list structure takes 1633 * up a lot of space in a source file. This macro takes 1634 * care of the common case and reduces the amount of 1635 * text involved. 1636 */ 1637 #define LSM_HOOK_INIT(HEAD, HOOK) \ 1638 { .head = &security_hook_heads.HEAD, .hook = { .HEAD = HOOK } } 1639 1640 extern struct security_hook_heads security_hook_heads; 1641 extern char *lsm_names; 1642 1643 extern void security_add_hooks(struct security_hook_list *hooks, int count, 1644 const char *lsm); 1645 1646 #define LSM_FLAG_LEGACY_MAJOR BIT(0) 1647 #define LSM_FLAG_EXCLUSIVE BIT(1) 1648 1649 enum lsm_order { 1650 LSM_ORDER_FIRST = -1, /* This is only for capabilities. */ 1651 LSM_ORDER_MUTABLE = 0, 1652 }; 1653 1654 struct lsm_info { 1655 const char *name; /* Required. */ 1656 enum lsm_order order; /* Optional: default is LSM_ORDER_MUTABLE */ 1657 unsigned long flags; /* Optional: flags describing LSM */ 1658 int *enabled; /* Optional: controlled by CONFIG_LSM */ 1659 int (*init)(void); /* Required. */ 1660 struct lsm_blob_sizes *blobs; /* Optional: for blob sharing. */ 1661 }; 1662 1663 extern struct lsm_info __start_lsm_info[], __end_lsm_info[]; 1664 extern struct lsm_info __start_early_lsm_info[], __end_early_lsm_info[]; 1665 1666 #define DEFINE_LSM(lsm) \ 1667 static struct lsm_info __lsm_##lsm \ 1668 __used __section(".lsm_info.init") \ 1669 __aligned(sizeof(unsigned long)) 1670 1671 #define DEFINE_EARLY_LSM(lsm) \ 1672 static struct lsm_info __early_lsm_##lsm \ 1673 __used __section(".early_lsm_info.init") \ 1674 __aligned(sizeof(unsigned long)) 1675 1676 #ifdef CONFIG_SECURITY_SELINUX_DISABLE 1677 /* 1678 * Assuring the safety of deleting a security module is up to 1679 * the security module involved. This may entail ordering the 1680 * module's hook list in a particular way, refusing to disable 1681 * the module once a policy is loaded or any number of other 1682 * actions better imagined than described. 1683 * 1684 * The name of the configuration option reflects the only module 1685 * that currently uses the mechanism. Any developer who thinks 1686 * disabling their module is a good idea needs to be at least as 1687 * careful as the SELinux team. 1688 */ 1689 static inline void security_delete_hooks(struct security_hook_list *hooks, 1690 int count) 1691 { 1692 int i; 1693 1694 for (i = 0; i < count; i++) 1695 hlist_del_rcu(&hooks[i].list); 1696 } 1697 #endif /* CONFIG_SECURITY_SELINUX_DISABLE */ 1698 1699 /* Currently required to handle SELinux runtime hook disable. */ 1700 #ifdef CONFIG_SECURITY_WRITABLE_HOOKS 1701 #define __lsm_ro_after_init 1702 #else 1703 #define __lsm_ro_after_init __ro_after_init 1704 #endif /* CONFIG_SECURITY_WRITABLE_HOOKS */ 1705 1706 extern int lsm_inode_alloc(struct inode *inode); 1707 1708 #endif /* ! __LINUX_LSM_HOOKS_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |