]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - include/linux/security.h
[PATCH] lsm: add task_setioprio hook
[mirror_ubuntu-zesty-kernel.git] / include / linux / security.h
CommitLineData
1da177e4
LT
1/*
2 * Linux Security plug
3 *
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)
9 *
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.
14 *
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.
19 *
20 */
21
22#ifndef __LINUX_SECURITY_H
23#define __LINUX_SECURITY_H
24
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>
29db9190 33#include <linux/key.h>
1da177e4
LT
34
35struct ctl_table;
36
37/*
38 * These functions are in security/capability.c and are used
39 * as the default capabilities functions
40 */
41extern int cap_capable (struct task_struct *tsk, int cap);
42extern int cap_settime (struct timespec *ts, struct timezone *tz);
43extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
44extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
45extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
46extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
47extern int cap_bprm_set_security (struct linux_binprm *bprm);
48extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
49extern int cap_bprm_secureexec(struct linux_binprm *bprm);
50extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
51extern int cap_inode_removexattr(struct dentry *dentry, char *name);
52extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
53extern void cap_task_reparent_to_init (struct task_struct *p);
54extern int cap_syslog (int type);
55extern int cap_vm_enough_memory (long pages);
56
57struct msghdr;
58struct sk_buff;
59struct sock;
60struct sockaddr;
61struct socket;
df71837d
TJ
62struct flowi;
63struct dst_entry;
64struct xfrm_selector;
65struct xfrm_policy;
66struct xfrm_state;
67struct xfrm_user_sec_ctx;
1da177e4
LT
68
69extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
70extern int cap_netlink_recv(struct sk_buff *skb);
71
72/*
73 * Values used in the task_security_ops calls
74 */
75/* setuid or setgid, id0 == uid or gid */
76#define LSM_SETID_ID 1
77
78/* setreuid or setregid, id0 == real, id1 == eff */
79#define LSM_SETID_RE 2
80
81/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
82#define LSM_SETID_RES 4
83
84/* setfsuid or setfsgid, id0 == fsuid or fsgid */
85#define LSM_SETID_FS 8
86
87/* forward declares to avoid warnings */
88struct nfsctl_arg;
89struct sched_param;
90struct swap_info_struct;
91
92/* bprm_apply_creds unsafe reasons */
93#define LSM_UNSAFE_SHARE 1
94#define LSM_UNSAFE_PTRACE 2
95#define LSM_UNSAFE_PTRACE_CAP 4
96
97#ifdef CONFIG_SECURITY
98
99/**
100 * struct security_operations - main security structure
101 *
102 * Security hooks for program execution operations.
103 *
104 * @bprm_alloc_security:
105 * Allocate and attach a security structure to the @bprm->security field.
106 * The security field is initialized to NULL when the bprm structure is
107 * allocated.
108 * @bprm contains the linux_binprm structure to be modified.
109 * Return 0 if operation was successful.
110 * @bprm_free_security:
111 * @bprm contains the linux_binprm structure to be modified.
112 * Deallocate and clear the @bprm->security field.
113 * @bprm_apply_creds:
114 * Compute and set the security attributes of a process being transformed
115 * by an execve operation based on the old attributes (current->security)
116 * and the information saved in @bprm->security by the set_security hook.
117 * Since this hook function (and its caller) are void, this hook can not
118 * return an error. However, it can leave the security attributes of the
119 * process unchanged if an access failure occurs at this point.
120 * bprm_apply_creds is called under task_lock. @unsafe indicates various
121 * reasons why it may be unsafe to change security state.
122 * @bprm contains the linux_binprm structure.
123 * @bprm_post_apply_creds:
124 * Runs after bprm_apply_creds with the task_lock dropped, so that
125 * functions which cannot be called safely under the task_lock can
126 * be used. This hook is a good place to perform state changes on
127 * the process such as closing open file descriptors to which access
128 * is no longer granted if the attributes were changed.
129 * Note that a security module might need to save state between
130 * bprm_apply_creds and bprm_post_apply_creds to store the decision
131 * on whether the process may proceed.
132 * @bprm contains the linux_binprm structure.
133 * @bprm_set_security:
134 * Save security information in the bprm->security field, typically based
135 * on information about the bprm->file, for later use by the apply_creds
136 * hook. This hook may also optionally check permissions (e.g. for
137 * transitions between security domains).
138 * This hook may be called multiple times during a single execve, e.g. for
139 * interpreters. The hook can tell whether it has already been called by
140 * checking to see if @bprm->security is non-NULL. If so, then the hook
141 * may decide either to retain the security information saved earlier or
142 * to replace it.
143 * @bprm contains the linux_binprm structure.
144 * Return 0 if the hook is successful and permission is granted.
145 * @bprm_check_security:
146 * This hook mediates the point when a search for a binary handler will
147 * begin. It allows a check the @bprm->security value which is set in
148 * the preceding set_security call. The primary difference from
149 * set_security is that the argv list and envp list are reliably
150 * available in @bprm. This hook may be called multiple times
151 * during a single execve; and in each pass set_security is called
152 * first.
153 * @bprm contains the linux_binprm structure.
154 * Return 0 if the hook is successful and permission is granted.
155 * @bprm_secureexec:
156 * Return a boolean value (0 or 1) indicating whether a "secure exec"
157 * is required. The flag is passed in the auxiliary table
158 * on the initial stack to the ELF interpreter to indicate whether libc
159 * should enable secure mode.
160 * @bprm contains the linux_binprm structure.
161 *
162 * Security hooks for filesystem operations.
163 *
164 * @sb_alloc_security:
165 * Allocate and attach a security structure to the sb->s_security field.
166 * The s_security field is initialized to NULL when the structure is
167 * allocated.
168 * @sb contains the super_block structure to be modified.
169 * Return 0 if operation was successful.
170 * @sb_free_security:
171 * Deallocate and clear the sb->s_security field.
172 * @sb contains the super_block structure to be modified.
173 * @sb_statfs:
726c3342
DH
174 * Check permission before obtaining filesystem statistics for the @mnt
175 * mountpoint.
176 * @dentry is a handle on the superblock for the filesystem.
1da177e4
LT
177 * Return 0 if permission is granted.
178 * @sb_mount:
179 * Check permission before an object specified by @dev_name is mounted on
180 * the mount point named by @nd. For an ordinary mount, @dev_name
181 * identifies a device if the file system type requires a device. For a
182 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
183 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
184 * pathname of the object being mounted.
185 * @dev_name contains the name for object being mounted.
186 * @nd contains the nameidata structure for mount point object.
187 * @type contains the filesystem type.
188 * @flags contains the mount flags.
189 * @data contains the filesystem-specific data.
190 * Return 0 if permission is granted.
191 * @sb_copy_data:
192 * Allow mount option data to be copied prior to parsing by the filesystem,
193 * so that the security module can extract security-specific mount
194 * options cleanly (a filesystem may modify the data e.g. with strsep()).
195 * This also allows the original mount data to be stripped of security-
196 * specific options to avoid having to make filesystems aware of them.
197 * @type the type of filesystem being mounted.
198 * @orig the original mount data copied from userspace.
199 * @copy copied data which will be passed to the security module.
200 * Returns 0 if the copy was successful.
201 * @sb_check_sb:
202 * Check permission before the device with superblock @mnt->sb is mounted
203 * on the mount point named by @nd.
204 * @mnt contains the vfsmount for device being mounted.
205 * @nd contains the nameidata object for the mount point.
206 * Return 0 if permission is granted.
207 * @sb_umount:
208 * Check permission before the @mnt file system is unmounted.
209 * @mnt contains the mounted file system.
210 * @flags contains the unmount flags, e.g. MNT_FORCE.
211 * Return 0 if permission is granted.
212 * @sb_umount_close:
213 * Close any files in the @mnt mounted filesystem that are held open by
214 * the security module. This hook is called during an umount operation
215 * prior to checking whether the filesystem is still busy.
216 * @mnt contains the mounted filesystem.
217 * @sb_umount_busy:
218 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
219 * any files that were closed by umount_close. This hook is called during
220 * an umount operation if the umount fails after a call to the
221 * umount_close hook.
222 * @mnt contains the mounted filesystem.
223 * @sb_post_remount:
224 * Update the security module's state when a filesystem is remounted.
225 * This hook is only called if the remount was successful.
226 * @mnt contains the mounted file system.
227 * @flags contains the new filesystem flags.
228 * @data contains the filesystem-specific data.
229 * @sb_post_mountroot:
230 * Update the security module's state when the root filesystem is mounted.
231 * This hook is only called if the mount was successful.
232 * @sb_post_addmount:
233 * Update the security module's state when a filesystem is mounted.
234 * This hook is called any time a mount is successfully grafetd to
235 * the tree.
236 * @mnt contains the mounted filesystem.
237 * @mountpoint_nd contains the nameidata structure for the mount point.
238 * @sb_pivotroot:
239 * Check permission before pivoting the root filesystem.
240 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
241 * @new_nd contains the nameidata structure for the new root (new_root).
242 * Return 0 if permission is granted.
243 * @sb_post_pivotroot:
244 * Update module state after a successful pivot.
245 * @old_nd contains the nameidata structure for the old root.
246 * @new_nd contains the nameidata structure for the new root.
247 *
248 * Security hooks for inode operations.
249 *
250 * @inode_alloc_security:
251 * Allocate and attach a security structure to @inode->i_security. The
252 * i_security field is initialized to NULL when the inode structure is
253 * allocated.
254 * @inode contains the inode structure.
255 * Return 0 if operation was successful.
256 * @inode_free_security:
257 * @inode contains the inode structure.
258 * Deallocate the inode security structure and set @inode->i_security to
259 * NULL.
5e41ff9e
SS
260 * @inode_init_security:
261 * Obtain the security attribute name suffix and value to set on a newly
262 * created inode and set up the incore security field for the new inode.
263 * This hook is called by the fs code as part of the inode creation
264 * transaction and provides for atomic labeling of the inode, unlike
265 * the post_create/mkdir/... hooks called by the VFS. The hook function
266 * is expected to allocate the name and value via kmalloc, with the caller
267 * being responsible for calling kfree after using them.
268 * If the security module does not use security attributes or does
269 * not wish to put a security attribute on this particular inode,
270 * then it should return -EOPNOTSUPP to skip this processing.
271 * @inode contains the inode structure of the newly created inode.
272 * @dir contains the inode structure of the parent directory.
273 * @name will be set to the allocated name suffix (e.g. selinux).
274 * @value will be set to the allocated attribute value.
275 * @len will be set to the length of the value.
276 * Returns 0 if @name and @value have been successfully set,
277 * -EOPNOTSUPP if no security attribute is needed, or
278 * -ENOMEM on memory allocation failure.
1da177e4
LT
279 * @inode_create:
280 * Check permission to create a regular file.
281 * @dir contains inode structure of the parent of the new file.
282 * @dentry contains the dentry structure for the file to be created.
283 * @mode contains the file mode of the file to be created.
284 * Return 0 if permission is granted.
1da177e4
LT
285 * @inode_link:
286 * Check permission before creating a new hard link to a file.
287 * @old_dentry contains the dentry structure for an existing link to the file.
288 * @dir contains the inode structure of the parent directory of the new link.
289 * @new_dentry contains the dentry structure for the new link.
290 * Return 0 if permission is granted.
1da177e4
LT
291 * @inode_unlink:
292 * Check the permission to remove a hard link to a file.
293 * @dir contains the inode structure of parent directory of the file.
294 * @dentry contains the dentry structure for file to be unlinked.
295 * Return 0 if permission is granted.
296 * @inode_symlink:
297 * Check the permission to create a symbolic link to a file.
298 * @dir contains the inode structure of parent directory of the symbolic link.
299 * @dentry contains the dentry structure of the symbolic link.
300 * @old_name contains the pathname of file.
301 * Return 0 if permission is granted.
1da177e4
LT
302 * @inode_mkdir:
303 * Check permissions to create a new directory in the existing directory
304 * associated with inode strcture @dir.
305 * @dir containst the inode structure of parent of the directory to be created.
306 * @dentry contains the dentry structure of new directory.
307 * @mode contains the mode of new directory.
308 * Return 0 if permission is granted.
1da177e4
LT
309 * @inode_rmdir:
310 * Check the permission to remove a directory.
311 * @dir contains the inode structure of parent of the directory to be removed.
312 * @dentry contains the dentry structure of directory to be removed.
313 * Return 0 if permission is granted.
314 * @inode_mknod:
315 * Check permissions when creating a special file (or a socket or a fifo
316 * file created via the mknod system call). Note that if mknod operation
317 * is being done for a regular file, then the create hook will be called
318 * and not this hook.
319 * @dir contains the inode structure of parent of the new file.
320 * @dentry contains the dentry structure of the new file.
321 * @mode contains the mode of the new file.
322 * @dev contains the the device number.
323 * Return 0 if permission is granted.
1da177e4
LT
324 * @inode_rename:
325 * Check for permission to rename a file or directory.
326 * @old_dir contains the inode structure for parent of the old link.
327 * @old_dentry contains the dentry structure of the old link.
328 * @new_dir contains the inode structure for parent of the new link.
329 * @new_dentry contains the dentry structure of the new link.
330 * Return 0 if permission is granted.
1da177e4
LT
331 * @inode_readlink:
332 * Check the permission to read the symbolic link.
333 * @dentry contains the dentry structure for the file link.
334 * Return 0 if permission is granted.
335 * @inode_follow_link:
336 * Check permission to follow a symbolic link when looking up a pathname.
337 * @dentry contains the dentry structure for the link.
338 * @nd contains the nameidata structure for the parent directory.
339 * Return 0 if permission is granted.
340 * @inode_permission:
341 * Check permission before accessing an inode. This hook is called by the
342 * existing Linux permission function, so a security module can use it to
343 * provide additional checking for existing Linux permission checks.
344 * Notice that this hook is called when a file is opened (as well as many
345 * other operations), whereas the file_security_ops permission hook is
346 * called when the actual read/write operations are performed.
347 * @inode contains the inode structure to check.
348 * @mask contains the permission mask.
349 * @nd contains the nameidata (may be NULL).
350 * Return 0 if permission is granted.
351 * @inode_setattr:
352 * Check permission before setting file attributes. Note that the kernel
353 * call to notify_change is performed from several locations, whenever
354 * file attributes change (such as when a file is truncated, chown/chmod
355 * operations, transferring disk quotas, etc).
356 * @dentry contains the dentry structure for the file.
357 * @attr is the iattr structure containing the new file attributes.
358 * Return 0 if permission is granted.
359 * @inode_getattr:
360 * Check permission before obtaining file attributes.
361 * @mnt is the vfsmount where the dentry was looked up
362 * @dentry contains the dentry structure for the file.
363 * Return 0 if permission is granted.
364 * @inode_delete:
365 * @inode contains the inode structure for deleted inode.
366 * This hook is called when a deleted inode is released (i.e. an inode
367 * with no hard links has its use count drop to zero). A security module
368 * can use this hook to release any persistent label associated with the
369 * inode.
370 * @inode_setxattr:
371 * Check permission before setting the extended attributes
372 * @value identified by @name for @dentry.
373 * Return 0 if permission is granted.
374 * @inode_post_setxattr:
375 * Update inode security field after successful setxattr operation.
376 * @value identified by @name for @dentry.
377 * @inode_getxattr:
378 * Check permission before obtaining the extended attributes
379 * identified by @name for @dentry.
380 * Return 0 if permission is granted.
381 * @inode_listxattr:
382 * Check permission before obtaining the list of extended attribute
383 * names for @dentry.
384 * Return 0 if permission is granted.
385 * @inode_removexattr:
386 * Check permission before removing the extended attribute
387 * identified by @name for @dentry.
388 * Return 0 if permission is granted.
389 * @inode_getsecurity:
390 * Copy the extended attribute representation of the security label
391 * associated with @name for @inode into @buffer. @buffer may be
392 * NULL to request the size of the buffer required. @size indicates
393 * the size of @buffer in bytes. Note that @name is the remainder
394 * of the attribute name after the security. prefix has been removed.
d381d8a9
JM
395 * @err is the return value from the preceding fs getxattr call,
396 * and can be used by the security module to determine whether it
397 * should try and canonicalize the attribute value.
1da177e4
LT
398 * Return number of bytes used/required on success.
399 * @inode_setsecurity:
400 * Set the security label associated with @name for @inode from the
401 * extended attribute value @value. @size indicates the size of the
402 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
403 * Note that @name is the remainder of the attribute name after the
404 * security. prefix has been removed.
405 * Return 0 on success.
406 * @inode_listsecurity:
407 * Copy the extended attribute names for the security labels
408 * associated with @inode into @buffer. The maximum size of @buffer
409 * is specified by @buffer_size. @buffer may be NULL to request
410 * the size of the buffer required.
411 * Returns number of bytes used/required on success.
412 *
413 * Security hooks for file operations
414 *
415 * @file_permission:
416 * Check file permissions before accessing an open file. This hook is
417 * called by various operations that read or write files. A security
418 * module can use this hook to perform additional checking on these
419 * operations, e.g. to revalidate permissions on use to support privilege
420 * bracketing or policy changes. Notice that this hook is used when the
421 * actual read/write operations are performed, whereas the
422 * inode_security_ops hook is called when a file is opened (as well as
423 * many other operations).
424 * Caveat: Although this hook can be used to revalidate permissions for
425 * various system call operations that read or write files, it does not
426 * address the revalidation of permissions for memory-mapped files.
427 * Security modules must handle this separately if they need such
428 * revalidation.
429 * @file contains the file structure being accessed.
430 * @mask contains the requested permissions.
431 * Return 0 if permission is granted.
432 * @file_alloc_security:
433 * Allocate and attach a security structure to the file->f_security field.
434 * The security field is initialized to NULL when the structure is first
435 * created.
436 * @file contains the file structure to secure.
437 * Return 0 if the hook is successful and permission is granted.
438 * @file_free_security:
439 * Deallocate and free any security structures stored in file->f_security.
440 * @file contains the file structure being modified.
441 * @file_ioctl:
442 * @file contains the file structure.
443 * @cmd contains the operation to perform.
444 * @arg contains the operational arguments.
445 * Check permission for an ioctl operation on @file. Note that @arg can
446 * sometimes represents a user space pointer; in other cases, it may be a
447 * simple integer value. When @arg represents a user space pointer, it
448 * should never be used by the security module.
449 * Return 0 if permission is granted.
450 * @file_mmap :
451 * Check permissions for a mmap operation. The @file may be NULL, e.g.
452 * if mapping anonymous memory.
453 * @file contains the file structure for file to map (may be NULL).
454 * @reqprot contains the protection requested by the application.
455 * @prot contains the protection that will be applied by the kernel.
456 * @flags contains the operational flags.
457 * Return 0 if permission is granted.
458 * @file_mprotect:
459 * Check permissions before changing memory access permissions.
460 * @vma contains the memory region to modify.
461 * @reqprot contains the protection requested by the application.
462 * @prot contains the protection that will be applied by the kernel.
463 * Return 0 if permission is granted.
464 * @file_lock:
465 * Check permission before performing file locking operations.
466 * Note: this hook mediates both flock and fcntl style locks.
467 * @file contains the file structure.
468 * @cmd contains the posix-translated lock operation to perform
469 * (e.g. F_RDLCK, F_WRLCK).
470 * Return 0 if permission is granted.
471 * @file_fcntl:
472 * Check permission before allowing the file operation specified by @cmd
473 * from being performed on the file @file. Note that @arg can sometimes
474 * represents a user space pointer; in other cases, it may be a simple
475 * integer value. When @arg represents a user space pointer, it should
476 * never be used by the security module.
477 * @file contains the file structure.
478 * @cmd contains the operation to be performed.
479 * @arg contains the operational arguments.
480 * Return 0 if permission is granted.
481 * @file_set_fowner:
482 * Save owner security information (typically from current->security) in
483 * file->f_security for later use by the send_sigiotask hook.
484 * @file contains the file structure to update.
485 * Return 0 on success.
486 * @file_send_sigiotask:
487 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
488 * process @tsk. Note that this hook is sometimes called from interrupt.
489 * Note that the fown_struct, @fown, is never outside the context of a
490 * struct file, so the file structure (and associated security information)
491 * can always be obtained:
492 * (struct file *)((long)fown - offsetof(struct file,f_owner));
493 * @tsk contains the structure of task receiving signal.
494 * @fown contains the file owner information.
495 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
496 * Return 0 if permission is granted.
497 * @file_receive:
498 * This hook allows security modules to control the ability of a process
499 * to receive an open file descriptor via socket IPC.
500 * @file contains the file structure being received.
501 * Return 0 if permission is granted.
502 *
503 * Security hooks for task operations.
504 *
505 * @task_create:
506 * Check permission before creating a child process. See the clone(2)
507 * manual page for definitions of the @clone_flags.
508 * @clone_flags contains the flags indicating what should be shared.
509 * Return 0 if permission is granted.
510 * @task_alloc_security:
511 * @p contains the task_struct for child process.
512 * Allocate and attach a security structure to the p->security field. The
513 * security field is initialized to NULL when the task structure is
514 * allocated.
515 * Return 0 if operation was successful.
516 * @task_free_security:
517 * @p contains the task_struct for process.
518 * Deallocate and clear the p->security field.
519 * @task_setuid:
520 * Check permission before setting one or more of the user identity
521 * attributes of the current process. The @flags parameter indicates
522 * which of the set*uid system calls invoked this hook and how to
523 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
524 * definitions at the beginning of this file for the @flags values and
525 * their meanings.
526 * @id0 contains a uid.
527 * @id1 contains a uid.
528 * @id2 contains a uid.
529 * @flags contains one of the LSM_SETID_* values.
530 * Return 0 if permission is granted.
531 * @task_post_setuid:
532 * Update the module's state after setting one or more of the user
533 * identity attributes of the current process. The @flags parameter
534 * indicates which of the set*uid system calls invoked this hook. If
535 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
536 * parameters are not used.
537 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
538 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
539 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
540 * @flags contains one of the LSM_SETID_* values.
541 * Return 0 on success.
542 * @task_setgid:
543 * Check permission before setting one or more of the group identity
544 * attributes of the current process. The @flags parameter indicates
545 * which of the set*gid system calls invoked this hook and how to
546 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
547 * definitions at the beginning of this file for the @flags values and
548 * their meanings.
549 * @id0 contains a gid.
550 * @id1 contains a gid.
551 * @id2 contains a gid.
552 * @flags contains one of the LSM_SETID_* values.
553 * Return 0 if permission is granted.
554 * @task_setpgid:
555 * Check permission before setting the process group identifier of the
556 * process @p to @pgid.
557 * @p contains the task_struct for process being modified.
558 * @pgid contains the new pgid.
559 * Return 0 if permission is granted.
560 * @task_getpgid:
561 * Check permission before getting the process group identifier of the
562 * process @p.
563 * @p contains the task_struct for the process.
564 * Return 0 if permission is granted.
565 * @task_getsid:
566 * Check permission before getting the session identifier of the process
567 * @p.
568 * @p contains the task_struct for the process.
569 * Return 0 if permission is granted.
570 * @task_setgroups:
571 * Check permission before setting the supplementary group set of the
572 * current process.
573 * @group_info contains the new group information.
574 * Return 0 if permission is granted.
575 * @task_setnice:
576 * Check permission before setting the nice value of @p to @nice.
577 * @p contains the task_struct of process.
578 * @nice contains the new nice value.
579 * Return 0 if permission is granted.
03e68060
JM
580 * @task_setioprio
581 * Check permission before setting the ioprio value of @p to @ioprio.
582 * @p contains the task_struct of process.
583 * @ioprio contains the new ioprio value
584 * Return 0 if permission is granted.
1da177e4
LT
585 * @task_setrlimit:
586 * Check permission before setting the resource limits of the current
587 * process for @resource to @new_rlim. The old resource limit values can
588 * be examined by dereferencing (current->signal->rlim + resource).
589 * @resource contains the resource whose limit is being set.
590 * @new_rlim contains the new limits for @resource.
591 * Return 0 if permission is granted.
592 * @task_setscheduler:
593 * Check permission before setting scheduling policy and/or parameters of
594 * process @p based on @policy and @lp.
595 * @p contains the task_struct for process.
596 * @policy contains the scheduling policy.
597 * @lp contains the scheduling parameters.
598 * Return 0 if permission is granted.
599 * @task_getscheduler:
600 * Check permission before obtaining scheduling information for process
601 * @p.
602 * @p contains the task_struct for process.
603 * Return 0 if permission is granted.
604 * @task_kill:
605 * Check permission before sending signal @sig to @p. @info can be NULL,
606 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
607 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
608 * from the kernel and should typically be permitted.
609 * SIGIO signals are handled separately by the send_sigiotask hook in
610 * file_security_ops.
611 * @p contains the task_struct for process.
612 * @info contains the signal information.
613 * @sig contains the signal value.
614 * Return 0 if permission is granted.
615 * @task_wait:
616 * Check permission before allowing a process to reap a child process @p
617 * and collect its status information.
618 * @p contains the task_struct for process.
619 * Return 0 if permission is granted.
620 * @task_prctl:
621 * Check permission before performing a process control operation on the
622 * current process.
623 * @option contains the operation.
624 * @arg2 contains a argument.
625 * @arg3 contains a argument.
626 * @arg4 contains a argument.
627 * @arg5 contains a argument.
628 * Return 0 if permission is granted.
629 * @task_reparent_to_init:
630 * Set the security attributes in @p->security for a kernel thread that
631 * is being reparented to the init task.
632 * @p contains the task_struct for the kernel thread.
633 * @task_to_inode:
634 * Set the security attributes for an inode based on an associated task's
635 * security attributes, e.g. for /proc/pid inodes.
636 * @p contains the task_struct for the task.
637 * @inode contains the inode structure for the inode.
638 *
639 * Security hooks for Netlink messaging.
640 *
641 * @netlink_send:
642 * Save security information for a netlink message so that permission
643 * checking can be performed when the message is processed. The security
644 * information can be saved using the eff_cap field of the
645 * netlink_skb_parms structure. Also may be used to provide fine
646 * grained control over message transmission.
647 * @sk associated sock of task sending the message.,
648 * @skb contains the sk_buff structure for the netlink message.
649 * Return 0 if the information was successfully saved and message
650 * is allowed to be transmitted.
651 * @netlink_recv:
652 * Check permission before processing the received netlink message in
653 * @skb.
654 * @skb contains the sk_buff structure for the netlink message.
655 * Return 0 if permission is granted.
656 *
657 * Security hooks for Unix domain networking.
658 *
659 * @unix_stream_connect:
660 * Check permissions before establishing a Unix domain stream connection
661 * between @sock and @other.
662 * @sock contains the socket structure.
663 * @other contains the peer socket structure.
664 * Return 0 if permission is granted.
665 * @unix_may_send:
666 * Check permissions before connecting or sending datagrams from @sock to
667 * @other.
668 * @sock contains the socket structure.
669 * @sock contains the peer socket structure.
670 * Return 0 if permission is granted.
671 *
672 * The @unix_stream_connect and @unix_may_send hooks were necessary because
673 * Linux provides an alternative to the conventional file name space for Unix
674 * domain sockets. Whereas binding and connecting to sockets in the file name
675 * space is mediated by the typical file permissions (and caught by the mknod
676 * and permission hooks in inode_security_ops), binding and connecting to
677 * sockets in the abstract name space is completely unmediated. Sufficient
678 * control of Unix domain sockets in the abstract name space isn't possible
679 * using only the socket layer hooks, since we need to know the actual target
680 * socket, which is not looked up until we are inside the af_unix code.
681 *
682 * Security hooks for socket operations.
683 *
684 * @socket_create:
685 * Check permissions prior to creating a new socket.
686 * @family contains the requested protocol family.
687 * @type contains the requested communications type.
688 * @protocol contains the requested protocol.
689 * @kern set to 1 if a kernel socket.
690 * Return 0 if permission is granted.
691 * @socket_post_create:
692 * This hook allows a module to update or allocate a per-socket security
693 * structure. Note that the security field was not added directly to the
694 * socket structure, but rather, the socket security information is stored
695 * in the associated inode. Typically, the inode alloc_security hook will
696 * allocate and and attach security information to
697 * sock->inode->i_security. This hook may be used to update the
698 * sock->inode->i_security field with additional information that wasn't
699 * available when the inode was allocated.
700 * @sock contains the newly created socket structure.
701 * @family contains the requested protocol family.
702 * @type contains the requested communications type.
703 * @protocol contains the requested protocol.
704 * @kern set to 1 if a kernel socket.
705 * @socket_bind:
706 * Check permission before socket protocol layer bind operation is
707 * performed and the socket @sock is bound to the address specified in the
708 * @address parameter.
709 * @sock contains the socket structure.
710 * @address contains the address to bind to.
711 * @addrlen contains the length of address.
712 * Return 0 if permission is granted.
713 * @socket_connect:
714 * Check permission before socket protocol layer connect operation
715 * attempts to connect socket @sock to a remote address, @address.
716 * @sock contains the socket structure.
717 * @address contains the address of remote endpoint.
718 * @addrlen contains the length of address.
719 * Return 0 if permission is granted.
720 * @socket_listen:
721 * Check permission before socket protocol layer listen operation.
722 * @sock contains the socket structure.
723 * @backlog contains the maximum length for the pending connection queue.
724 * Return 0 if permission is granted.
725 * @socket_accept:
726 * Check permission before accepting a new connection. Note that the new
727 * socket, @newsock, has been created and some information copied to it,
728 * but the accept operation has not actually been performed.
729 * @sock contains the listening socket structure.
730 * @newsock contains the newly created server socket for connection.
731 * Return 0 if permission is granted.
732 * @socket_post_accept:
733 * This hook allows a security module to copy security
734 * information into the newly created socket's inode.
735 * @sock contains the listening socket structure.
736 * @newsock contains the newly created server socket for connection.
737 * @socket_sendmsg:
738 * Check permission before transmitting a message to another socket.
739 * @sock contains the socket structure.
740 * @msg contains the message to be transmitted.
741 * @size contains the size of message.
742 * Return 0 if permission is granted.
743 * @socket_recvmsg:
744 * Check permission before receiving a message from a socket.
745 * @sock contains the socket structure.
746 * @msg contains the message structure.
747 * @size contains the size of message structure.
748 * @flags contains the operational flags.
749 * Return 0 if permission is granted.
750 * @socket_getsockname:
751 * Check permission before the local address (name) of the socket object
752 * @sock is retrieved.
753 * @sock contains the socket structure.
754 * Return 0 if permission is granted.
755 * @socket_getpeername:
756 * Check permission before the remote address (name) of a socket object
757 * @sock is retrieved.
758 * @sock contains the socket structure.
759 * Return 0 if permission is granted.
760 * @socket_getsockopt:
761 * Check permissions before retrieving the options associated with socket
762 * @sock.
763 * @sock contains the socket structure.
764 * @level contains the protocol level to retrieve option from.
765 * @optname contains the name of option to retrieve.
766 * Return 0 if permission is granted.
767 * @socket_setsockopt:
768 * Check permissions before setting the options associated with socket
769 * @sock.
770 * @sock contains the socket structure.
771 * @level contains the protocol level to set options for.
772 * @optname contains the name of the option to set.
773 * Return 0 if permission is granted.
774 * @socket_shutdown:
775 * Checks permission before all or part of a connection on the socket
776 * @sock is shut down.
777 * @sock contains the socket structure.
778 * @how contains the flag indicating how future sends and receives are handled.
779 * Return 0 if permission is granted.
780 * @socket_sock_rcv_skb:
781 * Check permissions on incoming network packets. This hook is distinct
782 * from Netfilter's IP input hooks since it is the first time that the
783 * incoming sk_buff @skb has been associated with a particular socket, @sk.
784 * @sk contains the sock (not socket) associated with the incoming sk_buff.
785 * @skb contains the incoming network data.
786 * @socket_getpeersec:
787 * This hook allows the security module to provide peer socket security
788 * state to userspace via getsockopt SO_GETPEERSEC.
789 * @sock is the local socket.
790 * @optval userspace memory where the security state is to be copied.
791 * @optlen userspace int where the module should copy the actual length
792 * of the security state.
793 * @len as input is the maximum length to copy to userspace provided
794 * by the caller.
795 * Return 0 if all is well, otherwise, typical getsockopt return
796 * values.
797 * @sk_alloc_security:
798 * Allocate and attach a security structure to the sk->sk_security field,
799 * which is used to copy security attributes between local stream sockets.
800 * @sk_free_security:
801 * Deallocate security structure.
df71837d
TJ
802 * @sk_getsid:
803 * Retrieve the LSM-specific sid for the sock to enable caching of network
804 * authorizations.
805 *
806 * Security hooks for XFRM operations.
807 *
808 * @xfrm_policy_alloc_security:
809 * @xp contains the xfrm_policy being added to Security Policy Database
810 * used by the XFRM system.
811 * @sec_ctx contains the security context information being provided by
812 * the user-level policy update program (e.g., setkey).
c8c05a8e 813 * Allocate a security structure to the xp->security field.
df71837d
TJ
814 * The security field is initialized to NULL when the xfrm_policy is
815 * allocated.
816 * Return 0 if operation was successful (memory to allocate, legal context)
817 * @xfrm_policy_clone_security:
818 * @old contains an existing xfrm_policy in the SPD.
819 * @new contains a new xfrm_policy being cloned from old.
c8c05a8e
CZ
820 * Allocate a security structure to the new->security field
821 * that contains the information from the old->security field.
df71837d
TJ
822 * Return 0 if operation was successful (memory to allocate).
823 * @xfrm_policy_free_security:
824 * @xp contains the xfrm_policy
c8c05a8e
CZ
825 * Deallocate xp->security.
826 * @xfrm_policy_delete_security:
827 * @xp contains the xfrm_policy.
828 * Authorize deletion of xp->security.
df71837d
TJ
829 * @xfrm_state_alloc_security:
830 * @x contains the xfrm_state being added to the Security Association
831 * Database by the XFRM system.
832 * @sec_ctx contains the security context information being provided by
833 * the user-level SA generation program (e.g., setkey or racoon).
c8c05a8e 834 * Allocate a security structure to the x->security field. The
df71837d
TJ
835 * security field is initialized to NULL when the xfrm_state is
836 * allocated.
837 * Return 0 if operation was successful (memory to allocate, legal context).
838 * @xfrm_state_free_security:
839 * @x contains the xfrm_state.
c8c05a8e
CZ
840 * Deallocate x->security.
841 * @xfrm_state_delete_security:
842 * @x contains the xfrm_state.
843 * Authorize deletion of x->security.
df71837d
TJ
844 * @xfrm_policy_lookup:
845 * @xp contains the xfrm_policy for which the access control is being
846 * checked.
847 * @sk_sid contains the sock security label that is used to authorize
848 * access to the policy xp.
849 * @dir contains the direction of the flow (input or output).
850 * Check permission when a sock selects a xfrm_policy for processing
851 * XFRMs on a packet. The hook is called when selecting either a
852 * per-socket policy or a generic xfrm policy.
853 * Return 0 if permission is granted.
1da177e4 854 *
29db9190
DH
855 * Security hooks affecting all Key Management operations
856 *
857 * @key_alloc:
858 * Permit allocation of a key and assign security data. Note that key does
859 * not have a serial number assigned at this point.
860 * @key points to the key.
861 * Return 0 if permission is granted, -ve error otherwise.
862 * @key_free:
863 * Notification of destruction; free security data.
864 * @key points to the key.
865 * No return value.
866 * @key_permission:
867 * See whether a specific operational right is granted to a process on a
868 * key.
869 * @key_ref refers to the key (key pointer + possession attribute bit).
870 * @context points to the process to provide the context against which to
871 * evaluate the security data on the key.
872 * @perm describes the combination of permissions required of this key.
873 * Return 1 if permission granted, 0 if permission denied and -ve it the
874 * normal permissions model should be effected.
875 *
1da177e4
LT
876 * Security hooks affecting all System V IPC operations.
877 *
878 * @ipc_permission:
879 * Check permissions for access to IPC
880 * @ipcp contains the kernel IPC permission structure
881 * @flag contains the desired (requested) permission set
882 * Return 0 if permission is granted.
883 *
884 * Security hooks for individual messages held in System V IPC message queues
885 * @msg_msg_alloc_security:
886 * Allocate and attach a security structure to the msg->security field.
887 * The security field is initialized to NULL when the structure is first
888 * created.
889 * @msg contains the message structure to be modified.
890 * Return 0 if operation was successful and permission is granted.
891 * @msg_msg_free_security:
892 * Deallocate the security structure for this message.
893 * @msg contains the message structure to be modified.
894 *
895 * Security hooks for System V IPC Message Queues
896 *
897 * @msg_queue_alloc_security:
898 * Allocate and attach a security structure to the
899 * msq->q_perm.security field. The security field is initialized to
900 * NULL when the structure is first created.
901 * @msq contains the message queue structure to be modified.
902 * Return 0 if operation was successful and permission is granted.
903 * @msg_queue_free_security:
904 * Deallocate security structure for this message queue.
905 * @msq contains the message queue structure to be modified.
906 * @msg_queue_associate:
907 * Check permission when a message queue is requested through the
908 * msgget system call. This hook is only called when returning the
909 * message queue identifier for an existing message queue, not when a
910 * new message queue is created.
911 * @msq contains the message queue to act upon.
912 * @msqflg contains the operation control flags.
913 * Return 0 if permission is granted.
914 * @msg_queue_msgctl:
915 * Check permission when a message control operation specified by @cmd
916 * is to be performed on the message queue @msq.
917 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
918 * @msq contains the message queue to act upon. May be NULL.
919 * @cmd contains the operation to be performed.
920 * Return 0 if permission is granted.
921 * @msg_queue_msgsnd:
922 * Check permission before a message, @msg, is enqueued on the message
923 * queue, @msq.
924 * @msq contains the message queue to send message to.
925 * @msg contains the message to be enqueued.
926 * @msqflg contains operational flags.
927 * Return 0 if permission is granted.
928 * @msg_queue_msgrcv:
929 * Check permission before a message, @msg, is removed from the message
930 * queue, @msq. The @target task structure contains a pointer to the
931 * process that will be receiving the message (not equal to the current
932 * process when inline receives are being performed).
933 * @msq contains the message queue to retrieve message from.
934 * @msg contains the message destination.
935 * @target contains the task structure for recipient process.
936 * @type contains the type of message requested.
937 * @mode contains the operational flags.
938 * Return 0 if permission is granted.
939 *
940 * Security hooks for System V Shared Memory Segments
941 *
942 * @shm_alloc_security:
943 * Allocate and attach a security structure to the shp->shm_perm.security
944 * field. The security field is initialized to NULL when the structure is
945 * first created.
946 * @shp contains the shared memory structure to be modified.
947 * Return 0 if operation was successful and permission is granted.
948 * @shm_free_security:
949 * Deallocate the security struct for this memory segment.
950 * @shp contains the shared memory structure to be modified.
951 * @shm_associate:
952 * Check permission when a shared memory region is requested through the
953 * shmget system call. This hook is only called when returning the shared
954 * memory region identifier for an existing region, not when a new shared
955 * memory region is created.
956 * @shp contains the shared memory structure to be modified.
957 * @shmflg contains the operation control flags.
958 * Return 0 if permission is granted.
959 * @shm_shmctl:
960 * Check permission when a shared memory control operation specified by
961 * @cmd is to be performed on the shared memory region @shp.
962 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
963 * @shp contains shared memory structure to be modified.
964 * @cmd contains the operation to be performed.
965 * Return 0 if permission is granted.
966 * @shm_shmat:
967 * Check permissions prior to allowing the shmat system call to attach the
968 * shared memory segment @shp to the data segment of the calling process.
969 * The attaching address is specified by @shmaddr.
970 * @shp contains the shared memory structure to be modified.
971 * @shmaddr contains the address to attach memory region to.
972 * @shmflg contains the operational flags.
973 * Return 0 if permission is granted.
974 *
975 * Security hooks for System V Semaphores
976 *
977 * @sem_alloc_security:
978 * Allocate and attach a security structure to the sma->sem_perm.security
979 * field. The security field is initialized to NULL when the structure is
980 * first created.
981 * @sma contains the semaphore structure
982 * Return 0 if operation was successful and permission is granted.
983 * @sem_free_security:
984 * deallocate security struct for this semaphore
985 * @sma contains the semaphore structure.
986 * @sem_associate:
987 * Check permission when a semaphore is requested through the semget
988 * system call. This hook is only called when returning the semaphore
989 * identifier for an existing semaphore, not when a new one must be
990 * created.
991 * @sma contains the semaphore structure.
992 * @semflg contains the operation control flags.
993 * Return 0 if permission is granted.
994 * @sem_semctl:
995 * Check permission when a semaphore operation specified by @cmd is to be
996 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
997 * IPC_INFO or SEM_INFO.
998 * @sma contains the semaphore structure. May be NULL.
999 * @cmd contains the operation to be performed.
1000 * Return 0 if permission is granted.
1001 * @sem_semop
1002 * Check permissions before performing operations on members of the
1003 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1004 * may be modified.
1005 * @sma contains the semaphore structure.
1006 * @sops contains the operations to perform.
1007 * @nsops contains the number of operations to perform.
1008 * @alter contains the flag indicating whether changes are to be made.
1009 * Return 0 if permission is granted.
1010 *
1011 * @ptrace:
1012 * Check permission before allowing the @parent process to trace the
1013 * @child process.
1014 * Security modules may also want to perform a process tracing check
1015 * during an execve in the set_security or apply_creds hooks of
1016 * binprm_security_ops if the process is being traced and its security
1017 * attributes would be changed by the execve.
1018 * @parent contains the task_struct structure for parent process.
1019 * @child contains the task_struct structure for child process.
1020 * Return 0 if permission is granted.
1021 * @capget:
1022 * Get the @effective, @inheritable, and @permitted capability sets for
1023 * the @target process. The hook may also perform permission checking to
1024 * determine if the current process is allowed to see the capability sets
1025 * of the @target process.
1026 * @target contains the task_struct structure for target process.
1027 * @effective contains the effective capability set.
1028 * @inheritable contains the inheritable capability set.
1029 * @permitted contains the permitted capability set.
1030 * Return 0 if the capability sets were successfully obtained.
1031 * @capset_check:
1032 * Check permission before setting the @effective, @inheritable, and
1033 * @permitted capability sets for the @target process.
1034 * Caveat: @target is also set to current if a set of processes is
1035 * specified (i.e. all processes other than current and init or a
1036 * particular process group). Hence, the capset_set hook may need to
1037 * revalidate permission to the actual target process.
1038 * @target contains the task_struct structure for target process.
1039 * @effective contains the effective capability set.
1040 * @inheritable contains the inheritable capability set.
1041 * @permitted contains the permitted capability set.
1042 * Return 0 if permission is granted.
1043 * @capset_set:
1044 * Set the @effective, @inheritable, and @permitted capability sets for
1045 * the @target process. Since capset_check cannot always check permission
1046 * to the real @target process, this hook may also perform permission
1047 * checking to determine if the current process is allowed to set the
1048 * capability sets of the @target process. However, this hook has no way
1049 * of returning an error due to the structure of the sys_capset code.
1050 * @target contains the task_struct structure for target process.
1051 * @effective contains the effective capability set.
1052 * @inheritable contains the inheritable capability set.
1053 * @permitted contains the permitted capability set.
12b5989b
CW
1054 * @capable:
1055 * Check whether the @tsk process has the @cap capability.
1056 * @tsk contains the task_struct for the process.
1057 * @cap contains the capability <include/linux/capability.h>.
1058 * Return 0 if the capability is granted for @tsk.
1da177e4
LT
1059 * @acct:
1060 * Check permission before enabling or disabling process accounting. If
1061 * accounting is being enabled, then @file refers to the open file used to
1062 * store accounting records. If accounting is being disabled, then @file
1063 * is NULL.
1064 * @file contains the file structure for the accounting file (may be NULL).
1065 * Return 0 if permission is granted.
1066 * @sysctl:
1067 * Check permission before accessing the @table sysctl variable in the
1068 * manner specified by @op.
1069 * @table contains the ctl_table structure for the sysctl variable.
1070 * @op contains the operation (001 = search, 002 = write, 004 = read).
1071 * Return 0 if permission is granted.
1da177e4
LT
1072 * @syslog:
1073 * Check permission before accessing the kernel message ring or changing
1074 * logging to the console.
1075 * See the syslog(2) manual page for an explanation of the @type values.
1076 * @type contains the type of action.
1077 * Return 0 if permission is granted.
1078 * @settime:
1079 * Check permission to change the system time.
1080 * struct timespec and timezone are defined in include/linux/time.h
1081 * @ts contains new time
1082 * @tz contains new timezone
1083 * Return 0 if permission is granted.
1084 * @vm_enough_memory:
1085 * Check permissions for allocating a new virtual mapping.
1086 * @pages contains the number of pages.
1087 * Return 0 if permission is granted.
1088 *
1089 * @register_security:
1090 * allow module stacking.
1091 * @name contains the name of the security module being stacked.
1092 * @ops contains a pointer to the struct security_operations of the module to stack.
1093 * @unregister_security:
1094 * remove a stacked module.
1095 * @name contains the name of the security module being unstacked.
1096 * @ops contains a pointer to the struct security_operations of the module to unstack.
1097 *
1098 * This is the main security structure.
1099 */
1100struct security_operations {
1101 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1102 int (*capget) (struct task_struct * target,
1103 kernel_cap_t * effective,
1104 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1105 int (*capset_check) (struct task_struct * target,
1106 kernel_cap_t * effective,
1107 kernel_cap_t * inheritable,
1108 kernel_cap_t * permitted);
1109 void (*capset_set) (struct task_struct * target,
1110 kernel_cap_t * effective,
1111 kernel_cap_t * inheritable,
1112 kernel_cap_t * permitted);
12b5989b 1113 int (*capable) (struct task_struct * tsk, int cap);
1da177e4
LT
1114 int (*acct) (struct file * file);
1115 int (*sysctl) (struct ctl_table * table, int op);
1da177e4
LT
1116 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1117 int (*quota_on) (struct dentry * dentry);
1118 int (*syslog) (int type);
1119 int (*settime) (struct timespec *ts, struct timezone *tz);
1120 int (*vm_enough_memory) (long pages);
1121
1122 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1123 void (*bprm_free_security) (struct linux_binprm * bprm);
1124 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1125 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1126 int (*bprm_set_security) (struct linux_binprm * bprm);
1127 int (*bprm_check_security) (struct linux_binprm * bprm);
1128 int (*bprm_secureexec) (struct linux_binprm * bprm);
1129
1130 int (*sb_alloc_security) (struct super_block * sb);
1131 void (*sb_free_security) (struct super_block * sb);
1132 int (*sb_copy_data)(struct file_system_type *type,
1133 void *orig, void *copy);
1134 int (*sb_kern_mount) (struct super_block *sb, void *data);
726c3342 1135 int (*sb_statfs) (struct dentry *dentry);
1da177e4
LT
1136 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1137 char *type, unsigned long flags, void *data);
1138 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1139 int (*sb_umount) (struct vfsmount * mnt, int flags);
1140 void (*sb_umount_close) (struct vfsmount * mnt);
1141 void (*sb_umount_busy) (struct vfsmount * mnt);
1142 void (*sb_post_remount) (struct vfsmount * mnt,
1143 unsigned long flags, void *data);
1144 void (*sb_post_mountroot) (void);
1145 void (*sb_post_addmount) (struct vfsmount * mnt,
1146 struct nameidata * mountpoint_nd);
1147 int (*sb_pivotroot) (struct nameidata * old_nd,
1148 struct nameidata * new_nd);
1149 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1150 struct nameidata * new_nd);
1151
1152 int (*inode_alloc_security) (struct inode *inode);
1153 void (*inode_free_security) (struct inode *inode);
5e41ff9e
SS
1154 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1155 char **name, void **value, size_t *len);
1da177e4
LT
1156 int (*inode_create) (struct inode *dir,
1157 struct dentry *dentry, int mode);
1da177e4
LT
1158 int (*inode_link) (struct dentry *old_dentry,
1159 struct inode *dir, struct dentry *new_dentry);
1da177e4
LT
1160 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1161 int (*inode_symlink) (struct inode *dir,
1162 struct dentry *dentry, const char *old_name);
1da177e4 1163 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1da177e4
LT
1164 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1165 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1166 int mode, dev_t dev);
1da177e4
LT
1167 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1168 struct inode *new_dir, struct dentry *new_dentry);
1da177e4
LT
1169 int (*inode_readlink) (struct dentry *dentry);
1170 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1171 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1172 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1173 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1174 void (*inode_delete) (struct inode *inode);
1175 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1176 size_t size, int flags);
1177 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1178 size_t size, int flags);
1179 int (*inode_getxattr) (struct dentry *dentry, char *name);
1180 int (*inode_listxattr) (struct dentry *dentry);
1181 int (*inode_removexattr) (struct dentry *dentry, char *name);
7306a0b9
DK
1182 const char *(*inode_xattr_getsuffix) (void);
1183 int (*inode_getsecurity)(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
1da177e4
LT
1184 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1185 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1186
1187 int (*file_permission) (struct file * file, int mask);
1188 int (*file_alloc_security) (struct file * file);
1189 void (*file_free_security) (struct file * file);
1190 int (*file_ioctl) (struct file * file, unsigned int cmd,
1191 unsigned long arg);
1192 int (*file_mmap) (struct file * file,
1193 unsigned long reqprot,
1194 unsigned long prot, unsigned long flags);
1195 int (*file_mprotect) (struct vm_area_struct * vma,
1196 unsigned long reqprot,
1197 unsigned long prot);
1198 int (*file_lock) (struct file * file, unsigned int cmd);
1199 int (*file_fcntl) (struct file * file, unsigned int cmd,
1200 unsigned long arg);
1201 int (*file_set_fowner) (struct file * file);
1202 int (*file_send_sigiotask) (struct task_struct * tsk,
1203 struct fown_struct * fown, int sig);
1204 int (*file_receive) (struct file * file);
1205
1206 int (*task_create) (unsigned long clone_flags);
1207 int (*task_alloc_security) (struct task_struct * p);
1208 void (*task_free_security) (struct task_struct * p);
1209 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1210 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1211 uid_t old_euid, uid_t old_suid, int flags);
1212 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1213 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1214 int (*task_getpgid) (struct task_struct * p);
1215 int (*task_getsid) (struct task_struct * p);
1216 int (*task_setgroups) (struct group_info *group_info);
1217 int (*task_setnice) (struct task_struct * p, int nice);
03e68060 1218 int (*task_setioprio) (struct task_struct * p, int ioprio);
1da177e4
LT
1219 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1220 int (*task_setscheduler) (struct task_struct * p, int policy,
1221 struct sched_param * lp);
1222 int (*task_getscheduler) (struct task_struct * p);
1223 int (*task_kill) (struct task_struct * p,
1224 struct siginfo * info, int sig);
1225 int (*task_wait) (struct task_struct * p);
1226 int (*task_prctl) (int option, unsigned long arg2,
1227 unsigned long arg3, unsigned long arg4,
1228 unsigned long arg5);
1229 void (*task_reparent_to_init) (struct task_struct * p);
1230 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1231
1232 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1233
1234 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1235 void (*msg_msg_free_security) (struct msg_msg * msg);
1236
1237 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1238 void (*msg_queue_free_security) (struct msg_queue * msq);
1239 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1240 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1241 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1242 struct msg_msg * msg, int msqflg);
1243 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1244 struct msg_msg * msg,
1245 struct task_struct * target,
1246 long type, int mode);
1247
1248 int (*shm_alloc_security) (struct shmid_kernel * shp);
1249 void (*shm_free_security) (struct shmid_kernel * shp);
1250 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1251 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1252 int (*shm_shmat) (struct shmid_kernel * shp,
1253 char __user *shmaddr, int shmflg);
1254
1255 int (*sem_alloc_security) (struct sem_array * sma);
1256 void (*sem_free_security) (struct sem_array * sma);
1257 int (*sem_associate) (struct sem_array * sma, int semflg);
1258 int (*sem_semctl) (struct sem_array * sma, int cmd);
1259 int (*sem_semop) (struct sem_array * sma,
1260 struct sembuf * sops, unsigned nsops, int alter);
1261
1262 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
1263 int (*netlink_recv) (struct sk_buff * skb);
1264
1265 /* allow module stacking */
1266 int (*register_security) (const char *name,
1267 struct security_operations *ops);
1268 int (*unregister_security) (const char *name,
1269 struct security_operations *ops);
1270
1271 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1272
1273 int (*getprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1274 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1275
1276#ifdef CONFIG_SECURITY_NETWORK
1277 int (*unix_stream_connect) (struct socket * sock,
1278 struct socket * other, struct sock * newsk);
1279 int (*unix_may_send) (struct socket * sock, struct socket * other);
1280
1281 int (*socket_create) (int family, int type, int protocol, int kern);
1282 void (*socket_post_create) (struct socket * sock, int family,
1283 int type, int protocol, int kern);
1284 int (*socket_bind) (struct socket * sock,
1285 struct sockaddr * address, int addrlen);
1286 int (*socket_connect) (struct socket * sock,
1287 struct sockaddr * address, int addrlen);
1288 int (*socket_listen) (struct socket * sock, int backlog);
1289 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1290 void (*socket_post_accept) (struct socket * sock,
1291 struct socket * newsock);
1292 int (*socket_sendmsg) (struct socket * sock,
1293 struct msghdr * msg, int size);
1294 int (*socket_recvmsg) (struct socket * sock,
1295 struct msghdr * msg, int size, int flags);
1296 int (*socket_getsockname) (struct socket * sock);
1297 int (*socket_getpeername) (struct socket * sock);
1298 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1299 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1300 int (*socket_shutdown) (struct socket * sock, int how);
1301 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
2c7946a7
CZ
1302 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1303 int (*socket_getpeersec_dgram) (struct sk_buff *skb, char **secdata, u32 *seclen);
7d877f3b 1304 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1da177e4 1305 void (*sk_free_security) (struct sock *sk);
df71837d 1306 unsigned int (*sk_getsid) (struct sock *sk, struct flowi *fl, u8 dir);
1da177e4 1307#endif /* CONFIG_SECURITY_NETWORK */
29db9190 1308
df71837d
TJ
1309#ifdef CONFIG_SECURITY_NETWORK_XFRM
1310 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
1311 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1312 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
c8c05a8e 1313 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
df71837d
TJ
1314 int (*xfrm_state_alloc_security) (struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1315 void (*xfrm_state_free_security) (struct xfrm_state *x);
c8c05a8e 1316 int (*xfrm_state_delete_security) (struct xfrm_state *x);
df71837d
TJ
1317 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 sk_sid, u8 dir);
1318#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1319
29db9190
DH
1320 /* key management security hooks */
1321#ifdef CONFIG_KEYS
d720024e 1322 int (*key_alloc)(struct key *key, struct task_struct *tsk);
29db9190
DH
1323 void (*key_free)(struct key *key);
1324 int (*key_permission)(key_ref_t key_ref,
1325 struct task_struct *context,
1326 key_perm_t perm);
1327
1328#endif /* CONFIG_KEYS */
1329
1da177e4
LT
1330};
1331
1332/* global variables */
1333extern struct security_operations *security_ops;
1334
1335/* inline stuff */
1336static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1337{
1338 return security_ops->ptrace (parent, child);
1339}
1340
1341static inline int security_capget (struct task_struct *target,
1342 kernel_cap_t *effective,
1343 kernel_cap_t *inheritable,
1344 kernel_cap_t *permitted)
1345{
1346 return security_ops->capget (target, effective, inheritable, permitted);
1347}
1348
1349static inline int security_capset_check (struct task_struct *target,
1350 kernel_cap_t *effective,
1351 kernel_cap_t *inheritable,
1352 kernel_cap_t *permitted)
1353{
1354 return security_ops->capset_check (target, effective, inheritable, permitted);
1355}
1356
1357static inline void security_capset_set (struct task_struct *target,
1358 kernel_cap_t *effective,
1359 kernel_cap_t *inheritable,
1360 kernel_cap_t *permitted)
1361{
1362 security_ops->capset_set (target, effective, inheritable, permitted);
1363}
1364
12b5989b
CW
1365static inline int security_capable(struct task_struct *tsk, int cap)
1366{
1367 return security_ops->capable(tsk, cap);
1368}
1369
1da177e4
LT
1370static inline int security_acct (struct file *file)
1371{
1372 return security_ops->acct (file);
1373}
1374
1375static inline int security_sysctl(struct ctl_table *table, int op)
1376{
1377 return security_ops->sysctl(table, op);
1378}
1379
1380static inline int security_quotactl (int cmds, int type, int id,
1381 struct super_block *sb)
1382{
1383 return security_ops->quotactl (cmds, type, id, sb);
1384}
1385
1386static inline int security_quota_on (struct dentry * dentry)
1387{
1388 return security_ops->quota_on (dentry);
1389}
1390
1391static inline int security_syslog(int type)
1392{
1393 return security_ops->syslog(type);
1394}
1395
1396static inline int security_settime(struct timespec *ts, struct timezone *tz)
1397{
1398 return security_ops->settime(ts, tz);
1399}
1400
1401
1402static inline int security_vm_enough_memory(long pages)
1403{
1404 return security_ops->vm_enough_memory(pages);
1405}
1406
1407static inline int security_bprm_alloc (struct linux_binprm *bprm)
1408{
1409 return security_ops->bprm_alloc_security (bprm);
1410}
1411static inline void security_bprm_free (struct linux_binprm *bprm)
1412{
1413 security_ops->bprm_free_security (bprm);
1414}
1415static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1416{
1417 security_ops->bprm_apply_creds (bprm, unsafe);
1418}
1419static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1420{
1421 security_ops->bprm_post_apply_creds (bprm);
1422}
1423static inline int security_bprm_set (struct linux_binprm *bprm)
1424{
1425 return security_ops->bprm_set_security (bprm);
1426}
1427
1428static inline int security_bprm_check (struct linux_binprm *bprm)
1429{
1430 return security_ops->bprm_check_security (bprm);
1431}
1432
1433static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1434{
1435 return security_ops->bprm_secureexec (bprm);
1436}
1437
1438static inline int security_sb_alloc (struct super_block *sb)
1439{
1440 return security_ops->sb_alloc_security (sb);
1441}
1442
1443static inline void security_sb_free (struct super_block *sb)
1444{
1445 security_ops->sb_free_security (sb);
1446}
1447
1448static inline int security_sb_copy_data (struct file_system_type *type,
1449 void *orig, void *copy)
1450{
1451 return security_ops->sb_copy_data (type, orig, copy);
1452}
1453
1454static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1455{
1456 return security_ops->sb_kern_mount (sb, data);
1457}
1458
726c3342 1459static inline int security_sb_statfs (struct dentry *dentry)
1da177e4 1460{
726c3342 1461 return security_ops->sb_statfs (dentry);
1da177e4
LT
1462}
1463
1464static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1465 char *type, unsigned long flags,
1466 void *data)
1467{
1468 return security_ops->sb_mount (dev_name, nd, type, flags, data);
1469}
1470
1471static inline int security_sb_check_sb (struct vfsmount *mnt,
1472 struct nameidata *nd)
1473{
1474 return security_ops->sb_check_sb (mnt, nd);
1475}
1476
1477static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1478{
1479 return security_ops->sb_umount (mnt, flags);
1480}
1481
1482static inline void security_sb_umount_close (struct vfsmount *mnt)
1483{
1484 security_ops->sb_umount_close (mnt);
1485}
1486
1487static inline void security_sb_umount_busy (struct vfsmount *mnt)
1488{
1489 security_ops->sb_umount_busy (mnt);
1490}
1491
1492static inline void security_sb_post_remount (struct vfsmount *mnt,
1493 unsigned long flags, void *data)
1494{
1495 security_ops->sb_post_remount (mnt, flags, data);
1496}
1497
1498static inline void security_sb_post_mountroot (void)
1499{
1500 security_ops->sb_post_mountroot ();
1501}
1502
1503static inline void security_sb_post_addmount (struct vfsmount *mnt,
1504 struct nameidata *mountpoint_nd)
1505{
1506 security_ops->sb_post_addmount (mnt, mountpoint_nd);
1507}
1508
1509static inline int security_sb_pivotroot (struct nameidata *old_nd,
1510 struct nameidata *new_nd)
1511{
1512 return security_ops->sb_pivotroot (old_nd, new_nd);
1513}
1514
1515static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1516 struct nameidata *new_nd)
1517{
1518 security_ops->sb_post_pivotroot (old_nd, new_nd);
1519}
1520
1521static inline int security_inode_alloc (struct inode *inode)
1522{
1da177e4
LT
1523 return security_ops->inode_alloc_security (inode);
1524}
1525
1526static inline void security_inode_free (struct inode *inode)
1527{
1da177e4
LT
1528 security_ops->inode_free_security (inode);
1529}
5e41ff9e
SS
1530
1531static inline int security_inode_init_security (struct inode *inode,
1532 struct inode *dir,
1533 char **name,
1534 void **value,
1535 size_t *len)
1536{
1537 if (unlikely (IS_PRIVATE (inode)))
1538 return -EOPNOTSUPP;
1539 return security_ops->inode_init_security (inode, dir, name, value, len);
1540}
1da177e4
LT
1541
1542static inline int security_inode_create (struct inode *dir,
1543 struct dentry *dentry,
1544 int mode)
1545{
1546 if (unlikely (IS_PRIVATE (dir)))
1547 return 0;
1548 return security_ops->inode_create (dir, dentry, mode);
1549}
1550
1da177e4
LT
1551static inline int security_inode_link (struct dentry *old_dentry,
1552 struct inode *dir,
1553 struct dentry *new_dentry)
1554{
1555 if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
1556 return 0;
1557 return security_ops->inode_link (old_dentry, dir, new_dentry);
1558}
1559
1da177e4
LT
1560static inline int security_inode_unlink (struct inode *dir,
1561 struct dentry *dentry)
1562{
1563 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1564 return 0;
1565 return security_ops->inode_unlink (dir, dentry);
1566}
1567
1568static inline int security_inode_symlink (struct inode *dir,
1569 struct dentry *dentry,
1570 const char *old_name)
1571{
1572 if (unlikely (IS_PRIVATE (dir)))
1573 return 0;
1574 return security_ops->inode_symlink (dir, dentry, old_name);
1575}
1576
1da177e4
LT
1577static inline int security_inode_mkdir (struct inode *dir,
1578 struct dentry *dentry,
1579 int mode)
1580{
1581 if (unlikely (IS_PRIVATE (dir)))
1582 return 0;
1583 return security_ops->inode_mkdir (dir, dentry, mode);
1584}
1585
1da177e4
LT
1586static inline int security_inode_rmdir (struct inode *dir,
1587 struct dentry *dentry)
1588{
1589 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1590 return 0;
1591 return security_ops->inode_rmdir (dir, dentry);
1592}
1593
1594static inline int security_inode_mknod (struct inode *dir,
1595 struct dentry *dentry,
1596 int mode, dev_t dev)
1597{
1598 if (unlikely (IS_PRIVATE (dir)))
1599 return 0;
1600 return security_ops->inode_mknod (dir, dentry, mode, dev);
1601}
1602
1da177e4
LT
1603static inline int security_inode_rename (struct inode *old_dir,
1604 struct dentry *old_dentry,
1605 struct inode *new_dir,
1606 struct dentry *new_dentry)
1607{
1608 if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
1609 (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
1610 return 0;
1611 return security_ops->inode_rename (old_dir, old_dentry,
1612 new_dir, new_dentry);
1613}
1614
1da177e4
LT
1615static inline int security_inode_readlink (struct dentry *dentry)
1616{
1617 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1618 return 0;
1619 return security_ops->inode_readlink (dentry);
1620}
1621
1622static inline int security_inode_follow_link (struct dentry *dentry,
1623 struct nameidata *nd)
1624{
1625 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1626 return 0;
1627 return security_ops->inode_follow_link (dentry, nd);
1628}
1629
1630static inline int security_inode_permission (struct inode *inode, int mask,
1631 struct nameidata *nd)
1632{
1633 if (unlikely (IS_PRIVATE (inode)))
1634 return 0;
1635 return security_ops->inode_permission (inode, mask, nd);
1636}
1637
1638static inline int security_inode_setattr (struct dentry *dentry,
1639 struct iattr *attr)
1640{
1641 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1642 return 0;
1643 return security_ops->inode_setattr (dentry, attr);
1644}
1645
1646static inline int security_inode_getattr (struct vfsmount *mnt,
1647 struct dentry *dentry)
1648{
1649 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1650 return 0;
1651 return security_ops->inode_getattr (mnt, dentry);
1652}
1653
1654static inline void security_inode_delete (struct inode *inode)
1655{
1656 if (unlikely (IS_PRIVATE (inode)))
1657 return;
1658 security_ops->inode_delete (inode);
1659}
1660
1661static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1662 void *value, size_t size, int flags)
1663{
1664 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1665 return 0;
1666 return security_ops->inode_setxattr (dentry, name, value, size, flags);
1667}
1668
1669static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1670 void *value, size_t size, int flags)
1671{
1672 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1673 return;
1674 security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1675}
1676
1677static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1678{
1679 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1680 return 0;
1681 return security_ops->inode_getxattr (dentry, name);
1682}
1683
1684static inline int security_inode_listxattr (struct dentry *dentry)
1685{
1686 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1687 return 0;
1688 return security_ops->inode_listxattr (dentry);
1689}
1690
1691static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1692{
1693 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1694 return 0;
1695 return security_ops->inode_removexattr (dentry, name);
1696}
1697
8c8570fb
DK
1698static inline const char *security_inode_xattr_getsuffix(void)
1699{
1700 return security_ops->inode_xattr_getsuffix();
1701}
1702
7306a0b9 1703static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
1da177e4
LT
1704{
1705 if (unlikely (IS_PRIVATE (inode)))
1706 return 0;
d381d8a9 1707 return security_ops->inode_getsecurity(inode, name, buffer, size, err);
1da177e4
LT
1708}
1709
1710static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1711{
1712 if (unlikely (IS_PRIVATE (inode)))
1713 return 0;
1714 return security_ops->inode_setsecurity(inode, name, value, size, flags);
1715}
1716
1717static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1718{
1719 if (unlikely (IS_PRIVATE (inode)))
1720 return 0;
1721 return security_ops->inode_listsecurity(inode, buffer, buffer_size);
1722}
1723
1724static inline int security_file_permission (struct file *file, int mask)
1725{
1726 return security_ops->file_permission (file, mask);
1727}
1728
1729static inline int security_file_alloc (struct file *file)
1730{
1731 return security_ops->file_alloc_security (file);
1732}
1733
1734static inline void security_file_free (struct file *file)
1735{
1736 security_ops->file_free_security (file);
1737}
1738
1739static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1740 unsigned long arg)
1741{
1742 return security_ops->file_ioctl (file, cmd, arg);
1743}
1744
1745static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1746 unsigned long prot,
1747 unsigned long flags)
1748{
1749 return security_ops->file_mmap (file, reqprot, prot, flags);
1750}
1751
1752static inline int security_file_mprotect (struct vm_area_struct *vma,
1753 unsigned long reqprot,
1754 unsigned long prot)
1755{
1756 return security_ops->file_mprotect (vma, reqprot, prot);
1757}
1758
1759static inline int security_file_lock (struct file *file, unsigned int cmd)
1760{
1761 return security_ops->file_lock (file, cmd);
1762}
1763
1764static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1765 unsigned long arg)
1766{
1767 return security_ops->file_fcntl (file, cmd, arg);
1768}
1769
1770static inline int security_file_set_fowner (struct file *file)
1771{
1772 return security_ops->file_set_fowner (file);
1773}
1774
1775static inline int security_file_send_sigiotask (struct task_struct *tsk,
1776 struct fown_struct *fown,
1777 int sig)
1778{
1779 return security_ops->file_send_sigiotask (tsk, fown, sig);
1780}
1781
1782static inline int security_file_receive (struct file *file)
1783{
1784 return security_ops->file_receive (file);
1785}
1786
1787static inline int security_task_create (unsigned long clone_flags)
1788{
1789 return security_ops->task_create (clone_flags);
1790}
1791
1792static inline int security_task_alloc (struct task_struct *p)
1793{
1794 return security_ops->task_alloc_security (p);
1795}
1796
1797static inline void security_task_free (struct task_struct *p)
1798{
1799 security_ops->task_free_security (p);
1800}
1801
1802static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1803 int flags)
1804{
1805 return security_ops->task_setuid (id0, id1, id2, flags);
1806}
1807
1808static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1809 uid_t old_suid, int flags)
1810{
1811 return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1812}
1813
1814static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1815 int flags)
1816{
1817 return security_ops->task_setgid (id0, id1, id2, flags);
1818}
1819
1820static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1821{
1822 return security_ops->task_setpgid (p, pgid);
1823}
1824
1825static inline int security_task_getpgid (struct task_struct *p)
1826{
1827 return security_ops->task_getpgid (p);
1828}
1829
1830static inline int security_task_getsid (struct task_struct *p)
1831{
1832 return security_ops->task_getsid (p);
1833}
1834
1835static inline int security_task_setgroups (struct group_info *group_info)
1836{
1837 return security_ops->task_setgroups (group_info);
1838}
1839
1840static inline int security_task_setnice (struct task_struct *p, int nice)
1841{
1842 return security_ops->task_setnice (p, nice);
1843}
1844
03e68060
JM
1845static inline int security_task_setioprio (struct task_struct *p, int ioprio)
1846{
1847 return security_ops->task_setioprio (p, ioprio);
1848}
1849
1da177e4
LT
1850static inline int security_task_setrlimit (unsigned int resource,
1851 struct rlimit *new_rlim)
1852{
1853 return security_ops->task_setrlimit (resource, new_rlim);
1854}
1855
1856static inline int security_task_setscheduler (struct task_struct *p,
1857 int policy,
1858 struct sched_param *lp)
1859{
1860 return security_ops->task_setscheduler (p, policy, lp);
1861}
1862
1863static inline int security_task_getscheduler (struct task_struct *p)
1864{
1865 return security_ops->task_getscheduler (p);
1866}
1867
1868static inline int security_task_kill (struct task_struct *p,
1869 struct siginfo *info, int sig)
1870{
1871 return security_ops->task_kill (p, info, sig);
1872}
1873
1874static inline int security_task_wait (struct task_struct *p)
1875{
1876 return security_ops->task_wait (p);
1877}
1878
1879static inline int security_task_prctl (int option, unsigned long arg2,
1880 unsigned long arg3,
1881 unsigned long arg4,
1882 unsigned long arg5)
1883{
1884 return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1885}
1886
1887static inline void security_task_reparent_to_init (struct task_struct *p)
1888{
1889 security_ops->task_reparent_to_init (p);
1890}
1891
1892static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1893{
1894 security_ops->task_to_inode(p, inode);
1895}
1896
1897static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
1898 short flag)
1899{
1900 return security_ops->ipc_permission (ipcp, flag);
1901}
1902
1903static inline int security_msg_msg_alloc (struct msg_msg * msg)
1904{
1905 return security_ops->msg_msg_alloc_security (msg);
1906}
1907
1908static inline void security_msg_msg_free (struct msg_msg * msg)
1909{
1910 security_ops->msg_msg_free_security(msg);
1911}
1912
1913static inline int security_msg_queue_alloc (struct msg_queue *msq)
1914{
1915 return security_ops->msg_queue_alloc_security (msq);
1916}
1917
1918static inline void security_msg_queue_free (struct msg_queue *msq)
1919{
1920 security_ops->msg_queue_free_security (msq);
1921}
1922
1923static inline int security_msg_queue_associate (struct msg_queue * msq,
1924 int msqflg)
1925{
1926 return security_ops->msg_queue_associate (msq, msqflg);
1927}
1928
1929static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
1930{
1931 return security_ops->msg_queue_msgctl (msq, cmd);
1932}
1933
1934static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
1935 struct msg_msg * msg, int msqflg)
1936{
1937 return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
1938}
1939
1940static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
1941 struct msg_msg * msg,
1942 struct task_struct * target,
1943 long type, int mode)
1944{
1945 return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
1946}
1947
1948static inline int security_shm_alloc (struct shmid_kernel *shp)
1949{
1950 return security_ops->shm_alloc_security (shp);
1951}
1952
1953static inline void security_shm_free (struct shmid_kernel *shp)
1954{
1955 security_ops->shm_free_security (shp);
1956}
1957
1958static inline int security_shm_associate (struct shmid_kernel * shp,
1959 int shmflg)
1960{
1961 return security_ops->shm_associate(shp, shmflg);
1962}
1963
1964static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
1965{
1966 return security_ops->shm_shmctl (shp, cmd);
1967}
1968
1969static inline int security_shm_shmat (struct shmid_kernel * shp,
1970 char __user *shmaddr, int shmflg)
1971{
1972 return security_ops->shm_shmat(shp, shmaddr, shmflg);
1973}
1974
1975static inline int security_sem_alloc (struct sem_array *sma)
1976{
1977 return security_ops->sem_alloc_security (sma);
1978}
1979
1980static inline void security_sem_free (struct sem_array *sma)
1981{
1982 security_ops->sem_free_security (sma);
1983}
1984
1985static inline int security_sem_associate (struct sem_array * sma, int semflg)
1986{
1987 return security_ops->sem_associate (sma, semflg);
1988}
1989
1990static inline int security_sem_semctl (struct sem_array * sma, int cmd)
1991{
1992 return security_ops->sem_semctl(sma, cmd);
1993}
1994
1995static inline int security_sem_semop (struct sem_array * sma,
1996 struct sembuf * sops, unsigned nsops,
1997 int alter)
1998{
1999 return security_ops->sem_semop(sma, sops, nsops, alter);
2000}
2001
2002static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2003{
2004 if (unlikely (inode && IS_PRIVATE (inode)))
2005 return;
2006 security_ops->d_instantiate (dentry, inode);
2007}
2008
2009static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2010{
2011 return security_ops->getprocattr(p, name, value, size);
2012}
2013
2014static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2015{
2016 return security_ops->setprocattr(p, name, value, size);
2017}
2018
2019static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
2020{
2021 return security_ops->netlink_send(sk, skb);
2022}
2023
2024static inline int security_netlink_recv(struct sk_buff * skb)
2025{
2026 return security_ops->netlink_recv(skb);
2027}
2028
2029/* prototypes */
2030extern int security_init (void);
2031extern int register_security (struct security_operations *ops);
2032extern int unregister_security (struct security_operations *ops);
2033extern int mod_reg_security (const char *name, struct security_operations *ops);
2034extern int mod_unreg_security (const char *name, struct security_operations *ops);
b67dbf9d
GKH
2035extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
2036 struct dentry *parent, void *data,
2037 struct file_operations *fops);
2038extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2039extern void securityfs_remove(struct dentry *dentry);
1da177e4
LT
2040
2041
2042#else /* CONFIG_SECURITY */
2043
2044/*
2045 * This is the default capabilities functionality. Most of these functions
2046 * are just stubbed out, but a few must call the proper capable code.
2047 */
2048
2049static inline int security_init(void)
2050{
2051 return 0;
2052}
2053
2054static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
2055{
2056 return cap_ptrace (parent, child);
2057}
2058
2059static inline int security_capget (struct task_struct *target,
2060 kernel_cap_t *effective,
2061 kernel_cap_t *inheritable,
2062 kernel_cap_t *permitted)
2063{
2064 return cap_capget (target, effective, inheritable, permitted);
2065}
2066
2067static inline int security_capset_check (struct task_struct *target,
2068 kernel_cap_t *effective,
2069 kernel_cap_t *inheritable,
2070 kernel_cap_t *permitted)
2071{
2072 return cap_capset_check (target, effective, inheritable, permitted);
2073}
2074
2075static inline void security_capset_set (struct task_struct *target,
2076 kernel_cap_t *effective,
2077 kernel_cap_t *inheritable,
2078 kernel_cap_t *permitted)
2079{
2080 cap_capset_set (target, effective, inheritable, permitted);
2081}
2082
12b5989b
CW
2083static inline int security_capable(struct task_struct *tsk, int cap)
2084{
2085 return cap_capable(tsk, cap);
2086}
2087
1da177e4
LT
2088static inline int security_acct (struct file *file)
2089{
2090 return 0;
2091}
2092
2093static inline int security_sysctl(struct ctl_table *table, int op)
2094{
2095 return 0;
2096}
2097
2098static inline int security_quotactl (int cmds, int type, int id,
2099 struct super_block * sb)
2100{
2101 return 0;
2102}
2103
2104static inline int security_quota_on (struct dentry * dentry)
2105{
2106 return 0;
2107}
2108
2109static inline int security_syslog(int type)
2110{
2111 return cap_syslog(type);
2112}
2113
2114static inline int security_settime(struct timespec *ts, struct timezone *tz)
2115{
2116 return cap_settime(ts, tz);
2117}
2118
2119static inline int security_vm_enough_memory(long pages)
2120{
2121 return cap_vm_enough_memory(pages);
2122}
2123
2124static inline int security_bprm_alloc (struct linux_binprm *bprm)
2125{
2126 return 0;
2127}
2128
2129static inline void security_bprm_free (struct linux_binprm *bprm)
2130{ }
2131
2132static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
2133{
2134 cap_bprm_apply_creds (bprm, unsafe);
2135}
2136
2137static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
2138{
2139 return;
2140}
2141
2142static inline int security_bprm_set (struct linux_binprm *bprm)
2143{
2144 return cap_bprm_set_security (bprm);
2145}
2146
2147static inline int security_bprm_check (struct linux_binprm *bprm)
2148{
2149 return 0;
2150}
2151
2152static inline int security_bprm_secureexec (struct linux_binprm *bprm)
2153{
2154 return cap_bprm_secureexec(bprm);
2155}
2156
2157static inline int security_sb_alloc (struct super_block *sb)
2158{
2159 return 0;
2160}
2161
2162static inline void security_sb_free (struct super_block *sb)
2163{ }
2164
2165static inline int security_sb_copy_data (struct file_system_type *type,
2166 void *orig, void *copy)
2167{
2168 return 0;
2169}
2170
2171static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2172{
2173 return 0;
2174}
2175
726c3342 2176static inline int security_sb_statfs (struct dentry *dentry)
1da177e4
LT
2177{
2178 return 0;
2179}
2180
2181static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2182 char *type, unsigned long flags,
2183 void *data)
2184{
2185 return 0;
2186}
2187
2188static inline int security_sb_check_sb (struct vfsmount *mnt,
2189 struct nameidata *nd)
2190{
2191 return 0;
2192}
2193
2194static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2195{
2196 return 0;
2197}
2198
2199static inline void security_sb_umount_close (struct vfsmount *mnt)
2200{ }
2201
2202static inline void security_sb_umount_busy (struct vfsmount *mnt)
2203{ }
2204
2205static inline void security_sb_post_remount (struct vfsmount *mnt,
2206 unsigned long flags, void *data)
2207{ }
2208
2209static inline void security_sb_post_mountroot (void)
2210{ }
2211
2212static inline void security_sb_post_addmount (struct vfsmount *mnt,
2213 struct nameidata *mountpoint_nd)
2214{ }
2215
2216static inline int security_sb_pivotroot (struct nameidata *old_nd,
2217 struct nameidata *new_nd)
2218{
2219 return 0;
2220}
2221
2222static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2223 struct nameidata *new_nd)
2224{ }
2225
2226static inline int security_inode_alloc (struct inode *inode)
2227{
2228 return 0;
2229}
2230
2231static inline void security_inode_free (struct inode *inode)
2232{ }
5e41ff9e
SS
2233
2234static inline int security_inode_init_security (struct inode *inode,
2235 struct inode *dir,
2236 char **name,
2237 void **value,
2238 size_t *len)
2239{
2240 return -EOPNOTSUPP;
2241}
1da177e4
LT
2242
2243static inline int security_inode_create (struct inode *dir,
2244 struct dentry *dentry,
2245 int mode)
2246{
2247 return 0;
2248}
2249
1da177e4
LT
2250static inline int security_inode_link (struct dentry *old_dentry,
2251 struct inode *dir,
2252 struct dentry *new_dentry)
2253{
2254 return 0;
2255}
2256
1da177e4
LT
2257static inline int security_inode_unlink (struct inode *dir,
2258 struct dentry *dentry)
2259{
2260 return 0;
2261}
2262
2263static inline int security_inode_symlink (struct inode *dir,
2264 struct dentry *dentry,
2265 const char *old_name)
2266{
2267 return 0;
2268}
2269
1da177e4
LT
2270static inline int security_inode_mkdir (struct inode *dir,
2271 struct dentry *dentry,
2272 int mode)
2273{
2274 return 0;
2275}
2276
1da177e4
LT
2277static inline int security_inode_rmdir (struct inode *dir,
2278 struct dentry *dentry)
2279{
2280 return 0;
2281}
2282
2283static inline int security_inode_mknod (struct inode *dir,
2284 struct dentry *dentry,
2285 int mode, dev_t dev)
2286{
2287 return 0;
2288}
2289
1da177e4
LT
2290static inline int security_inode_rename (struct inode *old_dir,
2291 struct dentry *old_dentry,
2292 struct inode *new_dir,
2293 struct dentry *new_dentry)
2294{
2295 return 0;
2296}
2297
1da177e4
LT
2298static inline int security_inode_readlink (struct dentry *dentry)
2299{
2300 return 0;
2301}
2302
2303static inline int security_inode_follow_link (struct dentry *dentry,
2304 struct nameidata *nd)
2305{
2306 return 0;
2307}
2308
2309static inline int security_inode_permission (struct inode *inode, int mask,
2310 struct nameidata *nd)
2311{
2312 return 0;
2313}
2314
2315static inline int security_inode_setattr (struct dentry *dentry,
2316 struct iattr *attr)
2317{
2318 return 0;
2319}
2320
2321static inline int security_inode_getattr (struct vfsmount *mnt,
2322 struct dentry *dentry)
2323{
2324 return 0;
2325}
2326
2327static inline void security_inode_delete (struct inode *inode)
2328{ }
2329
2330static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2331 void *value, size_t size, int flags)
2332{
2333 return cap_inode_setxattr(dentry, name, value, size, flags);
2334}
2335
2336static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2337 void *value, size_t size, int flags)
2338{ }
2339
2340static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2341{
2342 return 0;
2343}
2344
2345static inline int security_inode_listxattr (struct dentry *dentry)
2346{
2347 return 0;
2348}
2349
2350static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2351{
2352 return cap_inode_removexattr(dentry, name);
2353}
2354
8c8570fb
DK
2355static inline const char *security_inode_xattr_getsuffix (void)
2356{
2357 return NULL ;
2358}
2359
7306a0b9 2360static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
1da177e4
LT
2361{
2362 return -EOPNOTSUPP;
2363}
2364
2365static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2366{
2367 return -EOPNOTSUPP;
2368}
2369
2370static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2371{
2372 return 0;
2373}
2374
2375static inline int security_file_permission (struct file *file, int mask)
2376{
2377 return 0;
2378}
2379
2380static inline int security_file_alloc (struct file *file)
2381{
2382 return 0;
2383}
2384
2385static inline void security_file_free (struct file *file)
2386{ }
2387
2388static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2389 unsigned long arg)
2390{
2391 return 0;
2392}
2393
2394static inline int security_file_mmap (struct file *file, unsigned long reqprot,
2395 unsigned long prot,
2396 unsigned long flags)
2397{
2398 return 0;
2399}
2400
2401static inline int security_file_mprotect (struct vm_area_struct *vma,
2402 unsigned long reqprot,
2403 unsigned long prot)
2404{
2405 return 0;
2406}
2407
2408static inline int security_file_lock (struct file *file, unsigned int cmd)
2409{
2410 return 0;
2411}
2412
2413static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2414 unsigned long arg)
2415{
2416 return 0;
2417}
2418
2419static inline int security_file_set_fowner (struct file *file)
2420{
2421 return 0;
2422}
2423
2424static inline int security_file_send_sigiotask (struct task_struct *tsk,
2425 struct fown_struct *fown,
2426 int sig)
2427{
2428 return 0;
2429}
2430
2431static inline int security_file_receive (struct file *file)
2432{
2433 return 0;
2434}
2435
2436static inline int security_task_create (unsigned long clone_flags)
2437{
2438 return 0;
2439}
2440
2441static inline int security_task_alloc (struct task_struct *p)
2442{
2443 return 0;
2444}
2445
2446static inline void security_task_free (struct task_struct *p)
2447{ }
2448
2449static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2450 int flags)
2451{
2452 return 0;
2453}
2454
2455static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2456 uid_t old_suid, int flags)
2457{
2458 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2459}
2460
2461static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2462 int flags)
2463{
2464 return 0;
2465}
2466
2467static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2468{
2469 return 0;
2470}
2471
2472static inline int security_task_getpgid (struct task_struct *p)
2473{
2474 return 0;
2475}
2476
2477static inline int security_task_getsid (struct task_struct *p)
2478{
2479 return 0;
2480}
2481
2482static inline int security_task_setgroups (struct group_info *group_info)
2483{
2484 return 0;
2485}
2486
2487static inline int security_task_setnice (struct task_struct *p, int nice)
2488{
2489 return 0;
2490}
2491
03e68060
JM
2492static inline int security_task_setioprio (struct task_struct *p, int ioprio)
2493{
2494 return 0;
2495}
2496
1da177e4
LT
2497static inline int security_task_setrlimit (unsigned int resource,
2498 struct rlimit *new_rlim)
2499{
2500 return 0;
2501}
2502
2503static inline int security_task_setscheduler (struct task_struct *p,
2504 int policy,
2505 struct sched_param *lp)
2506{
2507 return 0;
2508}
2509
2510static inline int security_task_getscheduler (struct task_struct *p)
2511{
2512 return 0;
2513}
2514
2515static inline int security_task_kill (struct task_struct *p,
2516 struct siginfo *info, int sig)
2517{
2518 return 0;
2519}
2520
2521static inline int security_task_wait (struct task_struct *p)
2522{
2523 return 0;
2524}
2525
2526static inline int security_task_prctl (int option, unsigned long arg2,
2527 unsigned long arg3,
2528 unsigned long arg4,
2529 unsigned long arg5)
2530{
2531 return 0;
2532}
2533
2534static inline void security_task_reparent_to_init (struct task_struct *p)
2535{
2536 cap_task_reparent_to_init (p);
2537}
2538
2539static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2540{ }
2541
2542static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2543 short flag)
2544{
2545 return 0;
2546}
2547
2548static inline int security_msg_msg_alloc (struct msg_msg * msg)
2549{
2550 return 0;
2551}
2552
2553static inline void security_msg_msg_free (struct msg_msg * msg)
2554{ }
2555
2556static inline int security_msg_queue_alloc (struct msg_queue *msq)
2557{
2558 return 0;
2559}
2560
2561static inline void security_msg_queue_free (struct msg_queue *msq)
2562{ }
2563
2564static inline int security_msg_queue_associate (struct msg_queue * msq,
2565 int msqflg)
2566{
2567 return 0;
2568}
2569
2570static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2571{
2572 return 0;
2573}
2574
2575static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2576 struct msg_msg * msg, int msqflg)
2577{
2578 return 0;
2579}
2580
2581static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2582 struct msg_msg * msg,
2583 struct task_struct * target,
2584 long type, int mode)
2585{
2586 return 0;
2587}
2588
2589static inline int security_shm_alloc (struct shmid_kernel *shp)
2590{
2591 return 0;
2592}
2593
2594static inline void security_shm_free (struct shmid_kernel *shp)
2595{ }
2596
2597static inline int security_shm_associate (struct shmid_kernel * shp,
2598 int shmflg)
2599{
2600 return 0;
2601}
2602
2603static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2604{
2605 return 0;
2606}
2607
2608static inline int security_shm_shmat (struct shmid_kernel * shp,
2609 char __user *shmaddr, int shmflg)
2610{
2611 return 0;
2612}
2613
2614static inline int security_sem_alloc (struct sem_array *sma)
2615{
2616 return 0;
2617}
2618
2619static inline void security_sem_free (struct sem_array *sma)
2620{ }
2621
2622static inline int security_sem_associate (struct sem_array * sma, int semflg)
2623{
2624 return 0;
2625}
2626
2627static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2628{
2629 return 0;
2630}
2631
2632static inline int security_sem_semop (struct sem_array * sma,
2633 struct sembuf * sops, unsigned nsops,
2634 int alter)
2635{
2636 return 0;
2637}
2638
2639static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2640{ }
2641
2642static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2643{
2644 return -EINVAL;
2645}
2646
2647static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2648{
2649 return -EINVAL;
2650}
2651
2652static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2653{
2654 return cap_netlink_send (sk, skb);
2655}
2656
2657static inline int security_netlink_recv (struct sk_buff *skb)
2658{
2659 return cap_netlink_recv (skb);
2660}
2661
ed5a9270
RD
2662static inline struct dentry *securityfs_create_dir(const char *name,
2663 struct dentry *parent)
2664{
2665 return ERR_PTR(-ENODEV);
2666}
2667
2668static inline struct dentry *securityfs_create_file(const char *name,
2669 mode_t mode,
2670 struct dentry *parent,
2671 void *data,
2672 struct file_operations *fops)
2673{
2674 return ERR_PTR(-ENODEV);
2675}
2676
2677static inline void securityfs_remove(struct dentry *dentry)
2678{
2679}
2680
1da177e4
LT
2681#endif /* CONFIG_SECURITY */
2682
2683#ifdef CONFIG_SECURITY_NETWORK
2684static inline int security_unix_stream_connect(struct socket * sock,
2685 struct socket * other,
2686 struct sock * newsk)
2687{
2688 return security_ops->unix_stream_connect(sock, other, newsk);
2689}
2690
2691
2692static inline int security_unix_may_send(struct socket * sock,
2693 struct socket * other)
2694{
2695 return security_ops->unix_may_send(sock, other);
2696}
2697
2698static inline int security_socket_create (int family, int type,
2699 int protocol, int kern)
2700{
2701 return security_ops->socket_create(family, type, protocol, kern);
2702}
2703
2704static inline void security_socket_post_create(struct socket * sock,
2705 int family,
2706 int type,
2707 int protocol, int kern)
2708{
2709 security_ops->socket_post_create(sock, family, type,
2710 protocol, kern);
2711}
2712
2713static inline int security_socket_bind(struct socket * sock,
2714 struct sockaddr * address,
2715 int addrlen)
2716{
2717 return security_ops->socket_bind(sock, address, addrlen);
2718}
2719
2720static inline int security_socket_connect(struct socket * sock,
2721 struct sockaddr * address,
2722 int addrlen)
2723{
2724 return security_ops->socket_connect(sock, address, addrlen);
2725}
2726
2727static inline int security_socket_listen(struct socket * sock, int backlog)
2728{
2729 return security_ops->socket_listen(sock, backlog);
2730}
2731
2732static inline int security_socket_accept(struct socket * sock,
2733 struct socket * newsock)
2734{
2735 return security_ops->socket_accept(sock, newsock);
2736}
2737
2738static inline void security_socket_post_accept(struct socket * sock,
2739 struct socket * newsock)
2740{
2741 security_ops->socket_post_accept(sock, newsock);
2742}
2743
2744static inline int security_socket_sendmsg(struct socket * sock,
2745 struct msghdr * msg, int size)
2746{
2747 return security_ops->socket_sendmsg(sock, msg, size);
2748}
2749
2750static inline int security_socket_recvmsg(struct socket * sock,
2751 struct msghdr * msg, int size,
2752 int flags)
2753{
2754 return security_ops->socket_recvmsg(sock, msg, size, flags);
2755}
2756
2757static inline int security_socket_getsockname(struct socket * sock)
2758{
2759 return security_ops->socket_getsockname(sock);
2760}
2761
2762static inline int security_socket_getpeername(struct socket * sock)
2763{
2764 return security_ops->socket_getpeername(sock);
2765}
2766
2767static inline int security_socket_getsockopt(struct socket * sock,
2768 int level, int optname)
2769{
2770 return security_ops->socket_getsockopt(sock, level, optname);
2771}
2772
2773static inline int security_socket_setsockopt(struct socket * sock,
2774 int level, int optname)
2775{
2776 return security_ops->socket_setsockopt(sock, level, optname);
2777}
2778
2779static inline int security_socket_shutdown(struct socket * sock, int how)
2780{
2781 return security_ops->socket_shutdown(sock, how);
2782}
2783
2784static inline int security_sock_rcv_skb (struct sock * sk,
2785 struct sk_buff * skb)
2786{
2787 return security_ops->socket_sock_rcv_skb (sk, skb);
2788}
2789
2c7946a7
CZ
2790static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2791 int __user *optlen, unsigned len)
1da177e4 2792{
2c7946a7
CZ
2793 return security_ops->socket_getpeersec_stream(sock, optval, optlen, len);
2794}
2795
2796static inline int security_socket_getpeersec_dgram(struct sk_buff *skb, char **secdata,
2797 u32 *seclen)
2798{
2799 return security_ops->socket_getpeersec_dgram(skb, secdata, seclen);
1da177e4
LT
2800}
2801
dd0fc66f 2802static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
1da177e4
LT
2803{
2804 return security_ops->sk_alloc_security(sk, family, priority);
2805}
2806
2807static inline void security_sk_free(struct sock *sk)
2808{
2809 return security_ops->sk_free_security(sk);
2810}
df71837d
TJ
2811
2812static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir)
2813{
2814 return security_ops->sk_getsid(sk, fl, dir);
2815}
1da177e4
LT
2816#else /* CONFIG_SECURITY_NETWORK */
2817static inline int security_unix_stream_connect(struct socket * sock,
2818 struct socket * other,
2819 struct sock * newsk)
2820{
2821 return 0;
2822}
2823
2824static inline int security_unix_may_send(struct socket * sock,
2825 struct socket * other)
2826{
2827 return 0;
2828}
2829
2830static inline int security_socket_create (int family, int type,
2831 int protocol, int kern)
2832{
2833 return 0;
2834}
2835
2836static inline void security_socket_post_create(struct socket * sock,
2837 int family,
2838 int type,
2839 int protocol, int kern)
2840{
2841}
2842
2843static inline int security_socket_bind(struct socket * sock,
2844 struct sockaddr * address,
2845 int addrlen)
2846{
2847 return 0;
2848}
2849
2850static inline int security_socket_connect(struct socket * sock,
2851 struct sockaddr * address,
2852 int addrlen)
2853{
2854 return 0;
2855}
2856
2857static inline int security_socket_listen(struct socket * sock, int backlog)
2858{
2859 return 0;
2860}
2861
2862static inline int security_socket_accept(struct socket * sock,
2863 struct socket * newsock)
2864{
2865 return 0;
2866}
2867
2868static inline void security_socket_post_accept(struct socket * sock,
2869 struct socket * newsock)
2870{
2871}
2872
2873static inline int security_socket_sendmsg(struct socket * sock,
2874 struct msghdr * msg, int size)
2875{
2876 return 0;
2877}
2878
2879static inline int security_socket_recvmsg(struct socket * sock,
2880 struct msghdr * msg, int size,
2881 int flags)
2882{
2883 return 0;
2884}
2885
2886static inline int security_socket_getsockname(struct socket * sock)
2887{
2888 return 0;
2889}
2890
2891static inline int security_socket_getpeername(struct socket * sock)
2892{
2893 return 0;
2894}
2895
2896static inline int security_socket_getsockopt(struct socket * sock,
2897 int level, int optname)
2898{
2899 return 0;
2900}
2901
2902static inline int security_socket_setsockopt(struct socket * sock,
2903 int level, int optname)
2904{
2905 return 0;
2906}
2907
2908static inline int security_socket_shutdown(struct socket * sock, int how)
2909{
2910 return 0;
2911}
2912static inline int security_sock_rcv_skb (struct sock * sk,
2913 struct sk_buff * skb)
2914{
2915 return 0;
2916}
2917
2c7946a7
CZ
2918static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2919 int __user *optlen, unsigned len)
2920{
2921 return -ENOPROTOOPT;
2922}
2923
2924static inline int security_socket_getpeersec_dgram(struct sk_buff *skb, char **secdata,
2925 u32 *seclen)
1da177e4
LT
2926{
2927 return -ENOPROTOOPT;
2928}
2929
dd0fc66f 2930static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
1da177e4
LT
2931{
2932 return 0;
2933}
2934
2935static inline void security_sk_free(struct sock *sk)
2936{
2937}
df71837d
TJ
2938
2939static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir)
2940{
2941 return 0;
2942}
1da177e4
LT
2943#endif /* CONFIG_SECURITY_NETWORK */
2944
df71837d
TJ
2945#ifdef CONFIG_SECURITY_NETWORK_XFRM
2946static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
2947{
2948 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx);
2949}
2950
2951static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
2952{
2953 return security_ops->xfrm_policy_clone_security(old, new);
2954}
2955
2956static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
2957{
2958 security_ops->xfrm_policy_free_security(xp);
2959}
2960
c8c05a8e
CZ
2961static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
2962{
2963 return security_ops->xfrm_policy_delete_security(xp);
2964}
2965
df71837d
TJ
2966static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx)
2967{
2968 return security_ops->xfrm_state_alloc_security(x, sec_ctx);
2969}
2970
c8c05a8e
CZ
2971static inline int security_xfrm_state_delete(struct xfrm_state *x)
2972{
2973 return security_ops->xfrm_state_delete_security(x);
2974}
2975
df71837d
TJ
2976static inline void security_xfrm_state_free(struct xfrm_state *x)
2977{
2978 security_ops->xfrm_state_free_security(x);
2979}
2980
2981static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir)
2982{
2983 return security_ops->xfrm_policy_lookup(xp, sk_sid, dir);
2984}
2985#else /* CONFIG_SECURITY_NETWORK_XFRM */
2986static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
2987{
2988 return 0;
2989}
2990
2991static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
2992{
2993 return 0;
2994}
2995
2996static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
2997{
2998}
2999
c8c05a8e
CZ
3000static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3001{
3002 return 0;
3003}
3004
df71837d
TJ
3005static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx)
3006{
3007 return 0;
3008}
3009
3010static inline void security_xfrm_state_free(struct xfrm_state *x)
3011{
3012}
3013
6f68dc37 3014static inline int security_xfrm_state_delete(struct xfrm_state *x)
c8c05a8e
CZ
3015{
3016 return 0;
3017}
3018
df71837d
TJ
3019static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir)
3020{
3021 return 0;
3022}
3023#endif /* CONFIG_SECURITY_NETWORK_XFRM */
3024
29db9190
DH
3025#ifdef CONFIG_KEYS
3026#ifdef CONFIG_SECURITY
d720024e
ML
3027static inline int security_key_alloc(struct key *key,
3028 struct task_struct *tsk)
29db9190 3029{
d720024e 3030 return security_ops->key_alloc(key, tsk);
29db9190
DH
3031}
3032
3033static inline void security_key_free(struct key *key)
3034{
3035 security_ops->key_free(key);
3036}
3037
3038static inline int security_key_permission(key_ref_t key_ref,
3039 struct task_struct *context,
3040 key_perm_t perm)
3041{
3042 return security_ops->key_permission(key_ref, context, perm);
3043}
3044
3045#else
3046
d720024e
ML
3047static inline int security_key_alloc(struct key *key,
3048 struct task_struct *tsk)
29db9190
DH
3049{
3050 return 0;
3051}
3052
3053static inline void security_key_free(struct key *key)
3054{
3055}
3056
3057static inline int security_key_permission(key_ref_t key_ref,
3058 struct task_struct *context,
3059 key_perm_t perm)
3060{
3061 return 0;
3062}
3063
3064#endif
3065#endif /* CONFIG_KEYS */
3066
1da177e4
LT
3067#endif /* ! __LINUX_SECURITY_H */
3068