4 * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com>
5 * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com>
6 * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com>
7 * Copyright (C) 2001 James Morris <jmorris@intercode.com.au>
8 * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group)
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * Due to this file being licensed under the GPL there is controversy over
16 * whether this permits you to write a module that #includes this file
17 * without placing your module under the GPL. Please consult a lawyer for
18 * advice before doing this.
22 #ifndef __LINUX_SECURITY_H
23 #define __LINUX_SECURITY_H
26 #include <linux/binfmts.h>
27 #include <linux/signal.h>
28 #include <linux/resource.h>
29 #include <linux/sem.h>
30 #include <linux/shm.h>
31 #include <linux/msg.h>
32 #include <linux/sched.h>
33 #include <linux/key.h>
34 #include <linux/xfrm.h>
37 /* Maximum number of letters for an LSM name string */
38 #define SECURITY_NAME_MAX 10
40 /* If capable should audit the security request */
41 #define SECURITY_CAP_NOAUDIT 0
42 #define SECURITY_CAP_AUDIT 1
48 * These functions are in security/capability.c and are used
49 * as the default capabilities functions
51 extern int cap_capable(struct task_struct
*tsk
, int cap
, int audit
);
52 extern int cap_settime(struct timespec
*ts
, struct timezone
*tz
);
53 extern int cap_ptrace_may_access(struct task_struct
*child
, unsigned int mode
);
54 extern int cap_ptrace_traceme(struct task_struct
*parent
);
55 extern int cap_capget(struct task_struct
*target
, kernel_cap_t
*effective
, kernel_cap_t
*inheritable
, kernel_cap_t
*permitted
);
56 extern int cap_capset(struct cred
*new, const struct cred
*old
,
57 const kernel_cap_t
*effective
,
58 const kernel_cap_t
*inheritable
,
59 const kernel_cap_t
*permitted
);
60 extern int cap_bprm_set_creds(struct linux_binprm
*bprm
);
61 extern int cap_bprm_secureexec(struct linux_binprm
*bprm
);
62 extern int cap_inode_setxattr(struct dentry
*dentry
, const char *name
,
63 const void *value
, size_t size
, int flags
);
64 extern int cap_inode_removexattr(struct dentry
*dentry
, const char *name
);
65 extern int cap_inode_need_killpriv(struct dentry
*dentry
);
66 extern int cap_inode_killpriv(struct dentry
*dentry
);
67 extern int cap_task_fix_setuid(struct cred
*new, const struct cred
*old
, int flags
);
68 extern int cap_task_prctl(int option
, unsigned long arg2
, unsigned long arg3
,
69 unsigned long arg4
, unsigned long arg5
);
70 extern int cap_task_setscheduler(struct task_struct
*p
, int policy
, struct sched_param
*lp
);
71 extern int cap_task_setioprio(struct task_struct
*p
, int ioprio
);
72 extern int cap_task_setnice(struct task_struct
*p
, int nice
);
73 extern int cap_syslog(int type
);
74 extern int cap_vm_enough_memory(struct mm_struct
*mm
, long pages
);
86 struct xfrm_user_sec_ctx
;
89 extern int cap_netlink_send(struct sock
*sk
, struct sk_buff
*skb
);
90 extern int cap_netlink_recv(struct sk_buff
*skb
, int cap
);
92 extern unsigned long mmap_min_addr
;
94 * Values used in the task_security_ops calls
96 /* setuid or setgid, id0 == uid or gid */
97 #define LSM_SETID_ID 1
99 /* setreuid or setregid, id0 == real, id1 == eff */
100 #define LSM_SETID_RE 2
102 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
103 #define LSM_SETID_RES 4
105 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
106 #define LSM_SETID_FS 8
108 /* forward declares to avoid warnings */
112 /* bprm->unsafe reasons */
113 #define LSM_UNSAFE_SHARE 1
114 #define LSM_UNSAFE_PTRACE 2
115 #define LSM_UNSAFE_PTRACE_CAP 4
117 #ifdef CONFIG_SECURITY
119 struct security_mnt_opts
{
125 static inline void security_init_mnt_opts(struct security_mnt_opts
*opts
)
127 opts
->mnt_opts
= NULL
;
128 opts
->mnt_opts_flags
= NULL
;
129 opts
->num_mnt_opts
= 0;
132 static inline void security_free_mnt_opts(struct security_mnt_opts
*opts
)
136 for (i
= 0; i
< opts
->num_mnt_opts
; i
++)
137 kfree(opts
->mnt_opts
[i
]);
138 kfree(opts
->mnt_opts
);
139 opts
->mnt_opts
= NULL
;
140 kfree(opts
->mnt_opts_flags
);
141 opts
->mnt_opts_flags
= NULL
;
142 opts
->num_mnt_opts
= 0;
146 * struct security_operations - main security structure
148 * Security module identifier.
151 * A string that acts as a unique identifeir for the LSM with max number
152 * of characters = SECURITY_NAME_MAX.
154 * Security hooks for program execution operations.
157 * Save security information in the bprm->security field, typically based
158 * on information about the bprm->file, for later use by the apply_creds
159 * hook. This hook may also optionally check permissions (e.g. for
160 * transitions between security domains).
161 * This hook may be called multiple times during a single execve, e.g. for
162 * interpreters. The hook can tell whether it has already been called by
163 * checking to see if @bprm->security is non-NULL. If so, then the hook
164 * may decide either to retain the security information saved earlier or
166 * @bprm contains the linux_binprm structure.
167 * Return 0 if the hook is successful and permission is granted.
168 * @bprm_check_security:
169 * This hook mediates the point when a search for a binary handler will
170 * begin. It allows a check the @bprm->security value which is set in the
171 * preceding set_creds call. The primary difference from set_creds is
172 * that the argv list and envp list are reliably available in @bprm. This
173 * hook may be called multiple times during a single execve; and in each
174 * pass set_creds is called first.
175 * @bprm contains the linux_binprm structure.
176 * Return 0 if the hook is successful and permission is granted.
177 * @bprm_committing_creds:
178 * Prepare to install the new security attributes of a process being
179 * transformed by an execve operation, based on the old credentials
180 * pointed to by @current->cred and the information set in @bprm->cred by
181 * the bprm_set_creds hook. @bprm points to the linux_binprm structure.
182 * This hook is a good place to perform state changes on the process such
183 * as closing open file descriptors to which access will no longer be
184 * granted when the attributes are changed. This is called immediately
185 * before commit_creds().
186 * @bprm_committed_creds:
187 * Tidy up after the installation of the new security attributes of a
188 * process being transformed by an execve operation. The new credentials
189 * have, by this point, been set to @current->cred. @bprm points to the
190 * linux_binprm structure. This hook is a good place to perform state
191 * changes on the process such as clearing out non-inheritable signal
192 * state. This is called immediately after commit_creds().
194 * Return a boolean value (0 or 1) indicating whether a "secure exec"
195 * is required. The flag is passed in the auxiliary table
196 * on the initial stack to the ELF interpreter to indicate whether libc
197 * should enable secure mode.
198 * @bprm contains the linux_binprm structure.
200 * Security hooks for filesystem operations.
202 * @sb_alloc_security:
203 * Allocate and attach a security structure to the sb->s_security field.
204 * The s_security field is initialized to NULL when the structure is
206 * @sb contains the super_block structure to be modified.
207 * Return 0 if operation was successful.
209 * Deallocate and clear the sb->s_security field.
210 * @sb contains the super_block structure to be modified.
212 * Check permission before obtaining filesystem statistics for the @mnt
214 * @dentry is a handle on the superblock for the filesystem.
215 * Return 0 if permission is granted.
217 * Check permission before an object specified by @dev_name is mounted on
218 * the mount point named by @nd. For an ordinary mount, @dev_name
219 * identifies a device if the file system type requires a device. For a
220 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
221 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
222 * pathname of the object being mounted.
223 * @dev_name contains the name for object being mounted.
224 * @path contains the path for mount point object.
225 * @type contains the filesystem type.
226 * @flags contains the mount flags.
227 * @data contains the filesystem-specific data.
228 * Return 0 if permission is granted.
230 * Allow mount option data to be copied prior to parsing by the filesystem,
231 * so that the security module can extract security-specific mount
232 * options cleanly (a filesystem may modify the data e.g. with strsep()).
233 * This also allows the original mount data to be stripped of security-
234 * specific options to avoid having to make filesystems aware of them.
235 * @type the type of filesystem being mounted.
236 * @orig the original mount data copied from userspace.
237 * @copy copied data which will be passed to the security module.
238 * Returns 0 if the copy was successful.
240 * Check permission before the device with superblock @mnt->sb is mounted
241 * on the mount point named by @nd.
242 * @mnt contains the vfsmount for device being mounted.
243 * @path contains the path for the mount point.
244 * Return 0 if permission is granted.
246 * Check permission before the @mnt file system is unmounted.
247 * @mnt contains the mounted file system.
248 * @flags contains the unmount flags, e.g. MNT_FORCE.
249 * Return 0 if permission is granted.
251 * Close any files in the @mnt mounted filesystem that are held open by
252 * the security module. This hook is called during an umount operation
253 * prior to checking whether the filesystem is still busy.
254 * @mnt contains the mounted filesystem.
256 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
257 * any files that were closed by umount_close. This hook is called during
258 * an umount operation if the umount fails after a call to the
260 * @mnt contains the mounted filesystem.
262 * Update the security module's state when a filesystem is remounted.
263 * This hook is only called if the remount was successful.
264 * @mnt contains the mounted file system.
265 * @flags contains the new filesystem flags.
266 * @data contains the filesystem-specific data.
268 * Update the security module's state when a filesystem is mounted.
269 * This hook is called any time a mount is successfully grafetd to
271 * @mnt contains the mounted filesystem.
272 * @mountpoint contains the path for the mount point.
274 * Check permission before pivoting the root filesystem.
275 * @old_path contains the path for the new location of the current root (put_old).
276 * @new_path contains the path for the new root (new_root).
277 * Return 0 if permission is granted.
278 * @sb_post_pivotroot:
279 * Update module state after a successful pivot.
280 * @old_path contains the path for the old root.
281 * @new_path contains the path for the new root.
283 * Set the security relevant mount options used for a superblock
284 * @sb the superblock to set security mount options for
285 * @opts binary data structure containing all lsm mount data
286 * @sb_clone_mnt_opts:
287 * Copy all security options from a given superblock to another
288 * @oldsb old superblock which contain information to clone
289 * @newsb new superblock which needs filled in
290 * @sb_parse_opts_str:
291 * Parse a string of security data filling in the opts structure
292 * @options string containing all mount options known by the LSM
293 * @opts binary data structure usable by the LSM
295 * Security hooks for inode operations.
297 * @inode_alloc_security:
298 * Allocate and attach a security structure to @inode->i_security. The
299 * i_security field is initialized to NULL when the inode structure is
301 * @inode contains the inode structure.
302 * Return 0 if operation was successful.
303 * @inode_free_security:
304 * @inode contains the inode structure.
305 * Deallocate the inode security structure and set @inode->i_security to
307 * @inode_init_security:
308 * Obtain the security attribute name suffix and value to set on a newly
309 * created inode and set up the incore security field for the new inode.
310 * This hook is called by the fs code as part of the inode creation
311 * transaction and provides for atomic labeling of the inode, unlike
312 * the post_create/mkdir/... hooks called by the VFS. The hook function
313 * is expected to allocate the name and value via kmalloc, with the caller
314 * being responsible for calling kfree after using them.
315 * If the security module does not use security attributes or does
316 * not wish to put a security attribute on this particular inode,
317 * then it should return -EOPNOTSUPP to skip this processing.
318 * @inode contains the inode structure of the newly created inode.
319 * @dir contains the inode structure of the parent directory.
320 * @name will be set to the allocated name suffix (e.g. selinux).
321 * @value will be set to the allocated attribute value.
322 * @len will be set to the length of the value.
323 * Returns 0 if @name and @value have been successfully set,
324 * -EOPNOTSUPP if no security attribute is needed, or
325 * -ENOMEM on memory allocation failure.
327 * Check permission to create a regular file.
328 * @dir contains inode structure of the parent of the new file.
329 * @dentry contains the dentry structure for the file to be created.
330 * @mode contains the file mode of the file to be created.
331 * Return 0 if permission is granted.
333 * Check permission before creating a new hard link to a file.
334 * @old_dentry contains the dentry structure for an existing link to the file.
335 * @dir contains the inode structure of the parent directory of the new link.
336 * @new_dentry contains the dentry structure for the new link.
337 * Return 0 if permission is granted.
339 * Check the permission to remove a hard link to a file.
340 * @dir contains the inode structure of parent directory of the file.
341 * @dentry contains the dentry structure for file to be unlinked.
342 * Return 0 if permission is granted.
344 * Check the permission to create a symbolic link to a file.
345 * @dir contains the inode structure of parent directory of the symbolic link.
346 * @dentry contains the dentry structure of the symbolic link.
347 * @old_name contains the pathname of file.
348 * Return 0 if permission is granted.
350 * Check permissions to create a new directory in the existing directory
351 * associated with inode strcture @dir.
352 * @dir containst the inode structure of parent of the directory to be created.
353 * @dentry contains the dentry structure of new directory.
354 * @mode contains the mode of new directory.
355 * Return 0 if permission is granted.
357 * Check the permission to remove a directory.
358 * @dir contains the inode structure of parent of the directory to be removed.
359 * @dentry contains the dentry structure of directory to be removed.
360 * Return 0 if permission is granted.
362 * Check permissions when creating a special file (or a socket or a fifo
363 * file created via the mknod system call). Note that if mknod operation
364 * is being done for a regular file, then the create hook will be called
366 * @dir contains the inode structure of parent of the new file.
367 * @dentry contains the dentry structure of the new file.
368 * @mode contains the mode of the new file.
369 * @dev contains the device number.
370 * Return 0 if permission is granted.
372 * Check for permission to rename a file or directory.
373 * @old_dir contains the inode structure for parent of the old link.
374 * @old_dentry contains the dentry structure of the old link.
375 * @new_dir contains the inode structure for parent of the new link.
376 * @new_dentry contains the dentry structure of the new link.
377 * Return 0 if permission is granted.
379 * Check the permission to read the symbolic link.
380 * @dentry contains the dentry structure for the file link.
381 * Return 0 if permission is granted.
382 * @inode_follow_link:
383 * Check permission to follow a symbolic link when looking up a pathname.
384 * @dentry contains the dentry structure for the link.
385 * @nd contains the nameidata structure for the parent directory.
386 * Return 0 if permission is granted.
388 * Check permission before accessing an inode. This hook is called by the
389 * existing Linux permission function, so a security module can use it to
390 * provide additional checking for existing Linux permission checks.
391 * Notice that this hook is called when a file is opened (as well as many
392 * other operations), whereas the file_security_ops permission hook is
393 * called when the actual read/write operations are performed.
394 * @inode contains the inode structure to check.
395 * @mask contains the permission mask.
396 * @nd contains the nameidata (may be NULL).
397 * Return 0 if permission is granted.
399 * Check permission before setting file attributes. Note that the kernel
400 * call to notify_change is performed from several locations, whenever
401 * file attributes change (such as when a file is truncated, chown/chmod
402 * operations, transferring disk quotas, etc).
403 * @dentry contains the dentry structure for the file.
404 * @attr is the iattr structure containing the new file attributes.
405 * Return 0 if permission is granted.
407 * Check permission before obtaining file attributes.
408 * @mnt is the vfsmount where the dentry was looked up
409 * @dentry contains the dentry structure for the file.
410 * Return 0 if permission is granted.
412 * @inode contains the inode structure for deleted inode.
413 * This hook is called when a deleted inode is released (i.e. an inode
414 * with no hard links has its use count drop to zero). A security module
415 * can use this hook to release any persistent label associated with the
418 * Check permission before setting the extended attributes
419 * @value identified by @name for @dentry.
420 * Return 0 if permission is granted.
421 * @inode_post_setxattr:
422 * Update inode security field after successful setxattr operation.
423 * @value identified by @name for @dentry.
425 * Check permission before obtaining the extended attributes
426 * identified by @name for @dentry.
427 * Return 0 if permission is granted.
429 * Check permission before obtaining the list of extended attribute
431 * Return 0 if permission is granted.
432 * @inode_removexattr:
433 * Check permission before removing the extended attribute
434 * identified by @name for @dentry.
435 * Return 0 if permission is granted.
436 * @inode_getsecurity:
437 * Retrieve a copy of the extended attribute representation of the
438 * security label associated with @name for @inode via @buffer. Note that
439 * @name is the remainder of the attribute name after the security prefix
440 * has been removed. @alloc is used to specify of the call should return a
441 * value via the buffer or just the value length Return size of buffer on
443 * @inode_setsecurity:
444 * Set the security label associated with @name for @inode from the
445 * extended attribute value @value. @size indicates the size of the
446 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
447 * Note that @name is the remainder of the attribute name after the
448 * security. prefix has been removed.
449 * Return 0 on success.
450 * @inode_listsecurity:
451 * Copy the extended attribute names for the security labels
452 * associated with @inode into @buffer. The maximum size of @buffer
453 * is specified by @buffer_size. @buffer may be NULL to request
454 * the size of the buffer required.
455 * Returns number of bytes used/required on success.
456 * @inode_need_killpriv:
457 * Called when an inode has been changed.
458 * @dentry is the dentry being changed.
459 * Return <0 on error to abort the inode change operation.
460 * Return 0 if inode_killpriv does not need to be called.
461 * Return >0 if inode_killpriv does need to be called.
463 * The setuid bit is being removed. Remove similar security labels.
464 * Called with the dentry->d_inode->i_mutex held.
465 * @dentry is the dentry being changed.
466 * Return 0 on success. If error is returned, then the operation
467 * causing setuid bit removal is failed.
469 * Get the secid associated with the node.
470 * @inode contains a pointer to the inode.
471 * @secid contains a pointer to the location where result will be saved.
472 * In case of failure, @secid will be set to zero.
474 * Security hooks for file operations
477 * Check file permissions before accessing an open file. This hook is
478 * called by various operations that read or write files. A security
479 * module can use this hook to perform additional checking on these
480 * operations, e.g. to revalidate permissions on use to support privilege
481 * bracketing or policy changes. Notice that this hook is used when the
482 * actual read/write operations are performed, whereas the
483 * inode_security_ops hook is called when a file is opened (as well as
484 * many other operations).
485 * Caveat: Although this hook can be used to revalidate permissions for
486 * various system call operations that read or write files, it does not
487 * address the revalidation of permissions for memory-mapped files.
488 * Security modules must handle this separately if they need such
490 * @file contains the file structure being accessed.
491 * @mask contains the requested permissions.
492 * Return 0 if permission is granted.
493 * @file_alloc_security:
494 * Allocate and attach a security structure to the file->f_security field.
495 * The security field is initialized to NULL when the structure is first
497 * @file contains the file structure to secure.
498 * Return 0 if the hook is successful and permission is granted.
499 * @file_free_security:
500 * Deallocate and free any security structures stored in file->f_security.
501 * @file contains the file structure being modified.
503 * @file contains the file structure.
504 * @cmd contains the operation to perform.
505 * @arg contains the operational arguments.
506 * Check permission for an ioctl operation on @file. Note that @arg can
507 * sometimes represents a user space pointer; in other cases, it may be a
508 * simple integer value. When @arg represents a user space pointer, it
509 * should never be used by the security module.
510 * Return 0 if permission is granted.
512 * Check permissions for a mmap operation. The @file may be NULL, e.g.
513 * if mapping anonymous memory.
514 * @file contains the file structure for file to map (may be NULL).
515 * @reqprot contains the protection requested by the application.
516 * @prot contains the protection that will be applied by the kernel.
517 * @flags contains the operational flags.
518 * Return 0 if permission is granted.
520 * Check permissions before changing memory access permissions.
521 * @vma contains the memory region to modify.
522 * @reqprot contains the protection requested by the application.
523 * @prot contains the protection that will be applied by the kernel.
524 * Return 0 if permission is granted.
526 * Check permission before performing file locking operations.
527 * Note: this hook mediates both flock and fcntl style locks.
528 * @file contains the file structure.
529 * @cmd contains the posix-translated lock operation to perform
530 * (e.g. F_RDLCK, F_WRLCK).
531 * Return 0 if permission is granted.
533 * Check permission before allowing the file operation specified by @cmd
534 * from being performed on the file @file. Note that @arg can sometimes
535 * represents a user space pointer; in other cases, it may be a simple
536 * integer value. When @arg represents a user space pointer, it should
537 * never be used by the security module.
538 * @file contains the file structure.
539 * @cmd contains the operation to be performed.
540 * @arg contains the operational arguments.
541 * Return 0 if permission is granted.
543 * Save owner security information (typically from current->security) in
544 * file->f_security for later use by the send_sigiotask hook.
545 * @file contains the file structure to update.
546 * Return 0 on success.
547 * @file_send_sigiotask:
548 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
549 * process @tsk. Note that this hook is sometimes called from interrupt.
550 * Note that the fown_struct, @fown, is never outside the context of a
551 * struct file, so the file structure (and associated security information)
552 * can always be obtained:
553 * container_of(fown, struct file, f_owner)
554 * @tsk contains the structure of task receiving signal.
555 * @fown contains the file owner information.
556 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
557 * Return 0 if permission is granted.
559 * This hook allows security modules to control the ability of a process
560 * to receive an open file descriptor via socket IPC.
561 * @file contains the file structure being received.
562 * Return 0 if permission is granted.
564 * Security hook for dentry
567 * Save open-time permission checking state for later use upon
568 * file_permission, and recheck access if anything has changed
569 * since inode_permission.
571 * Security hooks for task operations.
574 * Check permission before creating a child process. See the clone(2)
575 * manual page for definitions of the @clone_flags.
576 * @clone_flags contains the flags indicating what should be shared.
577 * Return 0 if permission is granted.
579 * @cred points to the credentials.
580 * Deallocate and clear the cred->security field in a set of credentials.
582 * @new points to the new credentials.
583 * @old points to the original credentials.
584 * @gfp indicates the atomicity of any memory allocations.
585 * Prepare a new set of credentials by copying the data from the old set.
587 * @new points to the new credentials.
588 * @old points to the original credentials.
589 * Install a new set of credentials.
591 * Check permission before setting one or more of the user identity
592 * attributes of the current process. The @flags parameter indicates
593 * which of the set*uid system calls invoked this hook and how to
594 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
595 * definitions at the beginning of this file for the @flags values and
597 * @id0 contains a uid.
598 * @id1 contains a uid.
599 * @id2 contains a uid.
600 * @flags contains one of the LSM_SETID_* values.
601 * Return 0 if permission is granted.
603 * Update the module's state after setting one or more of the user
604 * identity attributes of the current process. The @flags parameter
605 * indicates which of the set*uid system calls invoked this hook. If
606 * @new is the set of credentials that will be installed. Modifications
607 * should be made to this rather than to @current->cred.
608 * @old is the set of credentials that are being replaces
609 * @flags contains one of the LSM_SETID_* values.
610 * Return 0 on success.
612 * Check permission before setting one or more of the group identity
613 * attributes of the current process. The @flags parameter indicates
614 * which of the set*gid system calls invoked this hook and how to
615 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
616 * definitions at the beginning of this file for the @flags values and
618 * @id0 contains a gid.
619 * @id1 contains a gid.
620 * @id2 contains a gid.
621 * @flags contains one of the LSM_SETID_* values.
622 * Return 0 if permission is granted.
624 * Check permission before setting the process group identifier of the
625 * process @p to @pgid.
626 * @p contains the task_struct for process being modified.
627 * @pgid contains the new pgid.
628 * Return 0 if permission is granted.
630 * Check permission before getting the process group identifier of the
632 * @p contains the task_struct for the process.
633 * Return 0 if permission is granted.
635 * Check permission before getting the session identifier of the process
637 * @p contains the task_struct for the process.
638 * Return 0 if permission is granted.
640 * Retrieve the security identifier of the process @p.
641 * @p contains the task_struct for the process and place is into @secid.
642 * In case of failure, @secid will be set to zero.
645 * Check permission before setting the supplementary group set of the
647 * @group_info contains the new group information.
648 * Return 0 if permission is granted.
650 * Check permission before setting the nice value of @p to @nice.
651 * @p contains the task_struct of process.
652 * @nice contains the new nice value.
653 * Return 0 if permission is granted.
655 * Check permission before setting the ioprio value of @p to @ioprio.
656 * @p contains the task_struct of process.
657 * @ioprio contains the new ioprio value
658 * Return 0 if permission is granted.
660 * Check permission before getting the ioprio value of @p.
661 * @p contains the task_struct of process.
662 * Return 0 if permission is granted.
664 * Check permission before setting the resource limits of the current
665 * process for @resource to @new_rlim. The old resource limit values can
666 * be examined by dereferencing (current->signal->rlim + resource).
667 * @resource contains the resource whose limit is being set.
668 * @new_rlim contains the new limits for @resource.
669 * Return 0 if permission is granted.
670 * @task_setscheduler:
671 * Check permission before setting scheduling policy and/or parameters of
672 * process @p based on @policy and @lp.
673 * @p contains the task_struct for process.
674 * @policy contains the scheduling policy.
675 * @lp contains the scheduling parameters.
676 * Return 0 if permission is granted.
677 * @task_getscheduler:
678 * Check permission before obtaining scheduling information for process
680 * @p contains the task_struct for process.
681 * Return 0 if permission is granted.
683 * Check permission before moving memory owned by process @p.
684 * @p contains the task_struct for process.
685 * Return 0 if permission is granted.
687 * Check permission before sending signal @sig to @p. @info can be NULL,
688 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
689 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
690 * from the kernel and should typically be permitted.
691 * SIGIO signals are handled separately by the send_sigiotask hook in
693 * @p contains the task_struct for process.
694 * @info contains the signal information.
695 * @sig contains the signal value.
696 * @secid contains the sid of the process where the signal originated
697 * Return 0 if permission is granted.
699 * Check permission before allowing a process to reap a child process @p
700 * and collect its status information.
701 * @p contains the task_struct for process.
702 * Return 0 if permission is granted.
704 * Check permission before performing a process control operation on the
706 * @option contains the operation.
707 * @arg2 contains a argument.
708 * @arg3 contains a argument.
709 * @arg4 contains a argument.
710 * @arg5 contains a argument.
711 * Return -ENOSYS if no-one wanted to handle this op, any other value to
712 * cause prctl() to return immediately with that value.
714 * Set the security attributes for an inode based on an associated task's
715 * security attributes, e.g. for /proc/pid inodes.
716 * @p contains the task_struct for the task.
717 * @inode contains the inode structure for the inode.
719 * Security hooks for Netlink messaging.
722 * Save security information for a netlink message so that permission
723 * checking can be performed when the message is processed. The security
724 * information can be saved using the eff_cap field of the
725 * netlink_skb_parms structure. Also may be used to provide fine
726 * grained control over message transmission.
727 * @sk associated sock of task sending the message.,
728 * @skb contains the sk_buff structure for the netlink message.
729 * Return 0 if the information was successfully saved and message
730 * is allowed to be transmitted.
732 * Check permission before processing the received netlink message in
734 * @skb contains the sk_buff structure for the netlink message.
735 * @cap indicates the capability required
736 * Return 0 if permission is granted.
738 * Security hooks for Unix domain networking.
740 * @unix_stream_connect:
741 * Check permissions before establishing a Unix domain stream connection
742 * between @sock and @other.
743 * @sock contains the socket structure.
744 * @other contains the peer socket structure.
745 * Return 0 if permission is granted.
747 * Check permissions before connecting or sending datagrams from @sock to
749 * @sock contains the socket structure.
750 * @sock contains the peer socket structure.
751 * Return 0 if permission is granted.
753 * The @unix_stream_connect and @unix_may_send hooks were necessary because
754 * Linux provides an alternative to the conventional file name space for Unix
755 * domain sockets. Whereas binding and connecting to sockets in the file name
756 * space is mediated by the typical file permissions (and caught by the mknod
757 * and permission hooks in inode_security_ops), binding and connecting to
758 * sockets in the abstract name space is completely unmediated. Sufficient
759 * control of Unix domain sockets in the abstract name space isn't possible
760 * using only the socket layer hooks, since we need to know the actual target
761 * socket, which is not looked up until we are inside the af_unix code.
763 * Security hooks for socket operations.
766 * Check permissions prior to creating a new socket.
767 * @family contains the requested protocol family.
768 * @type contains the requested communications type.
769 * @protocol contains the requested protocol.
770 * @kern set to 1 if a kernel socket.
771 * Return 0 if permission is granted.
772 * @socket_post_create:
773 * This hook allows a module to update or allocate a per-socket security
774 * structure. Note that the security field was not added directly to the
775 * socket structure, but rather, the socket security information is stored
776 * in the associated inode. Typically, the inode alloc_security hook will
777 * allocate and and attach security information to
778 * sock->inode->i_security. This hook may be used to update the
779 * sock->inode->i_security field with additional information that wasn't
780 * available when the inode was allocated.
781 * @sock contains the newly created socket structure.
782 * @family contains the requested protocol family.
783 * @type contains the requested communications type.
784 * @protocol contains the requested protocol.
785 * @kern set to 1 if a kernel socket.
787 * Check permission before socket protocol layer bind operation is
788 * performed and the socket @sock is bound to the address specified in the
789 * @address parameter.
790 * @sock contains the socket structure.
791 * @address contains the address to bind to.
792 * @addrlen contains the length of address.
793 * Return 0 if permission is granted.
795 * Check permission before socket protocol layer connect operation
796 * attempts to connect socket @sock to a remote address, @address.
797 * @sock contains the socket structure.
798 * @address contains the address of remote endpoint.
799 * @addrlen contains the length of address.
800 * Return 0 if permission is granted.
802 * Check permission before socket protocol layer listen operation.
803 * @sock contains the socket structure.
804 * @backlog contains the maximum length for the pending connection queue.
805 * Return 0 if permission is granted.
807 * Check permission before accepting a new connection. Note that the new
808 * socket, @newsock, has been created and some information copied to it,
809 * but the accept operation has not actually been performed.
810 * @sock contains the listening socket structure.
811 * @newsock contains the newly created server socket for connection.
812 * Return 0 if permission is granted.
813 * @socket_post_accept:
814 * This hook allows a security module to copy security
815 * information into the newly created socket's inode.
816 * @sock contains the listening socket structure.
817 * @newsock contains the newly created server socket for connection.
819 * Check permission before transmitting a message to another socket.
820 * @sock contains the socket structure.
821 * @msg contains the message to be transmitted.
822 * @size contains the size of message.
823 * Return 0 if permission is granted.
825 * Check permission before receiving a message from a socket.
826 * @sock contains the socket structure.
827 * @msg contains the message structure.
828 * @size contains the size of message structure.
829 * @flags contains the operational flags.
830 * Return 0 if permission is granted.
831 * @socket_getsockname:
832 * Check permission before the local address (name) of the socket object
833 * @sock is retrieved.
834 * @sock contains the socket structure.
835 * Return 0 if permission is granted.
836 * @socket_getpeername:
837 * Check permission before the remote address (name) of a socket object
838 * @sock is retrieved.
839 * @sock contains the socket structure.
840 * Return 0 if permission is granted.
841 * @socket_getsockopt:
842 * Check permissions before retrieving the options associated with socket
844 * @sock contains the socket structure.
845 * @level contains the protocol level to retrieve option from.
846 * @optname contains the name of option to retrieve.
847 * Return 0 if permission is granted.
848 * @socket_setsockopt:
849 * Check permissions before setting the options associated with socket
851 * @sock contains the socket structure.
852 * @level contains the protocol level to set options for.
853 * @optname contains the name of the option to set.
854 * Return 0 if permission is granted.
856 * Checks permission before all or part of a connection on the socket
857 * @sock is shut down.
858 * @sock contains the socket structure.
859 * @how contains the flag indicating how future sends and receives are handled.
860 * Return 0 if permission is granted.
861 * @socket_sock_rcv_skb:
862 * Check permissions on incoming network packets. This hook is distinct
863 * from Netfilter's IP input hooks since it is the first time that the
864 * incoming sk_buff @skb has been associated with a particular socket, @sk.
865 * @sk contains the sock (not socket) associated with the incoming sk_buff.
866 * @skb contains the incoming network data.
867 * @socket_getpeersec_stream:
868 * This hook allows the security module to provide peer socket security
869 * state for unix or connected tcp sockets to userspace via getsockopt
870 * SO_GETPEERSEC. For tcp sockets this can be meaningful if the
871 * socket is associated with an ipsec SA.
872 * @sock is the local socket.
873 * @optval userspace memory where the security state is to be copied.
874 * @optlen userspace int where the module should copy the actual length
875 * of the security state.
876 * @len as input is the maximum length to copy to userspace provided
878 * Return 0 if all is well, otherwise, typical getsockopt return
880 * @socket_getpeersec_dgram:
881 * This hook allows the security module to provide peer socket security
882 * state for udp sockets on a per-packet basis to userspace via
883 * getsockopt SO_GETPEERSEC. The application must first have indicated
884 * the IP_PASSSEC option via getsockopt. It can then retrieve the
885 * security state returned by this hook for a packet via the SCM_SECURITY
886 * ancillary message type.
887 * @skb is the skbuff for the packet being queried
888 * @secdata is a pointer to a buffer in which to copy the security data
889 * @seclen is the maximum length for @secdata
890 * Return 0 on success, error on failure.
891 * @sk_alloc_security:
892 * Allocate and attach a security structure to the sk->sk_security field,
893 * which is used to copy security attributes between local stream sockets.
895 * Deallocate security structure.
896 * @sk_clone_security:
897 * Clone/copy security structure.
899 * Retrieve the LSM-specific secid for the sock to enable caching of network
902 * Sets the socket's isec sid to the sock's sid.
903 * @inet_conn_request:
904 * Sets the openreq's sid to socket's sid with MLS portion taken from peer sid.
906 * Sets the new child socket's sid to the openreq sid.
907 * @inet_conn_established:
908 * Sets the connection's peersid to the secmark on skb.
909 * @req_classify_flow:
910 * Sets the flow's sid to the openreq sid.
912 * Security hooks for XFRM operations.
914 * @xfrm_policy_alloc_security:
915 * @ctxp is a pointer to the xfrm_sec_ctx being added to Security Policy
916 * Database used by the XFRM system.
917 * @sec_ctx contains the security context information being provided by
918 * the user-level policy update program (e.g., setkey).
919 * Allocate a security structure to the xp->security field; the security
920 * field is initialized to NULL when the xfrm_policy is allocated.
921 * Return 0 if operation was successful (memory to allocate, legal context)
922 * @xfrm_policy_clone_security:
923 * @old_ctx contains an existing xfrm_sec_ctx.
924 * @new_ctxp contains a new xfrm_sec_ctx being cloned from old.
925 * Allocate a security structure in new_ctxp that contains the
926 * information from the old_ctx structure.
927 * Return 0 if operation was successful (memory to allocate).
928 * @xfrm_policy_free_security:
929 * @ctx contains the xfrm_sec_ctx
930 * Deallocate xp->security.
931 * @xfrm_policy_delete_security:
932 * @ctx contains the xfrm_sec_ctx.
933 * Authorize deletion of xp->security.
934 * @xfrm_state_alloc_security:
935 * @x contains the xfrm_state being added to the Security Association
936 * Database by the XFRM system.
937 * @sec_ctx contains the security context information being provided by
938 * the user-level SA generation program (e.g., setkey or racoon).
939 * @secid contains the secid from which to take the mls portion of the context.
940 * Allocate a security structure to the x->security field; the security
941 * field is initialized to NULL when the xfrm_state is allocated. Set the
942 * context to correspond to either sec_ctx or polsec, with the mls portion
943 * taken from secid in the latter case.
944 * Return 0 if operation was successful (memory to allocate, legal context).
945 * @xfrm_state_free_security:
946 * @x contains the xfrm_state.
947 * Deallocate x->security.
948 * @xfrm_state_delete_security:
949 * @x contains the xfrm_state.
950 * Authorize deletion of x->security.
951 * @xfrm_policy_lookup:
952 * @ctx contains the xfrm_sec_ctx for which the access control is being
954 * @fl_secid contains the flow security label that is used to authorize
955 * access to the policy xp.
956 * @dir contains the direction of the flow (input or output).
957 * Check permission when a flow selects a xfrm_policy for processing
958 * XFRMs on a packet. The hook is called when selecting either a
959 * per-socket policy or a generic xfrm policy.
960 * Return 0 if permission is granted, -ESRCH otherwise, or -errno
962 * @xfrm_state_pol_flow_match:
963 * @x contains the state to match.
964 * @xp contains the policy to check for a match.
965 * @fl contains the flow to check for a match.
966 * Return 1 if there is a match.
967 * @xfrm_decode_session:
968 * @skb points to skb to decode.
969 * @secid points to the flow key secid to set.
970 * @ckall says if all xfrms used should be checked for same secid.
971 * Return 0 if ckall is zero or all xfrms used have the same secid.
973 * Security hooks affecting all Key Management operations
976 * Permit allocation of a key and assign security data. Note that key does
977 * not have a serial number assigned at this point.
978 * @key points to the key.
979 * @flags is the allocation flags
980 * Return 0 if permission is granted, -ve error otherwise.
982 * Notification of destruction; free security data.
983 * @key points to the key.
986 * See whether a specific operational right is granted to a process on a
988 * @key_ref refers to the key (key pointer + possession attribute bit).
989 * @cred points to the credentials to provide the context against which to
990 * evaluate the security data on the key.
991 * @perm describes the combination of permissions required of this key.
992 * Return 1 if permission granted, 0 if permission denied and -ve it the
993 * normal permissions model should be effected.
995 * Get a textual representation of the security context attached to a key
996 * for the purposes of honouring KEYCTL_GETSECURITY. This function
997 * allocates the storage for the NUL-terminated string and the caller
999 * @key points to the key to be queried.
1000 * @_buffer points to a pointer that should be set to point to the
1001 * resulting string (if no label or an error occurs).
1002 * Return the length of the string (including terminating NUL) or -ve if
1004 * May also return 0 (and a NULL buffer pointer) if there is no label.
1006 * Security hooks affecting all System V IPC operations.
1009 * Check permissions for access to IPC
1010 * @ipcp contains the kernel IPC permission structure
1011 * @flag contains the desired (requested) permission set
1012 * Return 0 if permission is granted.
1014 * Get the secid associated with the ipc object.
1015 * @ipcp contains the kernel IPC permission structure.
1016 * @secid contains a pointer to the location where result will be saved.
1017 * In case of failure, @secid will be set to zero.
1019 * Security hooks for individual messages held in System V IPC message queues
1020 * @msg_msg_alloc_security:
1021 * Allocate and attach a security structure to the msg->security field.
1022 * The security field is initialized to NULL when the structure is first
1024 * @msg contains the message structure to be modified.
1025 * Return 0 if operation was successful and permission is granted.
1026 * @msg_msg_free_security:
1027 * Deallocate the security structure for this message.
1028 * @msg contains the message structure to be modified.
1030 * Security hooks for System V IPC Message Queues
1032 * @msg_queue_alloc_security:
1033 * Allocate and attach a security structure to the
1034 * msq->q_perm.security field. The security field is initialized to
1035 * NULL when the structure is first created.
1036 * @msq contains the message queue structure to be modified.
1037 * Return 0 if operation was successful and permission is granted.
1038 * @msg_queue_free_security:
1039 * Deallocate security structure for this message queue.
1040 * @msq contains the message queue structure to be modified.
1041 * @msg_queue_associate:
1042 * Check permission when a message queue is requested through the
1043 * msgget system call. This hook is only called when returning the
1044 * message queue identifier for an existing message queue, not when a
1045 * new message queue is created.
1046 * @msq contains the message queue to act upon.
1047 * @msqflg contains the operation control flags.
1048 * Return 0 if permission is granted.
1049 * @msg_queue_msgctl:
1050 * Check permission when a message control operation specified by @cmd
1051 * is to be performed on the message queue @msq.
1052 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
1053 * @msq contains the message queue to act upon. May be NULL.
1054 * @cmd contains the operation to be performed.
1055 * Return 0 if permission is granted.
1056 * @msg_queue_msgsnd:
1057 * Check permission before a message, @msg, is enqueued on the message
1059 * @msq contains the message queue to send message to.
1060 * @msg contains the message to be enqueued.
1061 * @msqflg contains operational flags.
1062 * Return 0 if permission is granted.
1063 * @msg_queue_msgrcv:
1064 * Check permission before a message, @msg, is removed from the message
1065 * queue, @msq. The @target task structure contains a pointer to the
1066 * process that will be receiving the message (not equal to the current
1067 * process when inline receives are being performed).
1068 * @msq contains the message queue to retrieve message from.
1069 * @msg contains the message destination.
1070 * @target contains the task structure for recipient process.
1071 * @type contains the type of message requested.
1072 * @mode contains the operational flags.
1073 * Return 0 if permission is granted.
1075 * Security hooks for System V Shared Memory Segments
1077 * @shm_alloc_security:
1078 * Allocate and attach a security structure to the shp->shm_perm.security
1079 * field. The security field is initialized to NULL when the structure is
1081 * @shp contains the shared memory structure to be modified.
1082 * Return 0 if operation was successful and permission is granted.
1083 * @shm_free_security:
1084 * Deallocate the security struct for this memory segment.
1085 * @shp contains the shared memory structure to be modified.
1087 * Check permission when a shared memory region is requested through the
1088 * shmget system call. This hook is only called when returning the shared
1089 * memory region identifier for an existing region, not when a new shared
1090 * memory region is created.
1091 * @shp contains the shared memory structure to be modified.
1092 * @shmflg contains the operation control flags.
1093 * Return 0 if permission is granted.
1095 * Check permission when a shared memory control operation specified by
1096 * @cmd is to be performed on the shared memory region @shp.
1097 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1098 * @shp contains shared memory structure to be modified.
1099 * @cmd contains the operation to be performed.
1100 * Return 0 if permission is granted.
1102 * Check permissions prior to allowing the shmat system call to attach the
1103 * shared memory segment @shp to the data segment of the calling process.
1104 * The attaching address is specified by @shmaddr.
1105 * @shp contains the shared memory structure to be modified.
1106 * @shmaddr contains the address to attach memory region to.
1107 * @shmflg contains the operational flags.
1108 * Return 0 if permission is granted.
1110 * Security hooks for System V Semaphores
1112 * @sem_alloc_security:
1113 * Allocate and attach a security structure to the sma->sem_perm.security
1114 * field. The security field is initialized to NULL when the structure is
1116 * @sma contains the semaphore structure
1117 * Return 0 if operation was successful and permission is granted.
1118 * @sem_free_security:
1119 * deallocate security struct for this semaphore
1120 * @sma contains the semaphore structure.
1122 * Check permission when a semaphore is requested through the semget
1123 * system call. This hook is only called when returning the semaphore
1124 * identifier for an existing semaphore, not when a new one must be
1126 * @sma contains the semaphore structure.
1127 * @semflg contains the operation control flags.
1128 * Return 0 if permission is granted.
1130 * Check permission when a semaphore operation specified by @cmd is to be
1131 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
1132 * IPC_INFO or SEM_INFO.
1133 * @sma contains the semaphore structure. May be NULL.
1134 * @cmd contains the operation to be performed.
1135 * Return 0 if permission is granted.
1137 * Check permissions before performing operations on members of the
1138 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1140 * @sma contains the semaphore structure.
1141 * @sops contains the operations to perform.
1142 * @nsops contains the number of operations to perform.
1143 * @alter contains the flag indicating whether changes are to be made.
1144 * Return 0 if permission is granted.
1146 * @ptrace_may_access:
1147 * Check permission before allowing the current process to trace the
1149 * Security modules may also want to perform a process tracing check
1150 * during an execve in the set_security or apply_creds hooks of
1151 * tracing check during an execve in the bprm_set_creds hook of
1152 * binprm_security_ops if the process is being traced and its security
1153 * attributes would be changed by the execve.
1154 * @child contains the task_struct structure for the target process.
1155 * @mode contains the PTRACE_MODE flags indicating the form of access.
1156 * Return 0 if permission is granted.
1158 * Check that the @parent process has sufficient permission to trace the
1159 * current process before allowing the current process to present itself
1160 * to the @parent process for tracing.
1161 * The parent process will still have to undergo the ptrace_may_access
1162 * checks before it is allowed to trace this one.
1163 * @parent contains the task_struct structure for debugger process.
1164 * Return 0 if permission is granted.
1166 * Get the @effective, @inheritable, and @permitted capability sets for
1167 * the @target process. The hook may also perform permission checking to
1168 * determine if the current process is allowed to see the capability sets
1169 * of the @target process.
1170 * @target contains the task_struct structure for target process.
1171 * @effective contains the effective capability set.
1172 * @inheritable contains the inheritable capability set.
1173 * @permitted contains the permitted capability set.
1174 * Return 0 if the capability sets were successfully obtained.
1176 * Set the @effective, @inheritable, and @permitted capability sets for
1177 * the current process.
1178 * @new contains the new credentials structure for target process.
1179 * @old contains the current credentials structure for target process.
1180 * @effective contains the effective capability set.
1181 * @inheritable contains the inheritable capability set.
1182 * @permitted contains the permitted capability set.
1183 * Return 0 and update @new if permission is granted.
1185 * Check whether the @tsk process has the @cap capability.
1186 * @tsk contains the task_struct for the process.
1187 * @cap contains the capability <include/linux/capability.h>.
1188 * Return 0 if the capability is granted for @tsk.
1190 * Check permission before enabling or disabling process accounting. If
1191 * accounting is being enabled, then @file refers to the open file used to
1192 * store accounting records. If accounting is being disabled, then @file
1194 * @file contains the file structure for the accounting file (may be NULL).
1195 * Return 0 if permission is granted.
1197 * Check permission before accessing the @table sysctl variable in the
1198 * manner specified by @op.
1199 * @table contains the ctl_table structure for the sysctl variable.
1200 * @op contains the operation (001 = search, 002 = write, 004 = read).
1201 * Return 0 if permission is granted.
1203 * Check permission before accessing the kernel message ring or changing
1204 * logging to the console.
1205 * See the syslog(2) manual page for an explanation of the @type values.
1206 * @type contains the type of action.
1207 * Return 0 if permission is granted.
1209 * Check permission to change the system time.
1210 * struct timespec and timezone are defined in include/linux/time.h
1211 * @ts contains new time
1212 * @tz contains new timezone
1213 * Return 0 if permission is granted.
1214 * @vm_enough_memory:
1215 * Check permissions for allocating a new virtual mapping.
1216 * @mm contains the mm struct it is being added to.
1217 * @pages contains the number of pages.
1218 * Return 0 if permission is granted.
1221 * Convert secid to security context.
1222 * @secid contains the security ID.
1223 * @secdata contains the pointer that stores the converted security context.
1225 * Convert security context to secid.
1226 * @secid contains the pointer to the generated security ID.
1227 * @secdata contains the security context.
1230 * Release the security context.
1231 * @secdata contains the security context.
1232 * @seclen contains the length of the security context.
1234 * Security hooks for Audit
1237 * Allocate and initialize an LSM audit rule structure.
1238 * @field contains the required Audit action. Fields flags are defined in include/linux/audit.h
1239 * @op contains the operator the rule uses.
1240 * @rulestr contains the context where the rule will be applied to.
1241 * @lsmrule contains a pointer to receive the result.
1242 * Return 0 if @lsmrule has been successfully set,
1243 * -EINVAL in case of an invalid rule.
1245 * @audit_rule_known:
1246 * Specifies whether given @rule contains any fields related to current LSM.
1247 * @rule contains the audit rule of interest.
1248 * Return 1 in case of relation found, 0 otherwise.
1250 * @audit_rule_match:
1251 * Determine if given @secid matches a rule previously approved
1252 * by @audit_rule_known.
1253 * @secid contains the security id in question.
1254 * @field contains the field which relates to current LSM.
1255 * @op contains the operator that will be used for matching.
1256 * @rule points to the audit rule that will be checked against.
1257 * @actx points to the audit context associated with the check.
1258 * Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure.
1261 * Deallocate the LSM audit rule structure previously allocated by
1263 * @rule contains the allocated rule
1265 * This is the main security structure.
1267 struct security_operations
{
1268 char name
[SECURITY_NAME_MAX
+ 1];
1270 int (*ptrace_may_access
) (struct task_struct
*child
, unsigned int mode
);
1271 int (*ptrace_traceme
) (struct task_struct
*parent
);
1272 int (*capget
) (struct task_struct
*target
,
1273 kernel_cap_t
*effective
,
1274 kernel_cap_t
*inheritable
, kernel_cap_t
*permitted
);
1275 int (*capset
) (struct cred
*new,
1276 const struct cred
*old
,
1277 const kernel_cap_t
*effective
,
1278 const kernel_cap_t
*inheritable
,
1279 const kernel_cap_t
*permitted
);
1280 int (*capable
) (struct task_struct
*tsk
, int cap
, int audit
);
1281 int (*acct
) (struct file
*file
);
1282 int (*sysctl
) (struct ctl_table
*table
, int op
);
1283 int (*quotactl
) (int cmds
, int type
, int id
, struct super_block
*sb
);
1284 int (*quota_on
) (struct dentry
*dentry
);
1285 int (*syslog
) (int type
);
1286 int (*settime
) (struct timespec
*ts
, struct timezone
*tz
);
1287 int (*vm_enough_memory
) (struct mm_struct
*mm
, long pages
);
1289 int (*bprm_set_creds
) (struct linux_binprm
*bprm
);
1290 int (*bprm_check_security
) (struct linux_binprm
*bprm
);
1291 int (*bprm_secureexec
) (struct linux_binprm
*bprm
);
1292 void (*bprm_committing_creds
) (struct linux_binprm
*bprm
);
1293 void (*bprm_committed_creds
) (struct linux_binprm
*bprm
);
1295 int (*sb_alloc_security
) (struct super_block
*sb
);
1296 void (*sb_free_security
) (struct super_block
*sb
);
1297 int (*sb_copy_data
) (char *orig
, char *copy
);
1298 int (*sb_kern_mount
) (struct super_block
*sb
, void *data
);
1299 int (*sb_show_options
) (struct seq_file
*m
, struct super_block
*sb
);
1300 int (*sb_statfs
) (struct dentry
*dentry
);
1301 int (*sb_mount
) (char *dev_name
, struct path
*path
,
1302 char *type
, unsigned long flags
, void *data
);
1303 int (*sb_check_sb
) (struct vfsmount
*mnt
, struct path
*path
);
1304 int (*sb_umount
) (struct vfsmount
*mnt
, int flags
);
1305 void (*sb_umount_close
) (struct vfsmount
*mnt
);
1306 void (*sb_umount_busy
) (struct vfsmount
*mnt
);
1307 void (*sb_post_remount
) (struct vfsmount
*mnt
,
1308 unsigned long flags
, void *data
);
1309 void (*sb_post_addmount
) (struct vfsmount
*mnt
,
1310 struct path
*mountpoint
);
1311 int (*sb_pivotroot
) (struct path
*old_path
,
1312 struct path
*new_path
);
1313 void (*sb_post_pivotroot
) (struct path
*old_path
,
1314 struct path
*new_path
);
1315 int (*sb_set_mnt_opts
) (struct super_block
*sb
,
1316 struct security_mnt_opts
*opts
);
1317 void (*sb_clone_mnt_opts
) (const struct super_block
*oldsb
,
1318 struct super_block
*newsb
);
1319 int (*sb_parse_opts_str
) (char *options
, struct security_mnt_opts
*opts
);
1321 int (*inode_alloc_security
) (struct inode
*inode
);
1322 void (*inode_free_security
) (struct inode
*inode
);
1323 int (*inode_init_security
) (struct inode
*inode
, struct inode
*dir
,
1324 char **name
, void **value
, size_t *len
);
1325 int (*inode_create
) (struct inode
*dir
,
1326 struct dentry
*dentry
, int mode
);
1327 int (*inode_link
) (struct dentry
*old_dentry
,
1328 struct inode
*dir
, struct dentry
*new_dentry
);
1329 int (*inode_unlink
) (struct inode
*dir
, struct dentry
*dentry
);
1330 int (*inode_symlink
) (struct inode
*dir
,
1331 struct dentry
*dentry
, const char *old_name
);
1332 int (*inode_mkdir
) (struct inode
*dir
, struct dentry
*dentry
, int mode
);
1333 int (*inode_rmdir
) (struct inode
*dir
, struct dentry
*dentry
);
1334 int (*inode_mknod
) (struct inode
*dir
, struct dentry
*dentry
,
1335 int mode
, dev_t dev
);
1336 int (*inode_rename
) (struct inode
*old_dir
, struct dentry
*old_dentry
,
1337 struct inode
*new_dir
, struct dentry
*new_dentry
);
1338 int (*inode_readlink
) (struct dentry
*dentry
);
1339 int (*inode_follow_link
) (struct dentry
*dentry
, struct nameidata
*nd
);
1340 int (*inode_permission
) (struct inode
*inode
, int mask
);
1341 int (*inode_setattr
) (struct dentry
*dentry
, struct iattr
*attr
);
1342 int (*inode_getattr
) (struct vfsmount
*mnt
, struct dentry
*dentry
);
1343 void (*inode_delete
) (struct inode
*inode
);
1344 int (*inode_setxattr
) (struct dentry
*dentry
, const char *name
,
1345 const void *value
, size_t size
, int flags
);
1346 void (*inode_post_setxattr
) (struct dentry
*dentry
, const char *name
,
1347 const void *value
, size_t size
, int flags
);
1348 int (*inode_getxattr
) (struct dentry
*dentry
, const char *name
);
1349 int (*inode_listxattr
) (struct dentry
*dentry
);
1350 int (*inode_removexattr
) (struct dentry
*dentry
, const char *name
);
1351 int (*inode_need_killpriv
) (struct dentry
*dentry
);
1352 int (*inode_killpriv
) (struct dentry
*dentry
);
1353 int (*inode_getsecurity
) (const struct inode
*inode
, const char *name
, void **buffer
, bool alloc
);
1354 int (*inode_setsecurity
) (struct inode
*inode
, const char *name
, const void *value
, size_t size
, int flags
);
1355 int (*inode_listsecurity
) (struct inode
*inode
, char *buffer
, size_t buffer_size
);
1356 void (*inode_getsecid
) (const struct inode
*inode
, u32
*secid
);
1358 int (*file_permission
) (struct file
*file
, int mask
);
1359 int (*file_alloc_security
) (struct file
*file
);
1360 void (*file_free_security
) (struct file
*file
);
1361 int (*file_ioctl
) (struct file
*file
, unsigned int cmd
,
1363 int (*file_mmap
) (struct file
*file
,
1364 unsigned long reqprot
, unsigned long prot
,
1365 unsigned long flags
, unsigned long addr
,
1366 unsigned long addr_only
);
1367 int (*file_mprotect
) (struct vm_area_struct
*vma
,
1368 unsigned long reqprot
,
1369 unsigned long prot
);
1370 int (*file_lock
) (struct file
*file
, unsigned int cmd
);
1371 int (*file_fcntl
) (struct file
*file
, unsigned int cmd
,
1373 int (*file_set_fowner
) (struct file
*file
);
1374 int (*file_send_sigiotask
) (struct task_struct
*tsk
,
1375 struct fown_struct
*fown
, int sig
);
1376 int (*file_receive
) (struct file
*file
);
1377 int (*dentry_open
) (struct file
*file
, const struct cred
*cred
);
1379 int (*task_create
) (unsigned long clone_flags
);
1380 void (*cred_free
) (struct cred
*cred
);
1381 int (*cred_prepare
)(struct cred
*new, const struct cred
*old
,
1383 void (*cred_commit
)(struct cred
*new, const struct cred
*old
);
1384 int (*task_setuid
) (uid_t id0
, uid_t id1
, uid_t id2
, int flags
);
1385 int (*task_fix_setuid
) (struct cred
*new, const struct cred
*old
,
1387 int (*task_setgid
) (gid_t id0
, gid_t id1
, gid_t id2
, int flags
);
1388 int (*task_setpgid
) (struct task_struct
*p
, pid_t pgid
);
1389 int (*task_getpgid
) (struct task_struct
*p
);
1390 int (*task_getsid
) (struct task_struct
*p
);
1391 void (*task_getsecid
) (struct task_struct
*p
, u32
*secid
);
1392 int (*task_setgroups
) (struct group_info
*group_info
);
1393 int (*task_setnice
) (struct task_struct
*p
, int nice
);
1394 int (*task_setioprio
) (struct task_struct
*p
, int ioprio
);
1395 int (*task_getioprio
) (struct task_struct
*p
);
1396 int (*task_setrlimit
) (unsigned int resource
, struct rlimit
*new_rlim
);
1397 int (*task_setscheduler
) (struct task_struct
*p
, int policy
,
1398 struct sched_param
*lp
);
1399 int (*task_getscheduler
) (struct task_struct
*p
);
1400 int (*task_movememory
) (struct task_struct
*p
);
1401 int (*task_kill
) (struct task_struct
*p
,
1402 struct siginfo
*info
, int sig
, u32 secid
);
1403 int (*task_wait
) (struct task_struct
*p
);
1404 int (*task_prctl
) (int option
, unsigned long arg2
,
1405 unsigned long arg3
, unsigned long arg4
,
1406 unsigned long arg5
);
1407 void (*task_to_inode
) (struct task_struct
*p
, struct inode
*inode
);
1409 int (*ipc_permission
) (struct kern_ipc_perm
*ipcp
, short flag
);
1410 void (*ipc_getsecid
) (struct kern_ipc_perm
*ipcp
, u32
*secid
);
1412 int (*msg_msg_alloc_security
) (struct msg_msg
*msg
);
1413 void (*msg_msg_free_security
) (struct msg_msg
*msg
);
1415 int (*msg_queue_alloc_security
) (struct msg_queue
*msq
);
1416 void (*msg_queue_free_security
) (struct msg_queue
*msq
);
1417 int (*msg_queue_associate
) (struct msg_queue
*msq
, int msqflg
);
1418 int (*msg_queue_msgctl
) (struct msg_queue
*msq
, int cmd
);
1419 int (*msg_queue_msgsnd
) (struct msg_queue
*msq
,
1420 struct msg_msg
*msg
, int msqflg
);
1421 int (*msg_queue_msgrcv
) (struct msg_queue
*msq
,
1422 struct msg_msg
*msg
,
1423 struct task_struct
*target
,
1424 long type
, int mode
);
1426 int (*shm_alloc_security
) (struct shmid_kernel
*shp
);
1427 void (*shm_free_security
) (struct shmid_kernel
*shp
);
1428 int (*shm_associate
) (struct shmid_kernel
*shp
, int shmflg
);
1429 int (*shm_shmctl
) (struct shmid_kernel
*shp
, int cmd
);
1430 int (*shm_shmat
) (struct shmid_kernel
*shp
,
1431 char __user
*shmaddr
, int shmflg
);
1433 int (*sem_alloc_security
) (struct sem_array
*sma
);
1434 void (*sem_free_security
) (struct sem_array
*sma
);
1435 int (*sem_associate
) (struct sem_array
*sma
, int semflg
);
1436 int (*sem_semctl
) (struct sem_array
*sma
, int cmd
);
1437 int (*sem_semop
) (struct sem_array
*sma
,
1438 struct sembuf
*sops
, unsigned nsops
, int alter
);
1440 int (*netlink_send
) (struct sock
*sk
, struct sk_buff
*skb
);
1441 int (*netlink_recv
) (struct sk_buff
*skb
, int cap
);
1443 void (*d_instantiate
) (struct dentry
*dentry
, struct inode
*inode
);
1445 int (*getprocattr
) (struct task_struct
*p
, char *name
, char **value
);
1446 int (*setprocattr
) (struct task_struct
*p
, char *name
, void *value
, size_t size
);
1447 int (*secid_to_secctx
) (u32 secid
, char **secdata
, u32
*seclen
);
1448 int (*secctx_to_secid
) (const char *secdata
, u32 seclen
, u32
*secid
);
1449 void (*release_secctx
) (char *secdata
, u32 seclen
);
1451 #ifdef CONFIG_SECURITY_NETWORK
1452 int (*unix_stream_connect
) (struct socket
*sock
,
1453 struct socket
*other
, struct sock
*newsk
);
1454 int (*unix_may_send
) (struct socket
*sock
, struct socket
*other
);
1456 int (*socket_create
) (int family
, int type
, int protocol
, int kern
);
1457 int (*socket_post_create
) (struct socket
*sock
, int family
,
1458 int type
, int protocol
, int kern
);
1459 int (*socket_bind
) (struct socket
*sock
,
1460 struct sockaddr
*address
, int addrlen
);
1461 int (*socket_connect
) (struct socket
*sock
,
1462 struct sockaddr
*address
, int addrlen
);
1463 int (*socket_listen
) (struct socket
*sock
, int backlog
);
1464 int (*socket_accept
) (struct socket
*sock
, struct socket
*newsock
);
1465 void (*socket_post_accept
) (struct socket
*sock
,
1466 struct socket
*newsock
);
1467 int (*socket_sendmsg
) (struct socket
*sock
,
1468 struct msghdr
*msg
, int size
);
1469 int (*socket_recvmsg
) (struct socket
*sock
,
1470 struct msghdr
*msg
, int size
, int flags
);
1471 int (*socket_getsockname
) (struct socket
*sock
);
1472 int (*socket_getpeername
) (struct socket
*sock
);
1473 int (*socket_getsockopt
) (struct socket
*sock
, int level
, int optname
);
1474 int (*socket_setsockopt
) (struct socket
*sock
, int level
, int optname
);
1475 int (*socket_shutdown
) (struct socket
*sock
, int how
);
1476 int (*socket_sock_rcv_skb
) (struct sock
*sk
, struct sk_buff
*skb
);
1477 int (*socket_getpeersec_stream
) (struct socket
*sock
, char __user
*optval
, int __user
*optlen
, unsigned len
);
1478 int (*socket_getpeersec_dgram
) (struct socket
*sock
, struct sk_buff
*skb
, u32
*secid
);
1479 int (*sk_alloc_security
) (struct sock
*sk
, int family
, gfp_t priority
);
1480 void (*sk_free_security
) (struct sock
*sk
);
1481 void (*sk_clone_security
) (const struct sock
*sk
, struct sock
*newsk
);
1482 void (*sk_getsecid
) (struct sock
*sk
, u32
*secid
);
1483 void (*sock_graft
) (struct sock
*sk
, struct socket
*parent
);
1484 int (*inet_conn_request
) (struct sock
*sk
, struct sk_buff
*skb
,
1485 struct request_sock
*req
);
1486 void (*inet_csk_clone
) (struct sock
*newsk
, const struct request_sock
*req
);
1487 void (*inet_conn_established
) (struct sock
*sk
, struct sk_buff
*skb
);
1488 void (*req_classify_flow
) (const struct request_sock
*req
, struct flowi
*fl
);
1489 #endif /* CONFIG_SECURITY_NETWORK */
1491 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1492 int (*xfrm_policy_alloc_security
) (struct xfrm_sec_ctx
**ctxp
,
1493 struct xfrm_user_sec_ctx
*sec_ctx
);
1494 int (*xfrm_policy_clone_security
) (struct xfrm_sec_ctx
*old_ctx
, struct xfrm_sec_ctx
**new_ctx
);
1495 void (*xfrm_policy_free_security
) (struct xfrm_sec_ctx
*ctx
);
1496 int (*xfrm_policy_delete_security
) (struct xfrm_sec_ctx
*ctx
);
1497 int (*xfrm_state_alloc_security
) (struct xfrm_state
*x
,
1498 struct xfrm_user_sec_ctx
*sec_ctx
,
1500 void (*xfrm_state_free_security
) (struct xfrm_state
*x
);
1501 int (*xfrm_state_delete_security
) (struct xfrm_state
*x
);
1502 int (*xfrm_policy_lookup
) (struct xfrm_sec_ctx
*ctx
, u32 fl_secid
, u8 dir
);
1503 int (*xfrm_state_pol_flow_match
) (struct xfrm_state
*x
,
1504 struct xfrm_policy
*xp
,
1506 int (*xfrm_decode_session
) (struct sk_buff
*skb
, u32
*secid
, int ckall
);
1507 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1509 /* key management security hooks */
1511 int (*key_alloc
) (struct key
*key
, const struct cred
*cred
, unsigned long flags
);
1512 void (*key_free
) (struct key
*key
);
1513 int (*key_permission
) (key_ref_t key_ref
,
1514 const struct cred
*cred
,
1516 int (*key_getsecurity
)(struct key
*key
, char **_buffer
);
1517 #endif /* CONFIG_KEYS */
1520 int (*audit_rule_init
) (u32 field
, u32 op
, char *rulestr
, void **lsmrule
);
1521 int (*audit_rule_known
) (struct audit_krule
*krule
);
1522 int (*audit_rule_match
) (u32 secid
, u32 field
, u32 op
, void *lsmrule
,
1523 struct audit_context
*actx
);
1524 void (*audit_rule_free
) (void *lsmrule
);
1525 #endif /* CONFIG_AUDIT */
1529 extern int security_init(void);
1530 extern int security_module_enable(struct security_operations
*ops
);
1531 extern int register_security(struct security_operations
*ops
);
1533 /* Security operations */
1534 int security_ptrace_may_access(struct task_struct
*child
, unsigned int mode
);
1535 int security_ptrace_traceme(struct task_struct
*parent
);
1536 int security_capget(struct task_struct
*target
,
1537 kernel_cap_t
*effective
,
1538 kernel_cap_t
*inheritable
,
1539 kernel_cap_t
*permitted
);
1540 int security_capset(struct cred
*new, const struct cred
*old
,
1541 const kernel_cap_t
*effective
,
1542 const kernel_cap_t
*inheritable
,
1543 const kernel_cap_t
*permitted
);
1544 int security_capable(struct task_struct
*tsk
, int cap
);
1545 int security_capable_noaudit(struct task_struct
*tsk
, int cap
);
1546 int security_acct(struct file
*file
);
1547 int security_sysctl(struct ctl_table
*table
, int op
);
1548 int security_quotactl(int cmds
, int type
, int id
, struct super_block
*sb
);
1549 int security_quota_on(struct dentry
*dentry
);
1550 int security_syslog(int type
);
1551 int security_settime(struct timespec
*ts
, struct timezone
*tz
);
1552 int security_vm_enough_memory(long pages
);
1553 int security_vm_enough_memory_mm(struct mm_struct
*mm
, long pages
);
1554 int security_vm_enough_memory_kern(long pages
);
1555 int security_bprm_set_creds(struct linux_binprm
*bprm
);
1556 int security_bprm_check(struct linux_binprm
*bprm
);
1557 void security_bprm_committing_creds(struct linux_binprm
*bprm
);
1558 void security_bprm_committed_creds(struct linux_binprm
*bprm
);
1559 int security_bprm_secureexec(struct linux_binprm
*bprm
);
1560 int security_sb_alloc(struct super_block
*sb
);
1561 void security_sb_free(struct super_block
*sb
);
1562 int security_sb_copy_data(char *orig
, char *copy
);
1563 int security_sb_kern_mount(struct super_block
*sb
, void *data
);
1564 int security_sb_show_options(struct seq_file
*m
, struct super_block
*sb
);
1565 int security_sb_statfs(struct dentry
*dentry
);
1566 int security_sb_mount(char *dev_name
, struct path
*path
,
1567 char *type
, unsigned long flags
, void *data
);
1568 int security_sb_check_sb(struct vfsmount
*mnt
, struct path
*path
);
1569 int security_sb_umount(struct vfsmount
*mnt
, int flags
);
1570 void security_sb_umount_close(struct vfsmount
*mnt
);
1571 void security_sb_umount_busy(struct vfsmount
*mnt
);
1572 void security_sb_post_remount(struct vfsmount
*mnt
, unsigned long flags
, void *data
);
1573 void security_sb_post_addmount(struct vfsmount
*mnt
, struct path
*mountpoint
);
1574 int security_sb_pivotroot(struct path
*old_path
, struct path
*new_path
);
1575 void security_sb_post_pivotroot(struct path
*old_path
, struct path
*new_path
);
1576 int security_sb_set_mnt_opts(struct super_block
*sb
, struct security_mnt_opts
*opts
);
1577 void security_sb_clone_mnt_opts(const struct super_block
*oldsb
,
1578 struct super_block
*newsb
);
1579 int security_sb_parse_opts_str(char *options
, struct security_mnt_opts
*opts
);
1581 int security_inode_alloc(struct inode
*inode
);
1582 void security_inode_free(struct inode
*inode
);
1583 int security_inode_init_security(struct inode
*inode
, struct inode
*dir
,
1584 char **name
, void **value
, size_t *len
);
1585 int security_inode_create(struct inode
*dir
, struct dentry
*dentry
, int mode
);
1586 int security_inode_link(struct dentry
*old_dentry
, struct inode
*dir
,
1587 struct dentry
*new_dentry
);
1588 int security_inode_unlink(struct inode
*dir
, struct dentry
*dentry
);
1589 int security_inode_symlink(struct inode
*dir
, struct dentry
*dentry
,
1590 const char *old_name
);
1591 int security_inode_mkdir(struct inode
*dir
, struct dentry
*dentry
, int mode
);
1592 int security_inode_rmdir(struct inode
*dir
, struct dentry
*dentry
);
1593 int security_inode_mknod(struct inode
*dir
, struct dentry
*dentry
, int mode
, dev_t dev
);
1594 int security_inode_rename(struct inode
*old_dir
, struct dentry
*old_dentry
,
1595 struct inode
*new_dir
, struct dentry
*new_dentry
);
1596 int security_inode_readlink(struct dentry
*dentry
);
1597 int security_inode_follow_link(struct dentry
*dentry
, struct nameidata
*nd
);
1598 int security_inode_permission(struct inode
*inode
, int mask
);
1599 int security_inode_setattr(struct dentry
*dentry
, struct iattr
*attr
);
1600 int security_inode_getattr(struct vfsmount
*mnt
, struct dentry
*dentry
);
1601 void security_inode_delete(struct inode
*inode
);
1602 int security_inode_setxattr(struct dentry
*dentry
, const char *name
,
1603 const void *value
, size_t size
, int flags
);
1604 void security_inode_post_setxattr(struct dentry
*dentry
, const char *name
,
1605 const void *value
, size_t size
, int flags
);
1606 int security_inode_getxattr(struct dentry
*dentry
, const char *name
);
1607 int security_inode_listxattr(struct dentry
*dentry
);
1608 int security_inode_removexattr(struct dentry
*dentry
, const char *name
);
1609 int security_inode_need_killpriv(struct dentry
*dentry
);
1610 int security_inode_killpriv(struct dentry
*dentry
);
1611 int security_inode_getsecurity(const struct inode
*inode
, const char *name
, void **buffer
, bool alloc
);
1612 int security_inode_setsecurity(struct inode
*inode
, const char *name
, const void *value
, size_t size
, int flags
);
1613 int security_inode_listsecurity(struct inode
*inode
, char *buffer
, size_t buffer_size
);
1614 void security_inode_getsecid(const struct inode
*inode
, u32
*secid
);
1615 int security_file_permission(struct file
*file
, int mask
);
1616 int security_file_alloc(struct file
*file
);
1617 void security_file_free(struct file
*file
);
1618 int security_file_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
);
1619 int security_file_mmap(struct file
*file
, unsigned long reqprot
,
1620 unsigned long prot
, unsigned long flags
,
1621 unsigned long addr
, unsigned long addr_only
);
1622 int security_file_mprotect(struct vm_area_struct
*vma
, unsigned long reqprot
,
1623 unsigned long prot
);
1624 int security_file_lock(struct file
*file
, unsigned int cmd
);
1625 int security_file_fcntl(struct file
*file
, unsigned int cmd
, unsigned long arg
);
1626 int security_file_set_fowner(struct file
*file
);
1627 int security_file_send_sigiotask(struct task_struct
*tsk
,
1628 struct fown_struct
*fown
, int sig
);
1629 int security_file_receive(struct file
*file
);
1630 int security_dentry_open(struct file
*file
, const struct cred
*cred
);
1631 int security_task_create(unsigned long clone_flags
);
1632 void security_cred_free(struct cred
*cred
);
1633 int security_prepare_creds(struct cred
*new, const struct cred
*old
, gfp_t gfp
);
1634 void security_commit_creds(struct cred
*new, const struct cred
*old
);
1635 int security_task_setuid(uid_t id0
, uid_t id1
, uid_t id2
, int flags
);
1636 int security_task_fix_setuid(struct cred
*new, const struct cred
*old
,
1638 int security_task_setgid(gid_t id0
, gid_t id1
, gid_t id2
, int flags
);
1639 int security_task_setpgid(struct task_struct
*p
, pid_t pgid
);
1640 int security_task_getpgid(struct task_struct
*p
);
1641 int security_task_getsid(struct task_struct
*p
);
1642 void security_task_getsecid(struct task_struct
*p
, u32
*secid
);
1643 int security_task_setgroups(struct group_info
*group_info
);
1644 int security_task_setnice(struct task_struct
*p
, int nice
);
1645 int security_task_setioprio(struct task_struct
*p
, int ioprio
);
1646 int security_task_getioprio(struct task_struct
*p
);
1647 int security_task_setrlimit(unsigned int resource
, struct rlimit
*new_rlim
);
1648 int security_task_setscheduler(struct task_struct
*p
,
1649 int policy
, struct sched_param
*lp
);
1650 int security_task_getscheduler(struct task_struct
*p
);
1651 int security_task_movememory(struct task_struct
*p
);
1652 int security_task_kill(struct task_struct
*p
, struct siginfo
*info
,
1653 int sig
, u32 secid
);
1654 int security_task_wait(struct task_struct
*p
);
1655 int security_task_prctl(int option
, unsigned long arg2
, unsigned long arg3
,
1656 unsigned long arg4
, unsigned long arg5
);
1657 void security_task_to_inode(struct task_struct
*p
, struct inode
*inode
);
1658 int security_ipc_permission(struct kern_ipc_perm
*ipcp
, short flag
);
1659 void security_ipc_getsecid(struct kern_ipc_perm
*ipcp
, u32
*secid
);
1660 int security_msg_msg_alloc(struct msg_msg
*msg
);
1661 void security_msg_msg_free(struct msg_msg
*msg
);
1662 int security_msg_queue_alloc(struct msg_queue
*msq
);
1663 void security_msg_queue_free(struct msg_queue
*msq
);
1664 int security_msg_queue_associate(struct msg_queue
*msq
, int msqflg
);
1665 int security_msg_queue_msgctl(struct msg_queue
*msq
, int cmd
);
1666 int security_msg_queue_msgsnd(struct msg_queue
*msq
,
1667 struct msg_msg
*msg
, int msqflg
);
1668 int security_msg_queue_msgrcv(struct msg_queue
*msq
, struct msg_msg
*msg
,
1669 struct task_struct
*target
, long type
, int mode
);
1670 int security_shm_alloc(struct shmid_kernel
*shp
);
1671 void security_shm_free(struct shmid_kernel
*shp
);
1672 int security_shm_associate(struct shmid_kernel
*shp
, int shmflg
);
1673 int security_shm_shmctl(struct shmid_kernel
*shp
, int cmd
);
1674 int security_shm_shmat(struct shmid_kernel
*shp
, char __user
*shmaddr
, int shmflg
);
1675 int security_sem_alloc(struct sem_array
*sma
);
1676 void security_sem_free(struct sem_array
*sma
);
1677 int security_sem_associate(struct sem_array
*sma
, int semflg
);
1678 int security_sem_semctl(struct sem_array
*sma
, int cmd
);
1679 int security_sem_semop(struct sem_array
*sma
, struct sembuf
*sops
,
1680 unsigned nsops
, int alter
);
1681 void security_d_instantiate(struct dentry
*dentry
, struct inode
*inode
);
1682 int security_getprocattr(struct task_struct
*p
, char *name
, char **value
);
1683 int security_setprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
);
1684 int security_netlink_send(struct sock
*sk
, struct sk_buff
*skb
);
1685 int security_netlink_recv(struct sk_buff
*skb
, int cap
);
1686 int security_secid_to_secctx(u32 secid
, char **secdata
, u32
*seclen
);
1687 int security_secctx_to_secid(const char *secdata
, u32 seclen
, u32
*secid
);
1688 void security_release_secctx(char *secdata
, u32 seclen
);
1690 #else /* CONFIG_SECURITY */
1691 struct security_mnt_opts
{
1694 static inline void security_init_mnt_opts(struct security_mnt_opts
*opts
)
1698 static inline void security_free_mnt_opts(struct security_mnt_opts
*opts
)
1703 * This is the default capabilities functionality. Most of these functions
1704 * are just stubbed out, but a few must call the proper capable code.
1707 static inline int security_init(void)
1712 static inline int security_ptrace_may_access(struct task_struct
*child
,
1715 return cap_ptrace_may_access(child
, mode
);
1718 static inline int security_ptrace_traceme(struct task_struct
*parent
)
1720 return cap_ptrace_traceme(parent
);
1723 static inline int security_capget(struct task_struct
*target
,
1724 kernel_cap_t
*effective
,
1725 kernel_cap_t
*inheritable
,
1726 kernel_cap_t
*permitted
)
1728 return cap_capget(target
, effective
, inheritable
, permitted
);
1731 static inline int security_capset(struct cred
*new,
1732 const struct cred
*old
,
1733 const kernel_cap_t
*effective
,
1734 const kernel_cap_t
*inheritable
,
1735 const kernel_cap_t
*permitted
)
1737 return cap_capset(new, old
, effective
, inheritable
, permitted
);
1740 static inline int security_capable(struct task_struct
*tsk
, int cap
)
1742 return cap_capable(tsk
, cap
, SECURITY_CAP_AUDIT
);
1745 static inline int security_capable_noaudit(struct task_struct
*tsk
, int cap
)
1747 return cap_capable(tsk
, cap
, SECURITY_CAP_NOAUDIT
);
1750 static inline int security_acct(struct file
*file
)
1755 static inline int security_sysctl(struct ctl_table
*table
, int op
)
1760 static inline int security_quotactl(int cmds
, int type
, int id
,
1761 struct super_block
*sb
)
1766 static inline int security_quota_on(struct dentry
*dentry
)
1771 static inline int security_syslog(int type
)
1773 return cap_syslog(type
);
1776 static inline int security_settime(struct timespec
*ts
, struct timezone
*tz
)
1778 return cap_settime(ts
, tz
);
1781 static inline int security_vm_enough_memory(long pages
)
1783 return cap_vm_enough_memory(current
->mm
, pages
);
1786 static inline int security_vm_enough_memory_kern(long pages
)
1788 return cap_vm_enough_memory(current
->mm
, pages
);
1791 static inline int security_vm_enough_memory_mm(struct mm_struct
*mm
, long pages
)
1793 return cap_vm_enough_memory(mm
, pages
);
1796 static inline int security_bprm_set_creds(struct linux_binprm
*bprm
)
1798 return cap_bprm_set_creds(bprm
);
1801 static inline int security_bprm_check(struct linux_binprm
*bprm
)
1806 static inline void security_bprm_committing_creds(struct linux_binprm
*bprm
)
1810 static inline void security_bprm_committed_creds(struct linux_binprm
*bprm
)
1814 static inline int security_bprm_secureexec(struct linux_binprm
*bprm
)
1816 return cap_bprm_secureexec(bprm
);
1819 static inline int security_sb_alloc(struct super_block
*sb
)
1824 static inline void security_sb_free(struct super_block
*sb
)
1827 static inline int security_sb_copy_data(char *orig
, char *copy
)
1832 static inline int security_sb_kern_mount(struct super_block
*sb
, void *data
)
1837 static inline int security_sb_show_options(struct seq_file
*m
,
1838 struct super_block
*sb
)
1843 static inline int security_sb_statfs(struct dentry
*dentry
)
1848 static inline int security_sb_mount(char *dev_name
, struct path
*path
,
1849 char *type
, unsigned long flags
,
1855 static inline int security_sb_check_sb(struct vfsmount
*mnt
,
1861 static inline int security_sb_umount(struct vfsmount
*mnt
, int flags
)
1866 static inline void security_sb_umount_close(struct vfsmount
*mnt
)
1869 static inline void security_sb_umount_busy(struct vfsmount
*mnt
)
1872 static inline void security_sb_post_remount(struct vfsmount
*mnt
,
1873 unsigned long flags
, void *data
)
1876 static inline void security_sb_post_addmount(struct vfsmount
*mnt
,
1877 struct path
*mountpoint
)
1880 static inline int security_sb_pivotroot(struct path
*old_path
,
1881 struct path
*new_path
)
1886 static inline void security_sb_post_pivotroot(struct path
*old_path
,
1887 struct path
*new_path
)
1890 static inline int security_sb_set_mnt_opts(struct super_block
*sb
,
1891 struct security_mnt_opts
*opts
)
1896 static inline void security_sb_clone_mnt_opts(const struct super_block
*oldsb
,
1897 struct super_block
*newsb
)
1900 static inline int security_sb_parse_opts_str(char *options
, struct security_mnt_opts
*opts
)
1905 static inline int security_inode_alloc(struct inode
*inode
)
1910 static inline void security_inode_free(struct inode
*inode
)
1913 static inline int security_inode_init_security(struct inode
*inode
,
1922 static inline int security_inode_create(struct inode
*dir
,
1923 struct dentry
*dentry
,
1929 static inline int security_inode_link(struct dentry
*old_dentry
,
1931 struct dentry
*new_dentry
)
1936 static inline int security_inode_unlink(struct inode
*dir
,
1937 struct dentry
*dentry
)
1942 static inline int security_inode_symlink(struct inode
*dir
,
1943 struct dentry
*dentry
,
1944 const char *old_name
)
1949 static inline int security_inode_mkdir(struct inode
*dir
,
1950 struct dentry
*dentry
,
1956 static inline int security_inode_rmdir(struct inode
*dir
,
1957 struct dentry
*dentry
)
1962 static inline int security_inode_mknod(struct inode
*dir
,
1963 struct dentry
*dentry
,
1964 int mode
, dev_t dev
)
1969 static inline int security_inode_rename(struct inode
*old_dir
,
1970 struct dentry
*old_dentry
,
1971 struct inode
*new_dir
,
1972 struct dentry
*new_dentry
)
1977 static inline int security_inode_readlink(struct dentry
*dentry
)
1982 static inline int security_inode_follow_link(struct dentry
*dentry
,
1983 struct nameidata
*nd
)
1988 static inline int security_inode_permission(struct inode
*inode
, int mask
)
1993 static inline int security_inode_setattr(struct dentry
*dentry
,
1999 static inline int security_inode_getattr(struct vfsmount
*mnt
,
2000 struct dentry
*dentry
)
2005 static inline void security_inode_delete(struct inode
*inode
)
2008 static inline int security_inode_setxattr(struct dentry
*dentry
,
2009 const char *name
, const void *value
, size_t size
, int flags
)
2011 return cap_inode_setxattr(dentry
, name
, value
, size
, flags
);
2014 static inline void security_inode_post_setxattr(struct dentry
*dentry
,
2015 const char *name
, const void *value
, size_t size
, int flags
)
2018 static inline int security_inode_getxattr(struct dentry
*dentry
,
2024 static inline int security_inode_listxattr(struct dentry
*dentry
)
2029 static inline int security_inode_removexattr(struct dentry
*dentry
,
2032 return cap_inode_removexattr(dentry
, name
);
2035 static inline int security_inode_need_killpriv(struct dentry
*dentry
)
2037 return cap_inode_need_killpriv(dentry
);
2040 static inline int security_inode_killpriv(struct dentry
*dentry
)
2042 return cap_inode_killpriv(dentry
);
2045 static inline int security_inode_getsecurity(const struct inode
*inode
, const char *name
, void **buffer
, bool alloc
)
2050 static inline int security_inode_setsecurity(struct inode
*inode
, const char *name
, const void *value
, size_t size
, int flags
)
2055 static inline int security_inode_listsecurity(struct inode
*inode
, char *buffer
, size_t buffer_size
)
2060 static inline void security_inode_getsecid(const struct inode
*inode
, u32
*secid
)
2065 static inline int security_file_permission(struct file
*file
, int mask
)
2070 static inline int security_file_alloc(struct file
*file
)
2075 static inline void security_file_free(struct file
*file
)
2078 static inline int security_file_ioctl(struct file
*file
, unsigned int cmd
,
2084 static inline int security_file_mmap(struct file
*file
, unsigned long reqprot
,
2086 unsigned long flags
,
2088 unsigned long addr_only
)
2093 static inline int security_file_mprotect(struct vm_area_struct
*vma
,
2094 unsigned long reqprot
,
2100 static inline int security_file_lock(struct file
*file
, unsigned int cmd
)
2105 static inline int security_file_fcntl(struct file
*file
, unsigned int cmd
,
2111 static inline int security_file_set_fowner(struct file
*file
)
2116 static inline int security_file_send_sigiotask(struct task_struct
*tsk
,
2117 struct fown_struct
*fown
,
2123 static inline int security_file_receive(struct file
*file
)
2128 static inline int security_dentry_open(struct file
*file
,
2129 const struct cred
*cred
)
2134 static inline int security_task_create(unsigned long clone_flags
)
2139 static inline void security_cred_free(struct cred
*cred
)
2142 static inline int security_prepare_creds(struct cred
*new,
2143 const struct cred
*old
,
2149 static inline void security_commit_creds(struct cred
*new,
2150 const struct cred
*old
)
2154 static inline int security_task_setuid(uid_t id0
, uid_t id1
, uid_t id2
,
2160 static inline int security_task_fix_setuid(struct cred
*new,
2161 const struct cred
*old
,
2164 return cap_task_fix_setuid(new, old
, flags
);
2167 static inline int security_task_setgid(gid_t id0
, gid_t id1
, gid_t id2
,
2173 static inline int security_task_setpgid(struct task_struct
*p
, pid_t pgid
)
2178 static inline int security_task_getpgid(struct task_struct
*p
)
2183 static inline int security_task_getsid(struct task_struct
*p
)
2188 static inline void security_task_getsecid(struct task_struct
*p
, u32
*secid
)
2193 static inline int security_task_setgroups(struct group_info
*group_info
)
2198 static inline int security_task_setnice(struct task_struct
*p
, int nice
)
2200 return cap_task_setnice(p
, nice
);
2203 static inline int security_task_setioprio(struct task_struct
*p
, int ioprio
)
2205 return cap_task_setioprio(p
, ioprio
);
2208 static inline int security_task_getioprio(struct task_struct
*p
)
2213 static inline int security_task_setrlimit(unsigned int resource
,
2214 struct rlimit
*new_rlim
)
2219 static inline int security_task_setscheduler(struct task_struct
*p
,
2221 struct sched_param
*lp
)
2223 return cap_task_setscheduler(p
, policy
, lp
);
2226 static inline int security_task_getscheduler(struct task_struct
*p
)
2231 static inline int security_task_movememory(struct task_struct
*p
)
2236 static inline int security_task_kill(struct task_struct
*p
,
2237 struct siginfo
*info
, int sig
,
2243 static inline int security_task_wait(struct task_struct
*p
)
2248 static inline int security_task_prctl(int option
, unsigned long arg2
,
2253 return cap_task_prctl(option
, arg2
, arg3
, arg3
, arg5
);
2256 static inline void security_task_to_inode(struct task_struct
*p
, struct inode
*inode
)
2259 static inline int security_ipc_permission(struct kern_ipc_perm
*ipcp
,
2265 static inline void security_ipc_getsecid(struct kern_ipc_perm
*ipcp
, u32
*secid
)
2270 static inline int security_msg_msg_alloc(struct msg_msg
*msg
)
2275 static inline void security_msg_msg_free(struct msg_msg
*msg
)
2278 static inline int security_msg_queue_alloc(struct msg_queue
*msq
)
2283 static inline void security_msg_queue_free(struct msg_queue
*msq
)
2286 static inline int security_msg_queue_associate(struct msg_queue
*msq
,
2292 static inline int security_msg_queue_msgctl(struct msg_queue
*msq
, int cmd
)
2297 static inline int security_msg_queue_msgsnd(struct msg_queue
*msq
,
2298 struct msg_msg
*msg
, int msqflg
)
2303 static inline int security_msg_queue_msgrcv(struct msg_queue
*msq
,
2304 struct msg_msg
*msg
,
2305 struct task_struct
*target
,
2306 long type
, int mode
)
2311 static inline int security_shm_alloc(struct shmid_kernel
*shp
)
2316 static inline void security_shm_free(struct shmid_kernel
*shp
)
2319 static inline int security_shm_associate(struct shmid_kernel
*shp
,
2325 static inline int security_shm_shmctl(struct shmid_kernel
*shp
, int cmd
)
2330 static inline int security_shm_shmat(struct shmid_kernel
*shp
,
2331 char __user
*shmaddr
, int shmflg
)
2336 static inline int security_sem_alloc(struct sem_array
*sma
)
2341 static inline void security_sem_free(struct sem_array
*sma
)
2344 static inline int security_sem_associate(struct sem_array
*sma
, int semflg
)
2349 static inline int security_sem_semctl(struct sem_array
*sma
, int cmd
)
2354 static inline int security_sem_semop(struct sem_array
*sma
,
2355 struct sembuf
*sops
, unsigned nsops
,
2361 static inline void security_d_instantiate(struct dentry
*dentry
, struct inode
*inode
)
2364 static inline int security_getprocattr(struct task_struct
*p
, char *name
, char **value
)
2369 static inline int security_setprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
)
2374 static inline int security_netlink_send(struct sock
*sk
, struct sk_buff
*skb
)
2376 return cap_netlink_send(sk
, skb
);
2379 static inline int security_netlink_recv(struct sk_buff
*skb
, int cap
)
2381 return cap_netlink_recv(skb
, cap
);
2384 static inline int security_secid_to_secctx(u32 secid
, char **secdata
, u32
*seclen
)
2389 static inline int security_secctx_to_secid(const char *secdata
,
2396 static inline void security_release_secctx(char *secdata
, u32 seclen
)
2399 #endif /* CONFIG_SECURITY */
2401 #ifdef CONFIG_SECURITY_NETWORK
2403 int security_unix_stream_connect(struct socket
*sock
, struct socket
*other
,
2404 struct sock
*newsk
);
2405 int security_unix_may_send(struct socket
*sock
, struct socket
*other
);
2406 int security_socket_create(int family
, int type
, int protocol
, int kern
);
2407 int security_socket_post_create(struct socket
*sock
, int family
,
2408 int type
, int protocol
, int kern
);
2409 int security_socket_bind(struct socket
*sock
, struct sockaddr
*address
, int addrlen
);
2410 int security_socket_connect(struct socket
*sock
, struct sockaddr
*address
, int addrlen
);
2411 int security_socket_listen(struct socket
*sock
, int backlog
);
2412 int security_socket_accept(struct socket
*sock
, struct socket
*newsock
);
2413 void security_socket_post_accept(struct socket
*sock
, struct socket
*newsock
);
2414 int security_socket_sendmsg(struct socket
*sock
, struct msghdr
*msg
, int size
);
2415 int security_socket_recvmsg(struct socket
*sock
, struct msghdr
*msg
,
2416 int size
, int flags
);
2417 int security_socket_getsockname(struct socket
*sock
);
2418 int security_socket_getpeername(struct socket
*sock
);
2419 int security_socket_getsockopt(struct socket
*sock
, int level
, int optname
);
2420 int security_socket_setsockopt(struct socket
*sock
, int level
, int optname
);
2421 int security_socket_shutdown(struct socket
*sock
, int how
);
2422 int security_sock_rcv_skb(struct sock
*sk
, struct sk_buff
*skb
);
2423 int security_socket_getpeersec_stream(struct socket
*sock
, char __user
*optval
,
2424 int __user
*optlen
, unsigned len
);
2425 int security_socket_getpeersec_dgram(struct socket
*sock
, struct sk_buff
*skb
, u32
*secid
);
2426 int security_sk_alloc(struct sock
*sk
, int family
, gfp_t priority
);
2427 void security_sk_free(struct sock
*sk
);
2428 void security_sk_clone(const struct sock
*sk
, struct sock
*newsk
);
2429 void security_sk_classify_flow(struct sock
*sk
, struct flowi
*fl
);
2430 void security_req_classify_flow(const struct request_sock
*req
, struct flowi
*fl
);
2431 void security_sock_graft(struct sock
*sk
, struct socket
*parent
);
2432 int security_inet_conn_request(struct sock
*sk
,
2433 struct sk_buff
*skb
, struct request_sock
*req
);
2434 void security_inet_csk_clone(struct sock
*newsk
,
2435 const struct request_sock
*req
);
2436 void security_inet_conn_established(struct sock
*sk
,
2437 struct sk_buff
*skb
);
2439 #else /* CONFIG_SECURITY_NETWORK */
2440 static inline int security_unix_stream_connect(struct socket
*sock
,
2441 struct socket
*other
,
2447 static inline int security_unix_may_send(struct socket
*sock
,
2448 struct socket
*other
)
2453 static inline int security_socket_create(int family
, int type
,
2454 int protocol
, int kern
)
2459 static inline int security_socket_post_create(struct socket
*sock
,
2462 int protocol
, int kern
)
2467 static inline int security_socket_bind(struct socket
*sock
,
2468 struct sockaddr
*address
,
2474 static inline int security_socket_connect(struct socket
*sock
,
2475 struct sockaddr
*address
,
2481 static inline int security_socket_listen(struct socket
*sock
, int backlog
)
2486 static inline int security_socket_accept(struct socket
*sock
,
2487 struct socket
*newsock
)
2492 static inline void security_socket_post_accept(struct socket
*sock
,
2493 struct socket
*newsock
)
2497 static inline int security_socket_sendmsg(struct socket
*sock
,
2498 struct msghdr
*msg
, int size
)
2503 static inline int security_socket_recvmsg(struct socket
*sock
,
2504 struct msghdr
*msg
, int size
,
2510 static inline int security_socket_getsockname(struct socket
*sock
)
2515 static inline int security_socket_getpeername(struct socket
*sock
)
2520 static inline int security_socket_getsockopt(struct socket
*sock
,
2521 int level
, int optname
)
2526 static inline int security_socket_setsockopt(struct socket
*sock
,
2527 int level
, int optname
)
2532 static inline int security_socket_shutdown(struct socket
*sock
, int how
)
2536 static inline int security_sock_rcv_skb(struct sock
*sk
,
2537 struct sk_buff
*skb
)
2542 static inline int security_socket_getpeersec_stream(struct socket
*sock
, char __user
*optval
,
2543 int __user
*optlen
, unsigned len
)
2545 return -ENOPROTOOPT
;
2548 static inline int security_socket_getpeersec_dgram(struct socket
*sock
, struct sk_buff
*skb
, u32
*secid
)
2550 return -ENOPROTOOPT
;
2553 static inline int security_sk_alloc(struct sock
*sk
, int family
, gfp_t priority
)
2558 static inline void security_sk_free(struct sock
*sk
)
2562 static inline void security_sk_clone(const struct sock
*sk
, struct sock
*newsk
)
2566 static inline void security_sk_classify_flow(struct sock
*sk
, struct flowi
*fl
)
2570 static inline void security_req_classify_flow(const struct request_sock
*req
, struct flowi
*fl
)
2574 static inline void security_sock_graft(struct sock
*sk
, struct socket
*parent
)
2578 static inline int security_inet_conn_request(struct sock
*sk
,
2579 struct sk_buff
*skb
, struct request_sock
*req
)
2584 static inline void security_inet_csk_clone(struct sock
*newsk
,
2585 const struct request_sock
*req
)
2589 static inline void security_inet_conn_established(struct sock
*sk
,
2590 struct sk_buff
*skb
)
2593 #endif /* CONFIG_SECURITY_NETWORK */
2595 #ifdef CONFIG_SECURITY_NETWORK_XFRM
2597 int security_xfrm_policy_alloc(struct xfrm_sec_ctx
**ctxp
, struct xfrm_user_sec_ctx
*sec_ctx
);
2598 int security_xfrm_policy_clone(struct xfrm_sec_ctx
*old_ctx
, struct xfrm_sec_ctx
**new_ctxp
);
2599 void security_xfrm_policy_free(struct xfrm_sec_ctx
*ctx
);
2600 int security_xfrm_policy_delete(struct xfrm_sec_ctx
*ctx
);
2601 int security_xfrm_state_alloc(struct xfrm_state
*x
, struct xfrm_user_sec_ctx
*sec_ctx
);
2602 int security_xfrm_state_alloc_acquire(struct xfrm_state
*x
,
2603 struct xfrm_sec_ctx
*polsec
, u32 secid
);
2604 int security_xfrm_state_delete(struct xfrm_state
*x
);
2605 void security_xfrm_state_free(struct xfrm_state
*x
);
2606 int security_xfrm_policy_lookup(struct xfrm_sec_ctx
*ctx
, u32 fl_secid
, u8 dir
);
2607 int security_xfrm_state_pol_flow_match(struct xfrm_state
*x
,
2608 struct xfrm_policy
*xp
, struct flowi
*fl
);
2609 int security_xfrm_decode_session(struct sk_buff
*skb
, u32
*secid
);
2610 void security_skb_classify_flow(struct sk_buff
*skb
, struct flowi
*fl
);
2612 #else /* CONFIG_SECURITY_NETWORK_XFRM */
2614 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx
**ctxp
, struct xfrm_user_sec_ctx
*sec_ctx
)
2619 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx
*old
, struct xfrm_sec_ctx
**new_ctxp
)
2624 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx
*ctx
)
2628 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx
*ctx
)
2633 static inline int security_xfrm_state_alloc(struct xfrm_state
*x
,
2634 struct xfrm_user_sec_ctx
*sec_ctx
)
2639 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state
*x
,
2640 struct xfrm_sec_ctx
*polsec
, u32 secid
)
2645 static inline void security_xfrm_state_free(struct xfrm_state
*x
)
2649 static inline int security_xfrm_state_delete(struct xfrm_state
*x
)
2654 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx
*ctx
, u32 fl_secid
, u8 dir
)
2659 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state
*x
,
2660 struct xfrm_policy
*xp
, struct flowi
*fl
)
2665 static inline int security_xfrm_decode_session(struct sk_buff
*skb
, u32
*secid
)
2670 static inline void security_skb_classify_flow(struct sk_buff
*skb
, struct flowi
*fl
)
2674 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
2677 #ifdef CONFIG_SECURITY
2679 int security_key_alloc(struct key
*key
, const struct cred
*cred
, unsigned long flags
);
2680 void security_key_free(struct key
*key
);
2681 int security_key_permission(key_ref_t key_ref
,
2682 const struct cred
*cred
, key_perm_t perm
);
2683 int security_key_getsecurity(struct key
*key
, char **_buffer
);
2687 static inline int security_key_alloc(struct key
*key
,
2688 const struct cred
*cred
,
2689 unsigned long flags
)
2694 static inline void security_key_free(struct key
*key
)
2698 static inline int security_key_permission(key_ref_t key_ref
,
2699 const struct cred
*cred
,
2705 static inline int security_key_getsecurity(struct key
*key
, char **_buffer
)
2712 #endif /* CONFIG_KEYS */
2715 #ifdef CONFIG_SECURITY
2716 int security_audit_rule_init(u32 field
, u32 op
, char *rulestr
, void **lsmrule
);
2717 int security_audit_rule_known(struct audit_krule
*krule
);
2718 int security_audit_rule_match(u32 secid
, u32 field
, u32 op
, void *lsmrule
,
2719 struct audit_context
*actx
);
2720 void security_audit_rule_free(void *lsmrule
);
2724 static inline int security_audit_rule_init(u32 field
, u32 op
, char *rulestr
,
2730 static inline int security_audit_rule_known(struct audit_krule
*krule
)
2735 static inline int security_audit_rule_match(u32 secid
, u32 field
, u32 op
,
2736 void *lsmrule
, struct audit_context
*actx
)
2741 static inline void security_audit_rule_free(void *lsmrule
)
2744 #endif /* CONFIG_SECURITY */
2745 #endif /* CONFIG_AUDIT */
2747 #ifdef CONFIG_SECURITYFS
2749 extern struct dentry
*securityfs_create_file(const char *name
, mode_t mode
,
2750 struct dentry
*parent
, void *data
,
2751 const struct file_operations
*fops
);
2752 extern struct dentry
*securityfs_create_dir(const char *name
, struct dentry
*parent
);
2753 extern void securityfs_remove(struct dentry
*dentry
);
2755 #else /* CONFIG_SECURITYFS */
2757 static inline struct dentry
*securityfs_create_dir(const char *name
,
2758 struct dentry
*parent
)
2760 return ERR_PTR(-ENODEV
);
2763 static inline struct dentry
*securityfs_create_file(const char *name
,
2765 struct dentry
*parent
,
2767 const struct file_operations
*fops
)
2769 return ERR_PTR(-ENODEV
);
2772 static inline void securityfs_remove(struct dentry
*dentry
)
2777 #endif /* ! __LINUX_SECURITY_H */