Linux v2.6.15-rc7
[pohmelfs.git] / include / linux / security.h
blobf7e0ae018712257a11b67ffa6cd12eafb988c34b
1 /*
2 * Linux Security plug
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
25 #include <linux/fs.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>
35 struct ctl_table;
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_settime (struct timespec *ts, struct timezone *tz);
43 extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
44 extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
45 extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
46 extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
47 extern int cap_bprm_set_security (struct linux_binprm *bprm);
48 extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
49 extern int cap_bprm_secureexec(struct linux_binprm *bprm);
50 extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
51 extern int cap_inode_removexattr(struct dentry *dentry, char *name);
52 extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
53 extern void cap_task_reparent_to_init (struct task_struct *p);
54 extern int cap_syslog (int type);
55 extern int cap_vm_enough_memory (long pages);
57 struct msghdr;
58 struct sk_buff;
59 struct sock;
60 struct sockaddr;
61 struct socket;
63 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
64 extern int cap_netlink_recv(struct sk_buff *skb);
67 * Values used in the task_security_ops calls
69 /* setuid or setgid, id0 == uid or gid */
70 #define LSM_SETID_ID 1
72 /* setreuid or setregid, id0 == real, id1 == eff */
73 #define LSM_SETID_RE 2
75 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
76 #define LSM_SETID_RES 4
78 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
79 #define LSM_SETID_FS 8
81 /* forward declares to avoid warnings */
82 struct nfsctl_arg;
83 struct sched_param;
84 struct swap_info_struct;
86 /* bprm_apply_creds unsafe reasons */
87 #define LSM_UNSAFE_SHARE 1
88 #define LSM_UNSAFE_PTRACE 2
89 #define LSM_UNSAFE_PTRACE_CAP 4
91 #ifdef CONFIG_SECURITY
93 /**
94 * struct security_operations - main security structure
96 * Security hooks for program execution operations.
98 * @bprm_alloc_security:
99 * Allocate and attach a security structure to the @bprm->security field.
100 * The security field is initialized to NULL when the bprm structure is
101 * allocated.
102 * @bprm contains the linux_binprm structure to be modified.
103 * Return 0 if operation was successful.
104 * @bprm_free_security:
105 * @bprm contains the linux_binprm structure to be modified.
106 * Deallocate and clear the @bprm->security field.
107 * @bprm_apply_creds:
108 * Compute and set the security attributes of a process being transformed
109 * by an execve operation based on the old attributes (current->security)
110 * and the information saved in @bprm->security by the set_security hook.
111 * Since this hook function (and its caller) are void, this hook can not
112 * return an error. However, it can leave the security attributes of the
113 * process unchanged if an access failure occurs at this point.
114 * bprm_apply_creds is called under task_lock. @unsafe indicates various
115 * reasons why it may be unsafe to change security state.
116 * @bprm contains the linux_binprm structure.
117 * @bprm_post_apply_creds:
118 * Runs after bprm_apply_creds with the task_lock dropped, so that
119 * functions which cannot be called safely under the task_lock can
120 * be used. This hook is a good place to perform state changes on
121 * the process such as closing open file descriptors to which access
122 * is no longer granted if the attributes were changed.
123 * Note that a security module might need to save state between
124 * bprm_apply_creds and bprm_post_apply_creds to store the decision
125 * on whether the process may proceed.
126 * @bprm contains the linux_binprm structure.
127 * @bprm_set_security:
128 * Save security information in the bprm->security field, typically based
129 * on information about the bprm->file, for later use by the apply_creds
130 * hook. This hook may also optionally check permissions (e.g. for
131 * transitions between security domains).
132 * This hook may be called multiple times during a single execve, e.g. for
133 * interpreters. The hook can tell whether it has already been called by
134 * checking to see if @bprm->security is non-NULL. If so, then the hook
135 * may decide either to retain the security information saved earlier or
136 * to replace it.
137 * @bprm contains the linux_binprm structure.
138 * Return 0 if the hook is successful and permission is granted.
139 * @bprm_check_security:
140 * This hook mediates the point when a search for a binary handler will
141 * begin. It allows a check the @bprm->security value which is set in
142 * the preceding set_security call. The primary difference from
143 * set_security is that the argv list and envp list are reliably
144 * available in @bprm. This hook may be called multiple times
145 * during a single execve; and in each pass set_security is called
146 * first.
147 * @bprm contains the linux_binprm structure.
148 * Return 0 if the hook is successful and permission is granted.
149 * @bprm_secureexec:
150 * Return a boolean value (0 or 1) indicating whether a "secure exec"
151 * is required. The flag is passed in the auxiliary table
152 * on the initial stack to the ELF interpreter to indicate whether libc
153 * should enable secure mode.
154 * @bprm contains the linux_binprm structure.
156 * Security hooks for filesystem operations.
158 * @sb_alloc_security:
159 * Allocate and attach a security structure to the sb->s_security field.
160 * The s_security field is initialized to NULL when the structure is
161 * allocated.
162 * @sb contains the super_block structure to be modified.
163 * Return 0 if operation was successful.
164 * @sb_free_security:
165 * Deallocate and clear the sb->s_security field.
166 * @sb contains the super_block structure to be modified.
167 * @sb_statfs:
168 * Check permission before obtaining filesystem statistics for the @sb
169 * filesystem.
170 * @sb contains the super_block structure for the filesystem.
171 * Return 0 if permission is granted.
172 * @sb_mount:
173 * Check permission before an object specified by @dev_name is mounted on
174 * the mount point named by @nd. For an ordinary mount, @dev_name
175 * identifies a device if the file system type requires a device. For a
176 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
177 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
178 * pathname of the object being mounted.
179 * @dev_name contains the name for object being mounted.
180 * @nd contains the nameidata structure for mount point object.
181 * @type contains the filesystem type.
182 * @flags contains the mount flags.
183 * @data contains the filesystem-specific data.
184 * Return 0 if permission is granted.
185 * @sb_copy_data:
186 * Allow mount option data to be copied prior to parsing by the filesystem,
187 * so that the security module can extract security-specific mount
188 * options cleanly (a filesystem may modify the data e.g. with strsep()).
189 * This also allows the original mount data to be stripped of security-
190 * specific options to avoid having to make filesystems aware of them.
191 * @type the type of filesystem being mounted.
192 * @orig the original mount data copied from userspace.
193 * @copy copied data which will be passed to the security module.
194 * Returns 0 if the copy was successful.
195 * @sb_check_sb:
196 * Check permission before the device with superblock @mnt->sb is mounted
197 * on the mount point named by @nd.
198 * @mnt contains the vfsmount for device being mounted.
199 * @nd contains the nameidata object for the mount point.
200 * Return 0 if permission is granted.
201 * @sb_umount:
202 * Check permission before the @mnt file system is unmounted.
203 * @mnt contains the mounted file system.
204 * @flags contains the unmount flags, e.g. MNT_FORCE.
205 * Return 0 if permission is granted.
206 * @sb_umount_close:
207 * Close any files in the @mnt mounted filesystem that are held open by
208 * the security module. This hook is called during an umount operation
209 * prior to checking whether the filesystem is still busy.
210 * @mnt contains the mounted filesystem.
211 * @sb_umount_busy:
212 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
213 * any files that were closed by umount_close. This hook is called during
214 * an umount operation if the umount fails after a call to the
215 * umount_close hook.
216 * @mnt contains the mounted filesystem.
217 * @sb_post_remount:
218 * Update the security module's state when a filesystem is remounted.
219 * This hook is only called if the remount was successful.
220 * @mnt contains the mounted file system.
221 * @flags contains the new filesystem flags.
222 * @data contains the filesystem-specific data.
223 * @sb_post_mountroot:
224 * Update the security module's state when the root filesystem is mounted.
225 * This hook is only called if the mount was successful.
226 * @sb_post_addmount:
227 * Update the security module's state when a filesystem is mounted.
228 * This hook is called any time a mount is successfully grafetd to
229 * the tree.
230 * @mnt contains the mounted filesystem.
231 * @mountpoint_nd contains the nameidata structure for the mount point.
232 * @sb_pivotroot:
233 * Check permission before pivoting the root filesystem.
234 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
235 * @new_nd contains the nameidata structure for the new root (new_root).
236 * Return 0 if permission is granted.
237 * @sb_post_pivotroot:
238 * Update module state after a successful pivot.
239 * @old_nd contains the nameidata structure for the old root.
240 * @new_nd contains the nameidata structure for the new root.
242 * Security hooks for inode operations.
244 * @inode_alloc_security:
245 * Allocate and attach a security structure to @inode->i_security. The
246 * i_security field is initialized to NULL when the inode structure is
247 * allocated.
248 * @inode contains the inode structure.
249 * Return 0 if operation was successful.
250 * @inode_free_security:
251 * @inode contains the inode structure.
252 * Deallocate the inode security structure and set @inode->i_security to
253 * NULL.
254 * @inode_init_security:
255 * Obtain the security attribute name suffix and value to set on a newly
256 * created inode and set up the incore security field for the new inode.
257 * This hook is called by the fs code as part of the inode creation
258 * transaction and provides for atomic labeling of the inode, unlike
259 * the post_create/mkdir/... hooks called by the VFS. The hook function
260 * is expected to allocate the name and value via kmalloc, with the caller
261 * being responsible for calling kfree after using them.
262 * If the security module does not use security attributes or does
263 * not wish to put a security attribute on this particular inode,
264 * then it should return -EOPNOTSUPP to skip this processing.
265 * @inode contains the inode structure of the newly created inode.
266 * @dir contains the inode structure of the parent directory.
267 * @name will be set to the allocated name suffix (e.g. selinux).
268 * @value will be set to the allocated attribute value.
269 * @len will be set to the length of the value.
270 * Returns 0 if @name and @value have been successfully set,
271 * -EOPNOTSUPP if no security attribute is needed, or
272 * -ENOMEM on memory allocation failure.
273 * @inode_create:
274 * Check permission to create a regular file.
275 * @dir contains inode structure of the parent of the new file.
276 * @dentry contains the dentry structure for the file to be created.
277 * @mode contains the file mode of the file to be created.
278 * Return 0 if permission is granted.
279 * @inode_link:
280 * Check permission before creating a new hard link to a file.
281 * @old_dentry contains the dentry structure for an existing link to the file.
282 * @dir contains the inode structure of the parent directory of the new link.
283 * @new_dentry contains the dentry structure for the new link.
284 * Return 0 if permission is granted.
285 * @inode_unlink:
286 * Check the permission to remove a hard link to a file.
287 * @dir contains the inode structure of parent directory of the file.
288 * @dentry contains the dentry structure for file to be unlinked.
289 * Return 0 if permission is granted.
290 * @inode_symlink:
291 * Check the permission to create a symbolic link to a file.
292 * @dir contains the inode structure of parent directory of the symbolic link.
293 * @dentry contains the dentry structure of the symbolic link.
294 * @old_name contains the pathname of file.
295 * Return 0 if permission is granted.
296 * @inode_mkdir:
297 * Check permissions to create a new directory in the existing directory
298 * associated with inode strcture @dir.
299 * @dir containst the inode structure of parent of the directory to be created.
300 * @dentry contains the dentry structure of new directory.
301 * @mode contains the mode of new directory.
302 * Return 0 if permission is granted.
303 * @inode_rmdir:
304 * Check the permission to remove a directory.
305 * @dir contains the inode structure of parent of the directory to be removed.
306 * @dentry contains the dentry structure of directory to be removed.
307 * Return 0 if permission is granted.
308 * @inode_mknod:
309 * Check permissions when creating a special file (or a socket or a fifo
310 * file created via the mknod system call). Note that if mknod operation
311 * is being done for a regular file, then the create hook will be called
312 * and not this hook.
313 * @dir contains the inode structure of parent of the new file.
314 * @dentry contains the dentry structure of the new file.
315 * @mode contains the mode of the new file.
316 * @dev contains the the device number.
317 * Return 0 if permission is granted.
318 * @inode_rename:
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_readlink:
326 * Check the permission to read the symbolic link.
327 * @dentry contains the dentry structure for the file link.
328 * Return 0 if permission is granted.
329 * @inode_follow_link:
330 * Check permission to follow a symbolic link when looking up a pathname.
331 * @dentry contains the dentry structure for the link.
332 * @nd contains the nameidata structure for the parent directory.
333 * Return 0 if permission is granted.
334 * @inode_permission:
335 * Check permission before accessing an inode. This hook is called by the
336 * existing Linux permission function, so a security module can use it to
337 * provide additional checking for existing Linux permission checks.
338 * Notice that this hook is called when a file is opened (as well as many
339 * other operations), whereas the file_security_ops permission hook is
340 * called when the actual read/write operations are performed.
341 * @inode contains the inode structure to check.
342 * @mask contains the permission mask.
343 * @nd contains the nameidata (may be NULL).
344 * Return 0 if permission is granted.
345 * @inode_setattr:
346 * Check permission before setting file attributes. Note that the kernel
347 * call to notify_change is performed from several locations, whenever
348 * file attributes change (such as when a file is truncated, chown/chmod
349 * operations, transferring disk quotas, etc).
350 * @dentry contains the dentry structure for the file.
351 * @attr is the iattr structure containing the new file attributes.
352 * Return 0 if permission is granted.
353 * @inode_getattr:
354 * Check permission before obtaining file attributes.
355 * @mnt is the vfsmount where the dentry was looked up
356 * @dentry contains the dentry structure for the file.
357 * Return 0 if permission is granted.
358 * @inode_delete:
359 * @inode contains the inode structure for deleted inode.
360 * This hook is called when a deleted inode is released (i.e. an inode
361 * with no hard links has its use count drop to zero). A security module
362 * can use this hook to release any persistent label associated with the
363 * inode.
364 * @inode_setxattr:
365 * Check permission before setting the extended attributes
366 * @value identified by @name for @dentry.
367 * Return 0 if permission is granted.
368 * @inode_post_setxattr:
369 * Update inode security field after successful setxattr operation.
370 * @value identified by @name for @dentry.
371 * @inode_getxattr:
372 * Check permission before obtaining the extended attributes
373 * identified by @name for @dentry.
374 * Return 0 if permission is granted.
375 * @inode_listxattr:
376 * Check permission before obtaining the list of extended attribute
377 * names for @dentry.
378 * Return 0 if permission is granted.
379 * @inode_removexattr:
380 * Check permission before removing the extended attribute
381 * identified by @name for @dentry.
382 * Return 0 if permission is granted.
383 * @inode_getsecurity:
384 * Copy the extended attribute representation of the security label
385 * associated with @name for @inode into @buffer. @buffer may be
386 * NULL to request the size of the buffer required. @size indicates
387 * the size of @buffer in bytes. Note that @name is the remainder
388 * of the attribute name after the security. prefix has been removed.
389 * @err is the return value from the preceding fs getxattr call,
390 * and can be used by the security module to determine whether it
391 * should try and canonicalize the attribute value.
392 * Return number of bytes used/required on success.
393 * @inode_setsecurity:
394 * Set the security label associated with @name for @inode from the
395 * extended attribute value @value. @size indicates the size of the
396 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
397 * Note that @name is the remainder of the attribute name after the
398 * security. prefix has been removed.
399 * Return 0 on success.
400 * @inode_listsecurity:
401 * Copy the extended attribute names for the security labels
402 * associated with @inode into @buffer. The maximum size of @buffer
403 * is specified by @buffer_size. @buffer may be NULL to request
404 * the size of the buffer required.
405 * Returns number of bytes used/required on success.
407 * Security hooks for file operations
409 * @file_permission:
410 * Check file permissions before accessing an open file. This hook is
411 * called by various operations that read or write files. A security
412 * module can use this hook to perform additional checking on these
413 * operations, e.g. to revalidate permissions on use to support privilege
414 * bracketing or policy changes. Notice that this hook is used when the
415 * actual read/write operations are performed, whereas the
416 * inode_security_ops hook is called when a file is opened (as well as
417 * many other operations).
418 * Caveat: Although this hook can be used to revalidate permissions for
419 * various system call operations that read or write files, it does not
420 * address the revalidation of permissions for memory-mapped files.
421 * Security modules must handle this separately if they need such
422 * revalidation.
423 * @file contains the file structure being accessed.
424 * @mask contains the requested permissions.
425 * Return 0 if permission is granted.
426 * @file_alloc_security:
427 * Allocate and attach a security structure to the file->f_security field.
428 * The security field is initialized to NULL when the structure is first
429 * created.
430 * @file contains the file structure to secure.
431 * Return 0 if the hook is successful and permission is granted.
432 * @file_free_security:
433 * Deallocate and free any security structures stored in file->f_security.
434 * @file contains the file structure being modified.
435 * @file_ioctl:
436 * @file contains the file structure.
437 * @cmd contains the operation to perform.
438 * @arg contains the operational arguments.
439 * Check permission for an ioctl operation on @file. Note that @arg can
440 * sometimes represents a user space pointer; in other cases, it may be a
441 * simple integer value. When @arg represents a user space pointer, it
442 * should never be used by the security module.
443 * Return 0 if permission is granted.
444 * @file_mmap :
445 * Check permissions for a mmap operation. The @file may be NULL, e.g.
446 * if mapping anonymous memory.
447 * @file contains the file structure for file to map (may be NULL).
448 * @reqprot contains the protection requested by the application.
449 * @prot contains the protection that will be applied by the kernel.
450 * @flags contains the operational flags.
451 * Return 0 if permission is granted.
452 * @file_mprotect:
453 * Check permissions before changing memory access permissions.
454 * @vma contains the memory region to modify.
455 * @reqprot contains the protection requested by the application.
456 * @prot contains the protection that will be applied by the kernel.
457 * Return 0 if permission is granted.
458 * @file_lock:
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.
465 * @file_fcntl:
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.
475 * @file_set_fowner:
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 or SIGURG to the
482 * process @tsk. Note that this hook is sometimes called from interrupt.
483 * Note that the fown_struct, @fown, is never outside the context of a
484 * struct file, so the file structure (and associated security information)
485 * can always be obtained:
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 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
490 * Return 0 if permission is granted.
491 * @file_receive:
492 * This hook allows security modules to control the ability of a process
493 * to receive an open file descriptor via socket IPC.
494 * @file contains the file structure being received.
495 * Return 0 if permission is granted.
497 * Security hooks for task operations.
499 * @task_create:
500 * Check permission before creating a child process. See the clone(2)
501 * manual page for definitions of the @clone_flags.
502 * @clone_flags contains the flags indicating what should be shared.
503 * Return 0 if permission is granted.
504 * @task_alloc_security:
505 * @p contains the task_struct for child process.
506 * Allocate and attach a security structure to the p->security field. The
507 * security field is initialized to NULL when the task structure is
508 * allocated.
509 * Return 0 if operation was successful.
510 * @task_free_security:
511 * @p contains the task_struct for process.
512 * Deallocate and clear the p->security field.
513 * @task_setuid:
514 * Check permission before setting one or more of the user identity
515 * attributes of the current process. The @flags parameter indicates
516 * which of the set*uid system calls invoked this hook and how to
517 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
518 * definitions at the beginning of this file for the @flags values and
519 * their meanings.
520 * @id0 contains a uid.
521 * @id1 contains a uid.
522 * @id2 contains a uid.
523 * @flags contains one of the LSM_SETID_* values.
524 * Return 0 if permission is granted.
525 * @task_post_setuid:
526 * Update the module's state after setting one or more of the user
527 * identity attributes of the current process. The @flags parameter
528 * indicates which of the set*uid system calls invoked this hook. If
529 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
530 * parameters are not used.
531 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
532 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
533 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
534 * @flags contains one of the LSM_SETID_* values.
535 * Return 0 on success.
536 * @task_setgid:
537 * Check permission before setting one or more of the group identity
538 * attributes of the current process. The @flags parameter indicates
539 * which of the set*gid system calls invoked this hook and how to
540 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
541 * definitions at the beginning of this file for the @flags values and
542 * their meanings.
543 * @id0 contains a gid.
544 * @id1 contains a gid.
545 * @id2 contains a gid.
546 * @flags contains one of the LSM_SETID_* values.
547 * Return 0 if permission is granted.
548 * @task_setpgid:
549 * Check permission before setting the process group identifier of the
550 * process @p to @pgid.
551 * @p contains the task_struct for process being modified.
552 * @pgid contains the new pgid.
553 * Return 0 if permission is granted.
554 * @task_getpgid:
555 * Check permission before getting the process group identifier of the
556 * process @p.
557 * @p contains the task_struct for the process.
558 * Return 0 if permission is granted.
559 * @task_getsid:
560 * Check permission before getting the session identifier of the process
561 * @p.
562 * @p contains the task_struct for the process.
563 * Return 0 if permission is granted.
564 * @task_setgroups:
565 * Check permission before setting the supplementary group set of the
566 * current process.
567 * @group_info contains the new group information.
568 * Return 0 if permission is granted.
569 * @task_setnice:
570 * Check permission before setting the nice value of @p to @nice.
571 * @p contains the task_struct of process.
572 * @nice contains the new nice value.
573 * Return 0 if permission is granted.
574 * @task_setrlimit:
575 * Check permission before setting the resource limits of the current
576 * process for @resource to @new_rlim. The old resource limit values can
577 * be examined by dereferencing (current->signal->rlim + resource).
578 * @resource contains the resource whose limit is being set.
579 * @new_rlim contains the new limits for @resource.
580 * Return 0 if permission is granted.
581 * @task_setscheduler:
582 * Check permission before setting scheduling policy and/or parameters of
583 * process @p based on @policy and @lp.
584 * @p contains the task_struct for process.
585 * @policy contains the scheduling policy.
586 * @lp contains the scheduling parameters.
587 * Return 0 if permission is granted.
588 * @task_getscheduler:
589 * Check permission before obtaining scheduling information for process
590 * @p.
591 * @p contains the task_struct for process.
592 * Return 0 if permission is granted.
593 * @task_kill:
594 * Check permission before sending signal @sig to @p. @info can be NULL,
595 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
596 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
597 * from the kernel and should typically be permitted.
598 * SIGIO signals are handled separately by the send_sigiotask hook in
599 * file_security_ops.
600 * @p contains the task_struct for process.
601 * @info contains the signal information.
602 * @sig contains the signal value.
603 * Return 0 if permission is granted.
604 * @task_wait:
605 * Check permission before allowing a process to reap a child process @p
606 * and collect its status information.
607 * @p contains the task_struct for process.
608 * Return 0 if permission is granted.
609 * @task_prctl:
610 * Check permission before performing a process control operation on the
611 * current process.
612 * @option contains the operation.
613 * @arg2 contains a argument.
614 * @arg3 contains a argument.
615 * @arg4 contains a argument.
616 * @arg5 contains a argument.
617 * Return 0 if permission is granted.
618 * @task_reparent_to_init:
619 * Set the security attributes in @p->security for a kernel thread that
620 * is being reparented to the init task.
621 * @p contains the task_struct for the kernel thread.
622 * @task_to_inode:
623 * Set the security attributes for an inode based on an associated task's
624 * security attributes, e.g. for /proc/pid inodes.
625 * @p contains the task_struct for the task.
626 * @inode contains the inode structure for the inode.
628 * Security hooks for Netlink messaging.
630 * @netlink_send:
631 * Save security information for a netlink message so that permission
632 * checking can be performed when the message is processed. The security
633 * information can be saved using the eff_cap field of the
634 * netlink_skb_parms structure. Also may be used to provide fine
635 * grained control over message transmission.
636 * @sk associated sock of task sending the message.,
637 * @skb contains the sk_buff structure for the netlink message.
638 * Return 0 if the information was successfully saved and message
639 * is allowed to be transmitted.
640 * @netlink_recv:
641 * Check permission before processing the received netlink message in
642 * @skb.
643 * @skb contains the sk_buff structure for the netlink message.
644 * Return 0 if permission is granted.
646 * Security hooks for Unix domain networking.
648 * @unix_stream_connect:
649 * Check permissions before establishing a Unix domain stream connection
650 * between @sock and @other.
651 * @sock contains the socket structure.
652 * @other contains the peer socket structure.
653 * Return 0 if permission is granted.
654 * @unix_may_send:
655 * Check permissions before connecting or sending datagrams from @sock to
656 * @other.
657 * @sock contains the socket structure.
658 * @sock contains the peer socket structure.
659 * Return 0 if permission is granted.
661 * The @unix_stream_connect and @unix_may_send hooks were necessary because
662 * Linux provides an alternative to the conventional file name space for Unix
663 * domain sockets. Whereas binding and connecting to sockets in the file name
664 * space is mediated by the typical file permissions (and caught by the mknod
665 * and permission hooks in inode_security_ops), binding and connecting to
666 * sockets in the abstract name space is completely unmediated. Sufficient
667 * control of Unix domain sockets in the abstract name space isn't possible
668 * using only the socket layer hooks, since we need to know the actual target
669 * socket, which is not looked up until we are inside the af_unix code.
671 * Security hooks for socket operations.
673 * @socket_create:
674 * Check permissions prior to creating a new socket.
675 * @family contains the requested protocol family.
676 * @type contains the requested communications type.
677 * @protocol contains the requested protocol.
678 * @kern set to 1 if a kernel socket.
679 * Return 0 if permission is granted.
680 * @socket_post_create:
681 * This hook allows a module to update or allocate a per-socket security
682 * structure. Note that the security field was not added directly to the
683 * socket structure, but rather, the socket security information is stored
684 * in the associated inode. Typically, the inode alloc_security hook will
685 * allocate and and attach security information to
686 * sock->inode->i_security. This hook may be used to update the
687 * sock->inode->i_security field with additional information that wasn't
688 * available when the inode was allocated.
689 * @sock contains the newly created socket structure.
690 * @family contains the requested protocol family.
691 * @type contains the requested communications type.
692 * @protocol contains the requested protocol.
693 * @kern set to 1 if a kernel socket.
694 * @socket_bind:
695 * Check permission before socket protocol layer bind operation is
696 * performed and the socket @sock is bound to the address specified in the
697 * @address parameter.
698 * @sock contains the socket structure.
699 * @address contains the address to bind to.
700 * @addrlen contains the length of address.
701 * Return 0 if permission is granted.
702 * @socket_connect:
703 * Check permission before socket protocol layer connect operation
704 * attempts to connect socket @sock to a remote address, @address.
705 * @sock contains the socket structure.
706 * @address contains the address of remote endpoint.
707 * @addrlen contains the length of address.
708 * Return 0 if permission is granted.
709 * @socket_listen:
710 * Check permission before socket protocol layer listen operation.
711 * @sock contains the socket structure.
712 * @backlog contains the maximum length for the pending connection queue.
713 * Return 0 if permission is granted.
714 * @socket_accept:
715 * Check permission before accepting a new connection. Note that the new
716 * socket, @newsock, has been created and some information copied to it,
717 * but the accept operation has not actually been performed.
718 * @sock contains the listening socket structure.
719 * @newsock contains the newly created server socket for connection.
720 * Return 0 if permission is granted.
721 * @socket_post_accept:
722 * This hook allows a security module to copy security
723 * information into the newly created socket's inode.
724 * @sock contains the listening socket structure.
725 * @newsock contains the newly created server socket for connection.
726 * @socket_sendmsg:
727 * Check permission before transmitting a message to another socket.
728 * @sock contains the socket structure.
729 * @msg contains the message to be transmitted.
730 * @size contains the size of message.
731 * Return 0 if permission is granted.
732 * @socket_recvmsg:
733 * Check permission before receiving a message from a socket.
734 * @sock contains the socket structure.
735 * @msg contains the message structure.
736 * @size contains the size of message structure.
737 * @flags contains the operational flags.
738 * Return 0 if permission is granted.
739 * @socket_getsockname:
740 * Check permission before the local address (name) of the socket object
741 * @sock is retrieved.
742 * @sock contains the socket structure.
743 * Return 0 if permission is granted.
744 * @socket_getpeername:
745 * Check permission before the remote address (name) of a socket object
746 * @sock is retrieved.
747 * @sock contains the socket structure.
748 * Return 0 if permission is granted.
749 * @socket_getsockopt:
750 * Check permissions before retrieving the options associated with socket
751 * @sock.
752 * @sock contains the socket structure.
753 * @level contains the protocol level to retrieve option from.
754 * @optname contains the name of option to retrieve.
755 * Return 0 if permission is granted.
756 * @socket_setsockopt:
757 * Check permissions before setting the options associated with socket
758 * @sock.
759 * @sock contains the socket structure.
760 * @level contains the protocol level to set options for.
761 * @optname contains the name of the option to set.
762 * Return 0 if permission is granted.
763 * @socket_shutdown:
764 * Checks permission before all or part of a connection on the socket
765 * @sock is shut down.
766 * @sock contains the socket structure.
767 * @how contains the flag indicating how future sends and receives are handled.
768 * Return 0 if permission is granted.
769 * @socket_sock_rcv_skb:
770 * Check permissions on incoming network packets. This hook is distinct
771 * from Netfilter's IP input hooks since it is the first time that the
772 * incoming sk_buff @skb has been associated with a particular socket, @sk.
773 * @sk contains the sock (not socket) associated with the incoming sk_buff.
774 * @skb contains the incoming network data.
775 * @socket_getpeersec:
776 * This hook allows the security module to provide peer socket security
777 * state to userspace via getsockopt SO_GETPEERSEC.
778 * @sock is the local socket.
779 * @optval userspace memory where the security state is to be copied.
780 * @optlen userspace int where the module should copy the actual length
781 * of the security state.
782 * @len as input is the maximum length to copy to userspace provided
783 * by the caller.
784 * Return 0 if all is well, otherwise, typical getsockopt return
785 * values.
786 * @sk_alloc_security:
787 * Allocate and attach a security structure to the sk->sk_security field,
788 * which is used to copy security attributes between local stream sockets.
789 * @sk_free_security:
790 * Deallocate security structure.
792 * Security hooks affecting all Key Management operations
794 * @key_alloc:
795 * Permit allocation of a key and assign security data. Note that key does
796 * not have a serial number assigned at this point.
797 * @key points to the key.
798 * Return 0 if permission is granted, -ve error otherwise.
799 * @key_free:
800 * Notification of destruction; free security data.
801 * @key points to the key.
802 * No return value.
803 * @key_permission:
804 * See whether a specific operational right is granted to a process on a
805 * key.
806 * @key_ref refers to the key (key pointer + possession attribute bit).
807 * @context points to the process to provide the context against which to
808 * evaluate the security data on the key.
809 * @perm describes the combination of permissions required of this key.
810 * Return 1 if permission granted, 0 if permission denied and -ve it the
811 * normal permissions model should be effected.
813 * Security hooks affecting all System V IPC operations.
815 * @ipc_permission:
816 * Check permissions for access to IPC
817 * @ipcp contains the kernel IPC permission structure
818 * @flag contains the desired (requested) permission set
819 * Return 0 if permission is granted.
821 * Security hooks for individual messages held in System V IPC message queues
822 * @msg_msg_alloc_security:
823 * Allocate and attach a security structure to the msg->security field.
824 * The security field is initialized to NULL when the structure is first
825 * created.
826 * @msg contains the message structure to be modified.
827 * Return 0 if operation was successful and permission is granted.
828 * @msg_msg_free_security:
829 * Deallocate the security structure for this message.
830 * @msg contains the message structure to be modified.
832 * Security hooks for System V IPC Message Queues
834 * @msg_queue_alloc_security:
835 * Allocate and attach a security structure to the
836 * msq->q_perm.security field. The security field is initialized to
837 * NULL when the structure is first created.
838 * @msq contains the message queue structure to be modified.
839 * Return 0 if operation was successful and permission is granted.
840 * @msg_queue_free_security:
841 * Deallocate security structure for this message queue.
842 * @msq contains the message queue structure to be modified.
843 * @msg_queue_associate:
844 * Check permission when a message queue is requested through the
845 * msgget system call. This hook is only called when returning the
846 * message queue identifier for an existing message queue, not when a
847 * new message queue is created.
848 * @msq contains the message queue to act upon.
849 * @msqflg contains the operation control flags.
850 * Return 0 if permission is granted.
851 * @msg_queue_msgctl:
852 * Check permission when a message control operation specified by @cmd
853 * is to be performed on the message queue @msq.
854 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
855 * @msq contains the message queue to act upon. May be NULL.
856 * @cmd contains the operation to be performed.
857 * Return 0 if permission is granted.
858 * @msg_queue_msgsnd:
859 * Check permission before a message, @msg, is enqueued on the message
860 * queue, @msq.
861 * @msq contains the message queue to send message to.
862 * @msg contains the message to be enqueued.
863 * @msqflg contains operational flags.
864 * Return 0 if permission is granted.
865 * @msg_queue_msgrcv:
866 * Check permission before a message, @msg, is removed from the message
867 * queue, @msq. The @target task structure contains a pointer to the
868 * process that will be receiving the message (not equal to the current
869 * process when inline receives are being performed).
870 * @msq contains the message queue to retrieve message from.
871 * @msg contains the message destination.
872 * @target contains the task structure for recipient process.
873 * @type contains the type of message requested.
874 * @mode contains the operational flags.
875 * Return 0 if permission is granted.
877 * Security hooks for System V Shared Memory Segments
879 * @shm_alloc_security:
880 * Allocate and attach a security structure to the shp->shm_perm.security
881 * field. The security field is initialized to NULL when the structure is
882 * first created.
883 * @shp contains the shared memory structure to be modified.
884 * Return 0 if operation was successful and permission is granted.
885 * @shm_free_security:
886 * Deallocate the security struct for this memory segment.
887 * @shp contains the shared memory structure to be modified.
888 * @shm_associate:
889 * Check permission when a shared memory region is requested through the
890 * shmget system call. This hook is only called when returning the shared
891 * memory region identifier for an existing region, not when a new shared
892 * memory region is created.
893 * @shp contains the shared memory structure to be modified.
894 * @shmflg contains the operation control flags.
895 * Return 0 if permission is granted.
896 * @shm_shmctl:
897 * Check permission when a shared memory control operation specified by
898 * @cmd is to be performed on the shared memory region @shp.
899 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
900 * @shp contains shared memory structure to be modified.
901 * @cmd contains the operation to be performed.
902 * Return 0 if permission is granted.
903 * @shm_shmat:
904 * Check permissions prior to allowing the shmat system call to attach the
905 * shared memory segment @shp to the data segment of the calling process.
906 * The attaching address is specified by @shmaddr.
907 * @shp contains the shared memory structure to be modified.
908 * @shmaddr contains the address to attach memory region to.
909 * @shmflg contains the operational flags.
910 * Return 0 if permission is granted.
912 * Security hooks for System V Semaphores
914 * @sem_alloc_security:
915 * Allocate and attach a security structure to the sma->sem_perm.security
916 * field. The security field is initialized to NULL when the structure is
917 * first created.
918 * @sma contains the semaphore structure
919 * Return 0 if operation was successful and permission is granted.
920 * @sem_free_security:
921 * deallocate security struct for this semaphore
922 * @sma contains the semaphore structure.
923 * @sem_associate:
924 * Check permission when a semaphore is requested through the semget
925 * system call. This hook is only called when returning the semaphore
926 * identifier for an existing semaphore, not when a new one must be
927 * created.
928 * @sma contains the semaphore structure.
929 * @semflg contains the operation control flags.
930 * Return 0 if permission is granted.
931 * @sem_semctl:
932 * Check permission when a semaphore operation specified by @cmd is to be
933 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
934 * IPC_INFO or SEM_INFO.
935 * @sma contains the semaphore structure. May be NULL.
936 * @cmd contains the operation to be performed.
937 * Return 0 if permission is granted.
938 * @sem_semop
939 * Check permissions before performing operations on members of the
940 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
941 * may be modified.
942 * @sma contains the semaphore structure.
943 * @sops contains the operations to perform.
944 * @nsops contains the number of operations to perform.
945 * @alter contains the flag indicating whether changes are to be made.
946 * Return 0 if permission is granted.
948 * @ptrace:
949 * Check permission before allowing the @parent process to trace the
950 * @child process.
951 * Security modules may also want to perform a process tracing check
952 * during an execve in the set_security or apply_creds hooks of
953 * binprm_security_ops if the process is being traced and its security
954 * attributes would be changed by the execve.
955 * @parent contains the task_struct structure for parent process.
956 * @child contains the task_struct structure for child process.
957 * Return 0 if permission is granted.
958 * @capget:
959 * Get the @effective, @inheritable, and @permitted capability sets for
960 * the @target process. The hook may also perform permission checking to
961 * determine if the current process is allowed to see the capability sets
962 * of the @target process.
963 * @target contains the task_struct structure for target process.
964 * @effective contains the effective capability set.
965 * @inheritable contains the inheritable capability set.
966 * @permitted contains the permitted capability set.
967 * Return 0 if the capability sets were successfully obtained.
968 * @capset_check:
969 * Check permission before setting the @effective, @inheritable, and
970 * @permitted capability sets for the @target process.
971 * Caveat: @target is also set to current if a set of processes is
972 * specified (i.e. all processes other than current and init or a
973 * particular process group). Hence, the capset_set hook may need to
974 * revalidate permission to the actual target process.
975 * @target contains the task_struct structure for target process.
976 * @effective contains the effective capability set.
977 * @inheritable contains the inheritable capability set.
978 * @permitted contains the permitted capability set.
979 * Return 0 if permission is granted.
980 * @capset_set:
981 * Set the @effective, @inheritable, and @permitted capability sets for
982 * the @target process. Since capset_check cannot always check permission
983 * to the real @target process, this hook may also perform permission
984 * checking to determine if the current process is allowed to set the
985 * capability sets of the @target process. However, this hook has no way
986 * of returning an error due to the structure of the sys_capset code.
987 * @target contains the task_struct structure for target process.
988 * @effective contains the effective capability set.
989 * @inheritable contains the inheritable capability set.
990 * @permitted contains the permitted capability set.
991 * @acct:
992 * Check permission before enabling or disabling process accounting. If
993 * accounting is being enabled, then @file refers to the open file used to
994 * store accounting records. If accounting is being disabled, then @file
995 * is NULL.
996 * @file contains the file structure for the accounting file (may be NULL).
997 * Return 0 if permission is granted.
998 * @sysctl:
999 * Check permission before accessing the @table sysctl variable in the
1000 * manner specified by @op.
1001 * @table contains the ctl_table structure for the sysctl variable.
1002 * @op contains the operation (001 = search, 002 = write, 004 = read).
1003 * Return 0 if permission is granted.
1004 * @capable:
1005 * Check whether the @tsk process has the @cap capability.
1006 * @tsk contains the task_struct for the process.
1007 * @cap contains the capability <include/linux/capability.h>.
1008 * Return 0 if the capability is granted for @tsk.
1009 * @syslog:
1010 * Check permission before accessing the kernel message ring or changing
1011 * logging to the console.
1012 * See the syslog(2) manual page for an explanation of the @type values.
1013 * @type contains the type of action.
1014 * Return 0 if permission is granted.
1015 * @settime:
1016 * Check permission to change the system time.
1017 * struct timespec and timezone are defined in include/linux/time.h
1018 * @ts contains new time
1019 * @tz contains new timezone
1020 * Return 0 if permission is granted.
1021 * @vm_enough_memory:
1022 * Check permissions for allocating a new virtual mapping.
1023 * @pages contains the number of pages.
1024 * Return 0 if permission is granted.
1026 * @register_security:
1027 * allow module stacking.
1028 * @name contains the name of the security module being stacked.
1029 * @ops contains a pointer to the struct security_operations of the module to stack.
1030 * @unregister_security:
1031 * remove a stacked module.
1032 * @name contains the name of the security module being unstacked.
1033 * @ops contains a pointer to the struct security_operations of the module to unstack.
1035 * This is the main security structure.
1037 struct security_operations {
1038 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1039 int (*capget) (struct task_struct * target,
1040 kernel_cap_t * effective,
1041 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1042 int (*capset_check) (struct task_struct * target,
1043 kernel_cap_t * effective,
1044 kernel_cap_t * inheritable,
1045 kernel_cap_t * permitted);
1046 void (*capset_set) (struct task_struct * target,
1047 kernel_cap_t * effective,
1048 kernel_cap_t * inheritable,
1049 kernel_cap_t * permitted);
1050 int (*acct) (struct file * file);
1051 int (*sysctl) (struct ctl_table * table, int op);
1052 int (*capable) (struct task_struct * tsk, int cap);
1053 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1054 int (*quota_on) (struct dentry * dentry);
1055 int (*syslog) (int type);
1056 int (*settime) (struct timespec *ts, struct timezone *tz);
1057 int (*vm_enough_memory) (long pages);
1059 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1060 void (*bprm_free_security) (struct linux_binprm * bprm);
1061 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1062 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1063 int (*bprm_set_security) (struct linux_binprm * bprm);
1064 int (*bprm_check_security) (struct linux_binprm * bprm);
1065 int (*bprm_secureexec) (struct linux_binprm * bprm);
1067 int (*sb_alloc_security) (struct super_block * sb);
1068 void (*sb_free_security) (struct super_block * sb);
1069 int (*sb_copy_data)(struct file_system_type *type,
1070 void *orig, void *copy);
1071 int (*sb_kern_mount) (struct super_block *sb, void *data);
1072 int (*sb_statfs) (struct super_block * sb);
1073 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1074 char *type, unsigned long flags, void *data);
1075 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1076 int (*sb_umount) (struct vfsmount * mnt, int flags);
1077 void (*sb_umount_close) (struct vfsmount * mnt);
1078 void (*sb_umount_busy) (struct vfsmount * mnt);
1079 void (*sb_post_remount) (struct vfsmount * mnt,
1080 unsigned long flags, void *data);
1081 void (*sb_post_mountroot) (void);
1082 void (*sb_post_addmount) (struct vfsmount * mnt,
1083 struct nameidata * mountpoint_nd);
1084 int (*sb_pivotroot) (struct nameidata * old_nd,
1085 struct nameidata * new_nd);
1086 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1087 struct nameidata * new_nd);
1089 int (*inode_alloc_security) (struct inode *inode);
1090 void (*inode_free_security) (struct inode *inode);
1091 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1092 char **name, void **value, size_t *len);
1093 int (*inode_create) (struct inode *dir,
1094 struct dentry *dentry, int mode);
1095 int (*inode_link) (struct dentry *old_dentry,
1096 struct inode *dir, struct dentry *new_dentry);
1097 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1098 int (*inode_symlink) (struct inode *dir,
1099 struct dentry *dentry, const char *old_name);
1100 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1101 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1102 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1103 int mode, dev_t dev);
1104 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1105 struct inode *new_dir, struct dentry *new_dentry);
1106 int (*inode_readlink) (struct dentry *dentry);
1107 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1108 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1109 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1110 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1111 void (*inode_delete) (struct inode *inode);
1112 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1113 size_t size, int flags);
1114 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1115 size_t size, int flags);
1116 int (*inode_getxattr) (struct dentry *dentry, char *name);
1117 int (*inode_listxattr) (struct dentry *dentry);
1118 int (*inode_removexattr) (struct dentry *dentry, char *name);
1119 int (*inode_getsecurity)(struct inode *inode, const char *name, void *buffer, size_t size, int err);
1120 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1121 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1123 int (*file_permission) (struct file * file, int mask);
1124 int (*file_alloc_security) (struct file * file);
1125 void (*file_free_security) (struct file * file);
1126 int (*file_ioctl) (struct file * file, unsigned int cmd,
1127 unsigned long arg);
1128 int (*file_mmap) (struct file * file,
1129 unsigned long reqprot,
1130 unsigned long prot, unsigned long flags);
1131 int (*file_mprotect) (struct vm_area_struct * vma,
1132 unsigned long reqprot,
1133 unsigned long prot);
1134 int (*file_lock) (struct file * file, unsigned int cmd);
1135 int (*file_fcntl) (struct file * file, unsigned int cmd,
1136 unsigned long arg);
1137 int (*file_set_fowner) (struct file * file);
1138 int (*file_send_sigiotask) (struct task_struct * tsk,
1139 struct fown_struct * fown, int sig);
1140 int (*file_receive) (struct file * file);
1142 int (*task_create) (unsigned long clone_flags);
1143 int (*task_alloc_security) (struct task_struct * p);
1144 void (*task_free_security) (struct task_struct * p);
1145 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1146 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1147 uid_t old_euid, uid_t old_suid, int flags);
1148 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1149 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1150 int (*task_getpgid) (struct task_struct * p);
1151 int (*task_getsid) (struct task_struct * p);
1152 int (*task_setgroups) (struct group_info *group_info);
1153 int (*task_setnice) (struct task_struct * p, int nice);
1154 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1155 int (*task_setscheduler) (struct task_struct * p, int policy,
1156 struct sched_param * lp);
1157 int (*task_getscheduler) (struct task_struct * p);
1158 int (*task_kill) (struct task_struct * p,
1159 struct siginfo * info, int sig);
1160 int (*task_wait) (struct task_struct * p);
1161 int (*task_prctl) (int option, unsigned long arg2,
1162 unsigned long arg3, unsigned long arg4,
1163 unsigned long arg5);
1164 void (*task_reparent_to_init) (struct task_struct * p);
1165 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1167 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1169 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1170 void (*msg_msg_free_security) (struct msg_msg * msg);
1172 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1173 void (*msg_queue_free_security) (struct msg_queue * msq);
1174 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1175 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1176 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1177 struct msg_msg * msg, int msqflg);
1178 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1179 struct msg_msg * msg,
1180 struct task_struct * target,
1181 long type, int mode);
1183 int (*shm_alloc_security) (struct shmid_kernel * shp);
1184 void (*shm_free_security) (struct shmid_kernel * shp);
1185 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1186 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1187 int (*shm_shmat) (struct shmid_kernel * shp,
1188 char __user *shmaddr, int shmflg);
1190 int (*sem_alloc_security) (struct sem_array * sma);
1191 void (*sem_free_security) (struct sem_array * sma);
1192 int (*sem_associate) (struct sem_array * sma, int semflg);
1193 int (*sem_semctl) (struct sem_array * sma, int cmd);
1194 int (*sem_semop) (struct sem_array * sma,
1195 struct sembuf * sops, unsigned nsops, int alter);
1197 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
1198 int (*netlink_recv) (struct sk_buff * skb);
1200 /* allow module stacking */
1201 int (*register_security) (const char *name,
1202 struct security_operations *ops);
1203 int (*unregister_security) (const char *name,
1204 struct security_operations *ops);
1206 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1208 int (*getprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1209 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1211 #ifdef CONFIG_SECURITY_NETWORK
1212 int (*unix_stream_connect) (struct socket * sock,
1213 struct socket * other, struct sock * newsk);
1214 int (*unix_may_send) (struct socket * sock, struct socket * other);
1216 int (*socket_create) (int family, int type, int protocol, int kern);
1217 void (*socket_post_create) (struct socket * sock, int family,
1218 int type, int protocol, int kern);
1219 int (*socket_bind) (struct socket * sock,
1220 struct sockaddr * address, int addrlen);
1221 int (*socket_connect) (struct socket * sock,
1222 struct sockaddr * address, int addrlen);
1223 int (*socket_listen) (struct socket * sock, int backlog);
1224 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1225 void (*socket_post_accept) (struct socket * sock,
1226 struct socket * newsock);
1227 int (*socket_sendmsg) (struct socket * sock,
1228 struct msghdr * msg, int size);
1229 int (*socket_recvmsg) (struct socket * sock,
1230 struct msghdr * msg, int size, int flags);
1231 int (*socket_getsockname) (struct socket * sock);
1232 int (*socket_getpeername) (struct socket * sock);
1233 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1234 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1235 int (*socket_shutdown) (struct socket * sock, int how);
1236 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
1237 int (*socket_getpeersec) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1238 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1239 void (*sk_free_security) (struct sock *sk);
1240 #endif /* CONFIG_SECURITY_NETWORK */
1242 /* key management security hooks */
1243 #ifdef CONFIG_KEYS
1244 int (*key_alloc)(struct key *key);
1245 void (*key_free)(struct key *key);
1246 int (*key_permission)(key_ref_t key_ref,
1247 struct task_struct *context,
1248 key_perm_t perm);
1250 #endif /* CONFIG_KEYS */
1254 /* global variables */
1255 extern struct security_operations *security_ops;
1257 /* inline stuff */
1258 static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1260 return security_ops->ptrace (parent, child);
1263 static inline int security_capget (struct task_struct *target,
1264 kernel_cap_t *effective,
1265 kernel_cap_t *inheritable,
1266 kernel_cap_t *permitted)
1268 return security_ops->capget (target, effective, inheritable, permitted);
1271 static inline int security_capset_check (struct task_struct *target,
1272 kernel_cap_t *effective,
1273 kernel_cap_t *inheritable,
1274 kernel_cap_t *permitted)
1276 return security_ops->capset_check (target, effective, inheritable, permitted);
1279 static inline void security_capset_set (struct task_struct *target,
1280 kernel_cap_t *effective,
1281 kernel_cap_t *inheritable,
1282 kernel_cap_t *permitted)
1284 security_ops->capset_set (target, effective, inheritable, permitted);
1287 static inline int security_acct (struct file *file)
1289 return security_ops->acct (file);
1292 static inline int security_sysctl(struct ctl_table *table, int op)
1294 return security_ops->sysctl(table, op);
1297 static inline int security_quotactl (int cmds, int type, int id,
1298 struct super_block *sb)
1300 return security_ops->quotactl (cmds, type, id, sb);
1303 static inline int security_quota_on (struct dentry * dentry)
1305 return security_ops->quota_on (dentry);
1308 static inline int security_syslog(int type)
1310 return security_ops->syslog(type);
1313 static inline int security_settime(struct timespec *ts, struct timezone *tz)
1315 return security_ops->settime(ts, tz);
1319 static inline int security_vm_enough_memory(long pages)
1321 return security_ops->vm_enough_memory(pages);
1324 static inline int security_bprm_alloc (struct linux_binprm *bprm)
1326 return security_ops->bprm_alloc_security (bprm);
1328 static inline void security_bprm_free (struct linux_binprm *bprm)
1330 security_ops->bprm_free_security (bprm);
1332 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1334 security_ops->bprm_apply_creds (bprm, unsafe);
1336 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1338 security_ops->bprm_post_apply_creds (bprm);
1340 static inline int security_bprm_set (struct linux_binprm *bprm)
1342 return security_ops->bprm_set_security (bprm);
1345 static inline int security_bprm_check (struct linux_binprm *bprm)
1347 return security_ops->bprm_check_security (bprm);
1350 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1352 return security_ops->bprm_secureexec (bprm);
1355 static inline int security_sb_alloc (struct super_block *sb)
1357 return security_ops->sb_alloc_security (sb);
1360 static inline void security_sb_free (struct super_block *sb)
1362 security_ops->sb_free_security (sb);
1365 static inline int security_sb_copy_data (struct file_system_type *type,
1366 void *orig, void *copy)
1368 return security_ops->sb_copy_data (type, orig, copy);
1371 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1373 return security_ops->sb_kern_mount (sb, data);
1376 static inline int security_sb_statfs (struct super_block *sb)
1378 return security_ops->sb_statfs (sb);
1381 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1382 char *type, unsigned long flags,
1383 void *data)
1385 return security_ops->sb_mount (dev_name, nd, type, flags, data);
1388 static inline int security_sb_check_sb (struct vfsmount *mnt,
1389 struct nameidata *nd)
1391 return security_ops->sb_check_sb (mnt, nd);
1394 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1396 return security_ops->sb_umount (mnt, flags);
1399 static inline void security_sb_umount_close (struct vfsmount *mnt)
1401 security_ops->sb_umount_close (mnt);
1404 static inline void security_sb_umount_busy (struct vfsmount *mnt)
1406 security_ops->sb_umount_busy (mnt);
1409 static inline void security_sb_post_remount (struct vfsmount *mnt,
1410 unsigned long flags, void *data)
1412 security_ops->sb_post_remount (mnt, flags, data);
1415 static inline void security_sb_post_mountroot (void)
1417 security_ops->sb_post_mountroot ();
1420 static inline void security_sb_post_addmount (struct vfsmount *mnt,
1421 struct nameidata *mountpoint_nd)
1423 security_ops->sb_post_addmount (mnt, mountpoint_nd);
1426 static inline int security_sb_pivotroot (struct nameidata *old_nd,
1427 struct nameidata *new_nd)
1429 return security_ops->sb_pivotroot (old_nd, new_nd);
1432 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1433 struct nameidata *new_nd)
1435 security_ops->sb_post_pivotroot (old_nd, new_nd);
1438 static inline int security_inode_alloc (struct inode *inode)
1440 if (unlikely (IS_PRIVATE (inode)))
1441 return 0;
1442 return security_ops->inode_alloc_security (inode);
1445 static inline void security_inode_free (struct inode *inode)
1447 if (unlikely (IS_PRIVATE (inode)))
1448 return;
1449 security_ops->inode_free_security (inode);
1452 static inline int security_inode_init_security (struct inode *inode,
1453 struct inode *dir,
1454 char **name,
1455 void **value,
1456 size_t *len)
1458 if (unlikely (IS_PRIVATE (inode)))
1459 return -EOPNOTSUPP;
1460 return security_ops->inode_init_security (inode, dir, name, value, len);
1463 static inline int security_inode_create (struct inode *dir,
1464 struct dentry *dentry,
1465 int mode)
1467 if (unlikely (IS_PRIVATE (dir)))
1468 return 0;
1469 return security_ops->inode_create (dir, dentry, mode);
1472 static inline int security_inode_link (struct dentry *old_dentry,
1473 struct inode *dir,
1474 struct dentry *new_dentry)
1476 if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
1477 return 0;
1478 return security_ops->inode_link (old_dentry, dir, new_dentry);
1481 static inline int security_inode_unlink (struct inode *dir,
1482 struct dentry *dentry)
1484 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1485 return 0;
1486 return security_ops->inode_unlink (dir, dentry);
1489 static inline int security_inode_symlink (struct inode *dir,
1490 struct dentry *dentry,
1491 const char *old_name)
1493 if (unlikely (IS_PRIVATE (dir)))
1494 return 0;
1495 return security_ops->inode_symlink (dir, dentry, old_name);
1498 static inline int security_inode_mkdir (struct inode *dir,
1499 struct dentry *dentry,
1500 int mode)
1502 if (unlikely (IS_PRIVATE (dir)))
1503 return 0;
1504 return security_ops->inode_mkdir (dir, dentry, mode);
1507 static inline int security_inode_rmdir (struct inode *dir,
1508 struct dentry *dentry)
1510 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1511 return 0;
1512 return security_ops->inode_rmdir (dir, dentry);
1515 static inline int security_inode_mknod (struct inode *dir,
1516 struct dentry *dentry,
1517 int mode, dev_t dev)
1519 if (unlikely (IS_PRIVATE (dir)))
1520 return 0;
1521 return security_ops->inode_mknod (dir, dentry, mode, dev);
1524 static inline int security_inode_rename (struct inode *old_dir,
1525 struct dentry *old_dentry,
1526 struct inode *new_dir,
1527 struct dentry *new_dentry)
1529 if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
1530 (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
1531 return 0;
1532 return security_ops->inode_rename (old_dir, old_dentry,
1533 new_dir, new_dentry);
1536 static inline int security_inode_readlink (struct dentry *dentry)
1538 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1539 return 0;
1540 return security_ops->inode_readlink (dentry);
1543 static inline int security_inode_follow_link (struct dentry *dentry,
1544 struct nameidata *nd)
1546 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1547 return 0;
1548 return security_ops->inode_follow_link (dentry, nd);
1551 static inline int security_inode_permission (struct inode *inode, int mask,
1552 struct nameidata *nd)
1554 if (unlikely (IS_PRIVATE (inode)))
1555 return 0;
1556 return security_ops->inode_permission (inode, mask, nd);
1559 static inline int security_inode_setattr (struct dentry *dentry,
1560 struct iattr *attr)
1562 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1563 return 0;
1564 return security_ops->inode_setattr (dentry, attr);
1567 static inline int security_inode_getattr (struct vfsmount *mnt,
1568 struct dentry *dentry)
1570 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1571 return 0;
1572 return security_ops->inode_getattr (mnt, dentry);
1575 static inline void security_inode_delete (struct inode *inode)
1577 if (unlikely (IS_PRIVATE (inode)))
1578 return;
1579 security_ops->inode_delete (inode);
1582 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1583 void *value, size_t size, int flags)
1585 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1586 return 0;
1587 return security_ops->inode_setxattr (dentry, name, value, size, flags);
1590 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1591 void *value, size_t size, int flags)
1593 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1594 return;
1595 security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1598 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1600 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1601 return 0;
1602 return security_ops->inode_getxattr (dentry, name);
1605 static inline int security_inode_listxattr (struct dentry *dentry)
1607 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1608 return 0;
1609 return security_ops->inode_listxattr (dentry);
1612 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1614 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1615 return 0;
1616 return security_ops->inode_removexattr (dentry, name);
1619 static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size, int err)
1621 if (unlikely (IS_PRIVATE (inode)))
1622 return 0;
1623 return security_ops->inode_getsecurity(inode, name, buffer, size, err);
1626 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1628 if (unlikely (IS_PRIVATE (inode)))
1629 return 0;
1630 return security_ops->inode_setsecurity(inode, name, value, size, flags);
1633 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1635 if (unlikely (IS_PRIVATE (inode)))
1636 return 0;
1637 return security_ops->inode_listsecurity(inode, buffer, buffer_size);
1640 static inline int security_file_permission (struct file *file, int mask)
1642 return security_ops->file_permission (file, mask);
1645 static inline int security_file_alloc (struct file *file)
1647 return security_ops->file_alloc_security (file);
1650 static inline void security_file_free (struct file *file)
1652 security_ops->file_free_security (file);
1655 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1656 unsigned long arg)
1658 return security_ops->file_ioctl (file, cmd, arg);
1661 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1662 unsigned long prot,
1663 unsigned long flags)
1665 return security_ops->file_mmap (file, reqprot, prot, flags);
1668 static inline int security_file_mprotect (struct vm_area_struct *vma,
1669 unsigned long reqprot,
1670 unsigned long prot)
1672 return security_ops->file_mprotect (vma, reqprot, prot);
1675 static inline int security_file_lock (struct file *file, unsigned int cmd)
1677 return security_ops->file_lock (file, cmd);
1680 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1681 unsigned long arg)
1683 return security_ops->file_fcntl (file, cmd, arg);
1686 static inline int security_file_set_fowner (struct file *file)
1688 return security_ops->file_set_fowner (file);
1691 static inline int security_file_send_sigiotask (struct task_struct *tsk,
1692 struct fown_struct *fown,
1693 int sig)
1695 return security_ops->file_send_sigiotask (tsk, fown, sig);
1698 static inline int security_file_receive (struct file *file)
1700 return security_ops->file_receive (file);
1703 static inline int security_task_create (unsigned long clone_flags)
1705 return security_ops->task_create (clone_flags);
1708 static inline int security_task_alloc (struct task_struct *p)
1710 return security_ops->task_alloc_security (p);
1713 static inline void security_task_free (struct task_struct *p)
1715 security_ops->task_free_security (p);
1718 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1719 int flags)
1721 return security_ops->task_setuid (id0, id1, id2, flags);
1724 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1725 uid_t old_suid, int flags)
1727 return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1730 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1731 int flags)
1733 return security_ops->task_setgid (id0, id1, id2, flags);
1736 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1738 return security_ops->task_setpgid (p, pgid);
1741 static inline int security_task_getpgid (struct task_struct *p)
1743 return security_ops->task_getpgid (p);
1746 static inline int security_task_getsid (struct task_struct *p)
1748 return security_ops->task_getsid (p);
1751 static inline int security_task_setgroups (struct group_info *group_info)
1753 return security_ops->task_setgroups (group_info);
1756 static inline int security_task_setnice (struct task_struct *p, int nice)
1758 return security_ops->task_setnice (p, nice);
1761 static inline int security_task_setrlimit (unsigned int resource,
1762 struct rlimit *new_rlim)
1764 return security_ops->task_setrlimit (resource, new_rlim);
1767 static inline int security_task_setscheduler (struct task_struct *p,
1768 int policy,
1769 struct sched_param *lp)
1771 return security_ops->task_setscheduler (p, policy, lp);
1774 static inline int security_task_getscheduler (struct task_struct *p)
1776 return security_ops->task_getscheduler (p);
1779 static inline int security_task_kill (struct task_struct *p,
1780 struct siginfo *info, int sig)
1782 return security_ops->task_kill (p, info, sig);
1785 static inline int security_task_wait (struct task_struct *p)
1787 return security_ops->task_wait (p);
1790 static inline int security_task_prctl (int option, unsigned long arg2,
1791 unsigned long arg3,
1792 unsigned long arg4,
1793 unsigned long arg5)
1795 return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1798 static inline void security_task_reparent_to_init (struct task_struct *p)
1800 security_ops->task_reparent_to_init (p);
1803 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1805 security_ops->task_to_inode(p, inode);
1808 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
1809 short flag)
1811 return security_ops->ipc_permission (ipcp, flag);
1814 static inline int security_msg_msg_alloc (struct msg_msg * msg)
1816 return security_ops->msg_msg_alloc_security (msg);
1819 static inline void security_msg_msg_free (struct msg_msg * msg)
1821 security_ops->msg_msg_free_security(msg);
1824 static inline int security_msg_queue_alloc (struct msg_queue *msq)
1826 return security_ops->msg_queue_alloc_security (msq);
1829 static inline void security_msg_queue_free (struct msg_queue *msq)
1831 security_ops->msg_queue_free_security (msq);
1834 static inline int security_msg_queue_associate (struct msg_queue * msq,
1835 int msqflg)
1837 return security_ops->msg_queue_associate (msq, msqflg);
1840 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
1842 return security_ops->msg_queue_msgctl (msq, cmd);
1845 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
1846 struct msg_msg * msg, int msqflg)
1848 return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
1851 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
1852 struct msg_msg * msg,
1853 struct task_struct * target,
1854 long type, int mode)
1856 return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
1859 static inline int security_shm_alloc (struct shmid_kernel *shp)
1861 return security_ops->shm_alloc_security (shp);
1864 static inline void security_shm_free (struct shmid_kernel *shp)
1866 security_ops->shm_free_security (shp);
1869 static inline int security_shm_associate (struct shmid_kernel * shp,
1870 int shmflg)
1872 return security_ops->shm_associate(shp, shmflg);
1875 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
1877 return security_ops->shm_shmctl (shp, cmd);
1880 static inline int security_shm_shmat (struct shmid_kernel * shp,
1881 char __user *shmaddr, int shmflg)
1883 return security_ops->shm_shmat(shp, shmaddr, shmflg);
1886 static inline int security_sem_alloc (struct sem_array *sma)
1888 return security_ops->sem_alloc_security (sma);
1891 static inline void security_sem_free (struct sem_array *sma)
1893 security_ops->sem_free_security (sma);
1896 static inline int security_sem_associate (struct sem_array * sma, int semflg)
1898 return security_ops->sem_associate (sma, semflg);
1901 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
1903 return security_ops->sem_semctl(sma, cmd);
1906 static inline int security_sem_semop (struct sem_array * sma,
1907 struct sembuf * sops, unsigned nsops,
1908 int alter)
1910 return security_ops->sem_semop(sma, sops, nsops, alter);
1913 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
1915 if (unlikely (inode && IS_PRIVATE (inode)))
1916 return;
1917 security_ops->d_instantiate (dentry, inode);
1920 static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
1922 return security_ops->getprocattr(p, name, value, size);
1925 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
1927 return security_ops->setprocattr(p, name, value, size);
1930 static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
1932 return security_ops->netlink_send(sk, skb);
1935 static inline int security_netlink_recv(struct sk_buff * skb)
1937 return security_ops->netlink_recv(skb);
1940 /* prototypes */
1941 extern int security_init (void);
1942 extern int register_security (struct security_operations *ops);
1943 extern int unregister_security (struct security_operations *ops);
1944 extern int mod_reg_security (const char *name, struct security_operations *ops);
1945 extern int mod_unreg_security (const char *name, struct security_operations *ops);
1946 extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
1947 struct dentry *parent, void *data,
1948 struct file_operations *fops);
1949 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1950 extern void securityfs_remove(struct dentry *dentry);
1953 #else /* CONFIG_SECURITY */
1956 * This is the default capabilities functionality. Most of these functions
1957 * are just stubbed out, but a few must call the proper capable code.
1960 static inline int security_init(void)
1962 return 0;
1965 static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
1967 return cap_ptrace (parent, child);
1970 static inline int security_capget (struct task_struct *target,
1971 kernel_cap_t *effective,
1972 kernel_cap_t *inheritable,
1973 kernel_cap_t *permitted)
1975 return cap_capget (target, effective, inheritable, permitted);
1978 static inline int security_capset_check (struct task_struct *target,
1979 kernel_cap_t *effective,
1980 kernel_cap_t *inheritable,
1981 kernel_cap_t *permitted)
1983 return cap_capset_check (target, effective, inheritable, permitted);
1986 static inline void security_capset_set (struct task_struct *target,
1987 kernel_cap_t *effective,
1988 kernel_cap_t *inheritable,
1989 kernel_cap_t *permitted)
1991 cap_capset_set (target, effective, inheritable, permitted);
1994 static inline int security_acct (struct file *file)
1996 return 0;
1999 static inline int security_sysctl(struct ctl_table *table, int op)
2001 return 0;
2004 static inline int security_quotactl (int cmds, int type, int id,
2005 struct super_block * sb)
2007 return 0;
2010 static inline int security_quota_on (struct dentry * dentry)
2012 return 0;
2015 static inline int security_syslog(int type)
2017 return cap_syslog(type);
2020 static inline int security_settime(struct timespec *ts, struct timezone *tz)
2022 return cap_settime(ts, tz);
2025 static inline int security_vm_enough_memory(long pages)
2027 return cap_vm_enough_memory(pages);
2030 static inline int security_bprm_alloc (struct linux_binprm *bprm)
2032 return 0;
2035 static inline void security_bprm_free (struct linux_binprm *bprm)
2038 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
2040 cap_bprm_apply_creds (bprm, unsafe);
2043 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
2045 return;
2048 static inline int security_bprm_set (struct linux_binprm *bprm)
2050 return cap_bprm_set_security (bprm);
2053 static inline int security_bprm_check (struct linux_binprm *bprm)
2055 return 0;
2058 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
2060 return cap_bprm_secureexec(bprm);
2063 static inline int security_sb_alloc (struct super_block *sb)
2065 return 0;
2068 static inline void security_sb_free (struct super_block *sb)
2071 static inline int security_sb_copy_data (struct file_system_type *type,
2072 void *orig, void *copy)
2074 return 0;
2077 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2079 return 0;
2082 static inline int security_sb_statfs (struct super_block *sb)
2084 return 0;
2087 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2088 char *type, unsigned long flags,
2089 void *data)
2091 return 0;
2094 static inline int security_sb_check_sb (struct vfsmount *mnt,
2095 struct nameidata *nd)
2097 return 0;
2100 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2102 return 0;
2105 static inline void security_sb_umount_close (struct vfsmount *mnt)
2108 static inline void security_sb_umount_busy (struct vfsmount *mnt)
2111 static inline void security_sb_post_remount (struct vfsmount *mnt,
2112 unsigned long flags, void *data)
2115 static inline void security_sb_post_mountroot (void)
2118 static inline void security_sb_post_addmount (struct vfsmount *mnt,
2119 struct nameidata *mountpoint_nd)
2122 static inline int security_sb_pivotroot (struct nameidata *old_nd,
2123 struct nameidata *new_nd)
2125 return 0;
2128 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2129 struct nameidata *new_nd)
2132 static inline int security_inode_alloc (struct inode *inode)
2134 return 0;
2137 static inline void security_inode_free (struct inode *inode)
2140 static inline int security_inode_init_security (struct inode *inode,
2141 struct inode *dir,
2142 char **name,
2143 void **value,
2144 size_t *len)
2146 return -EOPNOTSUPP;
2149 static inline int security_inode_create (struct inode *dir,
2150 struct dentry *dentry,
2151 int mode)
2153 return 0;
2156 static inline int security_inode_link (struct dentry *old_dentry,
2157 struct inode *dir,
2158 struct dentry *new_dentry)
2160 return 0;
2163 static inline int security_inode_unlink (struct inode *dir,
2164 struct dentry *dentry)
2166 return 0;
2169 static inline int security_inode_symlink (struct inode *dir,
2170 struct dentry *dentry,
2171 const char *old_name)
2173 return 0;
2176 static inline int security_inode_mkdir (struct inode *dir,
2177 struct dentry *dentry,
2178 int mode)
2180 return 0;
2183 static inline int security_inode_rmdir (struct inode *dir,
2184 struct dentry *dentry)
2186 return 0;
2189 static inline int security_inode_mknod (struct inode *dir,
2190 struct dentry *dentry,
2191 int mode, dev_t dev)
2193 return 0;
2196 static inline int security_inode_rename (struct inode *old_dir,
2197 struct dentry *old_dentry,
2198 struct inode *new_dir,
2199 struct dentry *new_dentry)
2201 return 0;
2204 static inline int security_inode_readlink (struct dentry *dentry)
2206 return 0;
2209 static inline int security_inode_follow_link (struct dentry *dentry,
2210 struct nameidata *nd)
2212 return 0;
2215 static inline int security_inode_permission (struct inode *inode, int mask,
2216 struct nameidata *nd)
2218 return 0;
2221 static inline int security_inode_setattr (struct dentry *dentry,
2222 struct iattr *attr)
2224 return 0;
2227 static inline int security_inode_getattr (struct vfsmount *mnt,
2228 struct dentry *dentry)
2230 return 0;
2233 static inline void security_inode_delete (struct inode *inode)
2236 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2237 void *value, size_t size, int flags)
2239 return cap_inode_setxattr(dentry, name, value, size, flags);
2242 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2243 void *value, size_t size, int flags)
2246 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2248 return 0;
2251 static inline int security_inode_listxattr (struct dentry *dentry)
2253 return 0;
2256 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2258 return cap_inode_removexattr(dentry, name);
2261 static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size, int err)
2263 return -EOPNOTSUPP;
2266 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2268 return -EOPNOTSUPP;
2271 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2273 return 0;
2276 static inline int security_file_permission (struct file *file, int mask)
2278 return 0;
2281 static inline int security_file_alloc (struct file *file)
2283 return 0;
2286 static inline void security_file_free (struct file *file)
2289 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2290 unsigned long arg)
2292 return 0;
2295 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
2296 unsigned long prot,
2297 unsigned long flags)
2299 return 0;
2302 static inline int security_file_mprotect (struct vm_area_struct *vma,
2303 unsigned long reqprot,
2304 unsigned long prot)
2306 return 0;
2309 static inline int security_file_lock (struct file *file, unsigned int cmd)
2311 return 0;
2314 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2315 unsigned long arg)
2317 return 0;
2320 static inline int security_file_set_fowner (struct file *file)
2322 return 0;
2325 static inline int security_file_send_sigiotask (struct task_struct *tsk,
2326 struct fown_struct *fown,
2327 int sig)
2329 return 0;
2332 static inline int security_file_receive (struct file *file)
2334 return 0;
2337 static inline int security_task_create (unsigned long clone_flags)
2339 return 0;
2342 static inline int security_task_alloc (struct task_struct *p)
2344 return 0;
2347 static inline void security_task_free (struct task_struct *p)
2350 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2351 int flags)
2353 return 0;
2356 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2357 uid_t old_suid, int flags)
2359 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2362 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2363 int flags)
2365 return 0;
2368 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2370 return 0;
2373 static inline int security_task_getpgid (struct task_struct *p)
2375 return 0;
2378 static inline int security_task_getsid (struct task_struct *p)
2380 return 0;
2383 static inline int security_task_setgroups (struct group_info *group_info)
2385 return 0;
2388 static inline int security_task_setnice (struct task_struct *p, int nice)
2390 return 0;
2393 static inline int security_task_setrlimit (unsigned int resource,
2394 struct rlimit *new_rlim)
2396 return 0;
2399 static inline int security_task_setscheduler (struct task_struct *p,
2400 int policy,
2401 struct sched_param *lp)
2403 return 0;
2406 static inline int security_task_getscheduler (struct task_struct *p)
2408 return 0;
2411 static inline int security_task_kill (struct task_struct *p,
2412 struct siginfo *info, int sig)
2414 return 0;
2417 static inline int security_task_wait (struct task_struct *p)
2419 return 0;
2422 static inline int security_task_prctl (int option, unsigned long arg2,
2423 unsigned long arg3,
2424 unsigned long arg4,
2425 unsigned long arg5)
2427 return 0;
2430 static inline void security_task_reparent_to_init (struct task_struct *p)
2432 cap_task_reparent_to_init (p);
2435 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2438 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2439 short flag)
2441 return 0;
2444 static inline int security_msg_msg_alloc (struct msg_msg * msg)
2446 return 0;
2449 static inline void security_msg_msg_free (struct msg_msg * msg)
2452 static inline int security_msg_queue_alloc (struct msg_queue *msq)
2454 return 0;
2457 static inline void security_msg_queue_free (struct msg_queue *msq)
2460 static inline int security_msg_queue_associate (struct msg_queue * msq,
2461 int msqflg)
2463 return 0;
2466 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2468 return 0;
2471 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2472 struct msg_msg * msg, int msqflg)
2474 return 0;
2477 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2478 struct msg_msg * msg,
2479 struct task_struct * target,
2480 long type, int mode)
2482 return 0;
2485 static inline int security_shm_alloc (struct shmid_kernel *shp)
2487 return 0;
2490 static inline void security_shm_free (struct shmid_kernel *shp)
2493 static inline int security_shm_associate (struct shmid_kernel * shp,
2494 int shmflg)
2496 return 0;
2499 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2501 return 0;
2504 static inline int security_shm_shmat (struct shmid_kernel * shp,
2505 char __user *shmaddr, int shmflg)
2507 return 0;
2510 static inline int security_sem_alloc (struct sem_array *sma)
2512 return 0;
2515 static inline void security_sem_free (struct sem_array *sma)
2518 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2520 return 0;
2523 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2525 return 0;
2528 static inline int security_sem_semop (struct sem_array * sma,
2529 struct sembuf * sops, unsigned nsops,
2530 int alter)
2532 return 0;
2535 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2538 static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2540 return -EINVAL;
2543 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2545 return -EINVAL;
2548 static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2550 return cap_netlink_send (sk, skb);
2553 static inline int security_netlink_recv (struct sk_buff *skb)
2555 return cap_netlink_recv (skb);
2558 #endif /* CONFIG_SECURITY */
2560 #ifdef CONFIG_SECURITY_NETWORK
2561 static inline int security_unix_stream_connect(struct socket * sock,
2562 struct socket * other,
2563 struct sock * newsk)
2565 return security_ops->unix_stream_connect(sock, other, newsk);
2569 static inline int security_unix_may_send(struct socket * sock,
2570 struct socket * other)
2572 return security_ops->unix_may_send(sock, other);
2575 static inline int security_socket_create (int family, int type,
2576 int protocol, int kern)
2578 return security_ops->socket_create(family, type, protocol, kern);
2581 static inline void security_socket_post_create(struct socket * sock,
2582 int family,
2583 int type,
2584 int protocol, int kern)
2586 security_ops->socket_post_create(sock, family, type,
2587 protocol, kern);
2590 static inline int security_socket_bind(struct socket * sock,
2591 struct sockaddr * address,
2592 int addrlen)
2594 return security_ops->socket_bind(sock, address, addrlen);
2597 static inline int security_socket_connect(struct socket * sock,
2598 struct sockaddr * address,
2599 int addrlen)
2601 return security_ops->socket_connect(sock, address, addrlen);
2604 static inline int security_socket_listen(struct socket * sock, int backlog)
2606 return security_ops->socket_listen(sock, backlog);
2609 static inline int security_socket_accept(struct socket * sock,
2610 struct socket * newsock)
2612 return security_ops->socket_accept(sock, newsock);
2615 static inline void security_socket_post_accept(struct socket * sock,
2616 struct socket * newsock)
2618 security_ops->socket_post_accept(sock, newsock);
2621 static inline int security_socket_sendmsg(struct socket * sock,
2622 struct msghdr * msg, int size)
2624 return security_ops->socket_sendmsg(sock, msg, size);
2627 static inline int security_socket_recvmsg(struct socket * sock,
2628 struct msghdr * msg, int size,
2629 int flags)
2631 return security_ops->socket_recvmsg(sock, msg, size, flags);
2634 static inline int security_socket_getsockname(struct socket * sock)
2636 return security_ops->socket_getsockname(sock);
2639 static inline int security_socket_getpeername(struct socket * sock)
2641 return security_ops->socket_getpeername(sock);
2644 static inline int security_socket_getsockopt(struct socket * sock,
2645 int level, int optname)
2647 return security_ops->socket_getsockopt(sock, level, optname);
2650 static inline int security_socket_setsockopt(struct socket * sock,
2651 int level, int optname)
2653 return security_ops->socket_setsockopt(sock, level, optname);
2656 static inline int security_socket_shutdown(struct socket * sock, int how)
2658 return security_ops->socket_shutdown(sock, how);
2661 static inline int security_sock_rcv_skb (struct sock * sk,
2662 struct sk_buff * skb)
2664 return security_ops->socket_sock_rcv_skb (sk, skb);
2667 static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
2668 int __user *optlen, unsigned len)
2670 return security_ops->socket_getpeersec(sock, optval, optlen, len);
2673 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2675 return security_ops->sk_alloc_security(sk, family, priority);
2678 static inline void security_sk_free(struct sock *sk)
2680 return security_ops->sk_free_security(sk);
2682 #else /* CONFIG_SECURITY_NETWORK */
2683 static inline int security_unix_stream_connect(struct socket * sock,
2684 struct socket * other,
2685 struct sock * newsk)
2687 return 0;
2690 static inline int security_unix_may_send(struct socket * sock,
2691 struct socket * other)
2693 return 0;
2696 static inline int security_socket_create (int family, int type,
2697 int protocol, int kern)
2699 return 0;
2702 static inline void security_socket_post_create(struct socket * sock,
2703 int family,
2704 int type,
2705 int protocol, int kern)
2709 static inline int security_socket_bind(struct socket * sock,
2710 struct sockaddr * address,
2711 int addrlen)
2713 return 0;
2716 static inline int security_socket_connect(struct socket * sock,
2717 struct sockaddr * address,
2718 int addrlen)
2720 return 0;
2723 static inline int security_socket_listen(struct socket * sock, int backlog)
2725 return 0;
2728 static inline int security_socket_accept(struct socket * sock,
2729 struct socket * newsock)
2731 return 0;
2734 static inline void security_socket_post_accept(struct socket * sock,
2735 struct socket * newsock)
2739 static inline int security_socket_sendmsg(struct socket * sock,
2740 struct msghdr * msg, int size)
2742 return 0;
2745 static inline int security_socket_recvmsg(struct socket * sock,
2746 struct msghdr * msg, int size,
2747 int flags)
2749 return 0;
2752 static inline int security_socket_getsockname(struct socket * sock)
2754 return 0;
2757 static inline int security_socket_getpeername(struct socket * sock)
2759 return 0;
2762 static inline int security_socket_getsockopt(struct socket * sock,
2763 int level, int optname)
2765 return 0;
2768 static inline int security_socket_setsockopt(struct socket * sock,
2769 int level, int optname)
2771 return 0;
2774 static inline int security_socket_shutdown(struct socket * sock, int how)
2776 return 0;
2778 static inline int security_sock_rcv_skb (struct sock * sk,
2779 struct sk_buff * skb)
2781 return 0;
2784 static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
2785 int __user *optlen, unsigned len)
2787 return -ENOPROTOOPT;
2790 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2792 return 0;
2795 static inline void security_sk_free(struct sock *sk)
2798 #endif /* CONFIG_SECURITY_NETWORK */
2800 #ifdef CONFIG_KEYS
2801 #ifdef CONFIG_SECURITY
2802 static inline int security_key_alloc(struct key *key)
2804 return security_ops->key_alloc(key);
2807 static inline void security_key_free(struct key *key)
2809 security_ops->key_free(key);
2812 static inline int security_key_permission(key_ref_t key_ref,
2813 struct task_struct *context,
2814 key_perm_t perm)
2816 return security_ops->key_permission(key_ref, context, perm);
2819 #else
2821 static inline int security_key_alloc(struct key *key)
2823 return 0;
2826 static inline void security_key_free(struct key *key)
2830 static inline int security_key_permission(key_ref_t key_ref,
2831 struct task_struct *context,
2832 key_perm_t perm)
2834 return 0;
2837 #endif
2838 #endif /* CONFIG_KEYS */
2840 #endif /* ! __LINUX_SECURITY_H */