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/sysctl.h>
31 #include <linux/shm.h>
32 #include <linux/msg.h>
33 #include <linux/sched.h>
34 #include <linux/skbuff.h>
35 #include <linux/netlink.h>
38 * These functions are in security/capability.c and are used
39 * as the default capabilities functions
41 extern int cap_capable (struct task_struct *tsk, int cap);
42 extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
43 extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
44 extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
45 extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
46 extern int cap_bprm_set_security (struct linux_binprm *bprm);
47 extern void cap_bprm_compute_creds (struct linux_binprm *bprm);
48 extern int cap_bprm_secureexec(struct linux_binprm *bprm);
49 extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
50 extern int cap_inode_removexattr(struct dentry *dentry, char *name);
51 extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
52 extern void cap_task_reparent_to_init (struct task_struct *p);
53 extern int cap_syslog (int type);
54 extern int cap_vm_enough_memory (long pages);
56 static inline int cap_netlink_send (struct sk_buff *skb)
58 NETLINK_CB (skb).eff_cap = current->cap_effective;
62 static inline int cap_netlink_recv (struct sk_buff *skb)
64 if (!cap_raised (NETLINK_CB (skb).eff_cap, CAP_NET_ADMIN))
70 * Values used in the task_security_ops calls
72 /* setuid or setgid, id0 == uid or gid */
73 #define LSM_SETID_ID 1
75 /* setreuid or setregid, id0 == real, id1 == eff */
76 #define LSM_SETID_RE 2
78 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
79 #define LSM_SETID_RES 4
81 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
82 #define LSM_SETID_FS 8
84 /* forward declares to avoid warnings */
87 struct swap_info_struct;
89 #ifdef CONFIG_SECURITY
92 * struct security_operations - main security structure
94 * Security hooks for program execution operations.
96 * @bprm_alloc_security:
97 * Allocate and attach a security structure to the @bprm->security field.
98 * The security field is initialized to NULL when the bprm structure is
100 * @bprm contains the linux_binprm structure to be modified.
101 * Return 0 if operation was successful.
102 * @bprm_free_security:
103 * @bprm contains the linux_binprm structure to be modified.
104 * Deallocate and clear the @bprm->security field.
105 * @bprm_compute_creds:
106 * Compute and set the security attributes of a process being transformed
107 * by an execve operation based on the old attributes (current->security)
108 * and the information saved in @bprm->security by the set_security hook.
109 * Since this hook function (and its caller) are void, this hook can not
110 * return an error. However, it can leave the security attributes of the
111 * process unchanged if an access failure occurs at this point. It can
112 * also perform other state changes on the process (e.g. closing open
113 * file descriptors to which access is no longer granted if the attributes
115 * @bprm contains the linux_binprm structure.
116 * @bprm_set_security:
117 * Save security information in the bprm->security field, typically based
118 * on information about the bprm->file, for later use by the compute_creds
119 * hook. This hook may also optionally check permissions (e.g. for
120 * transitions between security domains).
121 * This hook may be called multiple times during a single execve, e.g. for
122 * interpreters. The hook can tell whether it has already been called by
123 * checking to see if @bprm->security is non-NULL. If so, then the hook
124 * may decide either to retain the security information saved earlier or
126 * @bprm contains the linux_binprm structure.
127 * Return 0 if the hook is successful and permission is granted.
128 * @bprm_check_security:
129 * This hook mediates the point when a search for a binary handler will
130 * begin. It allows a check the @bprm->security value which is set in
131 * the preceding set_security call. The primary difference from
132 * set_security is that the argv list and envp list are reliably
133 * available in @bprm. This hook may be called multiple times
134 * during a single execve; and in each pass set_security is called
136 * @bprm contains the linux_binprm structure.
137 * Return 0 if the hook is successful and permission is granted.
139 * Return a boolean value (0 or 1) indicating whether a "secure exec"
140 * is required. The flag is passed in the auxiliary table
141 * on the initial stack to the ELF interpreter to indicate whether libc
142 * should enable secure mode.
143 * @bprm contains the linux_binprm structure.
145 * Security hooks for filesystem operations.
147 * @sb_alloc_security:
148 * Allocate and attach a security structure to the sb->s_security field.
149 * The s_security field is initialized to NULL when the structure is
151 * @sb contains the super_block structure to be modified.
152 * Return 0 if operation was successful.
154 * Deallocate and clear the sb->s_security field.
155 * @sb contains the super_block structure to be modified.
157 * Check permission before obtaining filesystem statistics for the @sb
159 * @sb contains the super_block structure for the filesystem.
160 * Return 0 if permission is granted.
162 * Check permission before an object specified by @dev_name is mounted on
163 * the mount point named by @nd. For an ordinary mount, @dev_name
164 * identifies a device if the file system type requires a device. For a
165 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
166 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
167 * pathname of the object being mounted.
168 * @dev_name contains the name for object being mounted.
169 * @nd contains the nameidata structure for mount point object.
170 * @type contains the filesystem type.
171 * @flags contains the mount flags.
172 * @data contains the filesystem-specific data.
173 * Return 0 if permission is granted.
175 * Allow mount option data to be copied prior to parsing by the filesystem,
176 * so that the security module can extract security-specific mount
177 * options cleanly (a filesystem may modify the data e.g. with strsep()).
178 * This also allows the original mount data to be stripped of security-
179 * specific options to avoid having to make filesystems aware of them.
180 * @fstype the type of filesystem being mounted.
181 * @orig the original mount data copied from userspace.
182 * @copy copied data which will be passed to the security module.
183 * Returns 0 if the copy was successful.
185 * Check permission before the device with superblock @mnt->sb is mounted
186 * on the mount point named by @nd.
187 * @mnt contains the vfsmount for device being mounted.
188 * @nd contains the nameidata object for the mount point.
189 * Return 0 if permission is granted.
191 * Check permission before the @mnt file system is unmounted.
192 * @mnt contains the mounted file system.
193 * @flags contains the unmount flags, e.g. MNT_FORCE.
194 * Return 0 if permission is granted.
196 * Close any files in the @mnt mounted filesystem that are held open by
197 * the security module. This hook is called during an umount operation
198 * prior to checking whether the filesystem is still busy.
199 * @mnt contains the mounted filesystem.
201 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
202 * any files that were closed by umount_close. This hook is called during
203 * an umount operation if the umount fails after a call to the
205 * @mnt contains the mounted filesystem.
207 * Update the security module's state when a filesystem is remounted.
208 * This hook is only called if the remount was successful.
209 * @mnt contains the mounted file system.
210 * @flags contains the new filesystem flags.
211 * @data contains the filesystem-specific data.
212 * @sb_post_mountroot:
213 * Update the security module's state when the root filesystem is mounted.
214 * This hook is only called if the mount was successful.
216 * Update the security module's state when a filesystem is mounted.
217 * This hook is called any time a mount is successfully grafetd to
219 * @mnt contains the mounted filesystem.
220 * @mountpoint_nd contains the nameidata structure for the mount point.
222 * Check permission before pivoting the root filesystem.
223 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
224 * @new_nd contains the nameidata structure for the new root (new_root).
225 * Return 0 if permission is granted.
226 * @sb_post_pivotroot:
227 * Update module state after a successful pivot.
228 * @old_nd contains the nameidata structure for the old root.
229 * @new_nd contains the nameidata structure for the new root.
231 * Security hooks for inode operations.
233 * @inode_alloc_security:
234 * Allocate and attach a security structure to @inode->i_security. The
235 * i_security field is initialized to NULL when the inode structure is
237 * @inode contains the inode structure.
238 * Return 0 if operation was successful.
239 * @inode_free_security:
240 * @inode contains the inode structure.
241 * Deallocate the inode security structure and set @inode->i_security to
244 * Check permission to create a regular file.
245 * @dir contains inode structure of the parent of the new file.
246 * @dentry contains the dentry structure for the file to be created.
247 * @mode contains the file mode of the file to be created.
248 * Return 0 if permission is granted.
249 * @inode_post_create:
250 * Set the security attributes on a newly created regular file. This hook
251 * is called after a file has been successfully created.
252 * @dir contains the inode structure of the parent directory of the new file.
253 * @dentry contains the the dentry structure for the newly created file.
254 * @mode contains the file mode.
256 * Check permission before creating a new hard link to a file.
257 * @old_dentry contains the dentry structure for an existing link to the file.
258 * @dir contains the inode structure of the parent directory of the new link.
259 * @new_dentry contains the dentry structure for the new link.
260 * Return 0 if permission is granted.
262 * Set security attributes for a new hard link to a file.
263 * @old_dentry contains the dentry structure for the existing link.
264 * @dir contains the inode structure of the parent directory of the new file.
265 * @new_dentry contains the dentry structure for the new file link.
267 * Check the permission to remove a hard link to a file.
268 * @dir contains the inode structure of parent directory of the file.
269 * @dentry contains the dentry structure for file to be unlinked.
270 * Return 0 if permission is granted.
272 * Check the permission to create a symbolic link to a file.
273 * @dir contains the inode structure of parent directory of the symbolic link.
274 * @dentry contains the dentry structure of the symbolic link.
275 * @old_name contains the pathname of file.
276 * Return 0 if permission is granted.
277 * @inode_post_symlink:
278 * @dir contains the inode structure of the parent directory of the new link.
279 * @dentry contains the dentry structure of new symbolic link.
280 * @old_name contains the pathname of file.
281 * Set security attributes for a newly created symbolic link. Note that
282 * @dentry->d_inode may be NULL, since the filesystem might not
283 * instantiate the dentry (e.g. NFS).
285 * Check permissions to create a new directory in the existing directory
286 * associated with inode strcture @dir.
287 * @dir containst the inode structure of parent of the directory to be created.
288 * @dentry contains the dentry structure of new directory.
289 * @mode contains the mode of new directory.
290 * Return 0 if permission is granted.
292 * Set security attributes on a newly created directory.
293 * @dir contains the inode structure of parent of the directory to be created.
294 * @dentry contains the dentry structure of new directory.
295 * @mode contains the mode of new directory.
297 * Check the permission to remove a directory.
298 * @dir contains the inode structure of parent of the directory to be removed.
299 * @dentry contains the dentry structure of directory to be removed.
300 * Return 0 if permission is granted.
302 * Check permissions when creating a special file (or a socket or a fifo
303 * file created via the mknod system call). Note that if mknod operation
304 * is being done for a regular file, then the create hook will be called
306 * @dir contains the inode structure of parent of the new file.
307 * @dentry contains the dentry structure of the new file.
308 * @mode contains the mode of the new file.
309 * @dev contains the the device number.
310 * Return 0 if permission is granted.
312 * Set security attributes on a newly created special file (or socket or
313 * fifo file created via the mknod system call).
314 * @dir contains the inode structure of parent of the new node.
315 * @dentry contains the dentry structure of the new node.
316 * @mode contains the mode of the new node.
317 * @dev contains the the device number.
319 * Check for permission to rename a file or directory.
320 * @old_dir contains the inode structure for parent of the old link.
321 * @old_dentry contains the dentry structure of the old link.
322 * @new_dir contains the inode structure for parent of the new link.
323 * @new_dentry contains the dentry structure of the new link.
324 * Return 0 if permission is granted.
325 * @inode_post_rename:
326 * Set security attributes on a renamed file or directory.
327 * @old_dir contains the inode structure for parent of the old link.
328 * @old_dentry contains the dentry structure of the old link.
329 * @new_dir contains the inode structure for parent of the new link.
330 * @new_dentry contains the dentry structure of the new link.
332 * Check the permission to read the symbolic link.
333 * @dentry contains the dentry structure for the file link.
334 * Return 0 if permission is granted.
335 * @inode_follow_link:
336 * Check permission to follow a symbolic link when looking up a pathname.
337 * @dentry contains the dentry structure for the link.
338 * @nd contains the nameidata structure for the parent directory.
339 * Return 0 if permission is granted.
341 * Check permission before accessing an inode. This hook is called by the
342 * existing Linux permission function, so a security module can use it to
343 * provide additional checking for existing Linux permission checks.
344 * Notice that this hook is called when a file is opened (as well as many
345 * other operations), whereas the file_security_ops permission hook is
346 * called when the actual read/write operations are performed.
347 * @inode contains the inode structure to check.
348 * @mask contains the permission mask.
349 * @nd contains the nameidata (may be NULL).
350 * Return 0 if permission is granted.
352 * Check permission before setting file attributes. Note that the kernel
353 * call to notify_change is performed from several locations, whenever
354 * file attributes change (such as when a file is truncated, chown/chmod
355 * operations, transferring disk quotas, etc).
356 * @dentry contains the dentry structure for the file.
357 * @attr is the iattr structure containing the new file attributes.
358 * Return 0 if permission is granted.
360 * Check permission before obtaining file attributes.
361 * @mnt is the vfsmount where the dentry was looked up
362 * @dentry contains the dentry structure for the file.
363 * Return 0 if permission is granted.
365 * @inode contains the inode structure for deleted inode.
366 * This hook is called when a deleted inode is released (i.e. an inode
367 * with no hard links has its use count drop to zero). A security module
368 * can use this hook to release any persistent label associated with the
371 * Check permission before setting the extended attributes
372 * @value identified by @name for @dentry.
373 * Return 0 if permission is granted.
374 * @inode_post_setxattr:
375 * Update inode security field after successful setxattr operation.
376 * @value identified by @name for @dentry.
378 * Check permission before obtaining the extended attributes
379 * identified by @name for @dentry.
380 * Return 0 if permission is granted.
382 * Check permission before obtaining the list of extended attribute
384 * Return 0 if permission is granted.
385 * @inode_removexattr:
386 * Check permission before removing the extended attribute
387 * identified by @name for @dentry.
388 * Return 0 if permission is granted.
389 * @inode_getsecurity:
390 * Copy the extended attribute representation of the security label
391 * associated with @name for @dentry into @buffer. @buffer may be
392 * NULL to request the size of the buffer required. @size indicates
393 * the size of @buffer in bytes. Note that @name is the remainder
394 * of the attribute name after the security. prefix has been removed.
395 * Return number of bytes used/required on success.
396 * @inode_setsecurity:
397 * Set the security label associated with @name for @dentry from the
398 * extended attribute value @value. @size indicates the size of the
399 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
400 * Note that @name is the remainder of the attribute name after the
401 * security. prefix has been removed.
402 * Return 0 on success.
403 * @inode_listsecurity:
404 * Copy the extended attribute names for the security labels
405 * associated with @dentry into @buffer. @buffer may be NULL to
406 * request the size of the buffer required.
407 * Returns number of bytes used/required on success.
409 * Security hooks for file operations
412 * Check file permissions before accessing an open file. This hook is
413 * called by various operations that read or write files. A security
414 * module can use this hook to perform additional checking on these
415 * operations, e.g. to revalidate permissions on use to support privilege
416 * bracketing or policy changes. Notice that this hook is used when the
417 * actual read/write operations are performed, whereas the
418 * inode_security_ops hook is called when a file is opened (as well as
419 * many other operations).
420 * Caveat: Although this hook can be used to revalidate permissions for
421 * various system call operations that read or write files, it does not
422 * address the revalidation of permissions for memory-mapped files.
423 * Security modules must handle this separately if they need such
425 * @file contains the file structure being accessed.
426 * @mask contains the requested permissions.
427 * Return 0 if permission is granted.
428 * @file_alloc_security:
429 * Allocate and attach a security structure to the file->f_security field.
430 * The security field is initialized to NULL when the structure is first
432 * @file contains the file structure to secure.
433 * Return 0 if the hook is successful and permission is granted.
434 * @file_free_security:
435 * Deallocate and free any security structures stored in file->f_security.
436 * @file contains the file structure being modified.
438 * @file contains the file structure.
439 * @cmd contains the operation to perform.
440 * @arg contains the operational arguments.
441 * Check permission for an ioctl operation on @file. Note that @arg can
442 * sometimes represents a user space pointer; in other cases, it may be a
443 * simple integer value. When @arg represents a user space pointer, it
444 * should never be used by the security module.
445 * Return 0 if permission is granted.
447 * Check permissions for a mmap operation. The @file may be NULL, e.g.
448 * if mapping anonymous memory.
449 * @file contains the file structure for file to map (may be NULL).
450 * @prot contains the requested permissions.
451 * @flags contains the operational flags.
452 * Return 0 if permission is granted.
454 * Check permissions before changing memory access permissions.
455 * @vma contains the memory region to modify.
456 * @prot contains the requested permissions.
457 * Return 0 if permission is granted.
459 * Check permission before performing file locking operations.
460 * Note: this hook mediates both flock and fcntl style locks.
461 * @file contains the file structure.
462 * @cmd contains the posix-translated lock operation to perform
463 * (e.g. F_RDLCK, F_WRLCK).
464 * Return 0 if permission is granted.
466 * Check permission before allowing the file operation specified by @cmd
467 * from being performed on the file @file. Note that @arg can sometimes
468 * represents a user space pointer; in other cases, it may be a simple
469 * integer value. When @arg represents a user space pointer, it should
470 * never be used by the security module.
471 * @file contains the file structure.
472 * @cmd contains the operation to be performed.
473 * @arg contains the operational arguments.
474 * Return 0 if permission is granted.
476 * Save owner security information (typically from current->security) in
477 * file->f_security for later use by the send_sigiotask hook.
478 * @file contains the file structure to update.
479 * Return 0 on success.
480 * @file_send_sigiotask:
481 * Check permission for the file owner @fown to send SIGIO to the process
482 * @tsk. Note that this hook is always called from interrupt. Note that
483 * the fown_struct, @fown, is never outside the context of a struct file,
484 * so the file structure (and associated security information) can always
486 * (struct file *)((long)fown - offsetof(struct file,f_owner));
487 * @tsk contains the structure of task receiving signal.
488 * @fown contains the file owner information.
489 * @fd contains the file descriptor.
490 * @reason contains the operational flags.
491 * Return 0 if permission is granted.
493 * This hook allows security modules to control the ability of a process
494 * to receive an open file descriptor via socket IPC.
495 * @file contains the file structure being received.
496 * Return 0 if permission is granted.
498 * Security hooks for task operations.
501 * Check permission before creating a child process. See the clone(2)
502 * manual page for definitions of the @clone_flags.
503 * @clone_flags contains the flags indicating what should be shared.
504 * Return 0 if permission is granted.
505 * @task_alloc_security:
506 * @p contains the task_struct for child process.
507 * Allocate and attach a security structure to the p->security field. The
508 * security field is initialized to NULL when the task structure is
510 * Return 0 if operation was successful.
511 * @task_free_security:
512 * @p contains the task_struct for process.
513 * Deallocate and clear the p->security field.
515 * Check permission before setting one or more of the user identity
516 * attributes of the current process. The @flags parameter indicates
517 * which of the set*uid system calls invoked this hook and how to
518 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
519 * definitions at the beginning of this file for the @flags values and
521 * @id0 contains a uid.
522 * @id1 contains a uid.
523 * @id2 contains a uid.
524 * @flags contains one of the LSM_SETID_* values.
525 * Return 0 if permission is granted.
527 * Update the module's state after setting one or more of the user
528 * identity attributes of the current process. The @flags parameter
529 * indicates which of the set*uid system calls invoked this hook. If
530 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
531 * parameters are not used.
532 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
533 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
534 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
535 * @flags contains one of the LSM_SETID_* values.
536 * Return 0 on success.
538 * Check permission before setting one or more of the group identity
539 * attributes of the current process. The @flags parameter indicates
540 * which of the set*gid system calls invoked this hook and how to
541 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
542 * definitions at the beginning of this file for the @flags values and
544 * @id0 contains a gid.
545 * @id1 contains a gid.
546 * @id2 contains a gid.
547 * @flags contains one of the LSM_SETID_* values.
548 * Return 0 if permission is granted.
550 * Check permission before setting the process group identifier of the
551 * process @p to @pgid.
552 * @p contains the task_struct for process being modified.
553 * @pgid contains the new pgid.
554 * Return 0 if permission is granted.
556 * Check permission before getting the process group identifier of the
558 * @p contains the task_struct for the process.
559 * Return 0 if permission is granted.
561 * Check permission before getting the session identifier of the process
563 * @p contains the task_struct for the process.
564 * Return 0 if permission is granted.
566 * Check permission before setting the supplementary group set of the
568 * @group_info contains the new group information.
569 * Return 0 if permission is granted.
571 * Check permission before setting the nice value of @p to @nice.
572 * @p contains the task_struct of process.
573 * @nice contains the new nice value.
574 * Return 0 if permission is granted.
576 * Check permission before setting the resource limits of the current
577 * process for @resource to @new_rlim. The old resource limit values can
578 * be examined by dereferencing (current->rlim + resource).
579 * @resource contains the resource whose limit is being set.
580 * @new_rlim contains the new limits for @resource.
581 * Return 0 if permission is granted.
582 * @task_setscheduler:
583 * Check permission before setting scheduling policy and/or parameters of
584 * process @p based on @policy and @lp.
585 * @p contains the task_struct for process.
586 * @policy contains the scheduling policy.
587 * @lp contains the scheduling parameters.
588 * Return 0 if permission is granted.
589 * @task_getscheduler:
590 * Check permission before obtaining scheduling information for process
592 * @p contains the task_struct for process.
593 * Return 0 if permission is granted.
595 * Check permission before sending signal @sig to @p. @info can be NULL,
596 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
597 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
598 * from the kernel and should typically be permitted.
599 * SIGIO signals are handled separately by the send_sigiotask hook in
601 * @p contains the task_struct for process.
602 * @info contains the signal information.
603 * @sig contains the signal value.
604 * Return 0 if permission is granted.
606 * Check permission before allowing a process to reap a child process @p
607 * and collect its status information.
608 * @p contains the task_struct for process.
609 * Return 0 if permission is granted.
611 * Check permission before performing a process control operation on the
613 * @option contains the operation.
614 * @arg2 contains a argument.
615 * @arg3 contains a argument.
616 * @arg4 contains a argument.
617 * @arg5 contains a argument.
618 * Return 0 if permission is granted.
619 * @task_reparent_to_init:
620 * Set the security attributes in @p->security for a kernel thread that
621 * is being reparented to the init task.
622 * @p contains the task_struct for the kernel thread.
624 * Set the security attributes for an inode based on an associated task's
625 * security attributes, e.g. for /proc/pid inodes.
626 * @p contains the task_struct for the task.
627 * @inode contains the inode structure for the inode.
629 * Security hooks for Netlink messaging.
632 * Save security information for a netlink message so that permission
633 * checking can be performed when the message is processed. The security
634 * information can be saved using the eff_cap field of the
635 * netlink_skb_parms structure.
636 * @skb contains the sk_buff structure for the netlink message.
637 * Return 0 if the information was successfully saved.
639 * Check permission before processing the received netlink message in
641 * @skb contains the sk_buff structure for the netlink message.
642 * Return 0 if permission is granted.
644 * Security hooks for Unix domain networking.
646 * @unix_stream_connect:
647 * Check permissions before establishing a Unix domain stream connection
648 * between @sock and @other.
649 * @sock contains the socket structure.
650 * @other contains the peer socket structure.
651 * Return 0 if permission is granted.
653 * Check permissions before connecting or sending datagrams from @sock to
655 * @sock contains the socket structure.
656 * @sock contains the peer socket structure.
657 * Return 0 if permission is granted.
659 * The @unix_stream_connect and @unix_may_send hooks were necessary because
660 * Linux provides an alternative to the conventional file name space for Unix
661 * domain sockets. Whereas binding and connecting to sockets in the file name
662 * space is mediated by the typical file permissions (and caught by the mknod
663 * and permission hooks in inode_security_ops), binding and connecting to
664 * sockets in the abstract name space is completely unmediated. Sufficient
665 * control of Unix domain sockets in the abstract name space isn't possible
666 * using only the socket layer hooks, since we need to know the actual target
667 * socket, which is not looked up until we are inside the af_unix code.
669 * Security hooks for socket operations.
672 * Check permissions prior to creating a new socket.
673 * @family contains the requested protocol family.
674 * @type contains the requested communications type.
675 * @protocol contains the requested protocol.
676 * Return 0 if permission is granted.
677 * @socket_post_create:
678 * This hook allows a module to update or allocate a per-socket security
679 * structure. Note that the security field was not added directly to the
680 * socket structure, but rather, the socket security information is stored
681 * in the associated inode. Typically, the inode alloc_security hook will
682 * allocate and and attach security information to
683 * sock->inode->i_security. This hook may be used to update the
684 * sock->inode->i_security field with additional information that wasn't
685 * available when the inode was allocated.
686 * @sock contains the newly created socket structure.
687 * @family contains the requested protocol family.
688 * @type contains the requested communications type.
689 * @protocol contains the requested protocol.
691 * Check permission before socket protocol layer bind operation is
692 * performed and the socket @sock is bound to the address specified in the
693 * @address parameter.
694 * @sock contains the socket structure.
695 * @address contains the address to bind to.
696 * @addrlen contains the length of address.
697 * Return 0 if permission is granted.
699 * Check permission before socket protocol layer connect operation
700 * attempts to connect socket @sock to a remote address, @address.
701 * @sock contains the socket structure.
702 * @address contains the address of remote endpoint.
703 * @addrlen contains the length of address.
704 * Return 0 if permission is granted.
706 * Check permission before socket protocol layer listen operation.
707 * @sock contains the socket structure.
708 * @backlog contains the maximum length for the pending connection queue.
709 * Return 0 if permission is granted.
711 * Check permission before accepting a new connection. Note that the new
712 * socket, @newsock, has been created and some information copied to it,
713 * but the accept operation has not actually been performed.
714 * @sock contains the listening socket structure.
715 * @newsock contains the newly created server socket for connection.
716 * Return 0 if permission is granted.
717 * @socket_post_accept:
718 * This hook allows a security module to copy security
719 * information into the newly created socket's inode.
720 * @sock contains the listening socket structure.
721 * @newsock contains the newly created server socket for connection.
723 * Check permission before transmitting a message to another socket.
724 * @sock contains the socket structure.
725 * @msg contains the message to be transmitted.
726 * @size contains the size of message.
727 * Return 0 if permission is granted.
729 * Check permission before receiving a message from a socket.
730 * @sock contains the socket structure.
731 * @msg contains the message structure.
732 * @size contains the size of message structure.
733 * @flags contains the operational flags.
734 * Return 0 if permission is granted.
735 * @socket_getsockname:
736 * Check permission before the local address (name) of the socket object
737 * @sock is retrieved.
738 * @sock contains the socket structure.
739 * Return 0 if permission is granted.
740 * @socket_getpeername:
741 * Check permission before the remote address (name) of a socket object
742 * @sock is retrieved.
743 * @sock contains the socket structure.
744 * Return 0 if permission is granted.
745 * @socket_getsockopt:
746 * Check permissions before retrieving the options associated with socket
748 * @sock contains the socket structure.
749 * @level contains the protocol level to retrieve option from.
750 * @optname contains the name of option to retrieve.
751 * Return 0 if permission is granted.
752 * @socket_setsockopt:
753 * Check permissions before setting the options associated with socket
755 * @sock contains the socket structure.
756 * @level contains the protocol level to set options for.
757 * @optname contains the name of the option to set.
758 * Return 0 if permission is granted.
760 * Checks permission before all or part of a connection on the socket
761 * @sock is shut down.
762 * @sock contains the socket structure.
763 * @how contains the flag indicating how future sends and receives are handled.
764 * Return 0 if permission is granted.
765 * @socket_sock_rcv_skb:
766 * Check permissions on incoming network packets. This hook is distinct
767 * from Netfilter's IP input hooks since it is the first time that the
768 * incoming sk_buff @skb has been associated with a particular socket, @sk.
769 * @sk contains the sock (not socket) associated with the incoming sk_buff.
770 * @skb contains the incoming network data.
771 * @socket_getpeersec:
772 * This hook allows the security module to provide peer socket security
773 * state to userspace via getsockopt SO_GETPEERSEC.
774 * @sock is the local socket.
775 * @optval userspace memory where the security state is to be copied.
776 * @optlen userspace int where the module should copy the actual length
777 * of the security state.
778 * @len as input is the maximum length to copy to userspace provided
780 * Return 0 if all is well, otherwise, typical getsockopt return
782 * @sk_alloc_security:
783 * Allocate and attach a security structure to the sk->sk_security field,
784 * which is used to copy security attributes between local stream sockets.
786 * Deallocate security structure.
788 * Security hooks affecting all System V IPC operations.
791 * Check permissions for access to IPC
792 * @ipcp contains the kernel IPC permission structure
793 * @flag contains the desired (requested) permission set
794 * Return 0 if permission is granted.
796 * Security hooks for individual messages held in System V IPC message queues
797 * @msg_msg_alloc_security:
798 * Allocate and attach a security structure to the msg->security field.
799 * The security field is initialized to NULL when the structure is first
801 * @msg contains the message structure to be modified.
802 * Return 0 if operation was successful and permission is granted.
803 * @msg_msg_free_security:
804 * Deallocate the security structure for this message.
805 * @msg contains the message structure to be modified.
807 * Security hooks for System V IPC Message Queues
809 * @msg_queue_alloc_security:
810 * Allocate and attach a security structure to the
811 * msq->q_perm.security field. The security field is initialized to
812 * NULL when the structure is first created.
813 * @msq contains the message queue structure to be modified.
814 * Return 0 if operation was successful and permission is granted.
815 * @msg_queue_free_security:
816 * Deallocate security structure for this message queue.
817 * @msq contains the message queue structure to be modified.
818 * @msg_queue_associate:
819 * Check permission when a message queue is requested through the
820 * msgget system call. This hook is only called when returning the
821 * message queue identifier for an existing message queue, not when a
822 * new message queue is created.
823 * @msq contains the message queue to act upon.
824 * @msqflg contains the operation control flags.
825 * Return 0 if permission is granted.
827 * Check permission when a message control operation specified by @cmd
828 * is to be performed on the message queue @msq.
829 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
830 * @msq contains the message queue to act upon. May be NULL.
831 * @cmd contains the operation to be performed.
832 * Return 0 if permission is granted.
834 * Check permission before a message, @msg, is enqueued on the message
836 * @msq contains the message queue to send message to.
837 * @msg contains the message to be enqueued.
838 * @msqflg contains operational flags.
839 * Return 0 if permission is granted.
841 * Check permission before a message, @msg, is removed from the message
842 * queue, @msq. The @target task structure contains a pointer to the
843 * process that will be receiving the message (not equal to the current
844 * process when inline receives are being performed).
845 * @msq contains the message queue to retrieve message from.
846 * @msg contains the message destination.
847 * @target contains the task structure for recipient process.
848 * @type contains the type of message requested.
849 * @mode contains the operational flags.
850 * Return 0 if permission is granted.
852 * Security hooks for System V Shared Memory Segments
854 * @shm_alloc_security:
855 * Allocate and attach a security structure to the shp->shm_perm.security
856 * field. The security field is initialized to NULL when the structure is
858 * @shp contains the shared memory structure to be modified.
859 * Return 0 if operation was successful and permission is granted.
860 * @shm_free_security:
861 * Deallocate the security struct for this memory segment.
862 * @shp contains the shared memory structure to be modified.
864 * Check permission when a shared memory region is requested through the
865 * shmget system call. This hook is only called when returning the shared
866 * memory region identifier for an existing region, not when a new shared
867 * memory region is created.
868 * @shp contains the shared memory structure to be modified.
869 * @shmflg contains the operation control flags.
870 * Return 0 if permission is granted.
872 * Check permission when a shared memory control operation specified by
873 * @cmd is to be performed on the shared memory region @shp.
874 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
875 * @shp contains shared memory structure to be modified.
876 * @cmd contains the operation to be performed.
877 * Return 0 if permission is granted.
879 * Check permissions prior to allowing the shmat system call to attach the
880 * shared memory segment @shp to the data segment of the calling process.
881 * The attaching address is specified by @shmaddr.
882 * @shp contains the shared memory structure to be modified.
883 * @shmaddr contains the address to attach memory region to.
884 * @shmflg contains the operational flags.
885 * Return 0 if permission is granted.
887 * Security hooks for System V Semaphores
889 * @sem_alloc_security:
890 * Allocate and attach a security structure to the sma->sem_perm.security
891 * field. The security field is initialized to NULL when the structure is
893 * @sma contains the semaphore structure
894 * Return 0 if operation was successful and permission is granted.
895 * @sem_free_security:
896 * deallocate security struct for this semaphore
897 * @sma contains the semaphore structure.
899 * Check permission when a semaphore is requested through the semget
900 * system call. This hook is only called when returning the semaphore
901 * identifier for an existing semaphore, not when a new one must be
903 * @sma contains the semaphore structure.
904 * @semflg contains the operation control flags.
905 * Return 0 if permission is granted.
907 * Check permission when a semaphore operation specified by @cmd is to be
908 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
909 * IPC_INFO or SEM_INFO.
910 * @sma contains the semaphore structure. May be NULL.
911 * @cmd contains the operation to be performed.
912 * Return 0 if permission is granted.
914 * Check permissions before performing operations on members of the
915 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
917 * @sma contains the semaphore structure.
918 * @sops contains the operations to perform.
919 * @nsops contains the number of operations to perform.
920 * @alter contains the flag indicating whether changes are to be made.
921 * Return 0 if permission is granted.
924 * Check permission before allowing the @parent process to trace the
926 * Security modules may also want to perform a process tracing check
927 * during an execve in the set_security or compute_creds hooks of
928 * binprm_security_ops if the process is being traced and its security
929 * attributes would be changed by the execve.
930 * @parent contains the task_struct structure for parent process.
931 * @child contains the task_struct structure for child process.
932 * Return 0 if permission is granted.
934 * Get the @effective, @inheritable, and @permitted capability sets for
935 * the @target process. The hook may also perform permission checking to
936 * determine if the current process is allowed to see the capability sets
937 * of the @target process.
938 * @target contains the task_struct structure for target process.
939 * @effective contains the effective capability set.
940 * @inheritable contains the inheritable capability set.
941 * @permitted contains the permitted capability set.
942 * Return 0 if the capability sets were successfully obtained.
944 * Check permission before setting the @effective, @inheritable, and
945 * @permitted capability sets for the @target process.
946 * Caveat: @target is also set to current if a set of processes is
947 * specified (i.e. all processes other than current and init or a
948 * particular process group). Hence, the capset_set hook may need to
949 * revalidate permission to the actual target process.
950 * @target contains the task_struct structure for target process.
951 * @effective contains the effective capability set.
952 * @inheritable contains the inheritable capability set.
953 * @permitted contains the permitted capability set.
954 * Return 0 if permission is granted.
956 * Set the @effective, @inheritable, and @permitted capability sets for
957 * the @target process. Since capset_check cannot always check permission
958 * to the real @target process, this hook may also perform permission
959 * checking to determine if the current process is allowed to set the
960 * capability sets of the @target process. However, this hook has no way
961 * of returning an error due to the structure of the sys_capset code.
962 * @target contains the task_struct structure for target process.
963 * @effective contains the effective capability set.
964 * @inheritable contains the inheritable capability set.
965 * @permitted contains the permitted capability set.
967 * Check permission before enabling or disabling process accounting. If
968 * accounting is being enabled, then @file refers to the open file used to
969 * store accounting records. If accounting is being disabled, then @file
971 * @file contains the file structure for the accounting file (may be NULL).
972 * Return 0 if permission is granted.
974 * Check permission before accessing the @table sysctl variable in the
975 * manner specified by @op.
976 * @table contains the ctl_table structure for the sysctl variable.
977 * @op contains the operation (001 = search, 002 = write, 004 = read).
978 * Return 0 if permission is granted.
980 * Check whether the @tsk process has the @cap capability.
981 * @tsk contains the task_struct for the process.
982 * @cap contains the capability <include/linux/capability.h>.
983 * Return 0 if the capability is granted for @tsk.
985 * Check permission before accessing the kernel message ring or changing
986 * logging to the console.
987 * See the syslog(2) manual page for an explanation of the @type values.
988 * @type contains the type of action.
989 * Return 0 if permission is granted.
991 * Check permissions for allocating a new virtual mapping.
992 * @pages contains the number of pages.
993 * Return 0 if permission is granted.
995 * @register_security:
996 * allow module stacking.
997 * @name contains the name of the security module being stacked.
998 * @ops contains a pointer to the struct security_operations of the module to stack.
999 * @unregister_security:
1000 * remove a stacked module.
1001 * @name contains the name of the security module being unstacked.
1002 * @ops contains a pointer to the struct security_operations of the module to unstack.
1004 * This is the main security structure.
1006 struct security_operations {
1007 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1008 int (*capget) (struct task_struct * target,
1009 kernel_cap_t * effective,
1010 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1011 int (*capset_check) (struct task_struct * target,
1012 kernel_cap_t * effective,
1013 kernel_cap_t * inheritable,
1014 kernel_cap_t * permitted);
1015 void (*capset_set) (struct task_struct * target,
1016 kernel_cap_t * effective,
1017 kernel_cap_t * inheritable,
1018 kernel_cap_t * permitted);
1019 int (*acct) (struct file * file);
1020 int (*sysctl) (ctl_table * table, int op);
1021 int (*capable) (struct task_struct * tsk, int cap);
1022 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1023 int (*quota_on) (struct file * f);
1024 int (*syslog) (int type);
1025 int (*vm_enough_memory) (long pages);
1027 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1028 void (*bprm_free_security) (struct linux_binprm * bprm);
1029 void (*bprm_compute_creds) (struct linux_binprm * bprm);
1030 int (*bprm_set_security) (struct linux_binprm * bprm);
1031 int (*bprm_check_security) (struct linux_binprm * bprm);
1032 int (*bprm_secureexec) (struct linux_binprm * bprm);
1034 int (*sb_alloc_security) (struct super_block * sb);
1035 void (*sb_free_security) (struct super_block * sb);
1036 int (*sb_copy_data)(const char *fstype, void *orig, void *copy);
1037 int (*sb_kern_mount) (struct super_block *sb, void *data);
1038 int (*sb_statfs) (struct super_block * sb);
1039 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1040 char *type, unsigned long flags, void *data);
1041 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1042 int (*sb_umount) (struct vfsmount * mnt, int flags);
1043 void (*sb_umount_close) (struct vfsmount * mnt);
1044 void (*sb_umount_busy) (struct vfsmount * mnt);
1045 void (*sb_post_remount) (struct vfsmount * mnt,
1046 unsigned long flags, void *data);
1047 void (*sb_post_mountroot) (void);
1048 void (*sb_post_addmount) (struct vfsmount * mnt,
1049 struct nameidata * mountpoint_nd);
1050 int (*sb_pivotroot) (struct nameidata * old_nd,
1051 struct nameidata * new_nd);
1052 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1053 struct nameidata * new_nd);
1055 int (*inode_alloc_security) (struct inode *inode);
1056 void (*inode_free_security) (struct inode *inode);
1057 int (*inode_create) (struct inode *dir,
1058 struct dentry *dentry, int mode);
1059 void (*inode_post_create) (struct inode *dir,
1060 struct dentry *dentry, int mode);
1061 int (*inode_link) (struct dentry *old_dentry,
1062 struct inode *dir, struct dentry *new_dentry);
1063 void (*inode_post_link) (struct dentry *old_dentry,
1064 struct inode *dir, struct dentry *new_dentry);
1065 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1066 int (*inode_symlink) (struct inode *dir,
1067 struct dentry *dentry, const char *old_name);
1068 void (*inode_post_symlink) (struct inode *dir,
1069 struct dentry *dentry,
1070 const char *old_name);
1071 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1072 void (*inode_post_mkdir) (struct inode *dir, struct dentry *dentry,
1074 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1075 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1076 int mode, dev_t dev);
1077 void (*inode_post_mknod) (struct inode *dir, struct dentry *dentry,
1078 int mode, dev_t dev);
1079 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1080 struct inode *new_dir, struct dentry *new_dentry);
1081 void (*inode_post_rename) (struct inode *old_dir,
1082 struct dentry *old_dentry,
1083 struct inode *new_dir,
1084 struct dentry *new_dentry);
1085 int (*inode_readlink) (struct dentry *dentry);
1086 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1087 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1088 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1089 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1090 void (*inode_delete) (struct inode *inode);
1091 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1092 size_t size, int flags);
1093 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1094 size_t size, int flags);
1095 int (*inode_getxattr) (struct dentry *dentry, char *name);
1096 int (*inode_listxattr) (struct dentry *dentry);
1097 int (*inode_removexattr) (struct dentry *dentry, char *name);
1098 int (*inode_getsecurity)(struct dentry *dentry, const char *name, void *buffer, size_t size);
1099 int (*inode_setsecurity)(struct dentry *dentry, const char *name, const void *value, size_t size, int flags);
1100 int (*inode_listsecurity)(struct dentry *dentry, char *buffer);
1102 int (*file_permission) (struct file * file, int mask);
1103 int (*file_alloc_security) (struct file * file);
1104 void (*file_free_security) (struct file * file);
1105 int (*file_ioctl) (struct file * file, unsigned int cmd,
1107 int (*file_mmap) (struct file * file,
1108 unsigned long prot, unsigned long flags);
1109 int (*file_mprotect) (struct vm_area_struct * vma, unsigned long prot);
1110 int (*file_lock) (struct file * file, unsigned int cmd);
1111 int (*file_fcntl) (struct file * file, unsigned int cmd,
1113 int (*file_set_fowner) (struct file * file);
1114 int (*file_send_sigiotask) (struct task_struct * tsk,
1115 struct fown_struct * fown,
1116 int fd, int reason);
1117 int (*file_receive) (struct file * file);
1119 int (*task_create) (unsigned long clone_flags);
1120 int (*task_alloc_security) (struct task_struct * p);
1121 void (*task_free_security) (struct task_struct * p);
1122 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1123 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1124 uid_t old_euid, uid_t old_suid, int flags);
1125 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1126 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1127 int (*task_getpgid) (struct task_struct * p);
1128 int (*task_getsid) (struct task_struct * p);
1129 int (*task_setgroups) (struct group_info *group_info);
1130 int (*task_setnice) (struct task_struct * p, int nice);
1131 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1132 int (*task_setscheduler) (struct task_struct * p, int policy,
1133 struct sched_param * lp);
1134 int (*task_getscheduler) (struct task_struct * p);
1135 int (*task_kill) (struct task_struct * p,
1136 struct siginfo * info, int sig);
1137 int (*task_wait) (struct task_struct * p);
1138 int (*task_prctl) (int option, unsigned long arg2,
1139 unsigned long arg3, unsigned long arg4,
1140 unsigned long arg5);
1141 void (*task_reparent_to_init) (struct task_struct * p);
1142 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1144 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1146 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1147 void (*msg_msg_free_security) (struct msg_msg * msg);
1149 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1150 void (*msg_queue_free_security) (struct msg_queue * msq);
1151 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1152 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1153 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1154 struct msg_msg * msg, int msqflg);
1155 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1156 struct msg_msg * msg,
1157 struct task_struct * target,
1158 long type, int mode);
1160 int (*shm_alloc_security) (struct shmid_kernel * shp);
1161 void (*shm_free_security) (struct shmid_kernel * shp);
1162 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1163 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1164 int (*shm_shmat) (struct shmid_kernel * shp,
1165 char *shmaddr, int shmflg);
1167 int (*sem_alloc_security) (struct sem_array * sma);
1168 void (*sem_free_security) (struct sem_array * sma);
1169 int (*sem_associate) (struct sem_array * sma, int semflg);
1170 int (*sem_semctl) (struct sem_array * sma, int cmd);
1171 int (*sem_semop) (struct sem_array * sma,
1172 struct sembuf * sops, unsigned nsops, int alter);
1174 int (*netlink_send) (struct sk_buff * skb);
1175 int (*netlink_recv) (struct sk_buff * skb);
1177 /* allow module stacking */
1178 int (*register_security) (const char *name,
1179 struct security_operations *ops);
1180 int (*unregister_security) (const char *name,
1181 struct security_operations *ops);
1183 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1185 int (*getprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1186 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1188 #ifdef CONFIG_SECURITY_NETWORK
1189 int (*unix_stream_connect) (struct socket * sock,
1190 struct socket * other, struct sock * newsk);
1191 int (*unix_may_send) (struct socket * sock, struct socket * other);
1193 int (*socket_create) (int family, int type, int protocol);
1194 void (*socket_post_create) (struct socket * sock, int family,
1195 int type, int protocol);
1196 int (*socket_bind) (struct socket * sock,
1197 struct sockaddr * address, int addrlen);
1198 int (*socket_connect) (struct socket * sock,
1199 struct sockaddr * address, int addrlen);
1200 int (*socket_listen) (struct socket * sock, int backlog);
1201 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1202 void (*socket_post_accept) (struct socket * sock,
1203 struct socket * newsock);
1204 int (*socket_sendmsg) (struct socket * sock,
1205 struct msghdr * msg, int size);
1206 int (*socket_recvmsg) (struct socket * sock,
1207 struct msghdr * msg, int size, int flags);
1208 int (*socket_getsockname) (struct socket * sock);
1209 int (*socket_getpeername) (struct socket * sock);
1210 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1211 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1212 int (*socket_shutdown) (struct socket * sock, int how);
1213 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
1214 int (*socket_getpeersec) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1215 int (*sk_alloc_security) (struct sock *sk, int family, int priority);
1216 void (*sk_free_security) (struct sock *sk);
1217 #endif /* CONFIG_SECURITY_NETWORK */
1220 /* global variables */
1221 extern struct security_operations *security_ops;
1224 static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1226 return security_ops->ptrace (parent, child);
1229 static inline int security_capget (struct task_struct *target,
1230 kernel_cap_t *effective,
1231 kernel_cap_t *inheritable,
1232 kernel_cap_t *permitted)
1234 return security_ops->capget (target, effective, inheritable, permitted);
1237 static inline int security_capset_check (struct task_struct *target,
1238 kernel_cap_t *effective,
1239 kernel_cap_t *inheritable,
1240 kernel_cap_t *permitted)
1242 return security_ops->capset_check (target, effective, inheritable, permitted);
1245 static inline void security_capset_set (struct task_struct *target,
1246 kernel_cap_t *effective,
1247 kernel_cap_t *inheritable,
1248 kernel_cap_t *permitted)
1250 security_ops->capset_set (target, effective, inheritable, permitted);
1253 static inline int security_acct (struct file *file)
1255 return security_ops->acct (file);
1258 static inline int security_sysctl(ctl_table * table, int op)
1260 return security_ops->sysctl(table, op);
1263 static inline int security_quotactl (int cmds, int type, int id,
1264 struct super_block *sb)
1266 return security_ops->quotactl (cmds, type, id, sb);
1269 static inline int security_quota_on (struct file * file)
1271 return security_ops->quota_on (file);
1274 static inline int security_syslog(int type)
1276 return security_ops->syslog(type);
1279 static inline int security_vm_enough_memory(long pages)
1281 return security_ops->vm_enough_memory(pages);
1284 static inline int security_bprm_alloc (struct linux_binprm *bprm)
1286 return security_ops->bprm_alloc_security (bprm);
1288 static inline void security_bprm_free (struct linux_binprm *bprm)
1290 security_ops->bprm_free_security (bprm);
1292 static inline void security_bprm_compute_creds (struct linux_binprm *bprm)
1294 security_ops->bprm_compute_creds (bprm);
1296 static inline int security_bprm_set (struct linux_binprm *bprm)
1298 return security_ops->bprm_set_security (bprm);
1301 static inline int security_bprm_check (struct linux_binprm *bprm)
1303 return security_ops->bprm_check_security (bprm);
1306 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1308 return security_ops->bprm_secureexec (bprm);
1311 static inline int security_sb_alloc (struct super_block *sb)
1313 return security_ops->sb_alloc_security (sb);
1316 static inline void security_sb_free (struct super_block *sb)
1318 security_ops->sb_free_security (sb);
1321 static inline int security_sb_copy_data (const char *fstype, void *orig, void *copy)
1323 return security_ops->sb_copy_data (fstype, orig, copy);
1326 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1328 return security_ops->sb_kern_mount (sb, data);
1331 static inline int security_sb_statfs (struct super_block *sb)
1333 return security_ops->sb_statfs (sb);
1336 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1337 char *type, unsigned long flags,
1340 return security_ops->sb_mount (dev_name, nd, type, flags, data);
1343 static inline int security_sb_check_sb (struct vfsmount *mnt,
1344 struct nameidata *nd)
1346 return security_ops->sb_check_sb (mnt, nd);
1349 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1351 return security_ops->sb_umount (mnt, flags);
1354 static inline void security_sb_umount_close (struct vfsmount *mnt)
1356 security_ops->sb_umount_close (mnt);
1359 static inline void security_sb_umount_busy (struct vfsmount *mnt)
1361 security_ops->sb_umount_busy (mnt);
1364 static inline void security_sb_post_remount (struct vfsmount *mnt,
1365 unsigned long flags, void *data)
1367 security_ops->sb_post_remount (mnt, flags, data);
1370 static inline void security_sb_post_mountroot (void)
1372 security_ops->sb_post_mountroot ();
1375 static inline void security_sb_post_addmount (struct vfsmount *mnt,
1376 struct nameidata *mountpoint_nd)
1378 security_ops->sb_post_addmount (mnt, mountpoint_nd);
1381 static inline int security_sb_pivotroot (struct nameidata *old_nd,
1382 struct nameidata *new_nd)
1384 return security_ops->sb_pivotroot (old_nd, new_nd);
1387 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1388 struct nameidata *new_nd)
1390 security_ops->sb_post_pivotroot (old_nd, new_nd);
1393 static inline int security_inode_alloc (struct inode *inode)
1395 return security_ops->inode_alloc_security (inode);
1398 static inline void security_inode_free (struct inode *inode)
1400 security_ops->inode_free_security (inode);
1403 static inline int security_inode_create (struct inode *dir,
1404 struct dentry *dentry,
1407 return security_ops->inode_create (dir, dentry, mode);
1410 static inline void security_inode_post_create (struct inode *dir,
1411 struct dentry *dentry,
1414 security_ops->inode_post_create (dir, dentry, mode);
1417 static inline int security_inode_link (struct dentry *old_dentry,
1419 struct dentry *new_dentry)
1421 return security_ops->inode_link (old_dentry, dir, new_dentry);
1424 static inline void security_inode_post_link (struct dentry *old_dentry,
1426 struct dentry *new_dentry)
1428 security_ops->inode_post_link (old_dentry, dir, new_dentry);
1431 static inline int security_inode_unlink (struct inode *dir,
1432 struct dentry *dentry)
1434 return security_ops->inode_unlink (dir, dentry);
1437 static inline int security_inode_symlink (struct inode *dir,
1438 struct dentry *dentry,
1439 const char *old_name)
1441 return security_ops->inode_symlink (dir, dentry, old_name);
1444 static inline void security_inode_post_symlink (struct inode *dir,
1445 struct dentry *dentry,
1446 const char *old_name)
1448 security_ops->inode_post_symlink (dir, dentry, old_name);
1451 static inline int security_inode_mkdir (struct inode *dir,
1452 struct dentry *dentry,
1455 return security_ops->inode_mkdir (dir, dentry, mode);
1458 static inline void security_inode_post_mkdir (struct inode *dir,
1459 struct dentry *dentry,
1462 security_ops->inode_post_mkdir (dir, dentry, mode);
1465 static inline int security_inode_rmdir (struct inode *dir,
1466 struct dentry *dentry)
1468 return security_ops->inode_rmdir (dir, dentry);
1471 static inline int security_inode_mknod (struct inode *dir,
1472 struct dentry *dentry,
1473 int mode, dev_t dev)
1475 return security_ops->inode_mknod (dir, dentry, mode, dev);
1478 static inline void security_inode_post_mknod (struct inode *dir,
1479 struct dentry *dentry,
1480 int mode, dev_t dev)
1482 security_ops->inode_post_mknod (dir, dentry, mode, dev);
1485 static inline int security_inode_rename (struct inode *old_dir,
1486 struct dentry *old_dentry,
1487 struct inode *new_dir,
1488 struct dentry *new_dentry)
1490 return security_ops->inode_rename (old_dir, old_dentry,
1491 new_dir, new_dentry);
1494 static inline void security_inode_post_rename (struct inode *old_dir,
1495 struct dentry *old_dentry,
1496 struct inode *new_dir,
1497 struct dentry *new_dentry)
1499 security_ops->inode_post_rename (old_dir, old_dentry,
1500 new_dir, new_dentry);
1503 static inline int security_inode_readlink (struct dentry *dentry)
1505 return security_ops->inode_readlink (dentry);
1508 static inline int security_inode_follow_link (struct dentry *dentry,
1509 struct nameidata *nd)
1511 return security_ops->inode_follow_link (dentry, nd);
1514 static inline int security_inode_permission (struct inode *inode, int mask,
1515 struct nameidata *nd)
1517 return security_ops->inode_permission (inode, mask, nd);
1520 static inline int security_inode_setattr (struct dentry *dentry,
1523 return security_ops->inode_setattr (dentry, attr);
1526 static inline int security_inode_getattr (struct vfsmount *mnt,
1527 struct dentry *dentry)
1529 return security_ops->inode_getattr (mnt, dentry);
1532 static inline void security_inode_delete (struct inode *inode)
1534 security_ops->inode_delete (inode);
1537 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1538 void *value, size_t size, int flags)
1540 return security_ops->inode_setxattr (dentry, name, value, size, flags);
1543 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1544 void *value, size_t size, int flags)
1546 security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1549 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1551 return security_ops->inode_getxattr (dentry, name);
1554 static inline int security_inode_listxattr (struct dentry *dentry)
1556 return security_ops->inode_listxattr (dentry);
1559 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1561 return security_ops->inode_removexattr (dentry, name);
1564 static inline int security_inode_getsecurity(struct dentry *dentry, const char *name, void *buffer, size_t size)
1566 return security_ops->inode_getsecurity(dentry, name, buffer, size);
1569 static inline int security_inode_setsecurity(struct dentry *dentry, const char *name, const void *value, size_t size, int flags)
1571 return security_ops->inode_setsecurity(dentry, name, value, size, flags);
1574 static inline int security_inode_listsecurity(struct dentry *dentry, char *buffer)
1576 return security_ops->inode_listsecurity(dentry, buffer);
1579 static inline int security_file_permission (struct file *file, int mask)
1581 return security_ops->file_permission (file, mask);
1584 static inline int security_file_alloc (struct file *file)
1586 return security_ops->file_alloc_security (file);
1589 static inline void security_file_free (struct file *file)
1591 security_ops->file_free_security (file);
1594 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1597 return security_ops->file_ioctl (file, cmd, arg);
1600 static inline int security_file_mmap (struct file *file, unsigned long prot,
1601 unsigned long flags)
1603 return security_ops->file_mmap (file, prot, flags);
1606 static inline int security_file_mprotect (struct vm_area_struct *vma,
1609 return security_ops->file_mprotect (vma, prot);
1612 static inline int security_file_lock (struct file *file, unsigned int cmd)
1614 return security_ops->file_lock (file, cmd);
1617 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1620 return security_ops->file_fcntl (file, cmd, arg);
1623 static inline int security_file_set_fowner (struct file *file)
1625 return security_ops->file_set_fowner (file);
1628 static inline int security_file_send_sigiotask (struct task_struct *tsk,
1629 struct fown_struct *fown,
1632 return security_ops->file_send_sigiotask (tsk, fown, fd, reason);
1635 static inline int security_file_receive (struct file *file)
1637 return security_ops->file_receive (file);
1640 static inline int security_task_create (unsigned long clone_flags)
1642 return security_ops->task_create (clone_flags);
1645 static inline int security_task_alloc (struct task_struct *p)
1647 return security_ops->task_alloc_security (p);
1650 static inline void security_task_free (struct task_struct *p)
1652 security_ops->task_free_security (p);
1655 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1658 return security_ops->task_setuid (id0, id1, id2, flags);
1661 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1662 uid_t old_suid, int flags)
1664 return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1667 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1670 return security_ops->task_setgid (id0, id1, id2, flags);
1673 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1675 return security_ops->task_setpgid (p, pgid);
1678 static inline int security_task_getpgid (struct task_struct *p)
1680 return security_ops->task_getpgid (p);
1683 static inline int security_task_getsid (struct task_struct *p)
1685 return security_ops->task_getsid (p);
1688 static inline int security_task_setgroups (struct group_info *group_info)
1690 return security_ops->task_setgroups (group_info);
1693 static inline int security_task_setnice (struct task_struct *p, int nice)
1695 return security_ops->task_setnice (p, nice);
1698 static inline int security_task_setrlimit (unsigned int resource,
1699 struct rlimit *new_rlim)
1701 return security_ops->task_setrlimit (resource, new_rlim);
1704 static inline int security_task_setscheduler (struct task_struct *p,
1706 struct sched_param *lp)
1708 return security_ops->task_setscheduler (p, policy, lp);
1711 static inline int security_task_getscheduler (struct task_struct *p)
1713 return security_ops->task_getscheduler (p);
1716 static inline int security_task_kill (struct task_struct *p,
1717 struct siginfo *info, int sig)
1719 return security_ops->task_kill (p, info, sig);
1722 static inline int security_task_wait (struct task_struct *p)
1724 return security_ops->task_wait (p);
1727 static inline int security_task_prctl (int option, unsigned long arg2,
1732 return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1735 static inline void security_task_reparent_to_init (struct task_struct *p)
1737 security_ops->task_reparent_to_init (p);
1740 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1742 security_ops->task_to_inode(p, inode);
1745 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
1748 return security_ops->ipc_permission (ipcp, flag);
1751 static inline int security_msg_msg_alloc (struct msg_msg * msg)
1753 return security_ops->msg_msg_alloc_security (msg);
1756 static inline void security_msg_msg_free (struct msg_msg * msg)
1758 security_ops->msg_msg_free_security(msg);
1761 static inline int security_msg_queue_alloc (struct msg_queue *msq)
1763 return security_ops->msg_queue_alloc_security (msq);
1766 static inline void security_msg_queue_free (struct msg_queue *msq)
1768 security_ops->msg_queue_free_security (msq);
1771 static inline int security_msg_queue_associate (struct msg_queue * msq,
1774 return security_ops->msg_queue_associate (msq, msqflg);
1777 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
1779 return security_ops->msg_queue_msgctl (msq, cmd);
1782 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
1783 struct msg_msg * msg, int msqflg)
1785 return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
1788 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
1789 struct msg_msg * msg,
1790 struct task_struct * target,
1791 long type, int mode)
1793 return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
1796 static inline int security_shm_alloc (struct shmid_kernel *shp)
1798 return security_ops->shm_alloc_security (shp);
1801 static inline void security_shm_free (struct shmid_kernel *shp)
1803 security_ops->shm_free_security (shp);
1806 static inline int security_shm_associate (struct shmid_kernel * shp,
1809 return security_ops->shm_associate(shp, shmflg);
1812 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
1814 return security_ops->shm_shmctl (shp, cmd);
1817 static inline int security_shm_shmat (struct shmid_kernel * shp,
1818 char __user *shmaddr, int shmflg)
1820 return security_ops->shm_shmat(shp, shmaddr, shmflg);
1823 static inline int security_sem_alloc (struct sem_array *sma)
1825 return security_ops->sem_alloc_security (sma);
1828 static inline void security_sem_free (struct sem_array *sma)
1830 security_ops->sem_free_security (sma);
1833 static inline int security_sem_associate (struct sem_array * sma, int semflg)
1835 return security_ops->sem_associate (sma, semflg);
1838 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
1840 return security_ops->sem_semctl(sma, cmd);
1843 static inline int security_sem_semop (struct sem_array * sma,
1844 struct sembuf * sops, unsigned nsops,
1847 return security_ops->sem_semop(sma, sops, nsops, alter);
1850 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
1852 security_ops->d_instantiate (dentry, inode);
1855 static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
1857 return security_ops->getprocattr(p, name, value, size);
1860 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
1862 return security_ops->setprocattr(p, name, value, size);
1865 static inline int security_netlink_send(struct sk_buff * skb)
1867 return security_ops->netlink_send(skb);
1870 static inline int security_netlink_recv(struct sk_buff * skb)
1872 return security_ops->netlink_recv(skb);
1876 extern int security_scaffolding_startup (void);
1877 extern int register_security (struct security_operations *ops);
1878 extern int unregister_security (struct security_operations *ops);
1879 extern int mod_reg_security (const char *name, struct security_operations *ops);
1880 extern int mod_unreg_security (const char *name, struct security_operations *ops);
1883 #else /* CONFIG_SECURITY */
1886 * This is the default capabilities functionality. Most of these functions
1887 * are just stubbed out, but a few must call the proper capable code.
1890 static inline int security_scaffolding_startup (void)
1895 static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
1897 return cap_ptrace (parent, child);
1900 static inline int security_capget (struct task_struct *target,
1901 kernel_cap_t *effective,
1902 kernel_cap_t *inheritable,
1903 kernel_cap_t *permitted)
1905 return cap_capget (target, effective, inheritable, permitted);
1908 static inline int security_capset_check (struct task_struct *target,
1909 kernel_cap_t *effective,
1910 kernel_cap_t *inheritable,
1911 kernel_cap_t *permitted)
1913 return cap_capset_check (target, effective, inheritable, permitted);
1916 static inline void security_capset_set (struct task_struct *target,
1917 kernel_cap_t *effective,
1918 kernel_cap_t *inheritable,
1919 kernel_cap_t *permitted)
1921 cap_capset_set (target, effective, inheritable, permitted);
1924 static inline int security_acct (struct file *file)
1929 static inline int security_sysctl(ctl_table * table, int op)
1934 static inline int security_quotactl (int cmds, int type, int id,
1935 struct super_block * sb)
1940 static inline int security_quota_on (struct file * file)
1945 static inline int security_syslog(int type)
1947 return cap_syslog(type);
1950 static inline int security_vm_enough_memory(long pages)
1952 return cap_vm_enough_memory(pages);
1955 static inline int security_bprm_alloc (struct linux_binprm *bprm)
1960 static inline void security_bprm_free (struct linux_binprm *bprm)
1963 static inline void security_bprm_compute_creds (struct linux_binprm *bprm)
1965 cap_bprm_compute_creds (bprm);
1968 static inline int security_bprm_set (struct linux_binprm *bprm)
1970 return cap_bprm_set_security (bprm);
1973 static inline int security_bprm_check (struct linux_binprm *bprm)
1978 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1980 return cap_bprm_secureexec(bprm);
1983 static inline int security_sb_alloc (struct super_block *sb)
1988 static inline void security_sb_free (struct super_block *sb)
1991 static inline int security_sb_copy_data (const char *fstype, void *orig, void *copy)
1996 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2001 static inline int security_sb_statfs (struct super_block *sb)
2006 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2007 char *type, unsigned long flags,
2013 static inline int security_sb_check_sb (struct vfsmount *mnt,
2014 struct nameidata *nd)
2019 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2024 static inline void security_sb_umount_close (struct vfsmount *mnt)
2027 static inline void security_sb_umount_busy (struct vfsmount *mnt)
2030 static inline void security_sb_post_remount (struct vfsmount *mnt,
2031 unsigned long flags, void *data)
2034 static inline void security_sb_post_mountroot (void)
2037 static inline void security_sb_post_addmount (struct vfsmount *mnt,
2038 struct nameidata *mountpoint_nd)
2041 static inline int security_sb_pivotroot (struct nameidata *old_nd,
2042 struct nameidata *new_nd)
2047 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2048 struct nameidata *new_nd)
2051 static inline int security_inode_alloc (struct inode *inode)
2056 static inline void security_inode_free (struct inode *inode)
2059 static inline int security_inode_create (struct inode *dir,
2060 struct dentry *dentry,
2066 static inline void security_inode_post_create (struct inode *dir,
2067 struct dentry *dentry,
2071 static inline int security_inode_link (struct dentry *old_dentry,
2073 struct dentry *new_dentry)
2078 static inline void security_inode_post_link (struct dentry *old_dentry,
2080 struct dentry *new_dentry)
2083 static inline int security_inode_unlink (struct inode *dir,
2084 struct dentry *dentry)
2089 static inline int security_inode_symlink (struct inode *dir,
2090 struct dentry *dentry,
2091 const char *old_name)
2096 static inline void security_inode_post_symlink (struct inode *dir,
2097 struct dentry *dentry,
2098 const char *old_name)
2101 static inline int security_inode_mkdir (struct inode *dir,
2102 struct dentry *dentry,
2108 static inline void security_inode_post_mkdir (struct inode *dir,
2109 struct dentry *dentry,
2113 static inline int security_inode_rmdir (struct inode *dir,
2114 struct dentry *dentry)
2119 static inline int security_inode_mknod (struct inode *dir,
2120 struct dentry *dentry,
2121 int mode, dev_t dev)
2126 static inline void security_inode_post_mknod (struct inode *dir,
2127 struct dentry *dentry,
2128 int mode, dev_t dev)
2131 static inline int security_inode_rename (struct inode *old_dir,
2132 struct dentry *old_dentry,
2133 struct inode *new_dir,
2134 struct dentry *new_dentry)
2139 static inline void security_inode_post_rename (struct inode *old_dir,
2140 struct dentry *old_dentry,
2141 struct inode *new_dir,
2142 struct dentry *new_dentry)
2145 static inline int security_inode_readlink (struct dentry *dentry)
2150 static inline int security_inode_follow_link (struct dentry *dentry,
2151 struct nameidata *nd)
2156 static inline int security_inode_permission (struct inode *inode, int mask,
2157 struct nameidata *nd)
2162 static inline int security_inode_setattr (struct dentry *dentry,
2168 static inline int security_inode_getattr (struct vfsmount *mnt,
2169 struct dentry *dentry)
2174 static inline void security_inode_delete (struct inode *inode)
2177 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2178 void *value, size_t size, int flags)
2180 return cap_inode_setxattr(dentry, name, value, size, flags);
2183 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2184 void *value, size_t size, int flags)
2187 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2192 static inline int security_inode_listxattr (struct dentry *dentry)
2197 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2199 return cap_inode_removexattr(dentry, name);
2202 static inline int security_inode_getsecurity(struct dentry *dentry, const char *name, void *buffer, size_t size)
2207 static inline int security_inode_setsecurity(struct dentry *dentry, const char *name, const void *value, size_t size, int flags)
2212 static inline int security_inode_listsecurity(struct dentry *dentry, char *buffer)
2217 static inline int security_file_permission (struct file *file, int mask)
2222 static inline int security_file_alloc (struct file *file)
2227 static inline void security_file_free (struct file *file)
2230 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2236 static inline int security_file_mmap (struct file *file, unsigned long prot,
2237 unsigned long flags)
2242 static inline int security_file_mprotect (struct vm_area_struct *vma,
2248 static inline int security_file_lock (struct file *file, unsigned int cmd)
2253 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2259 static inline int security_file_set_fowner (struct file *file)
2264 static inline int security_file_send_sigiotask (struct task_struct *tsk,
2265 struct fown_struct *fown,
2271 static inline int security_file_receive (struct file *file)
2276 static inline int security_task_create (unsigned long clone_flags)
2281 static inline int security_task_alloc (struct task_struct *p)
2286 static inline void security_task_free (struct task_struct *p)
2289 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2295 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2296 uid_t old_suid, int flags)
2298 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2301 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2307 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2312 static inline int security_task_getpgid (struct task_struct *p)
2317 static inline int security_task_getsid (struct task_struct *p)
2322 static inline int security_task_setgroups (struct group_info *group_info)
2327 static inline int security_task_setnice (struct task_struct *p, int nice)
2332 static inline int security_task_setrlimit (unsigned int resource,
2333 struct rlimit *new_rlim)
2338 static inline int security_task_setscheduler (struct task_struct *p,
2340 struct sched_param *lp)
2345 static inline int security_task_getscheduler (struct task_struct *p)
2350 static inline int security_task_kill (struct task_struct *p,
2351 struct siginfo *info, int sig)
2356 static inline int security_task_wait (struct task_struct *p)
2361 static inline int security_task_prctl (int option, unsigned long arg2,
2369 static inline void security_task_reparent_to_init (struct task_struct *p)
2371 cap_task_reparent_to_init (p);
2374 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2377 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2383 static inline int security_msg_msg_alloc (struct msg_msg * msg)
2388 static inline void security_msg_msg_free (struct msg_msg * msg)
2391 static inline int security_msg_queue_alloc (struct msg_queue *msq)
2396 static inline void security_msg_queue_free (struct msg_queue *msq)
2399 static inline int security_msg_queue_associate (struct msg_queue * msq,
2405 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2410 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2411 struct msg_msg * msg, int msqflg)
2416 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2417 struct msg_msg * msg,
2418 struct task_struct * target,
2419 long type, int mode)
2424 static inline int security_shm_alloc (struct shmid_kernel *shp)
2429 static inline void security_shm_free (struct shmid_kernel *shp)
2432 static inline int security_shm_associate (struct shmid_kernel * shp,
2438 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2443 static inline int security_shm_shmat (struct shmid_kernel * shp,
2444 char __user *shmaddr, int shmflg)
2449 static inline int security_sem_alloc (struct sem_array *sma)
2454 static inline void security_sem_free (struct sem_array *sma)
2457 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2462 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2467 static inline int security_sem_semop (struct sem_array * sma,
2468 struct sembuf * sops, unsigned nsops,
2474 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2477 static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2482 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2488 * The netlink capability defaults need to be used inline by default
2489 * (rather than hooking into the capability module) to reduce overhead
2490 * in the networking code.
2492 static inline int security_netlink_send (struct sk_buff *skb)
2494 return cap_netlink_send (skb);
2497 static inline int security_netlink_recv (struct sk_buff *skb)
2499 return cap_netlink_recv (skb);
2502 #endif /* CONFIG_SECURITY */
2504 #ifdef CONFIG_SECURITY_NETWORK
2505 static inline int security_unix_stream_connect(struct socket * sock,
2506 struct socket * other,
2507 struct sock * newsk)
2509 return security_ops->unix_stream_connect(sock, other, newsk);
2513 static inline int security_unix_may_send(struct socket * sock,
2514 struct socket * other)
2516 return security_ops->unix_may_send(sock, other);
2519 static inline int security_socket_create (int family, int type, int protocol)
2521 return security_ops->socket_create(family, type, protocol);
2524 static inline void security_socket_post_create(struct socket * sock,
2529 security_ops->socket_post_create(sock, family, type, protocol);
2532 static inline int security_socket_bind(struct socket * sock,
2533 struct sockaddr * address,
2536 return security_ops->socket_bind(sock, address, addrlen);
2539 static inline int security_socket_connect(struct socket * sock,
2540 struct sockaddr * address,
2543 return security_ops->socket_connect(sock, address, addrlen);
2546 static inline int security_socket_listen(struct socket * sock, int backlog)
2548 return security_ops->socket_listen(sock, backlog);
2551 static inline int security_socket_accept(struct socket * sock,
2552 struct socket * newsock)
2554 return security_ops->socket_accept(sock, newsock);
2557 static inline void security_socket_post_accept(struct socket * sock,
2558 struct socket * newsock)
2560 security_ops->socket_post_accept(sock, newsock);
2563 static inline int security_socket_sendmsg(struct socket * sock,
2564 struct msghdr * msg, int size)
2566 return security_ops->socket_sendmsg(sock, msg, size);
2569 static inline int security_socket_recvmsg(struct socket * sock,
2570 struct msghdr * msg, int size,
2573 return security_ops->socket_recvmsg(sock, msg, size, flags);
2576 static inline int security_socket_getsockname(struct socket * sock)
2578 return security_ops->socket_getsockname(sock);
2581 static inline int security_socket_getpeername(struct socket * sock)
2583 return security_ops->socket_getpeername(sock);
2586 static inline int security_socket_getsockopt(struct socket * sock,
2587 int level, int optname)
2589 return security_ops->socket_getsockopt(sock, level, optname);
2592 static inline int security_socket_setsockopt(struct socket * sock,
2593 int level, int optname)
2595 return security_ops->socket_setsockopt(sock, level, optname);
2598 static inline int security_socket_shutdown(struct socket * sock, int how)
2600 return security_ops->socket_shutdown(sock, how);
2603 static inline int security_sock_rcv_skb (struct sock * sk,
2604 struct sk_buff * skb)
2606 return security_ops->socket_sock_rcv_skb (sk, skb);
2609 static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
2610 int __user *optlen, unsigned len)
2612 return security_ops->socket_getpeersec(sock, optval, optlen, len);
2615 static inline int security_sk_alloc(struct sock *sk, int family, int priority)
2617 return security_ops->sk_alloc_security(sk, family, priority);
2620 static inline void security_sk_free(struct sock *sk)
2622 return security_ops->sk_free_security(sk);
2624 #else /* CONFIG_SECURITY_NETWORK */
2625 static inline int security_unix_stream_connect(struct socket * sock,
2626 struct socket * other,
2627 struct sock * newsk)
2632 static inline int security_unix_may_send(struct socket * sock,
2633 struct socket * other)
2638 static inline int security_socket_create (int family, int type, int protocol)
2643 static inline void security_socket_post_create(struct socket * sock,
2650 static inline int security_socket_bind(struct socket * sock,
2651 struct sockaddr * address,
2657 static inline int security_socket_connect(struct socket * sock,
2658 struct sockaddr * address,
2664 static inline int security_socket_listen(struct socket * sock, int backlog)
2669 static inline int security_socket_accept(struct socket * sock,
2670 struct socket * newsock)
2675 static inline void security_socket_post_accept(struct socket * sock,
2676 struct socket * newsock)
2680 static inline int security_socket_sendmsg(struct socket * sock,
2681 struct msghdr * msg, int size)
2686 static inline int security_socket_recvmsg(struct socket * sock,
2687 struct msghdr * msg, int size,
2693 static inline int security_socket_getsockname(struct socket * sock)
2698 static inline int security_socket_getpeername(struct socket * sock)
2703 static inline int security_socket_getsockopt(struct socket * sock,
2704 int level, int optname)
2709 static inline int security_socket_setsockopt(struct socket * sock,
2710 int level, int optname)
2715 static inline int security_socket_shutdown(struct socket * sock, int how)
2719 static inline int security_sock_rcv_skb (struct sock * sk,
2720 struct sk_buff * skb)
2725 static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
2726 int __user *optlen, unsigned len)
2728 return -ENOPROTOOPT;
2731 static inline int security_sk_alloc(struct sock *sk, int family, int priority)
2736 static inline void security_sk_free(struct sock *sk)
2739 #endif /* CONFIG_SECURITY_NETWORK */
2741 #endif /* ! __LINUX_SECURITY_H */