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