blob: d4b13d617f634d5d92d07abbe9da5ed57097ad01 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
David Howells29db9192005-10-30 15:02:44 -080033#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
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;
Trent Jaegerdf718372005-12-13 23:12:27 -080062struct flowi;
63struct dst_entry;
64struct xfrm_selector;
65struct xfrm_policy;
66struct xfrm_state;
67struct xfrm_user_sec_ctx;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
Darrel Goeddelc7bdb542006-06-27 13:26:11 -070070extern int cap_netlink_recv(struct sk_buff *skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
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:
David Howells726c3342006-06-23 02:02:58 -0700174 * Check permission before obtaining filesystem statistics for the @mnt
175 * mountpoint.
176 * @dentry is a handle on the superblock for the filesystem.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 * 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.
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700260 * @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.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 * @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.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 * @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.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 * @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.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 * @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.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 * @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.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 * @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.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 * @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.
James Morrisd381d8a2005-10-30 14:59:22 -0800395 * @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.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 * 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.
David Quigleyf9008e42006-06-30 01:55:46 -0700570 * @task_getsecid:
571 * Retrieve the security identifier of the process @p.
572 * @p contains the task_struct for the process and place is into @secid.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 * @task_setgroups:
574 * Check permission before setting the supplementary group set of the
575 * current process.
576 * @group_info contains the new group information.
577 * Return 0 if permission is granted.
578 * @task_setnice:
579 * Check permission before setting the nice value of @p to @nice.
580 * @p contains the task_struct of process.
581 * @nice contains the new nice value.
582 * Return 0 if permission is granted.
James Morris03e68062006-06-23 02:03:58 -0700583 * @task_setioprio
584 * Check permission before setting the ioprio value of @p to @ioprio.
585 * @p contains the task_struct of process.
586 * @ioprio contains the new ioprio value
587 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 * @task_setrlimit:
589 * Check permission before setting the resource limits of the current
590 * process for @resource to @new_rlim. The old resource limit values can
591 * be examined by dereferencing (current->signal->rlim + resource).
592 * @resource contains the resource whose limit is being set.
593 * @new_rlim contains the new limits for @resource.
594 * Return 0 if permission is granted.
595 * @task_setscheduler:
596 * Check permission before setting scheduling policy and/or parameters of
597 * process @p based on @policy and @lp.
598 * @p contains the task_struct for process.
599 * @policy contains the scheduling policy.
600 * @lp contains the scheduling parameters.
601 * Return 0 if permission is granted.
602 * @task_getscheduler:
603 * Check permission before obtaining scheduling information for process
604 * @p.
605 * @p contains the task_struct for process.
606 * Return 0 if permission is granted.
David Quigley35601542006-06-23 02:04:01 -0700607 * @task_movememory
608 * Check permission before moving memory owned by process @p.
609 * @p contains the task_struct for process.
610 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 * @task_kill:
612 * Check permission before sending signal @sig to @p. @info can be NULL,
613 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
614 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
615 * from the kernel and should typically be permitted.
616 * SIGIO signals are handled separately by the send_sigiotask hook in
617 * file_security_ops.
618 * @p contains the task_struct for process.
619 * @info contains the signal information.
620 * @sig contains the signal value.
David Quigleyf9008e42006-06-30 01:55:46 -0700621 * @secid contains the sid of the process where the signal originated
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 * Return 0 if permission is granted.
623 * @task_wait:
624 * Check permission before allowing a process to reap a child process @p
625 * and collect its status information.
626 * @p contains the task_struct for process.
627 * Return 0 if permission is granted.
628 * @task_prctl:
629 * Check permission before performing a process control operation on the
630 * current process.
631 * @option contains the operation.
632 * @arg2 contains a argument.
633 * @arg3 contains a argument.
634 * @arg4 contains a argument.
635 * @arg5 contains a argument.
636 * Return 0 if permission is granted.
637 * @task_reparent_to_init:
638 * Set the security attributes in @p->security for a kernel thread that
639 * is being reparented to the init task.
640 * @p contains the task_struct for the kernel thread.
641 * @task_to_inode:
642 * Set the security attributes for an inode based on an associated task's
643 * security attributes, e.g. for /proc/pid inodes.
644 * @p contains the task_struct for the task.
645 * @inode contains the inode structure for the inode.
646 *
647 * Security hooks for Netlink messaging.
648 *
649 * @netlink_send:
650 * Save security information for a netlink message so that permission
651 * checking can be performed when the message is processed. The security
652 * information can be saved using the eff_cap field of the
653 * netlink_skb_parms structure. Also may be used to provide fine
654 * grained control over message transmission.
655 * @sk associated sock of task sending the message.,
656 * @skb contains the sk_buff structure for the netlink message.
657 * Return 0 if the information was successfully saved and message
658 * is allowed to be transmitted.
659 * @netlink_recv:
660 * Check permission before processing the received netlink message in
661 * @skb.
662 * @skb contains the sk_buff structure for the netlink message.
Darrel Goeddelc7bdb542006-06-27 13:26:11 -0700663 * @cap indicates the capability required
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 * Return 0 if permission is granted.
665 *
666 * Security hooks for Unix domain networking.
667 *
668 * @unix_stream_connect:
669 * Check permissions before establishing a Unix domain stream connection
670 * between @sock and @other.
671 * @sock contains the socket structure.
672 * @other contains the peer socket structure.
673 * Return 0 if permission is granted.
674 * @unix_may_send:
675 * Check permissions before connecting or sending datagrams from @sock to
676 * @other.
677 * @sock contains the socket structure.
678 * @sock contains the peer socket structure.
679 * Return 0 if permission is granted.
680 *
681 * The @unix_stream_connect and @unix_may_send hooks were necessary because
682 * Linux provides an alternative to the conventional file name space for Unix
683 * domain sockets. Whereas binding and connecting to sockets in the file name
684 * space is mediated by the typical file permissions (and caught by the mknod
685 * and permission hooks in inode_security_ops), binding and connecting to
686 * sockets in the abstract name space is completely unmediated. Sufficient
687 * control of Unix domain sockets in the abstract name space isn't possible
688 * using only the socket layer hooks, since we need to know the actual target
689 * socket, which is not looked up until we are inside the af_unix code.
690 *
691 * Security hooks for socket operations.
692 *
693 * @socket_create:
694 * Check permissions prior to creating a new socket.
695 * @family contains the requested protocol family.
696 * @type contains the requested communications type.
697 * @protocol contains the requested protocol.
698 * @kern set to 1 if a kernel socket.
699 * Return 0 if permission is granted.
700 * @socket_post_create:
701 * This hook allows a module to update or allocate a per-socket security
702 * structure. Note that the security field was not added directly to the
703 * socket structure, but rather, the socket security information is stored
704 * in the associated inode. Typically, the inode alloc_security hook will
705 * allocate and and attach security information to
706 * sock->inode->i_security. This hook may be used to update the
707 * sock->inode->i_security field with additional information that wasn't
708 * available when the inode was allocated.
709 * @sock contains the newly created socket structure.
710 * @family contains the requested protocol family.
711 * @type contains the requested communications type.
712 * @protocol contains the requested protocol.
713 * @kern set to 1 if a kernel socket.
714 * @socket_bind:
715 * Check permission before socket protocol layer bind operation is
716 * performed and the socket @sock is bound to the address specified in the
717 * @address parameter.
718 * @sock contains the socket structure.
719 * @address contains the address to bind to.
720 * @addrlen contains the length of address.
721 * Return 0 if permission is granted.
722 * @socket_connect:
723 * Check permission before socket protocol layer connect operation
724 * attempts to connect socket @sock to a remote address, @address.
725 * @sock contains the socket structure.
726 * @address contains the address of remote endpoint.
727 * @addrlen contains the length of address.
728 * Return 0 if permission is granted.
729 * @socket_listen:
730 * Check permission before socket protocol layer listen operation.
731 * @sock contains the socket structure.
732 * @backlog contains the maximum length for the pending connection queue.
733 * Return 0 if permission is granted.
734 * @socket_accept:
735 * Check permission before accepting a new connection. Note that the new
736 * socket, @newsock, has been created and some information copied to it,
737 * but the accept operation has not actually been performed.
738 * @sock contains the listening socket structure.
739 * @newsock contains the newly created server socket for connection.
740 * Return 0 if permission is granted.
741 * @socket_post_accept:
742 * This hook allows a security module to copy security
743 * information into the newly created socket's inode.
744 * @sock contains the listening socket structure.
745 * @newsock contains the newly created server socket for connection.
746 * @socket_sendmsg:
747 * Check permission before transmitting a message to another socket.
748 * @sock contains the socket structure.
749 * @msg contains the message to be transmitted.
750 * @size contains the size of message.
751 * Return 0 if permission is granted.
752 * @socket_recvmsg:
753 * Check permission before receiving a message from a socket.
754 * @sock contains the socket structure.
755 * @msg contains the message structure.
756 * @size contains the size of message structure.
757 * @flags contains the operational flags.
758 * Return 0 if permission is granted.
759 * @socket_getsockname:
760 * Check permission before the local address (name) of the socket object
761 * @sock is retrieved.
762 * @sock contains the socket structure.
763 * Return 0 if permission is granted.
764 * @socket_getpeername:
765 * Check permission before the remote address (name) of a socket object
766 * @sock is retrieved.
767 * @sock contains the socket structure.
768 * Return 0 if permission is granted.
769 * @socket_getsockopt:
770 * Check permissions before retrieving the options associated with socket
771 * @sock.
772 * @sock contains the socket structure.
773 * @level contains the protocol level to retrieve option from.
774 * @optname contains the name of option to retrieve.
775 * Return 0 if permission is granted.
776 * @socket_setsockopt:
777 * Check permissions before setting the options associated with socket
778 * @sock.
779 * @sock contains the socket structure.
780 * @level contains the protocol level to set options for.
781 * @optname contains the name of the option to set.
782 * Return 0 if permission is granted.
783 * @socket_shutdown:
784 * Checks permission before all or part of a connection on the socket
785 * @sock is shut down.
786 * @sock contains the socket structure.
787 * @how contains the flag indicating how future sends and receives are handled.
788 * Return 0 if permission is granted.
789 * @socket_sock_rcv_skb:
790 * Check permissions on incoming network packets. This hook is distinct
791 * from Netfilter's IP input hooks since it is the first time that the
792 * incoming sk_buff @skb has been associated with a particular socket, @sk.
793 * @sk contains the sock (not socket) associated with the incoming sk_buff.
794 * @skb contains the incoming network data.
795 * @socket_getpeersec:
796 * This hook allows the security module to provide peer socket security
797 * state to userspace via getsockopt SO_GETPEERSEC.
798 * @sock is the local socket.
799 * @optval userspace memory where the security state is to be copied.
800 * @optlen userspace int where the module should copy the actual length
801 * of the security state.
802 * @len as input is the maximum length to copy to userspace provided
803 * by the caller.
804 * Return 0 if all is well, otherwise, typical getsockopt return
805 * values.
806 * @sk_alloc_security:
807 * Allocate and attach a security structure to the sk->sk_security field,
808 * which is used to copy security attributes between local stream sockets.
809 * @sk_free_security:
810 * Deallocate security structure.
Trent Jaegerdf718372005-12-13 23:12:27 -0800811 * @sk_getsid:
812 * Retrieve the LSM-specific sid for the sock to enable caching of network
813 * authorizations.
814 *
815 * Security hooks for XFRM operations.
816 *
817 * @xfrm_policy_alloc_security:
818 * @xp contains the xfrm_policy being added to Security Policy Database
819 * used by the XFRM system.
820 * @sec_ctx contains the security context information being provided by
821 * the user-level policy update program (e.g., setkey).
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700822 * Allocate a security structure to the xp->security field.
Trent Jaegerdf718372005-12-13 23:12:27 -0800823 * The security field is initialized to NULL when the xfrm_policy is
824 * allocated.
825 * Return 0 if operation was successful (memory to allocate, legal context)
826 * @xfrm_policy_clone_security:
827 * @old contains an existing xfrm_policy in the SPD.
828 * @new contains a new xfrm_policy being cloned from old.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700829 * Allocate a security structure to the new->security field
830 * that contains the information from the old->security field.
Trent Jaegerdf718372005-12-13 23:12:27 -0800831 * Return 0 if operation was successful (memory to allocate).
832 * @xfrm_policy_free_security:
833 * @xp contains the xfrm_policy
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700834 * Deallocate xp->security.
835 * @xfrm_policy_delete_security:
836 * @xp contains the xfrm_policy.
837 * Authorize deletion of xp->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800838 * @xfrm_state_alloc_security:
839 * @x contains the xfrm_state being added to the Security Association
840 * Database by the XFRM system.
841 * @sec_ctx contains the security context information being provided by
842 * the user-level SA generation program (e.g., setkey or racoon).
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700843 * Allocate a security structure to the x->security field. The
Trent Jaegerdf718372005-12-13 23:12:27 -0800844 * security field is initialized to NULL when the xfrm_state is
845 * allocated.
846 * Return 0 if operation was successful (memory to allocate, legal context).
847 * @xfrm_state_free_security:
848 * @x contains the xfrm_state.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700849 * Deallocate x->security.
850 * @xfrm_state_delete_security:
851 * @x contains the xfrm_state.
852 * Authorize deletion of x->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800853 * @xfrm_policy_lookup:
854 * @xp contains the xfrm_policy for which the access control is being
855 * checked.
856 * @sk_sid contains the sock security label that is used to authorize
857 * access to the policy xp.
858 * @dir contains the direction of the flow (input or output).
859 * Check permission when a sock selects a xfrm_policy for processing
860 * XFRMs on a packet. The hook is called when selecting either a
861 * per-socket policy or a generic xfrm policy.
862 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863 *
David Howells29db9192005-10-30 15:02:44 -0800864 * Security hooks affecting all Key Management operations
865 *
866 * @key_alloc:
867 * Permit allocation of a key and assign security data. Note that key does
868 * not have a serial number assigned at this point.
869 * @key points to the key.
David Howells7e047ef2006-06-26 00:24:50 -0700870 * @flags is the allocation flags
David Howells29db9192005-10-30 15:02:44 -0800871 * Return 0 if permission is granted, -ve error otherwise.
872 * @key_free:
873 * Notification of destruction; free security data.
874 * @key points to the key.
875 * No return value.
876 * @key_permission:
877 * See whether a specific operational right is granted to a process on a
878 * key.
879 * @key_ref refers to the key (key pointer + possession attribute bit).
880 * @context points to the process to provide the context against which to
881 * evaluate the security data on the key.
882 * @perm describes the combination of permissions required of this key.
883 * Return 1 if permission granted, 0 if permission denied and -ve it the
884 * normal permissions model should be effected.
885 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 * Security hooks affecting all System V IPC operations.
887 *
888 * @ipc_permission:
889 * Check permissions for access to IPC
890 * @ipcp contains the kernel IPC permission structure
891 * @flag contains the desired (requested) permission set
892 * Return 0 if permission is granted.
893 *
894 * Security hooks for individual messages held in System V IPC message queues
895 * @msg_msg_alloc_security:
896 * Allocate and attach a security structure to the msg->security field.
897 * The security field is initialized to NULL when the structure is first
898 * created.
899 * @msg contains the message structure to be modified.
900 * Return 0 if operation was successful and permission is granted.
901 * @msg_msg_free_security:
902 * Deallocate the security structure for this message.
903 * @msg contains the message structure to be modified.
904 *
905 * Security hooks for System V IPC Message Queues
906 *
907 * @msg_queue_alloc_security:
908 * Allocate and attach a security structure to the
909 * msq->q_perm.security field. The security field is initialized to
910 * NULL when the structure is first created.
911 * @msq contains the message queue structure to be modified.
912 * Return 0 if operation was successful and permission is granted.
913 * @msg_queue_free_security:
914 * Deallocate security structure for this message queue.
915 * @msq contains the message queue structure to be modified.
916 * @msg_queue_associate:
917 * Check permission when a message queue is requested through the
918 * msgget system call. This hook is only called when returning the
919 * message queue identifier for an existing message queue, not when a
920 * new message queue is created.
921 * @msq contains the message queue to act upon.
922 * @msqflg contains the operation control flags.
923 * Return 0 if permission is granted.
924 * @msg_queue_msgctl:
925 * Check permission when a message control operation specified by @cmd
926 * is to be performed on the message queue @msq.
927 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
928 * @msq contains the message queue to act upon. May be NULL.
929 * @cmd contains the operation to be performed.
930 * Return 0 if permission is granted.
931 * @msg_queue_msgsnd:
932 * Check permission before a message, @msg, is enqueued on the message
933 * queue, @msq.
934 * @msq contains the message queue to send message to.
935 * @msg contains the message to be enqueued.
936 * @msqflg contains operational flags.
937 * Return 0 if permission is granted.
938 * @msg_queue_msgrcv:
939 * Check permission before a message, @msg, is removed from the message
940 * queue, @msq. The @target task structure contains a pointer to the
941 * process that will be receiving the message (not equal to the current
942 * process when inline receives are being performed).
943 * @msq contains the message queue to retrieve message from.
944 * @msg contains the message destination.
945 * @target contains the task structure for recipient process.
946 * @type contains the type of message requested.
947 * @mode contains the operational flags.
948 * Return 0 if permission is granted.
949 *
950 * Security hooks for System V Shared Memory Segments
951 *
952 * @shm_alloc_security:
953 * Allocate and attach a security structure to the shp->shm_perm.security
954 * field. The security field is initialized to NULL when the structure is
955 * first created.
956 * @shp contains the shared memory structure to be modified.
957 * Return 0 if operation was successful and permission is granted.
958 * @shm_free_security:
959 * Deallocate the security struct for this memory segment.
960 * @shp contains the shared memory structure to be modified.
961 * @shm_associate:
962 * Check permission when a shared memory region is requested through the
963 * shmget system call. This hook is only called when returning the shared
964 * memory region identifier for an existing region, not when a new shared
965 * memory region is created.
966 * @shp contains the shared memory structure to be modified.
967 * @shmflg contains the operation control flags.
968 * Return 0 if permission is granted.
969 * @shm_shmctl:
970 * Check permission when a shared memory control operation specified by
971 * @cmd is to be performed on the shared memory region @shp.
972 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
973 * @shp contains shared memory structure to be modified.
974 * @cmd contains the operation to be performed.
975 * Return 0 if permission is granted.
976 * @shm_shmat:
977 * Check permissions prior to allowing the shmat system call to attach the
978 * shared memory segment @shp to the data segment of the calling process.
979 * The attaching address is specified by @shmaddr.
980 * @shp contains the shared memory structure to be modified.
981 * @shmaddr contains the address to attach memory region to.
982 * @shmflg contains the operational flags.
983 * Return 0 if permission is granted.
984 *
985 * Security hooks for System V Semaphores
986 *
987 * @sem_alloc_security:
988 * Allocate and attach a security structure to the sma->sem_perm.security
989 * field. The security field is initialized to NULL when the structure is
990 * first created.
991 * @sma contains the semaphore structure
992 * Return 0 if operation was successful and permission is granted.
993 * @sem_free_security:
994 * deallocate security struct for this semaphore
995 * @sma contains the semaphore structure.
996 * @sem_associate:
997 * Check permission when a semaphore is requested through the semget
998 * system call. This hook is only called when returning the semaphore
999 * identifier for an existing semaphore, not when a new one must be
1000 * created.
1001 * @sma contains the semaphore structure.
1002 * @semflg contains the operation control flags.
1003 * Return 0 if permission is granted.
1004 * @sem_semctl:
1005 * Check permission when a semaphore operation specified by @cmd is to be
1006 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
1007 * IPC_INFO or SEM_INFO.
1008 * @sma contains the semaphore structure. May be NULL.
1009 * @cmd contains the operation to be performed.
1010 * Return 0 if permission is granted.
1011 * @sem_semop
1012 * Check permissions before performing operations on members of the
1013 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1014 * may be modified.
1015 * @sma contains the semaphore structure.
1016 * @sops contains the operations to perform.
1017 * @nsops contains the number of operations to perform.
1018 * @alter contains the flag indicating whether changes are to be made.
1019 * Return 0 if permission is granted.
1020 *
1021 * @ptrace:
1022 * Check permission before allowing the @parent process to trace the
1023 * @child process.
1024 * Security modules may also want to perform a process tracing check
1025 * during an execve in the set_security or apply_creds hooks of
1026 * binprm_security_ops if the process is being traced and its security
1027 * attributes would be changed by the execve.
1028 * @parent contains the task_struct structure for parent process.
1029 * @child contains the task_struct structure for child process.
1030 * Return 0 if permission is granted.
1031 * @capget:
1032 * Get the @effective, @inheritable, and @permitted capability sets for
1033 * the @target process. The hook may also perform permission checking to
1034 * determine if the current process is allowed to see the capability sets
1035 * of the @target process.
1036 * @target contains the task_struct structure for target process.
1037 * @effective contains the effective capability set.
1038 * @inheritable contains the inheritable capability set.
1039 * @permitted contains the permitted capability set.
1040 * Return 0 if the capability sets were successfully obtained.
1041 * @capset_check:
1042 * Check permission before setting the @effective, @inheritable, and
1043 * @permitted capability sets for the @target process.
1044 * Caveat: @target is also set to current if a set of processes is
1045 * specified (i.e. all processes other than current and init or a
1046 * particular process group). Hence, the capset_set hook may need to
1047 * revalidate permission to the actual target process.
1048 * @target contains the task_struct structure for target process.
1049 * @effective contains the effective capability set.
1050 * @inheritable contains the inheritable capability set.
1051 * @permitted contains the permitted capability set.
1052 * Return 0 if permission is granted.
1053 * @capset_set:
1054 * Set the @effective, @inheritable, and @permitted capability sets for
1055 * the @target process. Since capset_check cannot always check permission
1056 * to the real @target process, this hook may also perform permission
1057 * checking to determine if the current process is allowed to set the
1058 * capability sets of the @target process. However, this hook has no way
1059 * of returning an error due to the structure of the sys_capset code.
1060 * @target contains the task_struct structure for target process.
1061 * @effective contains the effective capability set.
1062 * @inheritable contains the inheritable capability set.
1063 * @permitted contains the permitted capability set.
Chris Wright12b59892006-03-25 03:07:41 -08001064 * @capable:
1065 * Check whether the @tsk process has the @cap capability.
1066 * @tsk contains the task_struct for the process.
1067 * @cap contains the capability <include/linux/capability.h>.
1068 * Return 0 if the capability is granted for @tsk.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001069 * @acct:
1070 * Check permission before enabling or disabling process accounting. If
1071 * accounting is being enabled, then @file refers to the open file used to
1072 * store accounting records. If accounting is being disabled, then @file
1073 * is NULL.
1074 * @file contains the file structure for the accounting file (may be NULL).
1075 * Return 0 if permission is granted.
1076 * @sysctl:
1077 * Check permission before accessing the @table sysctl variable in the
1078 * manner specified by @op.
1079 * @table contains the ctl_table structure for the sysctl variable.
1080 * @op contains the operation (001 = search, 002 = write, 004 = read).
1081 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082 * @syslog:
1083 * Check permission before accessing the kernel message ring or changing
1084 * logging to the console.
1085 * See the syslog(2) manual page for an explanation of the @type values.
1086 * @type contains the type of action.
1087 * Return 0 if permission is granted.
1088 * @settime:
1089 * Check permission to change the system time.
1090 * struct timespec and timezone are defined in include/linux/time.h
1091 * @ts contains new time
1092 * @tz contains new timezone
1093 * Return 0 if permission is granted.
1094 * @vm_enough_memory:
1095 * Check permissions for allocating a new virtual mapping.
1096 * @pages contains the number of pages.
1097 * Return 0 if permission is granted.
1098 *
1099 * @register_security:
1100 * allow module stacking.
1101 * @name contains the name of the security module being stacked.
1102 * @ops contains a pointer to the struct security_operations of the module to stack.
1103 * @unregister_security:
1104 * remove a stacked module.
1105 * @name contains the name of the security module being unstacked.
1106 * @ops contains a pointer to the struct security_operations of the module to unstack.
1107 *
1108 * This is the main security structure.
1109 */
1110struct security_operations {
1111 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1112 int (*capget) (struct task_struct * target,
1113 kernel_cap_t * effective,
1114 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1115 int (*capset_check) (struct task_struct * target,
1116 kernel_cap_t * effective,
1117 kernel_cap_t * inheritable,
1118 kernel_cap_t * permitted);
1119 void (*capset_set) (struct task_struct * target,
1120 kernel_cap_t * effective,
1121 kernel_cap_t * inheritable,
1122 kernel_cap_t * permitted);
Chris Wright12b59892006-03-25 03:07:41 -08001123 int (*capable) (struct task_struct * tsk, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124 int (*acct) (struct file * file);
1125 int (*sysctl) (struct ctl_table * table, int op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1127 int (*quota_on) (struct dentry * dentry);
1128 int (*syslog) (int type);
1129 int (*settime) (struct timespec *ts, struct timezone *tz);
1130 int (*vm_enough_memory) (long pages);
1131
1132 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1133 void (*bprm_free_security) (struct linux_binprm * bprm);
1134 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1135 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1136 int (*bprm_set_security) (struct linux_binprm * bprm);
1137 int (*bprm_check_security) (struct linux_binprm * bprm);
1138 int (*bprm_secureexec) (struct linux_binprm * bprm);
1139
1140 int (*sb_alloc_security) (struct super_block * sb);
1141 void (*sb_free_security) (struct super_block * sb);
1142 int (*sb_copy_data)(struct file_system_type *type,
1143 void *orig, void *copy);
1144 int (*sb_kern_mount) (struct super_block *sb, void *data);
David Howells726c3342006-06-23 02:02:58 -07001145 int (*sb_statfs) (struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1147 char *type, unsigned long flags, void *data);
1148 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1149 int (*sb_umount) (struct vfsmount * mnt, int flags);
1150 void (*sb_umount_close) (struct vfsmount * mnt);
1151 void (*sb_umount_busy) (struct vfsmount * mnt);
1152 void (*sb_post_remount) (struct vfsmount * mnt,
1153 unsigned long flags, void *data);
1154 void (*sb_post_mountroot) (void);
1155 void (*sb_post_addmount) (struct vfsmount * mnt,
1156 struct nameidata * mountpoint_nd);
1157 int (*sb_pivotroot) (struct nameidata * old_nd,
1158 struct nameidata * new_nd);
1159 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1160 struct nameidata * new_nd);
1161
1162 int (*inode_alloc_security) (struct inode *inode);
1163 void (*inode_free_security) (struct inode *inode);
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001164 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1165 char **name, void **value, size_t *len);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 int (*inode_create) (struct inode *dir,
1167 struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 int (*inode_link) (struct dentry *old_dentry,
1169 struct inode *dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1171 int (*inode_symlink) (struct inode *dir,
1172 struct dentry *dentry, const char *old_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1175 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1176 int mode, dev_t dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1178 struct inode *new_dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 int (*inode_readlink) (struct dentry *dentry);
1180 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1181 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1182 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1183 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1184 void (*inode_delete) (struct inode *inode);
1185 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1186 size_t size, int flags);
1187 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1188 size_t size, int flags);
1189 int (*inode_getxattr) (struct dentry *dentry, char *name);
1190 int (*inode_listxattr) (struct dentry *dentry);
1191 int (*inode_removexattr) (struct dentry *dentry, char *name);
Dustin Kirkland7306a0b2005-11-16 15:53:13 +00001192 const char *(*inode_xattr_getsuffix) (void);
1193 int (*inode_getsecurity)(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001194 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1195 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1196
1197 int (*file_permission) (struct file * file, int mask);
1198 int (*file_alloc_security) (struct file * file);
1199 void (*file_free_security) (struct file * file);
1200 int (*file_ioctl) (struct file * file, unsigned int cmd,
1201 unsigned long arg);
1202 int (*file_mmap) (struct file * file,
1203 unsigned long reqprot,
1204 unsigned long prot, unsigned long flags);
1205 int (*file_mprotect) (struct vm_area_struct * vma,
1206 unsigned long reqprot,
1207 unsigned long prot);
1208 int (*file_lock) (struct file * file, unsigned int cmd);
1209 int (*file_fcntl) (struct file * file, unsigned int cmd,
1210 unsigned long arg);
1211 int (*file_set_fowner) (struct file * file);
1212 int (*file_send_sigiotask) (struct task_struct * tsk,
1213 struct fown_struct * fown, int sig);
1214 int (*file_receive) (struct file * file);
1215
1216 int (*task_create) (unsigned long clone_flags);
1217 int (*task_alloc_security) (struct task_struct * p);
1218 void (*task_free_security) (struct task_struct * p);
1219 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1220 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1221 uid_t old_euid, uid_t old_suid, int flags);
1222 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1223 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1224 int (*task_getpgid) (struct task_struct * p);
1225 int (*task_getsid) (struct task_struct * p);
David Quigleyf9008e42006-06-30 01:55:46 -07001226 void (*task_getsecid) (struct task_struct * p, u32 * secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227 int (*task_setgroups) (struct group_info *group_info);
1228 int (*task_setnice) (struct task_struct * p, int nice);
James Morris03e68062006-06-23 02:03:58 -07001229 int (*task_setioprio) (struct task_struct * p, int ioprio);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1231 int (*task_setscheduler) (struct task_struct * p, int policy,
1232 struct sched_param * lp);
1233 int (*task_getscheduler) (struct task_struct * p);
David Quigley35601542006-06-23 02:04:01 -07001234 int (*task_movememory) (struct task_struct * p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235 int (*task_kill) (struct task_struct * p,
David Quigleyf9008e42006-06-30 01:55:46 -07001236 struct siginfo * info, int sig, u32 secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001237 int (*task_wait) (struct task_struct * p);
1238 int (*task_prctl) (int option, unsigned long arg2,
1239 unsigned long arg3, unsigned long arg4,
1240 unsigned long arg5);
1241 void (*task_reparent_to_init) (struct task_struct * p);
1242 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1243
1244 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1245
1246 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1247 void (*msg_msg_free_security) (struct msg_msg * msg);
1248
1249 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1250 void (*msg_queue_free_security) (struct msg_queue * msq);
1251 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1252 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1253 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1254 struct msg_msg * msg, int msqflg);
1255 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1256 struct msg_msg * msg,
1257 struct task_struct * target,
1258 long type, int mode);
1259
1260 int (*shm_alloc_security) (struct shmid_kernel * shp);
1261 void (*shm_free_security) (struct shmid_kernel * shp);
1262 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1263 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1264 int (*shm_shmat) (struct shmid_kernel * shp,
1265 char __user *shmaddr, int shmflg);
1266
1267 int (*sem_alloc_security) (struct sem_array * sma);
1268 void (*sem_free_security) (struct sem_array * sma);
1269 int (*sem_associate) (struct sem_array * sma, int semflg);
1270 int (*sem_semctl) (struct sem_array * sma, int cmd);
1271 int (*sem_semop) (struct sem_array * sma,
1272 struct sembuf * sops, unsigned nsops, int alter);
1273
1274 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07001275 int (*netlink_recv) (struct sk_buff * skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276
1277 /* allow module stacking */
1278 int (*register_security) (const char *name,
1279 struct security_operations *ops);
1280 int (*unregister_security) (const char *name,
1281 struct security_operations *ops);
1282
1283 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1284
1285 int (*getprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1286 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1287
1288#ifdef CONFIG_SECURITY_NETWORK
1289 int (*unix_stream_connect) (struct socket * sock,
1290 struct socket * other, struct sock * newsk);
1291 int (*unix_may_send) (struct socket * sock, struct socket * other);
1292
1293 int (*socket_create) (int family, int type, int protocol, int kern);
1294 void (*socket_post_create) (struct socket * sock, int family,
1295 int type, int protocol, int kern);
1296 int (*socket_bind) (struct socket * sock,
1297 struct sockaddr * address, int addrlen);
1298 int (*socket_connect) (struct socket * sock,
1299 struct sockaddr * address, int addrlen);
1300 int (*socket_listen) (struct socket * sock, int backlog);
1301 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1302 void (*socket_post_accept) (struct socket * sock,
1303 struct socket * newsock);
1304 int (*socket_sendmsg) (struct socket * sock,
1305 struct msghdr * msg, int size);
1306 int (*socket_recvmsg) (struct socket * sock,
1307 struct msghdr * msg, int size, int flags);
1308 int (*socket_getsockname) (struct socket * sock);
1309 int (*socket_getpeername) (struct socket * sock);
1310 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1311 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1312 int (*socket_shutdown) (struct socket * sock, int how);
1313 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
Catherine Zhang2c7946a2006-03-20 22:41:23 -08001314 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1315 int (*socket_getpeersec_dgram) (struct sk_buff *skb, char **secdata, u32 *seclen);
Al Viro7d877f32005-10-21 03:20:43 -04001316 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317 void (*sk_free_security) (struct sock *sk);
Trent Jaegerdf718372005-12-13 23:12:27 -08001318 unsigned int (*sk_getsid) (struct sock *sk, struct flowi *fl, u8 dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001319#endif /* CONFIG_SECURITY_NETWORK */
David Howells29db9192005-10-30 15:02:44 -08001320
Trent Jaegerdf718372005-12-13 23:12:27 -08001321#ifdef CONFIG_SECURITY_NETWORK_XFRM
1322 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
1323 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1324 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001325 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
Trent Jaegerdf718372005-12-13 23:12:27 -08001326 int (*xfrm_state_alloc_security) (struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1327 void (*xfrm_state_free_security) (struct xfrm_state *x);
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001328 int (*xfrm_state_delete_security) (struct xfrm_state *x);
Trent Jaegerdf718372005-12-13 23:12:27 -08001329 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 sk_sid, u8 dir);
1330#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1331
David Howells29db9192005-10-30 15:02:44 -08001332 /* key management security hooks */
1333#ifdef CONFIG_KEYS
David Howells7e047ef2006-06-26 00:24:50 -07001334 int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags);
David Howells29db9192005-10-30 15:02:44 -08001335 void (*key_free)(struct key *key);
1336 int (*key_permission)(key_ref_t key_ref,
1337 struct task_struct *context,
1338 key_perm_t perm);
1339
1340#endif /* CONFIG_KEYS */
1341
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342};
1343
1344/* global variables */
1345extern struct security_operations *security_ops;
1346
1347/* inline stuff */
1348static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1349{
1350 return security_ops->ptrace (parent, child);
1351}
1352
1353static inline int security_capget (struct task_struct *target,
1354 kernel_cap_t *effective,
1355 kernel_cap_t *inheritable,
1356 kernel_cap_t *permitted)
1357{
1358 return security_ops->capget (target, effective, inheritable, permitted);
1359}
1360
1361static inline int security_capset_check (struct task_struct *target,
1362 kernel_cap_t *effective,
1363 kernel_cap_t *inheritable,
1364 kernel_cap_t *permitted)
1365{
1366 return security_ops->capset_check (target, effective, inheritable, permitted);
1367}
1368
1369static inline void security_capset_set (struct task_struct *target,
1370 kernel_cap_t *effective,
1371 kernel_cap_t *inheritable,
1372 kernel_cap_t *permitted)
1373{
1374 security_ops->capset_set (target, effective, inheritable, permitted);
1375}
1376
Chris Wright12b59892006-03-25 03:07:41 -08001377static inline int security_capable(struct task_struct *tsk, int cap)
1378{
1379 return security_ops->capable(tsk, cap);
1380}
1381
Linus Torvalds1da177e2005-04-16 15:20:36 -07001382static inline int security_acct (struct file *file)
1383{
1384 return security_ops->acct (file);
1385}
1386
1387static inline int security_sysctl(struct ctl_table *table, int op)
1388{
1389 return security_ops->sysctl(table, op);
1390}
1391
1392static inline int security_quotactl (int cmds, int type, int id,
1393 struct super_block *sb)
1394{
1395 return security_ops->quotactl (cmds, type, id, sb);
1396}
1397
1398static inline int security_quota_on (struct dentry * dentry)
1399{
1400 return security_ops->quota_on (dentry);
1401}
1402
1403static inline int security_syslog(int type)
1404{
1405 return security_ops->syslog(type);
1406}
1407
1408static inline int security_settime(struct timespec *ts, struct timezone *tz)
1409{
1410 return security_ops->settime(ts, tz);
1411}
1412
1413
1414static inline int security_vm_enough_memory(long pages)
1415{
1416 return security_ops->vm_enough_memory(pages);
1417}
1418
1419static inline int security_bprm_alloc (struct linux_binprm *bprm)
1420{
1421 return security_ops->bprm_alloc_security (bprm);
1422}
1423static inline void security_bprm_free (struct linux_binprm *bprm)
1424{
1425 security_ops->bprm_free_security (bprm);
1426}
1427static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1428{
1429 security_ops->bprm_apply_creds (bprm, unsafe);
1430}
1431static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1432{
1433 security_ops->bprm_post_apply_creds (bprm);
1434}
1435static inline int security_bprm_set (struct linux_binprm *bprm)
1436{
1437 return security_ops->bprm_set_security (bprm);
1438}
1439
1440static inline int security_bprm_check (struct linux_binprm *bprm)
1441{
1442 return security_ops->bprm_check_security (bprm);
1443}
1444
1445static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1446{
1447 return security_ops->bprm_secureexec (bprm);
1448}
1449
1450static inline int security_sb_alloc (struct super_block *sb)
1451{
1452 return security_ops->sb_alloc_security (sb);
1453}
1454
1455static inline void security_sb_free (struct super_block *sb)
1456{
1457 security_ops->sb_free_security (sb);
1458}
1459
1460static inline int security_sb_copy_data (struct file_system_type *type,
1461 void *orig, void *copy)
1462{
1463 return security_ops->sb_copy_data (type, orig, copy);
1464}
1465
1466static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1467{
1468 return security_ops->sb_kern_mount (sb, data);
1469}
1470
David Howells726c3342006-06-23 02:02:58 -07001471static inline int security_sb_statfs (struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472{
David Howells726c3342006-06-23 02:02:58 -07001473 return security_ops->sb_statfs (dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474}
1475
1476static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1477 char *type, unsigned long flags,
1478 void *data)
1479{
1480 return security_ops->sb_mount (dev_name, nd, type, flags, data);
1481}
1482
1483static inline int security_sb_check_sb (struct vfsmount *mnt,
1484 struct nameidata *nd)
1485{
1486 return security_ops->sb_check_sb (mnt, nd);
1487}
1488
1489static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1490{
1491 return security_ops->sb_umount (mnt, flags);
1492}
1493
1494static inline void security_sb_umount_close (struct vfsmount *mnt)
1495{
1496 security_ops->sb_umount_close (mnt);
1497}
1498
1499static inline void security_sb_umount_busy (struct vfsmount *mnt)
1500{
1501 security_ops->sb_umount_busy (mnt);
1502}
1503
1504static inline void security_sb_post_remount (struct vfsmount *mnt,
1505 unsigned long flags, void *data)
1506{
1507 security_ops->sb_post_remount (mnt, flags, data);
1508}
1509
1510static inline void security_sb_post_mountroot (void)
1511{
1512 security_ops->sb_post_mountroot ();
1513}
1514
1515static inline void security_sb_post_addmount (struct vfsmount *mnt,
1516 struct nameidata *mountpoint_nd)
1517{
1518 security_ops->sb_post_addmount (mnt, mountpoint_nd);
1519}
1520
1521static inline int security_sb_pivotroot (struct nameidata *old_nd,
1522 struct nameidata *new_nd)
1523{
1524 return security_ops->sb_pivotroot (old_nd, new_nd);
1525}
1526
1527static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1528 struct nameidata *new_nd)
1529{
1530 security_ops->sb_post_pivotroot (old_nd, new_nd);
1531}
1532
1533static inline int security_inode_alloc (struct inode *inode)
1534{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001535 return security_ops->inode_alloc_security (inode);
1536}
1537
1538static inline void security_inode_free (struct inode *inode)
1539{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001540 security_ops->inode_free_security (inode);
1541}
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001542
1543static inline int security_inode_init_security (struct inode *inode,
1544 struct inode *dir,
1545 char **name,
1546 void **value,
1547 size_t *len)
1548{
1549 if (unlikely (IS_PRIVATE (inode)))
1550 return -EOPNOTSUPP;
1551 return security_ops->inode_init_security (inode, dir, name, value, len);
1552}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553
1554static inline int security_inode_create (struct inode *dir,
1555 struct dentry *dentry,
1556 int mode)
1557{
1558 if (unlikely (IS_PRIVATE (dir)))
1559 return 0;
1560 return security_ops->inode_create (dir, dentry, mode);
1561}
1562
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563static inline int security_inode_link (struct dentry *old_dentry,
1564 struct inode *dir,
1565 struct dentry *new_dentry)
1566{
1567 if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
1568 return 0;
1569 return security_ops->inode_link (old_dentry, dir, new_dentry);
1570}
1571
Linus Torvalds1da177e2005-04-16 15:20:36 -07001572static inline int security_inode_unlink (struct inode *dir,
1573 struct dentry *dentry)
1574{
1575 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1576 return 0;
1577 return security_ops->inode_unlink (dir, dentry);
1578}
1579
1580static inline int security_inode_symlink (struct inode *dir,
1581 struct dentry *dentry,
1582 const char *old_name)
1583{
1584 if (unlikely (IS_PRIVATE (dir)))
1585 return 0;
1586 return security_ops->inode_symlink (dir, dentry, old_name);
1587}
1588
Linus Torvalds1da177e2005-04-16 15:20:36 -07001589static inline int security_inode_mkdir (struct inode *dir,
1590 struct dentry *dentry,
1591 int mode)
1592{
1593 if (unlikely (IS_PRIVATE (dir)))
1594 return 0;
1595 return security_ops->inode_mkdir (dir, dentry, mode);
1596}
1597
Linus Torvalds1da177e2005-04-16 15:20:36 -07001598static inline int security_inode_rmdir (struct inode *dir,
1599 struct dentry *dentry)
1600{
1601 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1602 return 0;
1603 return security_ops->inode_rmdir (dir, dentry);
1604}
1605
1606static inline int security_inode_mknod (struct inode *dir,
1607 struct dentry *dentry,
1608 int mode, dev_t dev)
1609{
1610 if (unlikely (IS_PRIVATE (dir)))
1611 return 0;
1612 return security_ops->inode_mknod (dir, dentry, mode, dev);
1613}
1614
Linus Torvalds1da177e2005-04-16 15:20:36 -07001615static inline int security_inode_rename (struct inode *old_dir,
1616 struct dentry *old_dentry,
1617 struct inode *new_dir,
1618 struct dentry *new_dentry)
1619{
1620 if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
1621 (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
1622 return 0;
1623 return security_ops->inode_rename (old_dir, old_dentry,
1624 new_dir, new_dentry);
1625}
1626
Linus Torvalds1da177e2005-04-16 15:20:36 -07001627static inline int security_inode_readlink (struct dentry *dentry)
1628{
1629 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1630 return 0;
1631 return security_ops->inode_readlink (dentry);
1632}
1633
1634static inline int security_inode_follow_link (struct dentry *dentry,
1635 struct nameidata *nd)
1636{
1637 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1638 return 0;
1639 return security_ops->inode_follow_link (dentry, nd);
1640}
1641
1642static inline int security_inode_permission (struct inode *inode, int mask,
1643 struct nameidata *nd)
1644{
1645 if (unlikely (IS_PRIVATE (inode)))
1646 return 0;
1647 return security_ops->inode_permission (inode, mask, nd);
1648}
1649
1650static inline int security_inode_setattr (struct dentry *dentry,
1651 struct iattr *attr)
1652{
1653 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1654 return 0;
1655 return security_ops->inode_setattr (dentry, attr);
1656}
1657
1658static inline int security_inode_getattr (struct vfsmount *mnt,
1659 struct dentry *dentry)
1660{
1661 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1662 return 0;
1663 return security_ops->inode_getattr (mnt, dentry);
1664}
1665
1666static inline void security_inode_delete (struct inode *inode)
1667{
1668 if (unlikely (IS_PRIVATE (inode)))
1669 return;
1670 security_ops->inode_delete (inode);
1671}
1672
1673static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1674 void *value, size_t size, int flags)
1675{
1676 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1677 return 0;
1678 return security_ops->inode_setxattr (dentry, name, value, size, flags);
1679}
1680
1681static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1682 void *value, size_t size, int flags)
1683{
1684 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1685 return;
1686 security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1687}
1688
1689static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1690{
1691 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1692 return 0;
1693 return security_ops->inode_getxattr (dentry, name);
1694}
1695
1696static inline int security_inode_listxattr (struct dentry *dentry)
1697{
1698 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1699 return 0;
1700 return security_ops->inode_listxattr (dentry);
1701}
1702
1703static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1704{
1705 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1706 return 0;
1707 return security_ops->inode_removexattr (dentry, name);
1708}
1709
Dustin Kirkland8c8570f2005-11-03 17:15:16 +00001710static inline const char *security_inode_xattr_getsuffix(void)
1711{
1712 return security_ops->inode_xattr_getsuffix();
1713}
1714
Dustin Kirkland7306a0b2005-11-16 15:53:13 +00001715static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001716{
1717 if (unlikely (IS_PRIVATE (inode)))
1718 return 0;
James Morrisd381d8a2005-10-30 14:59:22 -08001719 return security_ops->inode_getsecurity(inode, name, buffer, size, err);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001720}
1721
1722static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1723{
1724 if (unlikely (IS_PRIVATE (inode)))
1725 return 0;
1726 return security_ops->inode_setsecurity(inode, name, value, size, flags);
1727}
1728
1729static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1730{
1731 if (unlikely (IS_PRIVATE (inode)))
1732 return 0;
1733 return security_ops->inode_listsecurity(inode, buffer, buffer_size);
1734}
1735
1736static inline int security_file_permission (struct file *file, int mask)
1737{
1738 return security_ops->file_permission (file, mask);
1739}
1740
1741static inline int security_file_alloc (struct file *file)
1742{
1743 return security_ops->file_alloc_security (file);
1744}
1745
1746static inline void security_file_free (struct file *file)
1747{
1748 security_ops->file_free_security (file);
1749}
1750
1751static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1752 unsigned long arg)
1753{
1754 return security_ops->file_ioctl (file, cmd, arg);
1755}
1756
1757static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1758 unsigned long prot,
1759 unsigned long flags)
1760{
1761 return security_ops->file_mmap (file, reqprot, prot, flags);
1762}
1763
1764static inline int security_file_mprotect (struct vm_area_struct *vma,
1765 unsigned long reqprot,
1766 unsigned long prot)
1767{
1768 return security_ops->file_mprotect (vma, reqprot, prot);
1769}
1770
1771static inline int security_file_lock (struct file *file, unsigned int cmd)
1772{
1773 return security_ops->file_lock (file, cmd);
1774}
1775
1776static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1777 unsigned long arg)
1778{
1779 return security_ops->file_fcntl (file, cmd, arg);
1780}
1781
1782static inline int security_file_set_fowner (struct file *file)
1783{
1784 return security_ops->file_set_fowner (file);
1785}
1786
1787static inline int security_file_send_sigiotask (struct task_struct *tsk,
1788 struct fown_struct *fown,
1789 int sig)
1790{
1791 return security_ops->file_send_sigiotask (tsk, fown, sig);
1792}
1793
1794static inline int security_file_receive (struct file *file)
1795{
1796 return security_ops->file_receive (file);
1797}
1798
1799static inline int security_task_create (unsigned long clone_flags)
1800{
1801 return security_ops->task_create (clone_flags);
1802}
1803
1804static inline int security_task_alloc (struct task_struct *p)
1805{
1806 return security_ops->task_alloc_security (p);
1807}
1808
1809static inline void security_task_free (struct task_struct *p)
1810{
1811 security_ops->task_free_security (p);
1812}
1813
1814static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1815 int flags)
1816{
1817 return security_ops->task_setuid (id0, id1, id2, flags);
1818}
1819
1820static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1821 uid_t old_suid, int flags)
1822{
1823 return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1824}
1825
1826static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1827 int flags)
1828{
1829 return security_ops->task_setgid (id0, id1, id2, flags);
1830}
1831
1832static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1833{
1834 return security_ops->task_setpgid (p, pgid);
1835}
1836
1837static inline int security_task_getpgid (struct task_struct *p)
1838{
1839 return security_ops->task_getpgid (p);
1840}
1841
1842static inline int security_task_getsid (struct task_struct *p)
1843{
1844 return security_ops->task_getsid (p);
1845}
1846
David Quigleyf9008e42006-06-30 01:55:46 -07001847static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
1848{
1849 security_ops->task_getsecid (p, secid);
1850}
1851
Linus Torvalds1da177e2005-04-16 15:20:36 -07001852static inline int security_task_setgroups (struct group_info *group_info)
1853{
1854 return security_ops->task_setgroups (group_info);
1855}
1856
1857static inline int security_task_setnice (struct task_struct *p, int nice)
1858{
1859 return security_ops->task_setnice (p, nice);
1860}
1861
James Morris03e68062006-06-23 02:03:58 -07001862static inline int security_task_setioprio (struct task_struct *p, int ioprio)
1863{
1864 return security_ops->task_setioprio (p, ioprio);
1865}
1866
Linus Torvalds1da177e2005-04-16 15:20:36 -07001867static inline int security_task_setrlimit (unsigned int resource,
1868 struct rlimit *new_rlim)
1869{
1870 return security_ops->task_setrlimit (resource, new_rlim);
1871}
1872
1873static inline int security_task_setscheduler (struct task_struct *p,
1874 int policy,
1875 struct sched_param *lp)
1876{
1877 return security_ops->task_setscheduler (p, policy, lp);
1878}
1879
1880static inline int security_task_getscheduler (struct task_struct *p)
1881{
1882 return security_ops->task_getscheduler (p);
1883}
1884
David Quigley35601542006-06-23 02:04:01 -07001885static inline int security_task_movememory (struct task_struct *p)
1886{
1887 return security_ops->task_movememory (p);
1888}
1889
Linus Torvalds1da177e2005-04-16 15:20:36 -07001890static inline int security_task_kill (struct task_struct *p,
David Quigleyf9008e42006-06-30 01:55:46 -07001891 struct siginfo *info, int sig,
1892 u32 secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001893{
David Quigleyf9008e42006-06-30 01:55:46 -07001894 return security_ops->task_kill (p, info, sig, secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895}
1896
1897static inline int security_task_wait (struct task_struct *p)
1898{
1899 return security_ops->task_wait (p);
1900}
1901
1902static inline int security_task_prctl (int option, unsigned long arg2,
1903 unsigned long arg3,
1904 unsigned long arg4,
1905 unsigned long arg5)
1906{
1907 return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1908}
1909
1910static inline void security_task_reparent_to_init (struct task_struct *p)
1911{
1912 security_ops->task_reparent_to_init (p);
1913}
1914
1915static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1916{
1917 security_ops->task_to_inode(p, inode);
1918}
1919
1920static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
1921 short flag)
1922{
1923 return security_ops->ipc_permission (ipcp, flag);
1924}
1925
1926static inline int security_msg_msg_alloc (struct msg_msg * msg)
1927{
1928 return security_ops->msg_msg_alloc_security (msg);
1929}
1930
1931static inline void security_msg_msg_free (struct msg_msg * msg)
1932{
1933 security_ops->msg_msg_free_security(msg);
1934}
1935
1936static inline int security_msg_queue_alloc (struct msg_queue *msq)
1937{
1938 return security_ops->msg_queue_alloc_security (msq);
1939}
1940
1941static inline void security_msg_queue_free (struct msg_queue *msq)
1942{
1943 security_ops->msg_queue_free_security (msq);
1944}
1945
1946static inline int security_msg_queue_associate (struct msg_queue * msq,
1947 int msqflg)
1948{
1949 return security_ops->msg_queue_associate (msq, msqflg);
1950}
1951
1952static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
1953{
1954 return security_ops->msg_queue_msgctl (msq, cmd);
1955}
1956
1957static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
1958 struct msg_msg * msg, int msqflg)
1959{
1960 return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
1961}
1962
1963static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
1964 struct msg_msg * msg,
1965 struct task_struct * target,
1966 long type, int mode)
1967{
1968 return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
1969}
1970
1971static inline int security_shm_alloc (struct shmid_kernel *shp)
1972{
1973 return security_ops->shm_alloc_security (shp);
1974}
1975
1976static inline void security_shm_free (struct shmid_kernel *shp)
1977{
1978 security_ops->shm_free_security (shp);
1979}
1980
1981static inline int security_shm_associate (struct shmid_kernel * shp,
1982 int shmflg)
1983{
1984 return security_ops->shm_associate(shp, shmflg);
1985}
1986
1987static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
1988{
1989 return security_ops->shm_shmctl (shp, cmd);
1990}
1991
1992static inline int security_shm_shmat (struct shmid_kernel * shp,
1993 char __user *shmaddr, int shmflg)
1994{
1995 return security_ops->shm_shmat(shp, shmaddr, shmflg);
1996}
1997
1998static inline int security_sem_alloc (struct sem_array *sma)
1999{
2000 return security_ops->sem_alloc_security (sma);
2001}
2002
2003static inline void security_sem_free (struct sem_array *sma)
2004{
2005 security_ops->sem_free_security (sma);
2006}
2007
2008static inline int security_sem_associate (struct sem_array * sma, int semflg)
2009{
2010 return security_ops->sem_associate (sma, semflg);
2011}
2012
2013static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2014{
2015 return security_ops->sem_semctl(sma, cmd);
2016}
2017
2018static inline int security_sem_semop (struct sem_array * sma,
2019 struct sembuf * sops, unsigned nsops,
2020 int alter)
2021{
2022 return security_ops->sem_semop(sma, sops, nsops, alter);
2023}
2024
2025static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2026{
2027 if (unlikely (inode && IS_PRIVATE (inode)))
2028 return;
2029 security_ops->d_instantiate (dentry, inode);
2030}
2031
2032static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2033{
2034 return security_ops->getprocattr(p, name, value, size);
2035}
2036
2037static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2038{
2039 return security_ops->setprocattr(p, name, value, size);
2040}
2041
2042static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
2043{
2044 return security_ops->netlink_send(sk, skb);
2045}
2046
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002047static inline int security_netlink_recv(struct sk_buff * skb, int cap)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002048{
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002049 return security_ops->netlink_recv(skb, cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002050}
2051
2052/* prototypes */
2053extern int security_init (void);
2054extern int register_security (struct security_operations *ops);
2055extern int unregister_security (struct security_operations *ops);
2056extern int mod_reg_security (const char *name, struct security_operations *ops);
2057extern int mod_unreg_security (const char *name, struct security_operations *ops);
Greg KHb67dbf92005-07-07 14:37:53 -07002058extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
2059 struct dentry *parent, void *data,
2060 struct file_operations *fops);
2061extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2062extern void securityfs_remove(struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002063
2064
2065#else /* CONFIG_SECURITY */
2066
2067/*
2068 * This is the default capabilities functionality. Most of these functions
2069 * are just stubbed out, but a few must call the proper capable code.
2070 */
2071
2072static inline int security_init(void)
2073{
2074 return 0;
2075}
2076
2077static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
2078{
2079 return cap_ptrace (parent, child);
2080}
2081
2082static inline int security_capget (struct task_struct *target,
2083 kernel_cap_t *effective,
2084 kernel_cap_t *inheritable,
2085 kernel_cap_t *permitted)
2086{
2087 return cap_capget (target, effective, inheritable, permitted);
2088}
2089
2090static inline int security_capset_check (struct task_struct *target,
2091 kernel_cap_t *effective,
2092 kernel_cap_t *inheritable,
2093 kernel_cap_t *permitted)
2094{
2095 return cap_capset_check (target, effective, inheritable, permitted);
2096}
2097
2098static inline void security_capset_set (struct task_struct *target,
2099 kernel_cap_t *effective,
2100 kernel_cap_t *inheritable,
2101 kernel_cap_t *permitted)
2102{
2103 cap_capset_set (target, effective, inheritable, permitted);
2104}
2105
Chris Wright12b59892006-03-25 03:07:41 -08002106static inline int security_capable(struct task_struct *tsk, int cap)
2107{
2108 return cap_capable(tsk, cap);
2109}
2110
Linus Torvalds1da177e2005-04-16 15:20:36 -07002111static inline int security_acct (struct file *file)
2112{
2113 return 0;
2114}
2115
2116static inline int security_sysctl(struct ctl_table *table, int op)
2117{
2118 return 0;
2119}
2120
2121static inline int security_quotactl (int cmds, int type, int id,
2122 struct super_block * sb)
2123{
2124 return 0;
2125}
2126
2127static inline int security_quota_on (struct dentry * dentry)
2128{
2129 return 0;
2130}
2131
2132static inline int security_syslog(int type)
2133{
2134 return cap_syslog(type);
2135}
2136
2137static inline int security_settime(struct timespec *ts, struct timezone *tz)
2138{
2139 return cap_settime(ts, tz);
2140}
2141
2142static inline int security_vm_enough_memory(long pages)
2143{
2144 return cap_vm_enough_memory(pages);
2145}
2146
2147static inline int security_bprm_alloc (struct linux_binprm *bprm)
2148{
2149 return 0;
2150}
2151
2152static inline void security_bprm_free (struct linux_binprm *bprm)
2153{ }
2154
2155static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
2156{
2157 cap_bprm_apply_creds (bprm, unsafe);
2158}
2159
2160static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
2161{
2162 return;
2163}
2164
2165static inline int security_bprm_set (struct linux_binprm *bprm)
2166{
2167 return cap_bprm_set_security (bprm);
2168}
2169
2170static inline int security_bprm_check (struct linux_binprm *bprm)
2171{
2172 return 0;
2173}
2174
2175static inline int security_bprm_secureexec (struct linux_binprm *bprm)
2176{
2177 return cap_bprm_secureexec(bprm);
2178}
2179
2180static inline int security_sb_alloc (struct super_block *sb)
2181{
2182 return 0;
2183}
2184
2185static inline void security_sb_free (struct super_block *sb)
2186{ }
2187
2188static inline int security_sb_copy_data (struct file_system_type *type,
2189 void *orig, void *copy)
2190{
2191 return 0;
2192}
2193
2194static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2195{
2196 return 0;
2197}
2198
David Howells726c3342006-06-23 02:02:58 -07002199static inline int security_sb_statfs (struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002200{
2201 return 0;
2202}
2203
2204static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2205 char *type, unsigned long flags,
2206 void *data)
2207{
2208 return 0;
2209}
2210
2211static inline int security_sb_check_sb (struct vfsmount *mnt,
2212 struct nameidata *nd)
2213{
2214 return 0;
2215}
2216
2217static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2218{
2219 return 0;
2220}
2221
2222static inline void security_sb_umount_close (struct vfsmount *mnt)
2223{ }
2224
2225static inline void security_sb_umount_busy (struct vfsmount *mnt)
2226{ }
2227
2228static inline void security_sb_post_remount (struct vfsmount *mnt,
2229 unsigned long flags, void *data)
2230{ }
2231
2232static inline void security_sb_post_mountroot (void)
2233{ }
2234
2235static inline void security_sb_post_addmount (struct vfsmount *mnt,
2236 struct nameidata *mountpoint_nd)
2237{ }
2238
2239static inline int security_sb_pivotroot (struct nameidata *old_nd,
2240 struct nameidata *new_nd)
2241{
2242 return 0;
2243}
2244
2245static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2246 struct nameidata *new_nd)
2247{ }
2248
2249static inline int security_inode_alloc (struct inode *inode)
2250{
2251 return 0;
2252}
2253
2254static inline void security_inode_free (struct inode *inode)
2255{ }
Stephen Smalley5e41ff92005-09-09 13:01:35 -07002256
2257static inline int security_inode_init_security (struct inode *inode,
2258 struct inode *dir,
2259 char **name,
2260 void **value,
2261 size_t *len)
2262{
2263 return -EOPNOTSUPP;
2264}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002265
2266static inline int security_inode_create (struct inode *dir,
2267 struct dentry *dentry,
2268 int mode)
2269{
2270 return 0;
2271}
2272
Linus Torvalds1da177e2005-04-16 15:20:36 -07002273static inline int security_inode_link (struct dentry *old_dentry,
2274 struct inode *dir,
2275 struct dentry *new_dentry)
2276{
2277 return 0;
2278}
2279
Linus Torvalds1da177e2005-04-16 15:20:36 -07002280static inline int security_inode_unlink (struct inode *dir,
2281 struct dentry *dentry)
2282{
2283 return 0;
2284}
2285
2286static inline int security_inode_symlink (struct inode *dir,
2287 struct dentry *dentry,
2288 const char *old_name)
2289{
2290 return 0;
2291}
2292
Linus Torvalds1da177e2005-04-16 15:20:36 -07002293static inline int security_inode_mkdir (struct inode *dir,
2294 struct dentry *dentry,
2295 int mode)
2296{
2297 return 0;
2298}
2299
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300static inline int security_inode_rmdir (struct inode *dir,
2301 struct dentry *dentry)
2302{
2303 return 0;
2304}
2305
2306static inline int security_inode_mknod (struct inode *dir,
2307 struct dentry *dentry,
2308 int mode, dev_t dev)
2309{
2310 return 0;
2311}
2312
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313static inline int security_inode_rename (struct inode *old_dir,
2314 struct dentry *old_dentry,
2315 struct inode *new_dir,
2316 struct dentry *new_dentry)
2317{
2318 return 0;
2319}
2320
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321static inline int security_inode_readlink (struct dentry *dentry)
2322{
2323 return 0;
2324}
2325
2326static inline int security_inode_follow_link (struct dentry *dentry,
2327 struct nameidata *nd)
2328{
2329 return 0;
2330}
2331
2332static inline int security_inode_permission (struct inode *inode, int mask,
2333 struct nameidata *nd)
2334{
2335 return 0;
2336}
2337
2338static inline int security_inode_setattr (struct dentry *dentry,
2339 struct iattr *attr)
2340{
2341 return 0;
2342}
2343
2344static inline int security_inode_getattr (struct vfsmount *mnt,
2345 struct dentry *dentry)
2346{
2347 return 0;
2348}
2349
2350static inline void security_inode_delete (struct inode *inode)
2351{ }
2352
2353static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2354 void *value, size_t size, int flags)
2355{
2356 return cap_inode_setxattr(dentry, name, value, size, flags);
2357}
2358
2359static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2360 void *value, size_t size, int flags)
2361{ }
2362
2363static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2364{
2365 return 0;
2366}
2367
2368static inline int security_inode_listxattr (struct dentry *dentry)
2369{
2370 return 0;
2371}
2372
2373static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2374{
2375 return cap_inode_removexattr(dentry, name);
2376}
2377
Dustin Kirkland8c8570f2005-11-03 17:15:16 +00002378static inline const char *security_inode_xattr_getsuffix (void)
2379{
2380 return NULL ;
2381}
2382
Dustin Kirkland7306a0b2005-11-16 15:53:13 +00002383static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384{
2385 return -EOPNOTSUPP;
2386}
2387
2388static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2389{
2390 return -EOPNOTSUPP;
2391}
2392
2393static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2394{
2395 return 0;
2396}
2397
2398static inline int security_file_permission (struct file *file, int mask)
2399{
2400 return 0;
2401}
2402
2403static inline int security_file_alloc (struct file *file)
2404{
2405 return 0;
2406}
2407
2408static inline void security_file_free (struct file *file)
2409{ }
2410
2411static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2412 unsigned long arg)
2413{
2414 return 0;
2415}
2416
2417static inline int security_file_mmap (struct file *file, unsigned long reqprot,
2418 unsigned long prot,
2419 unsigned long flags)
2420{
2421 return 0;
2422}
2423
2424static inline int security_file_mprotect (struct vm_area_struct *vma,
2425 unsigned long reqprot,
2426 unsigned long prot)
2427{
2428 return 0;
2429}
2430
2431static inline int security_file_lock (struct file *file, unsigned int cmd)
2432{
2433 return 0;
2434}
2435
2436static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2437 unsigned long arg)
2438{
2439 return 0;
2440}
2441
2442static inline int security_file_set_fowner (struct file *file)
2443{
2444 return 0;
2445}
2446
2447static inline int security_file_send_sigiotask (struct task_struct *tsk,
2448 struct fown_struct *fown,
2449 int sig)
2450{
2451 return 0;
2452}
2453
2454static inline int security_file_receive (struct file *file)
2455{
2456 return 0;
2457}
2458
2459static inline int security_task_create (unsigned long clone_flags)
2460{
2461 return 0;
2462}
2463
2464static inline int security_task_alloc (struct task_struct *p)
2465{
2466 return 0;
2467}
2468
2469static inline void security_task_free (struct task_struct *p)
2470{ }
2471
2472static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2473 int flags)
2474{
2475 return 0;
2476}
2477
2478static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2479 uid_t old_suid, int flags)
2480{
2481 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2482}
2483
2484static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2485 int flags)
2486{
2487 return 0;
2488}
2489
2490static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2491{
2492 return 0;
2493}
2494
2495static inline int security_task_getpgid (struct task_struct *p)
2496{
2497 return 0;
2498}
2499
2500static inline int security_task_getsid (struct task_struct *p)
2501{
2502 return 0;
2503}
2504
David Quigleyf9008e42006-06-30 01:55:46 -07002505static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
2506{ }
2507
Linus Torvalds1da177e2005-04-16 15:20:36 -07002508static inline int security_task_setgroups (struct group_info *group_info)
2509{
2510 return 0;
2511}
2512
2513static inline int security_task_setnice (struct task_struct *p, int nice)
2514{
2515 return 0;
2516}
2517
James Morris03e68062006-06-23 02:03:58 -07002518static inline int security_task_setioprio (struct task_struct *p, int ioprio)
2519{
2520 return 0;
2521}
2522
Linus Torvalds1da177e2005-04-16 15:20:36 -07002523static inline int security_task_setrlimit (unsigned int resource,
2524 struct rlimit *new_rlim)
2525{
2526 return 0;
2527}
2528
2529static inline int security_task_setscheduler (struct task_struct *p,
2530 int policy,
2531 struct sched_param *lp)
2532{
2533 return 0;
2534}
2535
2536static inline int security_task_getscheduler (struct task_struct *p)
2537{
2538 return 0;
2539}
2540
David Quigley35601542006-06-23 02:04:01 -07002541static inline int security_task_movememory (struct task_struct *p)
2542{
2543 return 0;
2544}
2545
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546static inline int security_task_kill (struct task_struct *p,
David Quigleyf9008e42006-06-30 01:55:46 -07002547 struct siginfo *info, int sig,
2548 u32 secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002549{
2550 return 0;
2551}
2552
2553static inline int security_task_wait (struct task_struct *p)
2554{
2555 return 0;
2556}
2557
2558static inline int security_task_prctl (int option, unsigned long arg2,
2559 unsigned long arg3,
2560 unsigned long arg4,
2561 unsigned long arg5)
2562{
2563 return 0;
2564}
2565
2566static inline void security_task_reparent_to_init (struct task_struct *p)
2567{
2568 cap_task_reparent_to_init (p);
2569}
2570
2571static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2572{ }
2573
2574static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2575 short flag)
2576{
2577 return 0;
2578}
2579
2580static inline int security_msg_msg_alloc (struct msg_msg * msg)
2581{
2582 return 0;
2583}
2584
2585static inline void security_msg_msg_free (struct msg_msg * msg)
2586{ }
2587
2588static inline int security_msg_queue_alloc (struct msg_queue *msq)
2589{
2590 return 0;
2591}
2592
2593static inline void security_msg_queue_free (struct msg_queue *msq)
2594{ }
2595
2596static inline int security_msg_queue_associate (struct msg_queue * msq,
2597 int msqflg)
2598{
2599 return 0;
2600}
2601
2602static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2603{
2604 return 0;
2605}
2606
2607static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2608 struct msg_msg * msg, int msqflg)
2609{
2610 return 0;
2611}
2612
2613static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2614 struct msg_msg * msg,
2615 struct task_struct * target,
2616 long type, int mode)
2617{
2618 return 0;
2619}
2620
2621static inline int security_shm_alloc (struct shmid_kernel *shp)
2622{
2623 return 0;
2624}
2625
2626static inline void security_shm_free (struct shmid_kernel *shp)
2627{ }
2628
2629static inline int security_shm_associate (struct shmid_kernel * shp,
2630 int shmflg)
2631{
2632 return 0;
2633}
2634
2635static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2636{
2637 return 0;
2638}
2639
2640static inline int security_shm_shmat (struct shmid_kernel * shp,
2641 char __user *shmaddr, int shmflg)
2642{
2643 return 0;
2644}
2645
2646static inline int security_sem_alloc (struct sem_array *sma)
2647{
2648 return 0;
2649}
2650
2651static inline void security_sem_free (struct sem_array *sma)
2652{ }
2653
2654static inline int security_sem_associate (struct sem_array * sma, int semflg)
2655{
2656 return 0;
2657}
2658
2659static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2660{
2661 return 0;
2662}
2663
2664static inline int security_sem_semop (struct sem_array * sma,
2665 struct sembuf * sops, unsigned nsops,
2666 int alter)
2667{
2668 return 0;
2669}
2670
2671static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2672{ }
2673
2674static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2675{
2676 return -EINVAL;
2677}
2678
2679static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2680{
2681 return -EINVAL;
2682}
2683
2684static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2685{
2686 return cap_netlink_send (sk, skb);
2687}
2688
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002689static inline int security_netlink_recv (struct sk_buff *skb, int cap)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690{
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002691 return cap_netlink_recv (skb, cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002692}
2693
Randy Dunlaped5a9272006-02-01 03:05:00 -08002694static inline struct dentry *securityfs_create_dir(const char *name,
2695 struct dentry *parent)
2696{
2697 return ERR_PTR(-ENODEV);
2698}
2699
2700static inline struct dentry *securityfs_create_file(const char *name,
2701 mode_t mode,
2702 struct dentry *parent,
2703 void *data,
2704 struct file_operations *fops)
2705{
2706 return ERR_PTR(-ENODEV);
2707}
2708
2709static inline void securityfs_remove(struct dentry *dentry)
2710{
2711}
2712
Linus Torvalds1da177e2005-04-16 15:20:36 -07002713#endif /* CONFIG_SECURITY */
2714
2715#ifdef CONFIG_SECURITY_NETWORK
2716static inline int security_unix_stream_connect(struct socket * sock,
2717 struct socket * other,
2718 struct sock * newsk)
2719{
2720 return security_ops->unix_stream_connect(sock, other, newsk);
2721}
2722
2723
2724static inline int security_unix_may_send(struct socket * sock,
2725 struct socket * other)
2726{
2727 return security_ops->unix_may_send(sock, other);
2728}
2729
2730static inline int security_socket_create (int family, int type,
2731 int protocol, int kern)
2732{
2733 return security_ops->socket_create(family, type, protocol, kern);
2734}
2735
2736static inline void security_socket_post_create(struct socket * sock,
2737 int family,
2738 int type,
2739 int protocol, int kern)
2740{
2741 security_ops->socket_post_create(sock, family, type,
2742 protocol, kern);
2743}
2744
2745static inline int security_socket_bind(struct socket * sock,
2746 struct sockaddr * address,
2747 int addrlen)
2748{
2749 return security_ops->socket_bind(sock, address, addrlen);
2750}
2751
2752static inline int security_socket_connect(struct socket * sock,
2753 struct sockaddr * address,
2754 int addrlen)
2755{
2756 return security_ops->socket_connect(sock, address, addrlen);
2757}
2758
2759static inline int security_socket_listen(struct socket * sock, int backlog)
2760{
2761 return security_ops->socket_listen(sock, backlog);
2762}
2763
2764static inline int security_socket_accept(struct socket * sock,
2765 struct socket * newsock)
2766{
2767 return security_ops->socket_accept(sock, newsock);
2768}
2769
2770static inline void security_socket_post_accept(struct socket * sock,
2771 struct socket * newsock)
2772{
2773 security_ops->socket_post_accept(sock, newsock);
2774}
2775
2776static inline int security_socket_sendmsg(struct socket * sock,
2777 struct msghdr * msg, int size)
2778{
2779 return security_ops->socket_sendmsg(sock, msg, size);
2780}
2781
2782static inline int security_socket_recvmsg(struct socket * sock,
2783 struct msghdr * msg, int size,
2784 int flags)
2785{
2786 return security_ops->socket_recvmsg(sock, msg, size, flags);
2787}
2788
2789static inline int security_socket_getsockname(struct socket * sock)
2790{
2791 return security_ops->socket_getsockname(sock);
2792}
2793
2794static inline int security_socket_getpeername(struct socket * sock)
2795{
2796 return security_ops->socket_getpeername(sock);
2797}
2798
2799static inline int security_socket_getsockopt(struct socket * sock,
2800 int level, int optname)
2801{
2802 return security_ops->socket_getsockopt(sock, level, optname);
2803}
2804
2805static inline int security_socket_setsockopt(struct socket * sock,
2806 int level, int optname)
2807{
2808 return security_ops->socket_setsockopt(sock, level, optname);
2809}
2810
2811static inline int security_socket_shutdown(struct socket * sock, int how)
2812{
2813 return security_ops->socket_shutdown(sock, how);
2814}
2815
2816static inline int security_sock_rcv_skb (struct sock * sk,
2817 struct sk_buff * skb)
2818{
2819 return security_ops->socket_sock_rcv_skb (sk, skb);
2820}
2821
Catherine Zhang2c7946a2006-03-20 22:41:23 -08002822static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2823 int __user *optlen, unsigned len)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002824{
Catherine Zhang2c7946a2006-03-20 22:41:23 -08002825 return security_ops->socket_getpeersec_stream(sock, optval, optlen, len);
2826}
2827
2828static inline int security_socket_getpeersec_dgram(struct sk_buff *skb, char **secdata,
2829 u32 *seclen)
2830{
2831 return security_ops->socket_getpeersec_dgram(skb, secdata, seclen);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002832}
2833
Al Virodd0fc662005-10-07 07:46:04 +01002834static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002835{
2836 return security_ops->sk_alloc_security(sk, family, priority);
2837}
2838
2839static inline void security_sk_free(struct sock *sk)
2840{
2841 return security_ops->sk_free_security(sk);
2842}
Trent Jaegerdf718372005-12-13 23:12:27 -08002843
2844static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir)
2845{
2846 return security_ops->sk_getsid(sk, fl, dir);
2847}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002848#else /* CONFIG_SECURITY_NETWORK */
2849static inline int security_unix_stream_connect(struct socket * sock,
2850 struct socket * other,
2851 struct sock * newsk)
2852{
2853 return 0;
2854}
2855
2856static inline int security_unix_may_send(struct socket * sock,
2857 struct socket * other)
2858{
2859 return 0;
2860}
2861
2862static inline int security_socket_create (int family, int type,
2863 int protocol, int kern)
2864{
2865 return 0;
2866}
2867
2868static inline void security_socket_post_create(struct socket * sock,
2869 int family,
2870 int type,
2871 int protocol, int kern)
2872{
2873}
2874
2875static inline int security_socket_bind(struct socket * sock,
2876 struct sockaddr * address,
2877 int addrlen)
2878{
2879 return 0;
2880}
2881
2882static inline int security_socket_connect(struct socket * sock,
2883 struct sockaddr * address,
2884 int addrlen)
2885{
2886 return 0;
2887}
2888
2889static inline int security_socket_listen(struct socket * sock, int backlog)
2890{
2891 return 0;
2892}
2893
2894static inline int security_socket_accept(struct socket * sock,
2895 struct socket * newsock)
2896{
2897 return 0;
2898}
2899
2900static inline void security_socket_post_accept(struct socket * sock,
2901 struct socket * newsock)
2902{
2903}
2904
2905static inline int security_socket_sendmsg(struct socket * sock,
2906 struct msghdr * msg, int size)
2907{
2908 return 0;
2909}
2910
2911static inline int security_socket_recvmsg(struct socket * sock,
2912 struct msghdr * msg, int size,
2913 int flags)
2914{
2915 return 0;
2916}
2917
2918static inline int security_socket_getsockname(struct socket * sock)
2919{
2920 return 0;
2921}
2922
2923static inline int security_socket_getpeername(struct socket * sock)
2924{
2925 return 0;
2926}
2927
2928static inline int security_socket_getsockopt(struct socket * sock,
2929 int level, int optname)
2930{
2931 return 0;
2932}
2933
2934static inline int security_socket_setsockopt(struct socket * sock,
2935 int level, int optname)
2936{
2937 return 0;
2938}
2939
2940static inline int security_socket_shutdown(struct socket * sock, int how)
2941{
2942 return 0;
2943}
2944static inline int security_sock_rcv_skb (struct sock * sk,
2945 struct sk_buff * skb)
2946{
2947 return 0;
2948}
2949
Catherine Zhang2c7946a2006-03-20 22:41:23 -08002950static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2951 int __user *optlen, unsigned len)
2952{
2953 return -ENOPROTOOPT;
2954}
2955
2956static inline int security_socket_getpeersec_dgram(struct sk_buff *skb, char **secdata,
2957 u32 *seclen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002958{
2959 return -ENOPROTOOPT;
2960}
2961
Al Virodd0fc662005-10-07 07:46:04 +01002962static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002963{
2964 return 0;
2965}
2966
2967static inline void security_sk_free(struct sock *sk)
2968{
2969}
Trent Jaegerdf718372005-12-13 23:12:27 -08002970
2971static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir)
2972{
2973 return 0;
2974}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002975#endif /* CONFIG_SECURITY_NETWORK */
2976
Trent Jaegerdf718372005-12-13 23:12:27 -08002977#ifdef CONFIG_SECURITY_NETWORK_XFRM
2978static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
2979{
2980 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx);
2981}
2982
2983static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
2984{
2985 return security_ops->xfrm_policy_clone_security(old, new);
2986}
2987
2988static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
2989{
2990 security_ops->xfrm_policy_free_security(xp);
2991}
2992
Catherine Zhangc8c05a82006-06-08 23:39:49 -07002993static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
2994{
2995 return security_ops->xfrm_policy_delete_security(xp);
2996}
2997
Trent Jaegerdf718372005-12-13 23:12:27 -08002998static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx)
2999{
3000 return security_ops->xfrm_state_alloc_security(x, sec_ctx);
3001}
3002
Catherine Zhangc8c05a82006-06-08 23:39:49 -07003003static inline int security_xfrm_state_delete(struct xfrm_state *x)
3004{
3005 return security_ops->xfrm_state_delete_security(x);
3006}
3007
Trent Jaegerdf718372005-12-13 23:12:27 -08003008static inline void security_xfrm_state_free(struct xfrm_state *x)
3009{
3010 security_ops->xfrm_state_free_security(x);
3011}
3012
3013static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir)
3014{
3015 return security_ops->xfrm_policy_lookup(xp, sk_sid, dir);
3016}
3017#else /* CONFIG_SECURITY_NETWORK_XFRM */
3018static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3019{
3020 return 0;
3021}
3022
3023static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3024{
3025 return 0;
3026}
3027
3028static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3029{
3030}
3031
Catherine Zhangc8c05a82006-06-08 23:39:49 -07003032static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3033{
3034 return 0;
3035}
3036
Trent Jaegerdf718372005-12-13 23:12:27 -08003037static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx)
3038{
3039 return 0;
3040}
3041
3042static inline void security_xfrm_state_free(struct xfrm_state *x)
3043{
3044}
3045
David S. Miller6f68dc32006-06-08 23:58:52 -07003046static inline int security_xfrm_state_delete(struct xfrm_state *x)
Catherine Zhangc8c05a82006-06-08 23:39:49 -07003047{
3048 return 0;
3049}
3050
Trent Jaegerdf718372005-12-13 23:12:27 -08003051static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir)
3052{
3053 return 0;
3054}
3055#endif /* CONFIG_SECURITY_NETWORK_XFRM */
3056
David Howells29db9192005-10-30 15:02:44 -08003057#ifdef CONFIG_KEYS
3058#ifdef CONFIG_SECURITY
Michael LeMayd7200242006-06-22 14:47:17 -07003059static inline int security_key_alloc(struct key *key,
David Howells7e047ef2006-06-26 00:24:50 -07003060 struct task_struct *tsk,
3061 unsigned long flags)
David Howells29db9192005-10-30 15:02:44 -08003062{
David Howells7e047ef2006-06-26 00:24:50 -07003063 return security_ops->key_alloc(key, tsk, flags);
David Howells29db9192005-10-30 15:02:44 -08003064}
3065
3066static inline void security_key_free(struct key *key)
3067{
3068 security_ops->key_free(key);
3069}
3070
3071static inline int security_key_permission(key_ref_t key_ref,
3072 struct task_struct *context,
3073 key_perm_t perm)
3074{
3075 return security_ops->key_permission(key_ref, context, perm);
3076}
3077
3078#else
3079
Michael LeMayd7200242006-06-22 14:47:17 -07003080static inline int security_key_alloc(struct key *key,
David Howells7e047ef2006-06-26 00:24:50 -07003081 struct task_struct *tsk,
3082 unsigned long flags)
David Howells29db9192005-10-30 15:02:44 -08003083{
3084 return 0;
3085}
3086
3087static inline void security_key_free(struct key *key)
3088{
3089}
3090
3091static inline int security_key_permission(key_ref_t key_ref,
3092 struct task_struct *context,
3093 key_perm_t perm)
3094{
3095 return 0;
3096}
3097
3098#endif
3099#endif /* CONFIG_KEYS */
3100
Linus Torvalds1da177e2005-04-16 15:20:36 -07003101#endif /* ! __LINUX_SECURITY_H */
3102