diff options
author | Casey Schaufler <casey@schaufler-ca.com> | 2015-05-02 18:10:53 -0400 |
---|---|---|
committer | James Morris <james.l.morris@oracle.com> | 2015-05-12 01:00:21 -0400 |
commit | fe7bb272ee72b5cc377e02b556d0d718d12bbede (patch) | |
tree | 5a33af6726ef88f5cf938fc1ad31d5e07d39cdaf /include/linux/lsm_hooks.h | |
parent | 3c4ed7bdf5997d8020cbb8d4abbef2fcfb9f1284 (diff) |
LSM: Add the comment to lsm_hooks.h
Add the large comment describing the content of the
security_operations structure to lsm_hooks.h. This
wasn't done in the previous (1/7) patch because it
would have exceeded the mail list size limits.
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Kees Cook <keescook@chromium.org>
Acked-by: Paul Moore <paul@paul-moore.com>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Acked-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: James Morris <james.l.morris@oracle.com>
Diffstat (limited to 'include/linux/lsm_hooks.h')
-rw-r--r-- | include/linux/lsm_hooks.h | 1279 |
1 files changed, 1279 insertions, 0 deletions
diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index c60f81b2d18c..b4c91de510c2 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h | |||
@@ -31,6 +31,1285 @@ | |||
31 | 31 | ||
32 | #ifdef CONFIG_SECURITY | 32 | #ifdef CONFIG_SECURITY |
33 | 33 | ||
34 | /** | ||
35 | * struct security_operations - main security structure | ||
36 | * | ||
37 | * Security module identifier. | ||
38 | * | ||
39 | * @name: | ||
40 | * A string that acts as a unique identifier for the LSM with max number | ||
41 | * of characters = SECURITY_NAME_MAX. | ||
42 | * | ||
43 | * Security hooks for program execution operations. | ||
44 | * | ||
45 | * @bprm_set_creds: | ||
46 | * Save security information in the bprm->security field, typically based | ||
47 | * on information about the bprm->file, for later use by the apply_creds | ||
48 | * hook. This hook may also optionally check permissions (e.g. for | ||
49 | * transitions between security domains). | ||
50 | * This hook may be called multiple times during a single execve, e.g. for | ||
51 | * interpreters. The hook can tell whether it has already been called by | ||
52 | * checking to see if @bprm->security is non-NULL. If so, then the hook | ||
53 | * may decide either to retain the security information saved earlier or | ||
54 | * to replace it. | ||
55 | * @bprm contains the linux_binprm structure. | ||
56 | * Return 0 if the hook is successful and permission is granted. | ||
57 | * @bprm_check_security: | ||
58 | * This hook mediates the point when a search for a binary handler will | ||
59 | * begin. It allows a check the @bprm->security value which is set in the | ||
60 | * preceding set_creds call. The primary difference from set_creds is | ||
61 | * that the argv list and envp list are reliably available in @bprm. This | ||
62 | * hook may be called multiple times during a single execve; and in each | ||
63 | * pass set_creds is called first. | ||
64 | * @bprm contains the linux_binprm structure. | ||
65 | * Return 0 if the hook is successful and permission is granted. | ||
66 | * @bprm_committing_creds: | ||
67 | * Prepare to install the new security attributes of a process being | ||
68 | * transformed by an execve operation, based on the old credentials | ||
69 | * pointed to by @current->cred and the information set in @bprm->cred by | ||
70 | * the bprm_set_creds hook. @bprm points to the linux_binprm structure. | ||
71 | * This hook is a good place to perform state changes on the process such | ||
72 | * as closing open file descriptors to which access will no longer be | ||
73 | * granted when the attributes are changed. This is called immediately | ||
74 | * before commit_creds(). | ||
75 | * @bprm_committed_creds: | ||
76 | * Tidy up after the installation of the new security attributes of a | ||
77 | * process being transformed by an execve operation. The new credentials | ||
78 | * have, by this point, been set to @current->cred. @bprm points to the | ||
79 | * linux_binprm structure. This hook is a good place to perform state | ||
80 | * changes on the process such as clearing out non-inheritable signal | ||
81 | * state. This is called immediately after commit_creds(). | ||
82 | * @bprm_secureexec: | ||
83 | * Return a boolean value (0 or 1) indicating whether a "secure exec" | ||
84 | * is required. The flag is passed in the auxiliary table | ||
85 | * on the initial stack to the ELF interpreter to indicate whether libc | ||
86 | * should enable secure mode. | ||
87 | * @bprm contains the linux_binprm structure. | ||
88 | * | ||
89 | * Security hooks for filesystem operations. | ||
90 | * | ||
91 | * @sb_alloc_security: | ||
92 | * Allocate and attach a security structure to the sb->s_security field. | ||
93 | * The s_security field is initialized to NULL when the structure is | ||
94 | * allocated. | ||
95 | * @sb contains the super_block structure to be modified. | ||
96 | * Return 0 if operation was successful. | ||
97 | * @sb_free_security: | ||
98 | * Deallocate and clear the sb->s_security field. | ||
99 | * @sb contains the super_block structure to be modified. | ||
100 | * @sb_statfs: | ||
101 | * Check permission before obtaining filesystem statistics for the @mnt | ||
102 | * mountpoint. | ||
103 | * @dentry is a handle on the superblock for the filesystem. | ||
104 | * Return 0 if permission is granted. | ||
105 | * @sb_mount: | ||
106 | * Check permission before an object specified by @dev_name is mounted on | ||
107 | * the mount point named by @nd. For an ordinary mount, @dev_name | ||
108 | * identifies a device if the file system type requires a device. For a | ||
109 | * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a | ||
110 | * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the | ||
111 | * pathname of the object being mounted. | ||
112 | * @dev_name contains the name for object being mounted. | ||
113 | * @path contains the path for mount point object. | ||
114 | * @type contains the filesystem type. | ||
115 | * @flags contains the mount flags. | ||
116 | * @data contains the filesystem-specific data. | ||
117 | * Return 0 if permission is granted. | ||
118 | * @sb_copy_data: | ||
119 | * Allow mount option data to be copied prior to parsing by the filesystem, | ||
120 | * so that the security module can extract security-specific mount | ||
121 | * options cleanly (a filesystem may modify the data e.g. with strsep()). | ||
122 | * This also allows the original mount data to be stripped of security- | ||
123 | * specific options to avoid having to make filesystems aware of them. | ||
124 | * @type the type of filesystem being mounted. | ||
125 | * @orig the original mount data copied from userspace. | ||
126 | * @copy copied data which will be passed to the security module. | ||
127 | * Returns 0 if the copy was successful. | ||
128 | * @sb_remount: | ||
129 | * Extracts security system specific mount options and verifies no changes | ||
130 | * are being made to those options. | ||
131 | * @sb superblock being remounted | ||
132 | * @data contains the filesystem-specific data. | ||
133 | * Return 0 if permission is granted. | ||
134 | * @sb_umount: | ||
135 | * Check permission before the @mnt file system is unmounted. | ||
136 | * @mnt contains the mounted file system. | ||
137 | * @flags contains the unmount flags, e.g. MNT_FORCE. | ||
138 | * Return 0 if permission is granted. | ||
139 | * @sb_pivotroot: | ||
140 | * Check permission before pivoting the root filesystem. | ||
141 | * @old_path contains the path for the new location of the | ||
142 | * current root (put_old). | ||
143 | * @new_path contains the path for the new root (new_root). | ||
144 | * Return 0 if permission is granted. | ||
145 | * @sb_set_mnt_opts: | ||
146 | * Set the security relevant mount options used for a superblock | ||
147 | * @sb the superblock to set security mount options for | ||
148 | * @opts binary data structure containing all lsm mount data | ||
149 | * @sb_clone_mnt_opts: | ||
150 | * Copy all security options from a given superblock to another | ||
151 | * @oldsb old superblock which contain information to clone | ||
152 | * @newsb new superblock which needs filled in | ||
153 | * @sb_parse_opts_str: | ||
154 | * Parse a string of security data filling in the opts structure | ||
155 | * @options string containing all mount options known by the LSM | ||
156 | * @opts binary data structure usable by the LSM | ||
157 | * @dentry_init_security: | ||
158 | * Compute a context for a dentry as the inode is not yet available | ||
159 | * since NFSv4 has no label backed by an EA anyway. | ||
160 | * @dentry dentry to use in calculating the context. | ||
161 | * @mode mode used to determine resource type. | ||
162 | * @name name of the last path component used to create file | ||
163 | * @ctx pointer to place the pointer to the resulting context in. | ||
164 | * @ctxlen point to place the length of the resulting context. | ||
165 | * | ||
166 | * | ||
167 | * Security hooks for inode operations. | ||
168 | * | ||
169 | * @inode_alloc_security: | ||
170 | * Allocate and attach a security structure to @inode->i_security. The | ||
171 | * i_security field is initialized to NULL when the inode structure is | ||
172 | * allocated. | ||
173 | * @inode contains the inode structure. | ||
174 | * Return 0 if operation was successful. | ||
175 | * @inode_free_security: | ||
176 | * @inode contains the inode structure. | ||
177 | * Deallocate the inode security structure and set @inode->i_security to | ||
178 | * NULL. | ||
179 | * @inode_init_security: | ||
180 | * Obtain the security attribute name suffix and value to set on a newly | ||
181 | * created inode and set up the incore security field for the new inode. | ||
182 | * This hook is called by the fs code as part of the inode creation | ||
183 | * transaction and provides for atomic labeling of the inode, unlike | ||
184 | * the post_create/mkdir/... hooks called by the VFS. The hook function | ||
185 | * is expected to allocate the name and value via kmalloc, with the caller | ||
186 | * being responsible for calling kfree after using them. | ||
187 | * If the security module does not use security attributes or does | ||
188 | * not wish to put a security attribute on this particular inode, | ||
189 | * then it should return -EOPNOTSUPP to skip this processing. | ||
190 | * @inode contains the inode structure of the newly created inode. | ||
191 | * @dir contains the inode structure of the parent directory. | ||
192 | * @qstr contains the last path component of the new object | ||
193 | * @name will be set to the allocated name suffix (e.g. selinux). | ||
194 | * @value will be set to the allocated attribute value. | ||
195 | * @len will be set to the length of the value. | ||
196 | * Returns 0 if @name and @value have been successfully set, | ||
197 | * -EOPNOTSUPP if no security attribute is needed, or | ||
198 | * -ENOMEM on memory allocation failure. | ||
199 | * @inode_create: | ||
200 | * Check permission to create a regular file. | ||
201 | * @dir contains inode structure of the parent of the new file. | ||
202 | * @dentry contains the dentry structure for the file to be created. | ||
203 | * @mode contains the file mode of the file to be created. | ||
204 | * Return 0 if permission is granted. | ||
205 | * @inode_link: | ||
206 | * Check permission before creating a new hard link to a file. | ||
207 | * @old_dentry contains the dentry structure for an existing | ||
208 | * link to the file. | ||
209 | * @dir contains the inode structure of the parent directory | ||
210 | * of the new link. | ||
211 | * @new_dentry contains the dentry structure for the new link. | ||
212 | * Return 0 if permission is granted. | ||
213 | * @path_link: | ||
214 | * Check permission before creating a new hard link to a file. | ||
215 | * @old_dentry contains the dentry structure for an existing link | ||
216 | * to the file. | ||
217 | * @new_dir contains the path structure of the parent directory of | ||
218 | * the new link. | ||
219 | * @new_dentry contains the dentry structure for the new link. | ||
220 | * Return 0 if permission is granted. | ||
221 | * @inode_unlink: | ||
222 | * Check the permission to remove a hard link to a file. | ||
223 | * @dir contains the inode structure of parent directory of the file. | ||
224 | * @dentry contains the dentry structure for file to be unlinked. | ||
225 | * Return 0 if permission is granted. | ||
226 | * @path_unlink: | ||
227 | * Check the permission to remove a hard link to a file. | ||
228 | * @dir contains the path structure of parent directory of the file. | ||
229 | * @dentry contains the dentry structure for file to be unlinked. | ||
230 | * Return 0 if permission is granted. | ||
231 | * @inode_symlink: | ||
232 | * Check the permission to create a symbolic link to a file. | ||
233 | * @dir contains the inode structure of parent directory of | ||
234 | * the symbolic link. | ||
235 | * @dentry contains the dentry structure of the symbolic link. | ||
236 | * @old_name contains the pathname of file. | ||
237 | * Return 0 if permission is granted. | ||
238 | * @path_symlink: | ||
239 | * Check the permission to create a symbolic link to a file. | ||
240 | * @dir contains the path structure of parent directory of | ||
241 | * the symbolic link. | ||
242 | * @dentry contains the dentry structure of the symbolic link. | ||
243 | * @old_name contains the pathname of file. | ||
244 | * Return 0 if permission is granted. | ||
245 | * @inode_mkdir: | ||
246 | * Check permissions to create a new directory in the existing directory | ||
247 | * associated with inode structure @dir. | ||
248 | * @dir contains the inode structure of parent of the directory | ||
249 | * to be created. | ||
250 | * @dentry contains the dentry structure of new directory. | ||
251 | * @mode contains the mode of new directory. | ||
252 | * Return 0 if permission is granted. | ||
253 | * @path_mkdir: | ||
254 | * Check permissions to create a new directory in the existing directory | ||
255 | * associated with path structure @path. | ||
256 | * @dir contains the path structure of parent of the directory | ||
257 | * to be created. | ||
258 | * @dentry contains the dentry structure of new directory. | ||
259 | * @mode contains the mode of new directory. | ||
260 | * Return 0 if permission is granted. | ||
261 | * @inode_rmdir: | ||
262 | * Check the permission to remove a directory. | ||
263 | * @dir contains the inode structure of parent of the directory | ||
264 | * to be removed. | ||
265 | * @dentry contains the dentry structure of directory to be removed. | ||
266 | * Return 0 if permission is granted. | ||
267 | * @path_rmdir: | ||
268 | * Check the permission to remove a directory. | ||
269 | * @dir contains the path structure of parent of the directory to be | ||
270 | * removed. | ||
271 | * @dentry contains the dentry structure of directory to be removed. | ||
272 | * Return 0 if permission is granted. | ||
273 | * @inode_mknod: | ||
274 | * Check permissions when creating a special file (or a socket or a fifo | ||
275 | * file created via the mknod system call). Note that if mknod operation | ||
276 | * is being done for a regular file, then the create hook will be called | ||
277 | * and not this hook. | ||
278 | * @dir contains the inode structure of parent of the new file. | ||
279 | * @dentry contains the dentry structure of the new file. | ||
280 | * @mode contains the mode of the new file. | ||
281 | * @dev contains the device number. | ||
282 | * Return 0 if permission is granted. | ||
283 | * @path_mknod: | ||
284 | * Check permissions when creating a file. Note that this hook is called | ||
285 | * even if mknod operation is being done for a regular file. | ||
286 | * @dir contains the path structure of parent of the new file. | ||
287 | * @dentry contains the dentry structure of the new file. | ||
288 | * @mode contains the mode of the new file. | ||
289 | * @dev contains the undecoded device number. Use new_decode_dev() to get | ||
290 | * the decoded device number. | ||
291 | * Return 0 if permission is granted. | ||
292 | * @inode_rename: | ||
293 | * Check for permission to rename a file or directory. | ||
294 | * @old_dir contains the inode structure for parent of the old link. | ||
295 | * @old_dentry contains the dentry structure of the old link. | ||
296 | * @new_dir contains the inode structure for parent of the new link. | ||
297 | * @new_dentry contains the dentry structure of the new link. | ||
298 | * Return 0 if permission is granted. | ||
299 | * @path_rename: | ||
300 | * Check for permission to rename a file or directory. | ||
301 | * @old_dir contains the path structure for parent of the old link. | ||
302 | * @old_dentry contains the dentry structure of the old link. | ||
303 | * @new_dir contains the path structure for parent of the new link. | ||
304 | * @new_dentry contains the dentry structure of the new link. | ||
305 | * Return 0 if permission is granted. | ||
306 | * @path_chmod: | ||
307 | * Check for permission to change DAC's permission of a file or directory. | ||
308 | * @dentry contains the dentry structure. | ||
309 | * @mnt contains the vfsmnt structure. | ||
310 | * @mode contains DAC's mode. | ||
311 | * Return 0 if permission is granted. | ||
312 | * @path_chown: | ||
313 | * Check for permission to change owner/group of a file or directory. | ||
314 | * @path contains the path structure. | ||
315 | * @uid contains new owner's ID. | ||
316 | * @gid contains new group's ID. | ||
317 | * Return 0 if permission is granted. | ||
318 | * @path_chroot: | ||
319 | * Check for permission to change root directory. | ||
320 | * @path contains the path structure. | ||
321 | * Return 0 if permission is granted. | ||
322 | * @inode_readlink: | ||
323 | * Check the permission to read the symbolic link. | ||
324 | * @dentry contains the dentry structure for the file link. | ||
325 | * Return 0 if permission is granted. | ||
326 | * @inode_follow_link: | ||
327 | * Check permission to follow a symbolic link when looking up a pathname. | ||
328 | * @dentry contains the dentry structure for the link. | ||
329 | * @nd contains the nameidata structure for the parent directory. | ||
330 | * Return 0 if permission is granted. | ||
331 | * @inode_permission: | ||
332 | * Check permission before accessing an inode. This hook is called by the | ||
333 | * existing Linux permission function, so a security module can use it to | ||
334 | * provide additional checking for existing Linux permission checks. | ||
335 | * Notice that this hook is called when a file is opened (as well as many | ||
336 | * other operations), whereas the file_security_ops permission hook is | ||
337 | * called when the actual read/write operations are performed. | ||
338 | * @inode contains the inode structure to check. | ||
339 | * @mask contains the permission mask. | ||
340 | * Return 0 if permission is granted. | ||
341 | * @inode_setattr: | ||
342 | * Check permission before setting file attributes. Note that the kernel | ||
343 | * call to notify_change is performed from several locations, whenever | ||
344 | * file attributes change (such as when a file is truncated, chown/chmod | ||
345 | * operations, transferring disk quotas, etc). | ||
346 | * @dentry contains the dentry structure for the file. | ||
347 | * @attr is the iattr structure containing the new file attributes. | ||
348 | * Return 0 if permission is granted. | ||
349 | * @path_truncate: | ||
350 | * Check permission before truncating a file. | ||
351 | * @path contains the path structure for the file. | ||
352 | * Return 0 if permission is granted. | ||
353 | * @inode_getattr: | ||
354 | * Check permission before obtaining file attributes. | ||
355 | * @mnt is the vfsmount where the dentry was looked up | ||
356 | * @dentry contains the dentry structure for the file. | ||
357 | * Return 0 if permission is granted. | ||
358 | * @inode_setxattr: | ||
359 | * Check permission before setting the extended attributes | ||
360 | * @value identified by @name for @dentry. | ||
361 | * Return 0 if permission is granted. | ||
362 | * @inode_post_setxattr: | ||
363 | * Update inode security field after successful setxattr operation. | ||
364 | * @value identified by @name for @dentry. | ||
365 | * @inode_getxattr: | ||
366 | * Check permission before obtaining the extended attributes | ||
367 | * identified by @name for @dentry. | ||
368 | * Return 0 if permission is granted. | ||
369 | * @inode_listxattr: | ||
370 | * Check permission before obtaining the list of extended attribute | ||
371 | * names for @dentry. | ||
372 | * Return 0 if permission is granted. | ||
373 | * @inode_removexattr: | ||
374 | * Check permission before removing the extended attribute | ||
375 | * identified by @name for @dentry. | ||
376 | * Return 0 if permission is granted. | ||
377 | * @inode_getsecurity: | ||
378 | * Retrieve a copy of the extended attribute representation of the | ||
379 | * security label associated with @name for @inode via @buffer. Note that | ||
380 | * @name is the remainder of the attribute name after the security prefix | ||
381 | * has been removed. @alloc is used to specify of the call should return a | ||
382 | * value via the buffer or just the value length Return size of buffer on | ||
383 | * success. | ||
384 | * @inode_setsecurity: | ||
385 | * Set the security label associated with @name for @inode from the | ||
386 | * extended attribute value @value. @size indicates the size of the | ||
387 | * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0. | ||
388 | * Note that @name is the remainder of the attribute name after the | ||
389 | * security. prefix has been removed. | ||
390 | * Return 0 on success. | ||
391 | * @inode_listsecurity: | ||
392 | * Copy the extended attribute names for the security labels | ||
393 | * associated with @inode into @buffer. The maximum size of @buffer | ||
394 | * is specified by @buffer_size. @buffer may be NULL to request | ||
395 | * the size of the buffer required. | ||
396 | * Returns number of bytes used/required on success. | ||
397 | * @inode_need_killpriv: | ||
398 | * Called when an inode has been changed. | ||
399 | * @dentry is the dentry being changed. | ||
400 | * Return <0 on error to abort the inode change operation. | ||
401 | * Return 0 if inode_killpriv does not need to be called. | ||
402 | * Return >0 if inode_killpriv does need to be called. | ||
403 | * @inode_killpriv: | ||
404 | * The setuid bit is being removed. Remove similar security labels. | ||
405 | * Called with the dentry->d_inode->i_mutex held. | ||
406 | * @dentry is the dentry being changed. | ||
407 | * Return 0 on success. If error is returned, then the operation | ||
408 | * causing setuid bit removal is failed. | ||
409 | * @inode_getsecid: | ||
410 | * Get the secid associated with the node. | ||
411 | * @inode contains a pointer to the inode. | ||
412 | * @secid contains a pointer to the location where result will be saved. | ||
413 | * In case of failure, @secid will be set to zero. | ||
414 | * | ||
415 | * Security hooks for file operations | ||
416 | * | ||
417 | * @file_permission: | ||
418 | * Check file permissions before accessing an open file. This hook is | ||
419 | * called by various operations that read or write files. A security | ||
420 | * module can use this hook to perform additional checking on these | ||
421 | * operations, e.g. to revalidate permissions on use to support privilege | ||
422 | * bracketing or policy changes. Notice that this hook is used when the | ||
423 | * actual read/write operations are performed, whereas the | ||
424 | * inode_security_ops hook is called when a file is opened (as well as | ||
425 | * many other operations). | ||
426 | * Caveat: Although this hook can be used to revalidate permissions for | ||
427 | * various system call operations that read or write files, it does not | ||
428 | * address the revalidation of permissions for memory-mapped files. | ||
429 | * Security modules must handle this separately if they need such | ||
430 | * revalidation. | ||
431 | * @file contains the file structure being accessed. | ||
432 | * @mask contains the requested permissions. | ||
433 | * Return 0 if permission is granted. | ||
434 | * @file_alloc_security: | ||
435 | * Allocate and attach a security structure to the file->f_security field. | ||
436 | * The security field is initialized to NULL when the structure is first | ||
437 | * created. | ||
438 | * @file contains the file structure to secure. | ||
439 | * Return 0 if the hook is successful and permission is granted. | ||
440 | * @file_free_security: | ||
441 | * Deallocate and free any security structures stored in file->f_security. | ||
442 | * @file contains the file structure being modified. | ||
443 | * @file_ioctl: | ||
444 | * @file contains the file structure. | ||
445 | * @cmd contains the operation to perform. | ||
446 | * @arg contains the operational arguments. | ||
447 | * Check permission for an ioctl operation on @file. Note that @arg | ||
448 | * sometimes represents a user space pointer; in other cases, it may be a | ||
449 | * simple integer value. When @arg represents a user space pointer, it | ||
450 | * should never be used by the security module. | ||
451 | * Return 0 if permission is granted. | ||
452 | * @mmap_addr : | ||
453 | * Check permissions for a mmap operation at @addr. | ||
454 | * @addr contains virtual address that will be used for the operation. | ||
455 | * Return 0 if permission is granted. | ||
456 | * @mmap_file : | ||
457 | * Check permissions for a mmap operation. The @file may be NULL, e.g. | ||
458 | * if mapping anonymous memory. | ||
459 | * @file contains the file structure for file to map (may be NULL). | ||
460 | * @reqprot contains the protection requested by the application. | ||
461 | * @prot contains the protection that will be applied by the kernel. | ||
462 | * @flags contains the operational flags. | ||
463 | * Return 0 if permission is granted. | ||
464 | * @file_mprotect: | ||
465 | * Check permissions before changing memory access permissions. | ||
466 | * @vma contains the memory region to modify. | ||
467 | * @reqprot contains the protection requested by the application. | ||
468 | * @prot contains the protection that will be applied by the kernel. | ||
469 | * Return 0 if permission is granted. | ||
470 | * @file_lock: | ||
471 | * Check permission before performing file locking operations. | ||
472 | * Note: this hook mediates both flock and fcntl style locks. | ||
473 | * @file contains the file structure. | ||
474 | * @cmd contains the posix-translated lock operation to perform | ||
475 | * (e.g. F_RDLCK, F_WRLCK). | ||
476 | * Return 0 if permission is granted. | ||
477 | * @file_fcntl: | ||
478 | * Check permission before allowing the file operation specified by @cmd | ||
479 | * from being performed on the file @file. Note that @arg sometimes | ||
480 | * represents a user space pointer; in other cases, it may be a simple | ||
481 | * integer value. When @arg represents a user space pointer, it should | ||
482 | * never be used by the security module. | ||
483 | * @file contains the file structure. | ||
484 | * @cmd contains the operation to be performed. | ||
485 | * @arg contains the operational arguments. | ||
486 | * Return 0 if permission is granted. | ||
487 | * @file_set_fowner: | ||
488 | * Save owner security information (typically from current->security) in | ||
489 | * file->f_security for later use by the send_sigiotask hook. | ||
490 | * @file contains the file structure to update. | ||
491 | * Return 0 on success. | ||
492 | * @file_send_sigiotask: | ||
493 | * Check permission for the file owner @fown to send SIGIO or SIGURG to the | ||
494 | * process @tsk. Note that this hook is sometimes called from interrupt. | ||
495 | * Note that the fown_struct, @fown, is never outside the context of a | ||
496 | * struct file, so the file structure (and associated security information) | ||
497 | * can always be obtained: | ||
498 | * container_of(fown, struct file, f_owner) | ||
499 | * @tsk contains the structure of task receiving signal. | ||
500 | * @fown contains the file owner information. | ||
501 | * @sig is the signal that will be sent. When 0, kernel sends SIGIO. | ||
502 | * Return 0 if permission is granted. | ||
503 | * @file_receive: | ||
504 | * This hook allows security modules to control the ability of a process | ||
505 | * to receive an open file descriptor via socket IPC. | ||
506 | * @file contains the file structure being received. | ||
507 | * Return 0 if permission is granted. | ||
508 | * @file_open | ||
509 | * Save open-time permission checking state for later use upon | ||
510 | * file_permission, and recheck access if anything has changed | ||
511 | * since inode_permission. | ||
512 | * | ||
513 | * Security hooks for task operations. | ||
514 | * | ||
515 | * @task_create: | ||
516 | * Check permission before creating a child process. See the clone(2) | ||
517 | * manual page for definitions of the @clone_flags. | ||
518 | * @clone_flags contains the flags indicating what should be shared. | ||
519 | * Return 0 if permission is granted. | ||
520 | * @task_free: | ||
521 | * @task task being freed | ||
522 | * Handle release of task-related resources. (Note that this can be called | ||
523 | * from interrupt context.) | ||
524 | * @cred_alloc_blank: | ||
525 | * @cred points to the credentials. | ||
526 | * @gfp indicates the atomicity of any memory allocations. | ||
527 | * Only allocate sufficient memory and attach to @cred such that | ||
528 | * cred_transfer() will not get ENOMEM. | ||
529 | * @cred_free: | ||
530 | * @cred points to the credentials. | ||
531 | * Deallocate and clear the cred->security field in a set of credentials. | ||
532 | * @cred_prepare: | ||
533 | * @new points to the new credentials. | ||
534 | * @old points to the original credentials. | ||
535 | * @gfp indicates the atomicity of any memory allocations. | ||
536 | * Prepare a new set of credentials by copying the data from the old set. | ||
537 | * @cred_transfer: | ||
538 | * @new points to the new credentials. | ||
539 | * @old points to the original credentials. | ||
540 | * Transfer data from original creds to new creds | ||
541 | * @kernel_act_as: | ||
542 | * Set the credentials for a kernel service to act as (subjective context). | ||
543 | * @new points to the credentials to be modified. | ||
544 | * @secid specifies the security ID to be set | ||
545 | * The current task must be the one that nominated @secid. | ||
546 | * Return 0 if successful. | ||
547 | * @kernel_create_files_as: | ||
548 | * Set the file creation context in a set of credentials to be the same as | ||
549 | * the objective context of the specified inode. | ||
550 | * @new points to the credentials to be modified. | ||
551 | * @inode points to the inode to use as a reference. | ||
552 | * The current task must be the one that nominated @inode. | ||
553 | * Return 0 if successful. | ||
554 | * @kernel_fw_from_file: | ||
555 | * Load firmware from userspace (not called for built-in firmware). | ||
556 | * @file contains the file structure pointing to the file containing | ||
557 | * the firmware to load. This argument will be NULL if the firmware | ||
558 | * was loaded via the uevent-triggered blob-based interface exposed | ||
559 | * by CONFIG_FW_LOADER_USER_HELPER. | ||
560 | * @buf pointer to buffer containing firmware contents. | ||
561 | * @size length of the firmware contents. | ||
562 | * Return 0 if permission is granted. | ||
563 | * @kernel_module_request: | ||
564 | * Ability to trigger the kernel to automatically upcall to userspace for | ||
565 | * userspace to load a kernel module with the given name. | ||
566 | * @kmod_name name of the module requested by the kernel | ||
567 | * Return 0 if successful. | ||
568 | * @kernel_module_from_file: | ||
569 | * Load a kernel module from userspace. | ||
570 | * @file contains the file structure pointing to the file containing | ||
571 | * the kernel module to load. If the module is being loaded from a blob, | ||
572 | * this argument will be NULL. | ||
573 | * Return 0 if permission is granted. | ||
574 | * @task_fix_setuid: | ||
575 | * Update the module's state after setting one or more of the user | ||
576 | * identity attributes of the current process. The @flags parameter | ||
577 | * indicates which of the set*uid system calls invoked this hook. If | ||
578 | * @new is the set of credentials that will be installed. Modifications | ||
579 | * should be made to this rather than to @current->cred. | ||
580 | * @old is the set of credentials that are being replaces | ||
581 | * @flags contains one of the LSM_SETID_* values. | ||
582 | * Return 0 on success. | ||
583 | * @task_setpgid: | ||
584 | * Check permission before setting the process group identifier of the | ||
585 | * process @p to @pgid. | ||
586 | * @p contains the task_struct for process being modified. | ||
587 | * @pgid contains the new pgid. | ||
588 | * Return 0 if permission is granted. | ||
589 | * @task_getpgid: | ||
590 | * Check permission before getting the process group identifier of the | ||
591 | * process @p. | ||
592 | * @p contains the task_struct for the process. | ||
593 | * Return 0 if permission is granted. | ||
594 | * @task_getsid: | ||
595 | * Check permission before getting the session identifier of the process | ||
596 | * @p. | ||
597 | * @p contains the task_struct for the process. | ||
598 | * Return 0 if permission is granted. | ||
599 | * @task_getsecid: | ||
600 | * Retrieve the security identifier of the process @p. | ||
601 | * @p contains the task_struct for the process and place is into @secid. | ||
602 | * In case of failure, @secid will be set to zero. | ||
603 | * | ||
604 | * @task_setnice: | ||
605 | * Check permission before setting the nice value of @p to @nice. | ||
606 | * @p contains the task_struct of process. | ||
607 | * @nice contains the new nice value. | ||
608 | * Return 0 if permission is granted. | ||
609 | * @task_setioprio | ||
610 | * Check permission before setting the ioprio value of @p to @ioprio. | ||
611 | * @p contains the task_struct of process. | ||
612 | * @ioprio contains the new ioprio value | ||
613 | * Return 0 if permission is granted. | ||
614 | * @task_getioprio | ||
615 | * Check permission before getting the ioprio value of @p. | ||
616 | * @p contains the task_struct of process. | ||
617 | * Return 0 if permission is granted. | ||
618 | * @task_setrlimit: | ||
619 | * Check permission before setting the resource limits of the current | ||
620 | * process for @resource to @new_rlim. The old resource limit values can | ||
621 | * be examined by dereferencing (current->signal->rlim + resource). | ||
622 | * @resource contains the resource whose limit is being set. | ||
623 | * @new_rlim contains the new limits for @resource. | ||
624 | * Return 0 if permission is granted. | ||
625 | * @task_setscheduler: | ||
626 | * Check permission before setting scheduling policy and/or parameters of | ||
627 | * process @p based on @policy and @lp. | ||
628 | * @p contains the task_struct for process. | ||
629 | * @policy contains the scheduling policy. | ||
630 | * @lp contains the scheduling parameters. | ||
631 | * Return 0 if permission is granted. | ||
632 | * @task_getscheduler: | ||
633 | * Check permission before obtaining scheduling information for process | ||
634 | * @p. | ||
635 | * @p contains the task_struct for process. | ||
636 | * Return 0 if permission is granted. | ||
637 | * @task_movememory | ||
638 | * Check permission before moving memory owned by process @p. | ||
639 | * @p contains the task_struct for process. | ||
640 | * Return 0 if permission is granted. | ||
641 | * @task_kill: | ||
642 | * Check permission before sending signal @sig to @p. @info can be NULL, | ||
643 | * the constant 1, or a pointer to a siginfo structure. If @info is 1 or | ||
644 | * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming | ||
645 | * from the kernel and should typically be permitted. | ||
646 | * SIGIO signals are handled separately by the send_sigiotask hook in | ||
647 | * file_security_ops. | ||
648 | * @p contains the task_struct for process. | ||
649 | * @info contains the signal information. | ||
650 | * @sig contains the signal value. | ||
651 | * @secid contains the sid of the process where the signal originated | ||
652 | * Return 0 if permission is granted. | ||
653 | * @task_wait: | ||
654 | * Check permission before allowing a process to reap a child process @p | ||
655 | * and collect its status information. | ||
656 | * @p contains the task_struct for process. | ||
657 | * Return 0 if permission is granted. | ||
658 | * @task_prctl: | ||
659 | * Check permission before performing a process control operation on the | ||
660 | * current process. | ||
661 | * @option contains the operation. | ||
662 | * @arg2 contains a argument. | ||
663 | * @arg3 contains a argument. | ||
664 | * @arg4 contains a argument. | ||
665 | * @arg5 contains a argument. | ||
666 | * Return -ENOSYS if no-one wanted to handle this op, any other value to | ||
667 | * cause prctl() to return immediately with that value. | ||
668 | * @task_to_inode: | ||
669 | * Set the security attributes for an inode based on an associated task's | ||
670 | * security attributes, e.g. for /proc/pid inodes. | ||
671 | * @p contains the task_struct for the task. | ||
672 | * @inode contains the inode structure for the inode. | ||
673 | * | ||
674 | * Security hooks for Netlink messaging. | ||
675 | * | ||
676 | * @netlink_send: | ||
677 | * Save security information for a netlink message so that permission | ||
678 | * checking can be performed when the message is processed. The security | ||
679 | * information can be saved using the eff_cap field of the | ||
680 | * netlink_skb_parms structure. Also may be used to provide fine | ||
681 | * grained control over message transmission. | ||
682 | * @sk associated sock of task sending the message. | ||
683 | * @skb contains the sk_buff structure for the netlink message. | ||
684 | * Return 0 if the information was successfully saved and message | ||
685 | * is allowed to be transmitted. | ||
686 | * | ||
687 | * Security hooks for Unix domain networking. | ||
688 | * | ||
689 | * @unix_stream_connect: | ||
690 | * Check permissions before establishing a Unix domain stream connection | ||
691 | * between @sock and @other. | ||
692 | * @sock contains the sock structure. | ||
693 | * @other contains the peer sock structure. | ||
694 | * @newsk contains the new sock structure. | ||
695 | * Return 0 if permission is granted. | ||
696 | * @unix_may_send: | ||
697 | * Check permissions before connecting or sending datagrams from @sock to | ||
698 | * @other. | ||
699 | * @sock contains the socket structure. | ||
700 | * @other contains the peer socket structure. | ||
701 | * Return 0 if permission is granted. | ||
702 | * | ||
703 | * The @unix_stream_connect and @unix_may_send hooks were necessary because | ||
704 | * Linux provides an alternative to the conventional file name space for Unix | ||
705 | * domain sockets. Whereas binding and connecting to sockets in the file name | ||
706 | * space is mediated by the typical file permissions (and caught by the mknod | ||
707 | * and permission hooks in inode_security_ops), binding and connecting to | ||
708 | * sockets in the abstract name space is completely unmediated. Sufficient | ||
709 | * control of Unix domain sockets in the abstract name space isn't possible | ||
710 | * using only the socket layer hooks, since we need to know the actual target | ||
711 | * socket, which is not looked up until we are inside the af_unix code. | ||
712 | * | ||
713 | * Security hooks for socket operations. | ||
714 | * | ||
715 | * @socket_create: | ||
716 | * Check permissions prior to creating a new socket. | ||
717 | * @family contains the requested protocol family. | ||
718 | * @type contains the requested communications type. | ||
719 | * @protocol contains the requested protocol. | ||
720 | * @kern set to 1 if a kernel socket. | ||
721 | * Return 0 if permission is granted. | ||
722 | * @socket_post_create: | ||
723 | * This hook allows a module to update or allocate a per-socket security | ||
724 | * structure. Note that the security field was not added directly to the | ||
725 | * socket structure, but rather, the socket security information is stored | ||
726 | * in the associated inode. Typically, the inode alloc_security hook will | ||
727 | * allocate and and attach security information to | ||
728 | * sock->inode->i_security. This hook may be used to update the | ||
729 | * sock->inode->i_security field with additional information that wasn't | ||
730 | * available when the inode was allocated. | ||
731 | * @sock contains the newly created socket structure. | ||
732 | * @family contains the requested protocol family. | ||
733 | * @type contains the requested communications type. | ||
734 | * @protocol contains the requested protocol. | ||
735 | * @kern set to 1 if a kernel socket. | ||
736 | * @socket_bind: | ||
737 | * Check permission before socket protocol layer bind operation is | ||
738 | * performed and the socket @sock is bound to the address specified in the | ||
739 | * @address parameter. | ||
740 | * @sock contains the socket structure. | ||
741 | * @address contains the address to bind to. | ||
742 | * @addrlen contains the length of address. | ||
743 | * Return 0 if permission is granted. | ||
744 | * @socket_connect: | ||
745 | * Check permission before socket protocol layer connect operation | ||
746 | * attempts to connect socket @sock to a remote address, @address. | ||
747 | * @sock contains the socket structure. | ||
748 | * @address contains the address of remote endpoint. | ||
749 | * @addrlen contains the length of address. | ||
750 | * Return 0 if permission is granted. | ||
751 | * @socket_listen: | ||
752 | * Check permission before socket protocol layer listen operation. | ||
753 | * @sock contains the socket structure. | ||
754 | * @backlog contains the maximum length for the pending connection queue. | ||
755 | * Return 0 if permission is granted. | ||
756 | * @socket_accept: | ||
757 | * Check permission before accepting a new connection. Note that the new | ||
758 | * socket, @newsock, has been created and some information copied to it, | ||
759 | * but the accept operation has not actually been performed. | ||
760 | * @sock contains the listening socket structure. | ||
761 | * @newsock contains the newly created server socket for connection. | ||
762 | * Return 0 if permission is granted. | ||
763 | * @socket_sendmsg: | ||
764 | * Check permission before transmitting a message to another socket. | ||
765 | * @sock contains the socket structure. | ||
766 | * @msg contains the message to be transmitted. | ||
767 | * @size contains the size of message. | ||
768 | * Return 0 if permission is granted. | ||
769 | * @socket_recvmsg: | ||
770 | * Check permission before receiving a message from a socket. | ||
771 | * @sock contains the socket structure. | ||
772 | * @msg contains the message structure. | ||
773 | * @size contains the size of message structure. | ||
774 | * @flags contains the operational flags. | ||
775 | * Return 0 if permission is granted. | ||
776 | * @socket_getsockname: | ||
777 | * Check permission before the local address (name) of the socket object | ||
778 | * @sock is retrieved. | ||
779 | * @sock contains the socket structure. | ||
780 | * Return 0 if permission is granted. | ||
781 | * @socket_getpeername: | ||
782 | * Check permission before the remote address (name) of a socket object | ||
783 | * @sock is retrieved. | ||
784 | * @sock contains the socket structure. | ||
785 | * Return 0 if permission is granted. | ||
786 | * @socket_getsockopt: | ||
787 | * Check permissions before retrieving the options associated with socket | ||
788 | * @sock. | ||
789 | * @sock contains the socket structure. | ||
790 | * @level contains the protocol level to retrieve option from. | ||
791 | * @optname contains the name of option to retrieve. | ||
792 | * Return 0 if permission is granted. | ||
793 | * @socket_setsockopt: | ||
794 | * Check permissions before setting the options associated with socket | ||
795 | * @sock. | ||
796 | * @sock contains the socket structure. | ||
797 | * @level contains the protocol level to set options for. | ||
798 | * @optname contains the name of the option to set. | ||
799 | * Return 0 if permission is granted. | ||
800 | * @socket_shutdown: | ||
801 | * Checks permission before all or part of a connection on the socket | ||
802 | * @sock is shut down. | ||
803 | * @sock contains the socket structure. | ||
804 | * @how contains the flag indicating how future sends and receives | ||
805 | * are handled. | ||
806 | * Return 0 if permission is granted. | ||
807 | * @socket_sock_rcv_skb: | ||
808 | * Check permissions on incoming network packets. This hook is distinct | ||
809 | * from Netfilter's IP input hooks since it is the first time that the | ||
810 | * incoming sk_buff @skb has been associated with a particular socket, @sk. | ||
811 | * Must not sleep inside this hook because some callers hold spinlocks. | ||
812 | * @sk contains the sock (not socket) associated with the incoming sk_buff. | ||
813 | * @skb contains the incoming network data. | ||
814 | * @socket_getpeersec_stream: | ||
815 | * This hook allows the security module to provide peer socket security | ||
816 | * state for unix or connected tcp sockets to userspace via getsockopt | ||
817 | * SO_GETPEERSEC. For tcp sockets this can be meaningful if the | ||
818 | * socket is associated with an ipsec SA. | ||
819 | * @sock is the local socket. | ||
820 | * @optval userspace memory where the security state is to be copied. | ||
821 | * @optlen userspace int where the module should copy the actual length | ||
822 | * of the security state. | ||
823 | * @len as input is the maximum length to copy to userspace provided | ||
824 | * by the caller. | ||
825 | * Return 0 if all is well, otherwise, typical getsockopt return | ||
826 | * values. | ||
827 | * @socket_getpeersec_dgram: | ||
828 | * This hook allows the security module to provide peer socket security | ||
829 | * state for udp sockets on a per-packet basis to userspace via | ||
830 | * getsockopt SO_GETPEERSEC. The application must first have indicated | ||
831 | * the IP_PASSSEC option via getsockopt. It can then retrieve the | ||
832 | * security state returned by this hook for a packet via the SCM_SECURITY | ||
833 | * ancillary message type. | ||
834 | * @skb is the skbuff for the packet being queried | ||
835 | * @secdata is a pointer to a buffer in which to copy the security data | ||
836 | * @seclen is the maximum length for @secdata | ||
837 | * Return 0 on success, error on failure. | ||
838 | * @sk_alloc_security: | ||
839 | * Allocate and attach a security structure to the sk->sk_security field, | ||
840 | * which is used to copy security attributes between local stream sockets. | ||
841 | * @sk_free_security: | ||
842 | * Deallocate security structure. | ||
843 | * @sk_clone_security: | ||
844 | * Clone/copy security structure. | ||
845 | * @sk_getsecid: | ||
846 | * Retrieve the LSM-specific secid for the sock to enable caching | ||
847 | * of network authorizations. | ||
848 | * @sock_graft: | ||
849 | * Sets the socket's isec sid to the sock's sid. | ||
850 | * @inet_conn_request: | ||
851 | * Sets the openreq's sid to socket's sid with MLS portion taken | ||
852 | * from peer sid. | ||
853 | * @inet_csk_clone: | ||
854 | * Sets the new child socket's sid to the openreq sid. | ||
855 | * @inet_conn_established: | ||
856 | * Sets the connection's peersid to the secmark on skb. | ||
857 | * @secmark_relabel_packet: | ||
858 | * check if the process should be allowed to relabel packets to | ||
859 | * the given secid | ||
860 | * @security_secmark_refcount_inc | ||
861 | * tells the LSM to increment the number of secmark labeling rules loaded | ||
862 | * @security_secmark_refcount_dec | ||
863 | * tells the LSM to decrement the number of secmark labeling rules loaded | ||
864 | * @req_classify_flow: | ||
865 | * Sets the flow's sid to the openreq sid. | ||
866 | * @tun_dev_alloc_security: | ||
867 | * This hook allows a module to allocate a security structure for a TUN | ||
868 | * device. | ||
869 | * @security pointer to a security structure pointer. | ||
870 | * Returns a zero on success, negative values on failure. | ||
871 | * @tun_dev_free_security: | ||
872 | * This hook allows a module to free the security structure for a TUN | ||
873 | * device. | ||
874 | * @security pointer to the TUN device's security structure | ||
875 | * @tun_dev_create: | ||
876 | * Check permissions prior to creating a new TUN device. | ||
877 | * @tun_dev_attach_queue: | ||
878 | * Check permissions prior to attaching to a TUN device queue. | ||
879 | * @security pointer to the TUN device's security structure. | ||
880 | * @tun_dev_attach: | ||
881 | * This hook can be used by the module to update any security state | ||
882 | * associated with the TUN device's sock structure. | ||
883 | * @sk contains the existing sock structure. | ||
884 | * @security pointer to the TUN device's security structure. | ||
885 | * @tun_dev_open: | ||
886 | * This hook can be used by the module to update any security state | ||
887 | * associated with the TUN device's security structure. | ||
888 | * @security pointer to the TUN devices's security structure. | ||
889 | * | ||
890 | * Security hooks for XFRM operations. | ||
891 | * | ||
892 | * @xfrm_policy_alloc_security: | ||
893 | * @ctxp is a pointer to the xfrm_sec_ctx being added to Security Policy | ||
894 | * Database used by the XFRM system. | ||
895 | * @sec_ctx contains the security context information being provided by | ||
896 | * the user-level policy update program (e.g., setkey). | ||
897 | * Allocate a security structure to the xp->security field; the security | ||
898 | * field is initialized to NULL when the xfrm_policy is allocated. | ||
899 | * Return 0 if operation was successful (memory to allocate, legal context) | ||
900 | * @gfp is to specify the context for the allocation | ||
901 | * @xfrm_policy_clone_security: | ||
902 | * @old_ctx contains an existing xfrm_sec_ctx. | ||
903 | * @new_ctxp contains a new xfrm_sec_ctx being cloned from old. | ||
904 | * Allocate a security structure in new_ctxp that contains the | ||
905 | * information from the old_ctx structure. | ||
906 | * Return 0 if operation was successful (memory to allocate). | ||
907 | * @xfrm_policy_free_security: | ||
908 | * @ctx contains the xfrm_sec_ctx | ||
909 | * Deallocate xp->security. | ||
910 | * @xfrm_policy_delete_security: | ||
911 | * @ctx contains the xfrm_sec_ctx. | ||
912 | * Authorize deletion of xp->security. | ||
913 | * @xfrm_state_alloc: | ||
914 | * @x contains the xfrm_state being added to the Security Association | ||
915 | * Database by the XFRM system. | ||
916 | * @sec_ctx contains the security context information being provided by | ||
917 | * the user-level SA generation program (e.g., setkey or racoon). | ||
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 sec_ctx. Return 0 if operation was successful | ||
921 | * (memory to allocate, legal context). | ||
922 | * @xfrm_state_alloc_acquire: | ||
923 | * @x contains the xfrm_state being added to the Security Association | ||
924 | * Database by the XFRM system. | ||
925 | * @polsec contains the policy's security context. | ||
926 | * @secid contains the secid from which to take the mls portion of the | ||
927 | * context. | ||
928 | * Allocate a security structure to the x->security field; the security | ||
929 | * field is initialized to NULL when the xfrm_state is allocated. Set the | ||
930 | * context to correspond to secid. Return 0 if operation was successful | ||
931 | * (memory to allocate, legal context). | ||
932 | * @xfrm_state_free_security: | ||
933 | * @x contains the xfrm_state. | ||
934 | * Deallocate x->security. | ||
935 | * @xfrm_state_delete_security: | ||
936 | * @x contains the xfrm_state. | ||
937 | * Authorize deletion of x->security. | ||
938 | * @xfrm_policy_lookup: | ||
939 | * @ctx contains the xfrm_sec_ctx for which the access control is being | ||
940 | * checked. | ||
941 | * @fl_secid contains the flow security label that is used to authorize | ||
942 | * access to the policy xp. | ||
943 | * @dir contains the direction of the flow (input or output). | ||
944 | * Check permission when a flow selects a xfrm_policy for processing | ||
945 | * XFRMs on a packet. The hook is called when selecting either a | ||
946 | * per-socket policy or a generic xfrm policy. | ||
947 | * Return 0 if permission is granted, -ESRCH otherwise, or -errno | ||
948 | * on other errors. | ||
949 | * @xfrm_state_pol_flow_match: | ||
950 | * @x contains the state to match. | ||
951 | * @xp contains the policy to check for a match. | ||
952 | * @fl contains the flow to check for a match. | ||
953 | * Return 1 if there is a match. | ||
954 | * @xfrm_decode_session: | ||
955 | * @skb points to skb to decode. | ||
956 | * @secid points to the flow key secid to set. | ||
957 | * @ckall says if all xfrms used should be checked for same secid. | ||
958 | * Return 0 if ckall is zero or all xfrms used have the same secid. | ||
959 | * | ||
960 | * Security hooks affecting all Key Management operations | ||
961 | * | ||
962 | * @key_alloc: | ||
963 | * Permit allocation of a key and assign security data. Note that key does | ||
964 | * not have a serial number assigned at this point. | ||
965 | * @key points to the key. | ||
966 | * @flags is the allocation flags | ||
967 | * Return 0 if permission is granted, -ve error otherwise. | ||
968 | * @key_free: | ||
969 | * Notification of destruction; free security data. | ||
970 | * @key points to the key. | ||
971 | * No return value. | ||
972 | * @key_permission: | ||
973 | * See whether a specific operational right is granted to a process on a | ||
974 | * key. | ||
975 | * @key_ref refers to the key (key pointer + possession attribute bit). | ||
976 | * @cred points to the credentials to provide the context against which to | ||
977 | * evaluate the security data on the key. | ||
978 | * @perm describes the combination of permissions required of this key. | ||
979 | * Return 0 if permission is granted, -ve error otherwise. | ||
980 | * @key_getsecurity: | ||
981 | * Get a textual representation of the security context attached to a key | ||
982 | * for the purposes of honouring KEYCTL_GETSECURITY. This function | ||
983 | * allocates the storage for the NUL-terminated string and the caller | ||
984 | * should free it. | ||
985 | * @key points to the key to be queried. | ||
986 | * @_buffer points to a pointer that should be set to point to the | ||
987 | * resulting string (if no label or an error occurs). | ||
988 | * Return the length of the string (including terminating NUL) or -ve if | ||
989 | * an error. | ||
990 | * May also return 0 (and a NULL buffer pointer) if there is no label. | ||
991 | * | ||
992 | * Security hooks affecting all System V IPC operations. | ||
993 | * | ||
994 | * @ipc_permission: | ||
995 | * Check permissions for access to IPC | ||
996 | * @ipcp contains the kernel IPC permission structure | ||
997 | * @flag contains the desired (requested) permission set | ||
998 | * Return 0 if permission is granted. | ||
999 | * @ipc_getsecid: | ||
1000 | * Get the secid associated with the ipc object. | ||
1001 | * @ipcp contains the kernel IPC permission structure. | ||
1002 | * @secid contains a pointer to the location where result will be saved. | ||
1003 | * In case of failure, @secid will be set to zero. | ||
1004 | * | ||
1005 | * Security hooks for individual messages held in System V IPC message queues | ||
1006 | * @msg_msg_alloc_security: | ||
1007 | * Allocate and attach a security structure to the msg->security field. | ||
1008 | * The security field is initialized to NULL when the structure is first | ||
1009 | * created. | ||
1010 | * @msg contains the message structure to be modified. | ||
1011 | * Return 0 if operation was successful and permission is granted. | ||
1012 | * @msg_msg_free_security: | ||
1013 | * Deallocate the security structure for this message. | ||
1014 | * @msg contains the message structure to be modified. | ||
1015 | * | ||
1016 | * Security hooks for System V IPC Message Queues | ||
1017 | * | ||
1018 | * @msg_queue_alloc_security: | ||
1019 | * Allocate and attach a security structure to the | ||
1020 | * msq->q_perm.security field. The security field is initialized to | ||
1021 | * NULL when the structure is first created. | ||
1022 | * @msq contains the message queue structure to be modified. | ||
1023 | * Return 0 if operation was successful and permission is granted. | ||
1024 | * @msg_queue_free_security: | ||
1025 | * Deallocate security structure for this message queue. | ||
1026 | * @msq contains the message queue structure to be modified. | ||
1027 | * @msg_queue_associate: | ||
1028 | * Check permission when a message queue is requested through the | ||
1029 | * msgget system call. This hook is only called when returning the | ||
1030 | * message queue identifier for an existing message queue, not when a | ||
1031 | * new message queue is created. | ||
1032 | * @msq contains the message queue to act upon. | ||
1033 | * @msqflg contains the operation control flags. | ||
1034 | * Return 0 if permission is granted. | ||
1035 | * @msg_queue_msgctl: | ||
1036 | * Check permission when a message control operation specified by @cmd | ||
1037 | * is to be performed on the message queue @msq. | ||
1038 | * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO. | ||
1039 | * @msq contains the message queue to act upon. May be NULL. | ||
1040 | * @cmd contains the operation to be performed. | ||
1041 | * Return 0 if permission is granted. | ||
1042 | * @msg_queue_msgsnd: | ||
1043 | * Check permission before a message, @msg, is enqueued on the message | ||
1044 | * queue, @msq. | ||
1045 | * @msq contains the message queue to send message to. | ||
1046 | * @msg contains the message to be enqueued. | ||
1047 | * @msqflg contains operational flags. | ||
1048 | * Return 0 if permission is granted. | ||
1049 | * @msg_queue_msgrcv: | ||
1050 | * Check permission before a message, @msg, is removed from the message | ||
1051 | * queue, @msq. The @target task structure contains a pointer to the | ||
1052 | * process that will be receiving the message (not equal to the current | ||
1053 | * process when inline receives are being performed). | ||
1054 | * @msq contains the message queue to retrieve message from. | ||
1055 | * @msg contains the message destination. | ||
1056 | * @target contains the task structure for recipient process. | ||
1057 | * @type contains the type of message requested. | ||
1058 | * @mode contains the operational flags. | ||
1059 | * Return 0 if permission is granted. | ||
1060 | * | ||
1061 | * Security hooks for System V Shared Memory Segments | ||
1062 | * | ||
1063 | * @shm_alloc_security: | ||
1064 | * Allocate and attach a security structure to the shp->shm_perm.security | ||
1065 | * field. The security field is initialized to NULL when the structure is | ||
1066 | * first created. | ||
1067 | * @shp contains the shared memory structure to be modified. | ||
1068 | * Return 0 if operation was successful and permission is granted. | ||
1069 | * @shm_free_security: | ||
1070 | * Deallocate the security struct for this memory segment. | ||
1071 | * @shp contains the shared memory structure to be modified. | ||
1072 | * @shm_associate: | ||
1073 | * Check permission when a shared memory region is requested through the | ||
1074 | * shmget system call. This hook is only called when returning the shared | ||
1075 | * memory region identifier for an existing region, not when a new shared | ||
1076 | * memory region is created. | ||
1077 | * @shp contains the shared memory structure to be modified. | ||
1078 | * @shmflg contains the operation control flags. | ||
1079 | * Return 0 if permission is granted. | ||
1080 | * @shm_shmctl: | ||
1081 | * Check permission when a shared memory control operation specified by | ||
1082 | * @cmd is to be performed on the shared memory region @shp. | ||
1083 | * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO. | ||
1084 | * @shp contains shared memory structure to be modified. | ||
1085 | * @cmd contains the operation to be performed. | ||
1086 | * Return 0 if permission is granted. | ||
1087 | * @shm_shmat: | ||
1088 | * Check permissions prior to allowing the shmat system call to attach the | ||
1089 | * shared memory segment @shp to the data segment of the calling process. | ||
1090 | * The attaching address is specified by @shmaddr. | ||
1091 | * @shp contains the shared memory structure to be modified. | ||
1092 | * @shmaddr contains the address to attach memory region to. | ||
1093 | * @shmflg contains the operational flags. | ||
1094 | * Return 0 if permission is granted. | ||
1095 | * | ||
1096 | * Security hooks for System V Semaphores | ||
1097 | * | ||
1098 | * @sem_alloc_security: | ||
1099 | * Allocate and attach a security structure to the sma->sem_perm.security | ||
1100 | * field. The security field is initialized to NULL when the structure is | ||
1101 | * first created. | ||
1102 | * @sma contains the semaphore structure | ||
1103 | * Return 0 if operation was successful and permission is granted. | ||
1104 | * @sem_free_security: | ||
1105 | * deallocate security struct for this semaphore | ||
1106 | * @sma contains the semaphore structure. | ||
1107 | * @sem_associate: | ||
1108 | * Check permission when a semaphore is requested through the semget | ||
1109 | * system call. This hook is only called when returning the semaphore | ||
1110 | * identifier for an existing semaphore, not when a new one must be | ||
1111 | * created. | ||
1112 | * @sma contains the semaphore structure. | ||
1113 | * @semflg contains the operation control flags. | ||
1114 | * Return 0 if permission is granted. | ||
1115 | * @sem_semctl: | ||
1116 | * Check permission when a semaphore operation specified by @cmd is to be | ||
1117 | * performed on the semaphore @sma. The @sma may be NULL, e.g. for | ||
1118 | * IPC_INFO or SEM_INFO. | ||
1119 | * @sma contains the semaphore structure. May be NULL. | ||
1120 | * @cmd contains the operation to be performed. | ||
1121 | * Return 0 if permission is granted. | ||
1122 | * @sem_semop | ||
1123 | * Check permissions before performing operations on members of the | ||
1124 | * semaphore set @sma. If the @alter flag is nonzero, the semaphore set | ||
1125 | * may be modified. | ||
1126 | * @sma contains the semaphore structure. | ||
1127 | * @sops contains the operations to perform. | ||
1128 | * @nsops contains the number of operations to perform. | ||
1129 | * @alter contains the flag indicating whether changes are to be made. | ||
1130 | * Return 0 if permission is granted. | ||
1131 | * | ||
1132 | * @binder_set_context_mgr | ||
1133 | * Check whether @mgr is allowed to be the binder context manager. | ||
1134 | * @mgr contains the task_struct for the task being registered. | ||
1135 | * Return 0 if permission is granted. | ||
1136 | * @binder_transaction | ||
1137 | * Check whether @from is allowed to invoke a binder transaction call | ||
1138 | * to @to. | ||
1139 | * @from contains the task_struct for the sending task. | ||
1140 | * @to contains the task_struct for the receiving task. | ||
1141 | * @binder_transfer_binder | ||
1142 | * Check whether @from is allowed to transfer a binder reference to @to. | ||
1143 | * @from contains the task_struct for the sending task. | ||
1144 | * @to contains the task_struct for the receiving task. | ||
1145 | * @binder_transfer_file | ||
1146 | * Check whether @from is allowed to transfer @file to @to. | ||
1147 | * @from contains the task_struct for the sending task. | ||
1148 | * @file contains the struct file being transferred. | ||
1149 | * @to contains the task_struct for the receiving task. | ||
1150 | * | ||
1151 | * @ptrace_access_check: | ||
1152 | * Check permission before allowing the current process to trace the | ||
1153 | * @child process. | ||
1154 | * Security modules may also want to perform a process tracing check | ||
1155 | * during an execve in the set_security or apply_creds hooks of | ||
1156 | * tracing check during an execve in the bprm_set_creds hook of | ||
1157 | * binprm_security_ops if the process is being traced and its security | ||
1158 | * attributes would be changed by the execve. | ||
1159 | * @child contains the task_struct structure for the target process. | ||
1160 | * @mode contains the PTRACE_MODE flags indicating the form of access. | ||
1161 | * Return 0 if permission is granted. | ||
1162 | * @ptrace_traceme: | ||
1163 | * Check that the @parent process has sufficient permission to trace the | ||
1164 | * current process before allowing the current process to present itself | ||
1165 | * to the @parent process for tracing. | ||
1166 | * @parent contains the task_struct structure for debugger process. | ||
1167 | * Return 0 if permission is granted. | ||
1168 | * @capget: | ||
1169 | * Get the @effective, @inheritable, and @permitted capability sets for | ||
1170 | * the @target process. The hook may also perform permission checking to | ||
1171 | * determine if the current process is allowed to see the capability sets | ||
1172 | * of the @target process. | ||
1173 | * @target contains the task_struct structure for target process. | ||
1174 | * @effective contains the effective capability set. | ||
1175 | * @inheritable contains the inheritable capability set. | ||
1176 | * @permitted contains the permitted capability set. | ||
1177 | * Return 0 if the capability sets were successfully obtained. | ||
1178 | * @capset: | ||
1179 | * Set the @effective, @inheritable, and @permitted capability sets for | ||
1180 | * the current process. | ||
1181 | * @new contains the new credentials structure for target process. | ||
1182 | * @old contains the current credentials structure for target process. | ||
1183 | * @effective contains the effective capability set. | ||
1184 | * @inheritable contains the inheritable capability set. | ||
1185 | * @permitted contains the permitted capability set. | ||
1186 | * Return 0 and update @new if permission is granted. | ||
1187 | * @capable: | ||
1188 | * Check whether the @tsk process has the @cap capability in the indicated | ||
1189 | * credentials. | ||
1190 | * @cred contains the credentials to use. | ||
1191 | * @ns contains the user namespace we want the capability in | ||
1192 | * @cap contains the capability <include/linux/capability.h>. | ||
1193 | * @audit: Whether to write an audit message or not | ||
1194 | * Return 0 if the capability is granted for @tsk. | ||
1195 | * @syslog: | ||
1196 | * Check permission before accessing the kernel message ring or changing | ||
1197 | * logging to the console. | ||
1198 | * See the syslog(2) manual page for an explanation of the @type values. | ||
1199 | * @type contains the type of action. | ||
1200 | * @from_file indicates the context of action (if it came from /proc). | ||
1201 | * Return 0 if permission is granted. | ||
1202 | * @settime: | ||
1203 | * Check permission to change the system time. | ||
1204 | * struct timespec and timezone are defined in include/linux/time.h | ||
1205 | * @ts contains new time | ||
1206 | * @tz contains new timezone | ||
1207 | * Return 0 if permission is granted. | ||
1208 | * @vm_enough_memory: | ||
1209 | * Check permissions for allocating a new virtual mapping. | ||
1210 | * @mm contains the mm struct it is being added to. | ||
1211 | * @pages contains the number of pages. | ||
1212 | * Return 0 if permission is granted. | ||
1213 | * | ||
1214 | * @ismaclabel: | ||
1215 | * Check if the extended attribute specified by @name | ||
1216 | * represents a MAC label. Returns 1 if name is a MAC | ||
1217 | * attribute otherwise returns 0. | ||
1218 | * @name full extended attribute name to check against | ||
1219 | * LSM as a MAC label. | ||
1220 | * | ||
1221 | * @secid_to_secctx: | ||
1222 | * Convert secid to security context. If secdata is NULL the length of | ||
1223 | * the result will be returned in seclen, but no secdata will be returned. | ||
1224 | * This does mean that the length could change between calls to check the | ||
1225 | * length and the next call which actually allocates and returns the | ||
1226 | * secdata. | ||
1227 | * @secid contains the security ID. | ||
1228 | * @secdata contains the pointer that stores the converted security | ||
1229 | * context. | ||
1230 | * @seclen pointer which contains the length of the data | ||
1231 | * @secctx_to_secid: | ||
1232 | * Convert security context to secid. | ||
1233 | * @secid contains the pointer to the generated security ID. | ||
1234 | * @secdata contains the security context. | ||
1235 | * | ||
1236 | * @release_secctx: | ||
1237 | * Release the security context. | ||
1238 | * @secdata contains the security context. | ||
1239 | * @seclen contains the length of the security context. | ||
1240 | * | ||
1241 | * Security hooks for Audit | ||
1242 | * | ||
1243 | * @audit_rule_init: | ||
1244 | * Allocate and initialize an LSM audit rule structure. | ||
1245 | * @field contains the required Audit action. | ||
1246 | * Fields flags are defined in include/linux/audit.h | ||
1247 | * @op contains the operator the rule uses. | ||
1248 | * @rulestr contains the context where the rule will be applied to. | ||
1249 | * @lsmrule contains a pointer to receive the result. | ||
1250 | * Return 0 if @lsmrule has been successfully set, | ||
1251 | * -EINVAL in case of an invalid rule. | ||
1252 | * | ||
1253 | * @audit_rule_known: | ||
1254 | * Specifies whether given @rule contains any fields related to | ||
1255 | * current LSM. | ||
1256 | * @rule contains the audit rule of interest. | ||
1257 | * Return 1 in case of relation found, 0 otherwise. | ||
1258 | * | ||
1259 | * @audit_rule_match: | ||
1260 | * Determine if given @secid matches a rule previously approved | ||
1261 | * by @audit_rule_known. | ||
1262 | * @secid contains the security id in question. | ||
1263 | * @field contains the field which relates to current LSM. | ||
1264 | * @op contains the operator that will be used for matching. | ||
1265 | * @rule points to the audit rule that will be checked against. | ||
1266 | * @actx points to the audit context associated with the check. | ||
1267 | * Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure. | ||
1268 | * | ||
1269 | * @audit_rule_free: | ||
1270 | * Deallocate the LSM audit rule structure previously allocated by | ||
1271 | * audit_rule_init. | ||
1272 | * @rule contains the allocated rule | ||
1273 | * | ||
1274 | * @inode_notifysecctx: | ||
1275 | * Notify the security module of what the security context of an inode | ||
1276 | * should be. Initializes the incore security context managed by the | ||
1277 | * security module for this inode. Example usage: NFS client invokes | ||
1278 | * this hook to initialize the security context in its incore inode to the | ||
1279 | * value provided by the server for the file when the server returned the | ||
1280 | * file's attributes to the client. | ||
1281 | * | ||
1282 | * Must be called with inode->i_mutex locked. | ||
1283 | * | ||
1284 | * @inode we wish to set the security context of. | ||
1285 | * @ctx contains the string which we wish to set in the inode. | ||
1286 | * @ctxlen contains the length of @ctx. | ||
1287 | * | ||
1288 | * @inode_setsecctx: | ||
1289 | * Change the security context of an inode. Updates the | ||
1290 | * incore security context managed by the security module and invokes the | ||
1291 | * fs code as needed (via __vfs_setxattr_noperm) to update any backing | ||
1292 | * xattrs that represent the context. Example usage: NFS server invokes | ||
1293 | * this hook to change the security context in its incore inode and on the | ||
1294 | * backing filesystem to a value provided by the client on a SETATTR | ||
1295 | * operation. | ||
1296 | * | ||
1297 | * Must be called with inode->i_mutex locked. | ||
1298 | * | ||
1299 | * @dentry contains the inode we wish to set the security context of. | ||
1300 | * @ctx contains the string which we wish to set in the inode. | ||
1301 | * @ctxlen contains the length of @ctx. | ||
1302 | * | ||
1303 | * @inode_getsecctx: | ||
1304 | * On success, returns 0 and fills out @ctx and @ctxlen with the security | ||
1305 | * context for the given @inode. | ||
1306 | * | ||
1307 | * @inode we wish to get the security context of. | ||
1308 | * @ctx is a pointer in which to place the allocated security context. | ||
1309 | * @ctxlen points to the place to put the length of @ctx. | ||
1310 | * This is the main security structure. | ||
1311 | */ | ||
1312 | |||
34 | struct security_operations { | 1313 | struct security_operations { |
35 | char name[SECURITY_NAME_MAX + 1]; | 1314 | char name[SECURITY_NAME_MAX + 1]; |
36 | 1315 | ||