blob: df591d289ec98e18aec72af323c2cb941c560236 [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>
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -070035#include <net/flow.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37struct ctl_table;
38
39/*
40 * These functions are in security/capability.c and are used
41 * as the default capabilities functions
42 */
43extern int cap_capable (struct task_struct *tsk, int cap);
44extern int cap_settime (struct timespec *ts, struct timezone *tz);
45extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
46extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
47extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
48extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
49extern int cap_bprm_set_security (struct linux_binprm *bprm);
50extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
51extern int cap_bprm_secureexec(struct linux_binprm *bprm);
52extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
53extern int cap_inode_removexattr(struct dentry *dentry, char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -070054extern int cap_inode_need_killpriv(struct dentry *dentry);
55extern int cap_inode_killpriv(struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
57extern void cap_task_reparent_to_init (struct task_struct *p);
Serge E. Hallynb5376772007-10-16 23:31:36 -070058extern int cap_task_kill(struct task_struct *p, struct siginfo *info, int sig, u32 secid);
59extern int cap_task_setscheduler (struct task_struct *p, int policy, struct sched_param *lp);
60extern int cap_task_setioprio (struct task_struct *p, int ioprio);
61extern int cap_task_setnice (struct task_struct *p, int nice);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062extern int cap_syslog (int type);
James Morris20510f22007-10-16 23:31:32 -070063extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65struct msghdr;
66struct sk_buff;
67struct sock;
68struct sockaddr;
69struct socket;
Trent Jaegerdf718372005-12-13 23:12:27 -080070struct flowi;
71struct dst_entry;
72struct xfrm_selector;
73struct xfrm_policy;
74struct xfrm_state;
75struct xfrm_user_sec_ctx;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
Darrel Goeddelc7bdb542006-06-27 13:26:11 -070078extern int cap_netlink_recv(struct sk_buff *skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
Eric Parised032182007-06-28 15:55:21 -040080extern unsigned long mmap_min_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081/*
82 * Values used in the task_security_ops calls
83 */
84/* setuid or setgid, id0 == uid or gid */
85#define LSM_SETID_ID 1
86
87/* setreuid or setregid, id0 == real, id1 == eff */
88#define LSM_SETID_RE 2
89
90/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
91#define LSM_SETID_RES 4
92
93/* setfsuid or setfsgid, id0 == fsuid or fsgid */
94#define LSM_SETID_FS 8
95
96/* forward declares to avoid warnings */
97struct nfsctl_arg;
98struct sched_param;
99struct swap_info_struct;
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700100struct request_sock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
102/* bprm_apply_creds unsafe reasons */
103#define LSM_UNSAFE_SHARE 1
104#define LSM_UNSAFE_PTRACE 2
105#define LSM_UNSAFE_PTRACE_CAP 4
106
107#ifdef CONFIG_SECURITY
108
109/**
110 * struct security_operations - main security structure
111 *
112 * Security hooks for program execution operations.
113 *
114 * @bprm_alloc_security:
115 * Allocate and attach a security structure to the @bprm->security field.
116 * The security field is initialized to NULL when the bprm structure is
117 * allocated.
118 * @bprm contains the linux_binprm structure to be modified.
119 * Return 0 if operation was successful.
120 * @bprm_free_security:
121 * @bprm contains the linux_binprm structure to be modified.
122 * Deallocate and clear the @bprm->security field.
123 * @bprm_apply_creds:
124 * Compute and set the security attributes of a process being transformed
125 * by an execve operation based on the old attributes (current->security)
126 * and the information saved in @bprm->security by the set_security hook.
127 * Since this hook function (and its caller) are void, this hook can not
128 * return an error. However, it can leave the security attributes of the
129 * process unchanged if an access failure occurs at this point.
130 * bprm_apply_creds is called under task_lock. @unsafe indicates various
131 * reasons why it may be unsafe to change security state.
132 * @bprm contains the linux_binprm structure.
133 * @bprm_post_apply_creds:
134 * Runs after bprm_apply_creds with the task_lock dropped, so that
135 * functions which cannot be called safely under the task_lock can
136 * be used. This hook is a good place to perform state changes on
137 * the process such as closing open file descriptors to which access
138 * is no longer granted if the attributes were changed.
139 * Note that a security module might need to save state between
140 * bprm_apply_creds and bprm_post_apply_creds to store the decision
141 * on whether the process may proceed.
142 * @bprm contains the linux_binprm structure.
143 * @bprm_set_security:
144 * Save security information in the bprm->security field, typically based
145 * on information about the bprm->file, for later use by the apply_creds
146 * hook. This hook may also optionally check permissions (e.g. for
147 * transitions between security domains).
148 * This hook may be called multiple times during a single execve, e.g. for
149 * interpreters. The hook can tell whether it has already been called by
150 * checking to see if @bprm->security is non-NULL. If so, then the hook
151 * may decide either to retain the security information saved earlier or
152 * to replace it.
153 * @bprm contains the linux_binprm structure.
154 * Return 0 if the hook is successful and permission is granted.
155 * @bprm_check_security:
156 * This hook mediates the point when a search for a binary handler will
157 * begin. It allows a check the @bprm->security value which is set in
158 * the preceding set_security call. The primary difference from
159 * set_security is that the argv list and envp list are reliably
160 * available in @bprm. This hook may be called multiple times
161 * during a single execve; and in each pass set_security is called
162 * first.
163 * @bprm contains the linux_binprm structure.
164 * Return 0 if the hook is successful and permission is granted.
165 * @bprm_secureexec:
166 * Return a boolean value (0 or 1) indicating whether a "secure exec"
167 * is required. The flag is passed in the auxiliary table
168 * on the initial stack to the ELF interpreter to indicate whether libc
169 * should enable secure mode.
170 * @bprm contains the linux_binprm structure.
171 *
172 * Security hooks for filesystem operations.
173 *
174 * @sb_alloc_security:
175 * Allocate and attach a security structure to the sb->s_security field.
176 * The s_security field is initialized to NULL when the structure is
177 * allocated.
178 * @sb contains the super_block structure to be modified.
179 * Return 0 if operation was successful.
180 * @sb_free_security:
181 * Deallocate and clear the sb->s_security field.
182 * @sb contains the super_block structure to be modified.
183 * @sb_statfs:
David Howells726c3342006-06-23 02:02:58 -0700184 * Check permission before obtaining filesystem statistics for the @mnt
185 * mountpoint.
186 * @dentry is a handle on the superblock for the filesystem.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 * Return 0 if permission is granted.
188 * @sb_mount:
189 * Check permission before an object specified by @dev_name is mounted on
190 * the mount point named by @nd. For an ordinary mount, @dev_name
191 * identifies a device if the file system type requires a device. For a
192 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
193 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
194 * pathname of the object being mounted.
195 * @dev_name contains the name for object being mounted.
196 * @nd contains the nameidata structure for mount point object.
197 * @type contains the filesystem type.
198 * @flags contains the mount flags.
199 * @data contains the filesystem-specific data.
200 * Return 0 if permission is granted.
201 * @sb_copy_data:
202 * Allow mount option data to be copied prior to parsing by the filesystem,
203 * so that the security module can extract security-specific mount
204 * options cleanly (a filesystem may modify the data e.g. with strsep()).
205 * This also allows the original mount data to be stripped of security-
206 * specific options to avoid having to make filesystems aware of them.
207 * @type the type of filesystem being mounted.
208 * @orig the original mount data copied from userspace.
209 * @copy copied data which will be passed to the security module.
210 * Returns 0 if the copy was successful.
211 * @sb_check_sb:
212 * Check permission before the device with superblock @mnt->sb is mounted
213 * on the mount point named by @nd.
214 * @mnt contains the vfsmount for device being mounted.
215 * @nd contains the nameidata object for the mount point.
216 * Return 0 if permission is granted.
217 * @sb_umount:
218 * Check permission before the @mnt file system is unmounted.
219 * @mnt contains the mounted file system.
220 * @flags contains the unmount flags, e.g. MNT_FORCE.
221 * Return 0 if permission is granted.
222 * @sb_umount_close:
223 * Close any files in the @mnt mounted filesystem that are held open by
224 * the security module. This hook is called during an umount operation
225 * prior to checking whether the filesystem is still busy.
226 * @mnt contains the mounted filesystem.
227 * @sb_umount_busy:
228 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
229 * any files that were closed by umount_close. This hook is called during
230 * an umount operation if the umount fails after a call to the
231 * umount_close hook.
232 * @mnt contains the mounted filesystem.
233 * @sb_post_remount:
234 * Update the security module's state when a filesystem is remounted.
235 * This hook is only called if the remount was successful.
236 * @mnt contains the mounted file system.
237 * @flags contains the new filesystem flags.
238 * @data contains the filesystem-specific data.
239 * @sb_post_mountroot:
240 * Update the security module's state when the root filesystem is mounted.
241 * This hook is only called if the mount was successful.
242 * @sb_post_addmount:
243 * Update the security module's state when a filesystem is mounted.
244 * This hook is called any time a mount is successfully grafetd to
245 * the tree.
246 * @mnt contains the mounted filesystem.
247 * @mountpoint_nd contains the nameidata structure for the mount point.
248 * @sb_pivotroot:
249 * Check permission before pivoting the root filesystem.
250 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
251 * @new_nd contains the nameidata structure for the new root (new_root).
252 * Return 0 if permission is granted.
253 * @sb_post_pivotroot:
254 * Update module state after a successful pivot.
255 * @old_nd contains the nameidata structure for the old root.
256 * @new_nd contains the nameidata structure for the new root.
257 *
258 * Security hooks for inode operations.
259 *
260 * @inode_alloc_security:
261 * Allocate and attach a security structure to @inode->i_security. The
262 * i_security field is initialized to NULL when the inode structure is
263 * allocated.
264 * @inode contains the inode structure.
265 * Return 0 if operation was successful.
266 * @inode_free_security:
267 * @inode contains the inode structure.
268 * Deallocate the inode security structure and set @inode->i_security to
269 * NULL.
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700270 * @inode_init_security:
271 * Obtain the security attribute name suffix and value to set on a newly
272 * created inode and set up the incore security field for the new inode.
273 * This hook is called by the fs code as part of the inode creation
274 * transaction and provides for atomic labeling of the inode, unlike
275 * the post_create/mkdir/... hooks called by the VFS. The hook function
276 * is expected to allocate the name and value via kmalloc, with the caller
277 * being responsible for calling kfree after using them.
278 * If the security module does not use security attributes or does
279 * not wish to put a security attribute on this particular inode,
280 * then it should return -EOPNOTSUPP to skip this processing.
281 * @inode contains the inode structure of the newly created inode.
282 * @dir contains the inode structure of the parent directory.
283 * @name will be set to the allocated name suffix (e.g. selinux).
284 * @value will be set to the allocated attribute value.
285 * @len will be set to the length of the value.
286 * Returns 0 if @name and @value have been successfully set,
287 * -EOPNOTSUPP if no security attribute is needed, or
288 * -ENOMEM on memory allocation failure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 * @inode_create:
290 * Check permission to create a regular file.
291 * @dir contains inode structure of the parent of the new file.
292 * @dentry contains the dentry structure for the file to be created.
293 * @mode contains the file mode of the file to be created.
294 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 * @inode_link:
296 * Check permission before creating a new hard link to a file.
297 * @old_dentry contains the dentry structure for an existing link to the file.
298 * @dir contains the inode structure of the parent directory of the new link.
299 * @new_dentry contains the dentry structure for the new link.
300 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 * @inode_unlink:
302 * Check the permission to remove a hard link to a file.
303 * @dir contains the inode structure of parent directory of the file.
304 * @dentry contains the dentry structure for file to be unlinked.
305 * Return 0 if permission is granted.
306 * @inode_symlink:
307 * Check the permission to create a symbolic link to a file.
308 * @dir contains the inode structure of parent directory of the symbolic link.
309 * @dentry contains the dentry structure of the symbolic link.
310 * @old_name contains the pathname of file.
311 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 * @inode_mkdir:
313 * Check permissions to create a new directory in the existing directory
314 * associated with inode strcture @dir.
315 * @dir containst the inode structure of parent of the directory to be created.
316 * @dentry contains the dentry structure of new directory.
317 * @mode contains the mode of new directory.
318 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 * @inode_rmdir:
320 * Check the permission to remove a directory.
321 * @dir contains the inode structure of parent of the directory to be removed.
322 * @dentry contains the dentry structure of directory to be removed.
323 * Return 0 if permission is granted.
324 * @inode_mknod:
325 * Check permissions when creating a special file (or a socket or a fifo
326 * file created via the mknod system call). Note that if mknod operation
327 * is being done for a regular file, then the create hook will be called
328 * and not this hook.
329 * @dir contains the inode structure of parent of the new file.
330 * @dentry contains the dentry structure of the new file.
331 * @mode contains the mode of the new file.
Michael Opdenacker59c51592007-05-09 08:57:56 +0200332 * @dev contains the device number.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 * @inode_rename:
335 * Check for permission to rename a file or directory.
336 * @old_dir contains the inode structure for parent of the old link.
337 * @old_dentry contains the dentry structure of the old link.
338 * @new_dir contains the inode structure for parent of the new link.
339 * @new_dentry contains the dentry structure of the new link.
340 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 * @inode_readlink:
342 * Check the permission to read the symbolic link.
343 * @dentry contains the dentry structure for the file link.
344 * Return 0 if permission is granted.
345 * @inode_follow_link:
346 * Check permission to follow a symbolic link when looking up a pathname.
347 * @dentry contains the dentry structure for the link.
348 * @nd contains the nameidata structure for the parent directory.
349 * Return 0 if permission is granted.
350 * @inode_permission:
351 * Check permission before accessing an inode. This hook is called by the
352 * existing Linux permission function, so a security module can use it to
353 * provide additional checking for existing Linux permission checks.
354 * Notice that this hook is called when a file is opened (as well as many
355 * other operations), whereas the file_security_ops permission hook is
356 * called when the actual read/write operations are performed.
357 * @inode contains the inode structure to check.
358 * @mask contains the permission mask.
359 * @nd contains the nameidata (may be NULL).
360 * Return 0 if permission is granted.
361 * @inode_setattr:
362 * Check permission before setting file attributes. Note that the kernel
363 * call to notify_change is performed from several locations, whenever
364 * file attributes change (such as when a file is truncated, chown/chmod
365 * operations, transferring disk quotas, etc).
366 * @dentry contains the dentry structure for the file.
367 * @attr is the iattr structure containing the new file attributes.
368 * Return 0 if permission is granted.
369 * @inode_getattr:
370 * Check permission before obtaining file attributes.
371 * @mnt is the vfsmount where the dentry was looked up
372 * @dentry contains the dentry structure for the file.
373 * Return 0 if permission is granted.
374 * @inode_delete:
375 * @inode contains the inode structure for deleted inode.
376 * This hook is called when a deleted inode is released (i.e. an inode
377 * with no hard links has its use count drop to zero). A security module
378 * can use this hook to release any persistent label associated with the
379 * inode.
380 * @inode_setxattr:
381 * Check permission before setting the extended attributes
382 * @value identified by @name for @dentry.
383 * Return 0 if permission is granted.
384 * @inode_post_setxattr:
385 * Update inode security field after successful setxattr operation.
386 * @value identified by @name for @dentry.
387 * @inode_getxattr:
388 * Check permission before obtaining the extended attributes
389 * identified by @name for @dentry.
390 * Return 0 if permission is granted.
391 * @inode_listxattr:
392 * Check permission before obtaining the list of extended attribute
393 * names for @dentry.
394 * Return 0 if permission is granted.
395 * @inode_removexattr:
396 * Check permission before removing the extended attribute
397 * identified by @name for @dentry.
398 * Return 0 if permission is granted.
399 * @inode_getsecurity:
400 * Copy the extended attribute representation of the security label
401 * associated with @name for @inode into @buffer. @buffer may be
402 * NULL to request the size of the buffer required. @size indicates
403 * the size of @buffer in bytes. Note that @name is the remainder
404 * of the attribute name after the security. prefix has been removed.
James Morrisd381d8a2005-10-30 14:59:22 -0800405 * @err is the return value from the preceding fs getxattr call,
406 * and can be used by the security module to determine whether it
407 * should try and canonicalize the attribute value.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 * Return number of bytes used/required on success.
409 * @inode_setsecurity:
410 * Set the security label associated with @name for @inode from the
411 * extended attribute value @value. @size indicates the size of the
412 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
413 * Note that @name is the remainder of the attribute name after the
414 * security. prefix has been removed.
415 * Return 0 on success.
416 * @inode_listsecurity:
417 * Copy the extended attribute names for the security labels
418 * associated with @inode into @buffer. The maximum size of @buffer
419 * is specified by @buffer_size. @buffer may be NULL to request
420 * the size of the buffer required.
421 * Returns number of bytes used/required on success.
Serge E. Hallynb5376772007-10-16 23:31:36 -0700422 * @inode_need_killpriv:
423 * Called when an inode has been changed.
424 * @dentry is the dentry being changed.
425 * Return <0 on error to abort the inode change operation.
426 * Return 0 if inode_killpriv does not need to be called.
427 * Return >0 if inode_killpriv does need to be called.
428 * @inode_killpriv:
429 * The setuid bit is being removed. Remove similar security labels.
430 * Called with the dentry->d_inode->i_mutex held.
431 * @dentry is the dentry being changed.
432 * Return 0 on success. If error is returned, then the operation
433 * causing setuid bit removal is failed.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 *
435 * Security hooks for file operations
436 *
437 * @file_permission:
438 * Check file permissions before accessing an open file. This hook is
439 * called by various operations that read or write files. A security
440 * module can use this hook to perform additional checking on these
441 * operations, e.g. to revalidate permissions on use to support privilege
442 * bracketing or policy changes. Notice that this hook is used when the
443 * actual read/write operations are performed, whereas the
444 * inode_security_ops hook is called when a file is opened (as well as
445 * many other operations).
446 * Caveat: Although this hook can be used to revalidate permissions for
447 * various system call operations that read or write files, it does not
448 * address the revalidation of permissions for memory-mapped files.
449 * Security modules must handle this separately if they need such
450 * revalidation.
451 * @file contains the file structure being accessed.
452 * @mask contains the requested permissions.
453 * Return 0 if permission is granted.
454 * @file_alloc_security:
455 * Allocate and attach a security structure to the file->f_security field.
456 * The security field is initialized to NULL when the structure is first
457 * created.
458 * @file contains the file structure to secure.
459 * Return 0 if the hook is successful and permission is granted.
460 * @file_free_security:
461 * Deallocate and free any security structures stored in file->f_security.
462 * @file contains the file structure being modified.
463 * @file_ioctl:
464 * @file contains the file structure.
465 * @cmd contains the operation to perform.
466 * @arg contains the operational arguments.
467 * Check permission for an ioctl operation on @file. Note that @arg can
468 * sometimes represents a user space pointer; in other cases, it may be a
469 * simple integer value. When @arg represents a user space pointer, it
470 * should never be used by the security module.
471 * Return 0 if permission is granted.
472 * @file_mmap :
473 * Check permissions for a mmap operation. The @file may be NULL, e.g.
474 * if mapping anonymous memory.
475 * @file contains the file structure for file to map (may be NULL).
476 * @reqprot contains the protection requested by the application.
477 * @prot contains the protection that will be applied by the kernel.
478 * @flags contains the operational flags.
479 * Return 0 if permission is granted.
480 * @file_mprotect:
481 * Check permissions before changing memory access permissions.
482 * @vma contains the memory region to modify.
483 * @reqprot contains the protection requested by the application.
484 * @prot contains the protection that will be applied by the kernel.
485 * Return 0 if permission is granted.
486 * @file_lock:
487 * Check permission before performing file locking operations.
488 * Note: this hook mediates both flock and fcntl style locks.
489 * @file contains the file structure.
490 * @cmd contains the posix-translated lock operation to perform
491 * (e.g. F_RDLCK, F_WRLCK).
492 * Return 0 if permission is granted.
493 * @file_fcntl:
494 * Check permission before allowing the file operation specified by @cmd
495 * from being performed on the file @file. Note that @arg can sometimes
496 * represents a user space pointer; in other cases, it may be a simple
497 * integer value. When @arg represents a user space pointer, it should
498 * never be used by the security module.
499 * @file contains the file structure.
500 * @cmd contains the operation to be performed.
501 * @arg contains the operational arguments.
502 * Return 0 if permission is granted.
503 * @file_set_fowner:
504 * Save owner security information (typically from current->security) in
505 * file->f_security for later use by the send_sigiotask hook.
506 * @file contains the file structure to update.
507 * Return 0 on success.
508 * @file_send_sigiotask:
509 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
510 * process @tsk. Note that this hook is sometimes called from interrupt.
511 * Note that the fown_struct, @fown, is never outside the context of a
512 * struct file, so the file structure (and associated security information)
513 * can always be obtained:
Robert P. J. Dayb385a142007-02-10 01:46:25 -0800514 * container_of(fown, struct file, f_owner)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 * @tsk contains the structure of task receiving signal.
516 * @fown contains the file owner information.
517 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
518 * Return 0 if permission is granted.
519 * @file_receive:
520 * This hook allows security modules to control the ability of a process
521 * to receive an open file descriptor via socket IPC.
522 * @file contains the file structure being received.
523 * Return 0 if permission is granted.
524 *
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +0900525 * Security hook for dentry
526 *
527 * @dentry_open
528 * Save open-time permission checking state for later use upon
529 * file_permission, and recheck access if anything has changed
530 * since inode_permission.
531 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 * Security hooks for task operations.
533 *
534 * @task_create:
535 * Check permission before creating a child process. See the clone(2)
536 * manual page for definitions of the @clone_flags.
537 * @clone_flags contains the flags indicating what should be shared.
538 * Return 0 if permission is granted.
539 * @task_alloc_security:
540 * @p contains the task_struct for child process.
541 * Allocate and attach a security structure to the p->security field. The
542 * security field is initialized to NULL when the task structure is
543 * allocated.
544 * Return 0 if operation was successful.
545 * @task_free_security:
546 * @p contains the task_struct for process.
547 * Deallocate and clear the p->security field.
548 * @task_setuid:
549 * Check permission before setting one or more of the user identity
550 * attributes of the current process. The @flags parameter indicates
551 * which of the set*uid system calls invoked this hook and how to
552 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
553 * definitions at the beginning of this file for the @flags values and
554 * their meanings.
555 * @id0 contains a uid.
556 * @id1 contains a uid.
557 * @id2 contains a uid.
558 * @flags contains one of the LSM_SETID_* values.
559 * Return 0 if permission is granted.
560 * @task_post_setuid:
561 * Update the module's state after setting one or more of the user
562 * identity attributes of the current process. The @flags parameter
563 * indicates which of the set*uid system calls invoked this hook. If
564 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
565 * parameters are not used.
566 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
567 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
568 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
569 * @flags contains one of the LSM_SETID_* values.
570 * Return 0 on success.
571 * @task_setgid:
572 * Check permission before setting one or more of the group identity
573 * attributes of the current process. The @flags parameter indicates
574 * which of the set*gid system calls invoked this hook and how to
575 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
576 * definitions at the beginning of this file for the @flags values and
577 * their meanings.
578 * @id0 contains a gid.
579 * @id1 contains a gid.
580 * @id2 contains a gid.
581 * @flags contains one of the LSM_SETID_* values.
582 * Return 0 if permission is granted.
583 * @task_setpgid:
584 * Check permission before setting the process group identifier of the
585 * process @p to @pgid.
586 * @p contains the task_struct for process being modified.
587 * @pgid contains the new pgid.
588 * Return 0 if permission is granted.
589 * @task_getpgid:
590 * Check permission before getting the process group identifier of the
591 * process @p.
592 * @p contains the task_struct for the process.
593 * Return 0 if permission is granted.
594 * @task_getsid:
595 * Check permission before getting the session identifier of the process
596 * @p.
597 * @p contains the task_struct for the process.
598 * Return 0 if permission is granted.
David Quigleyf9008e42006-06-30 01:55:46 -0700599 * @task_getsecid:
600 * Retrieve the security identifier of the process @p.
601 * @p contains the task_struct for the process and place is into @secid.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 * @task_setgroups:
603 * Check permission before setting the supplementary group set of the
604 * current process.
605 * @group_info contains the new group information.
606 * Return 0 if permission is granted.
607 * @task_setnice:
608 * Check permission before setting the nice value of @p to @nice.
609 * @p contains the task_struct of process.
610 * @nice contains the new nice value.
611 * Return 0 if permission is granted.
James Morris03e68062006-06-23 02:03:58 -0700612 * @task_setioprio
613 * Check permission before setting the ioprio value of @p to @ioprio.
614 * @p contains the task_struct of process.
615 * @ioprio contains the new ioprio value
616 * Return 0 if permission is granted.
David Quigleya1836a42006-06-30 01:55:49 -0700617 * @task_getioprio
618 * Check permission before getting the ioprio value of @p.
619 * @p contains the task_struct of process.
620 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 * @task_setrlimit:
622 * Check permission before setting the resource limits of the current
623 * process for @resource to @new_rlim. The old resource limit values can
624 * be examined by dereferencing (current->signal->rlim + resource).
625 * @resource contains the resource whose limit is being set.
626 * @new_rlim contains the new limits for @resource.
627 * Return 0 if permission is granted.
628 * @task_setscheduler:
629 * Check permission before setting scheduling policy and/or parameters of
630 * process @p based on @policy and @lp.
631 * @p contains the task_struct for process.
632 * @policy contains the scheduling policy.
633 * @lp contains the scheduling parameters.
634 * Return 0 if permission is granted.
635 * @task_getscheduler:
636 * Check permission before obtaining scheduling information for process
637 * @p.
638 * @p contains the task_struct for process.
639 * Return 0 if permission is granted.
David Quigley35601542006-06-23 02:04:01 -0700640 * @task_movememory
641 * Check permission before moving memory owned by process @p.
642 * @p contains the task_struct for process.
643 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 * @task_kill:
645 * Check permission before sending signal @sig to @p. @info can be NULL,
646 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
647 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
648 * from the kernel and should typically be permitted.
649 * SIGIO signals are handled separately by the send_sigiotask hook in
650 * file_security_ops.
651 * @p contains the task_struct for process.
652 * @info contains the signal information.
653 * @sig contains the signal value.
David Quigleyf9008e42006-06-30 01:55:46 -0700654 * @secid contains the sid of the process where the signal originated
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 * Return 0 if permission is granted.
656 * @task_wait:
657 * Check permission before allowing a process to reap a child process @p
658 * and collect its status information.
659 * @p contains the task_struct for process.
660 * Return 0 if permission is granted.
661 * @task_prctl:
662 * Check permission before performing a process control operation on the
663 * current process.
664 * @option contains the operation.
665 * @arg2 contains a argument.
666 * @arg3 contains a argument.
667 * @arg4 contains a argument.
668 * @arg5 contains a argument.
669 * Return 0 if permission is granted.
670 * @task_reparent_to_init:
671 * Set the security attributes in @p->security for a kernel thread that
672 * is being reparented to the init task.
673 * @p contains the task_struct for the kernel thread.
674 * @task_to_inode:
675 * Set the security attributes for an inode based on an associated task's
676 * security attributes, e.g. for /proc/pid inodes.
677 * @p contains the task_struct for the task.
678 * @inode contains the inode structure for the inode.
679 *
680 * Security hooks for Netlink messaging.
681 *
682 * @netlink_send:
683 * Save security information for a netlink message so that permission
684 * checking can be performed when the message is processed. The security
685 * information can be saved using the eff_cap field of the
686 * netlink_skb_parms structure. Also may be used to provide fine
687 * grained control over message transmission.
688 * @sk associated sock of task sending the message.,
689 * @skb contains the sk_buff structure for the netlink message.
690 * Return 0 if the information was successfully saved and message
691 * is allowed to be transmitted.
692 * @netlink_recv:
693 * Check permission before processing the received netlink message in
694 * @skb.
695 * @skb contains the sk_buff structure for the netlink message.
Darrel Goeddelc7bdb542006-06-27 13:26:11 -0700696 * @cap indicates the capability required
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 * Return 0 if permission is granted.
698 *
699 * Security hooks for Unix domain networking.
700 *
701 * @unix_stream_connect:
702 * Check permissions before establishing a Unix domain stream connection
703 * between @sock and @other.
704 * @sock contains the socket structure.
705 * @other contains the peer socket structure.
706 * Return 0 if permission is granted.
707 * @unix_may_send:
708 * Check permissions before connecting or sending datagrams from @sock to
709 * @other.
710 * @sock contains the socket structure.
711 * @sock contains the peer socket structure.
712 * Return 0 if permission is granted.
713 *
714 * The @unix_stream_connect and @unix_may_send hooks were necessary because
715 * Linux provides an alternative to the conventional file name space for Unix
716 * domain sockets. Whereas binding and connecting to sockets in the file name
717 * space is mediated by the typical file permissions (and caught by the mknod
718 * and permission hooks in inode_security_ops), binding and connecting to
719 * sockets in the abstract name space is completely unmediated. Sufficient
720 * control of Unix domain sockets in the abstract name space isn't possible
721 * using only the socket layer hooks, since we need to know the actual target
722 * socket, which is not looked up until we are inside the af_unix code.
723 *
724 * Security hooks for socket operations.
725 *
726 * @socket_create:
727 * Check permissions prior to creating a new socket.
728 * @family contains the requested protocol family.
729 * @type contains the requested communications type.
730 * @protocol contains the requested protocol.
731 * @kern set to 1 if a kernel socket.
732 * Return 0 if permission is granted.
733 * @socket_post_create:
734 * This hook allows a module to update or allocate a per-socket security
735 * structure. Note that the security field was not added directly to the
736 * socket structure, but rather, the socket security information is stored
737 * in the associated inode. Typically, the inode alloc_security hook will
738 * allocate and and attach security information to
739 * sock->inode->i_security. This hook may be used to update the
740 * sock->inode->i_security field with additional information that wasn't
741 * available when the inode was allocated.
742 * @sock contains the newly created socket structure.
743 * @family contains the requested protocol family.
744 * @type contains the requested communications type.
745 * @protocol contains the requested protocol.
746 * @kern set to 1 if a kernel socket.
747 * @socket_bind:
748 * Check permission before socket protocol layer bind operation is
749 * performed and the socket @sock is bound to the address specified in the
750 * @address parameter.
751 * @sock contains the socket structure.
752 * @address contains the address to bind to.
753 * @addrlen contains the length of address.
754 * Return 0 if permission is granted.
755 * @socket_connect:
756 * Check permission before socket protocol layer connect operation
757 * attempts to connect socket @sock to a remote address, @address.
758 * @sock contains the socket structure.
759 * @address contains the address of remote endpoint.
760 * @addrlen contains the length of address.
761 * Return 0 if permission is granted.
762 * @socket_listen:
763 * Check permission before socket protocol layer listen operation.
764 * @sock contains the socket structure.
765 * @backlog contains the maximum length for the pending connection queue.
766 * Return 0 if permission is granted.
767 * @socket_accept:
768 * Check permission before accepting a new connection. Note that the new
769 * socket, @newsock, has been created and some information copied to it,
770 * but the accept operation has not actually been performed.
771 * @sock contains the listening socket structure.
772 * @newsock contains the newly created server socket for connection.
773 * Return 0 if permission is granted.
774 * @socket_post_accept:
775 * This hook allows a security module to copy security
776 * information into the newly created socket's inode.
777 * @sock contains the listening socket structure.
778 * @newsock contains the newly created server socket for connection.
779 * @socket_sendmsg:
780 * Check permission before transmitting a message to another socket.
781 * @sock contains the socket structure.
782 * @msg contains the message to be transmitted.
783 * @size contains the size of message.
784 * Return 0 if permission is granted.
785 * @socket_recvmsg:
786 * Check permission before receiving a message from a socket.
787 * @sock contains the socket structure.
788 * @msg contains the message structure.
789 * @size contains the size of message structure.
790 * @flags contains the operational flags.
791 * Return 0 if permission is granted.
792 * @socket_getsockname:
793 * Check permission before the local address (name) of the socket object
794 * @sock is retrieved.
795 * @sock contains the socket structure.
796 * Return 0 if permission is granted.
797 * @socket_getpeername:
798 * Check permission before the remote address (name) of a socket object
799 * @sock is retrieved.
800 * @sock contains the socket structure.
801 * Return 0 if permission is granted.
802 * @socket_getsockopt:
803 * Check permissions before retrieving the options associated with socket
804 * @sock.
805 * @sock contains the socket structure.
806 * @level contains the protocol level to retrieve option from.
807 * @optname contains the name of option to retrieve.
808 * Return 0 if permission is granted.
809 * @socket_setsockopt:
810 * Check permissions before setting the options associated with socket
811 * @sock.
812 * @sock contains the socket structure.
813 * @level contains the protocol level to set options for.
814 * @optname contains the name of the option to set.
815 * Return 0 if permission is granted.
816 * @socket_shutdown:
817 * Checks permission before all or part of a connection on the socket
818 * @sock is shut down.
819 * @sock contains the socket structure.
820 * @how contains the flag indicating how future sends and receives are handled.
821 * Return 0 if permission is granted.
822 * @socket_sock_rcv_skb:
823 * Check permissions on incoming network packets. This hook is distinct
824 * from Netfilter's IP input hooks since it is the first time that the
825 * incoming sk_buff @skb has been associated with a particular socket, @sk.
826 * @sk contains the sock (not socket) associated with the incoming sk_buff.
827 * @skb contains the incoming network data.
828 * @socket_getpeersec:
829 * This hook allows the security module to provide peer socket security
830 * state to userspace via getsockopt SO_GETPEERSEC.
831 * @sock is the local socket.
832 * @optval userspace memory where the security state is to be copied.
833 * @optlen userspace int where the module should copy the actual length
834 * of the security state.
835 * @len as input is the maximum length to copy to userspace provided
836 * by the caller.
837 * Return 0 if all is well, otherwise, typical getsockopt return
838 * values.
839 * @sk_alloc_security:
840 * Allocate and attach a security structure to the sk->sk_security field,
841 * which is used to copy security attributes between local stream sockets.
842 * @sk_free_security:
843 * Deallocate security structure.
Venkat Yekkirala892c1412006-08-04 23:08:56 -0700844 * @sk_clone_security:
845 * Clone/copy security structure.
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -0700846 * @sk_getsecid:
847 * Retrieve the LSM-specific secid for the sock to enable caching of network
Trent Jaegerdf718372005-12-13 23:12:27 -0800848 * authorizations.
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700849 * @sock_graft:
850 * Sets the socket's isec sid to the sock's sid.
851 * @inet_conn_request:
852 * Sets the openreq's sid to socket's sid with MLS portion taken from peer sid.
853 * @inet_csk_clone:
854 * Sets the new child socket's sid to the openreq sid.
Venkat Yekkirala6b877692006-11-08 17:04:09 -0600855 * @inet_conn_established:
856 * Sets the connection's peersid to the secmark on skb.
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700857 * @req_classify_flow:
858 * Sets the flow's sid to the openreq sid.
Trent Jaegerdf718372005-12-13 23:12:27 -0800859 *
860 * Security hooks for XFRM operations.
861 *
862 * @xfrm_policy_alloc_security:
863 * @xp contains the xfrm_policy being added to Security Policy Database
864 * used by the XFRM system.
865 * @sec_ctx contains the security context information being provided by
866 * the user-level policy update program (e.g., setkey).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700867 * Allocate a security structure to the xp->security field; the security
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -0600868 * field is initialized to NULL when the xfrm_policy is allocated.
Trent Jaegerdf718372005-12-13 23:12:27 -0800869 * Return 0 if operation was successful (memory to allocate, legal context)
870 * @xfrm_policy_clone_security:
871 * @old contains an existing xfrm_policy in the SPD.
872 * @new contains a new xfrm_policy being cloned from old.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700873 * Allocate a security structure to the new->security field
874 * that contains the information from the old->security field.
Trent Jaegerdf718372005-12-13 23:12:27 -0800875 * Return 0 if operation was successful (memory to allocate).
876 * @xfrm_policy_free_security:
877 * @xp contains the xfrm_policy
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700878 * Deallocate xp->security.
879 * @xfrm_policy_delete_security:
880 * @xp contains the xfrm_policy.
881 * Authorize deletion of xp->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800882 * @xfrm_state_alloc_security:
883 * @x contains the xfrm_state being added to the Security Association
884 * Database by the XFRM system.
885 * @sec_ctx contains the security context information being provided by
886 * the user-level SA generation program (e.g., setkey or racoon).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700887 * @secid contains the secid from which to take the mls portion of the context.
888 * Allocate a security structure to the x->security field; the security
889 * field is initialized to NULL when the xfrm_state is allocated. Set the
890 * context to correspond to either sec_ctx or polsec, with the mls portion
891 * taken from secid in the latter case.
Trent Jaegerdf718372005-12-13 23:12:27 -0800892 * Return 0 if operation was successful (memory to allocate, legal context).
893 * @xfrm_state_free_security:
894 * @x contains the xfrm_state.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700895 * Deallocate x->security.
896 * @xfrm_state_delete_security:
897 * @x contains the xfrm_state.
898 * Authorize deletion of x->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800899 * @xfrm_policy_lookup:
900 * @xp contains the xfrm_policy for which the access control is being
901 * checked.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700902 * @fl_secid contains the flow security label that is used to authorize
Trent Jaegerdf718372005-12-13 23:12:27 -0800903 * access to the policy xp.
904 * @dir contains the direction of the flow (input or output).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700905 * Check permission when a flow selects a xfrm_policy for processing
Trent Jaegerdf718372005-12-13 23:12:27 -0800906 * XFRMs on a packet. The hook is called when selecting either a
907 * per-socket policy or a generic xfrm policy.
Venkat Yekkirala5b368e62006-10-05 15:42:18 -0500908 * Return 0 if permission is granted, -ESRCH otherwise, or -errno
909 * on other errors.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700910 * @xfrm_state_pol_flow_match:
911 * @x contains the state to match.
912 * @xp contains the policy to check for a match.
913 * @fl contains the flow to check for a match.
914 * Return 1 if there is a match.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700915 * @xfrm_decode_session:
916 * @skb points to skb to decode.
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -0700917 * @secid points to the flow key secid to set.
918 * @ckall says if all xfrms used should be checked for same secid.
919 * Return 0 if ckall is zero or all xfrms used have the same secid.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920 *
David Howells29db9192005-10-30 15:02:44 -0800921 * Security hooks affecting all Key Management operations
922 *
923 * @key_alloc:
924 * Permit allocation of a key and assign security data. Note that key does
925 * not have a serial number assigned at this point.
926 * @key points to the key.
David Howells7e047ef2006-06-26 00:24:50 -0700927 * @flags is the allocation flags
David Howells29db9192005-10-30 15:02:44 -0800928 * Return 0 if permission is granted, -ve error otherwise.
929 * @key_free:
930 * Notification of destruction; free security data.
931 * @key points to the key.
932 * No return value.
933 * @key_permission:
934 * See whether a specific operational right is granted to a process on a
935 * key.
936 * @key_ref refers to the key (key pointer + possession attribute bit).
937 * @context points to the process to provide the context against which to
938 * evaluate the security data on the key.
939 * @perm describes the combination of permissions required of this key.
940 * Return 1 if permission granted, 0 if permission denied and -ve it the
941 * normal permissions model should be effected.
942 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943 * Security hooks affecting all System V IPC operations.
944 *
945 * @ipc_permission:
946 * Check permissions for access to IPC
947 * @ipcp contains the kernel IPC permission structure
948 * @flag contains the desired (requested) permission set
949 * Return 0 if permission is granted.
950 *
951 * Security hooks for individual messages held in System V IPC message queues
952 * @msg_msg_alloc_security:
953 * Allocate and attach a security structure to the msg->security field.
954 * The security field is initialized to NULL when the structure is first
955 * created.
956 * @msg contains the message structure to be modified.
957 * Return 0 if operation was successful and permission is granted.
958 * @msg_msg_free_security:
959 * Deallocate the security structure for this message.
960 * @msg contains the message structure to be modified.
961 *
962 * Security hooks for System V IPC Message Queues
963 *
964 * @msg_queue_alloc_security:
965 * Allocate and attach a security structure to the
966 * msq->q_perm.security field. The security field is initialized to
967 * NULL when the structure is first created.
968 * @msq contains the message queue structure to be modified.
969 * Return 0 if operation was successful and permission is granted.
970 * @msg_queue_free_security:
971 * Deallocate security structure for this message queue.
972 * @msq contains the message queue structure to be modified.
973 * @msg_queue_associate:
974 * Check permission when a message queue is requested through the
975 * msgget system call. This hook is only called when returning the
976 * message queue identifier for an existing message queue, not when a
977 * new message queue is created.
978 * @msq contains the message queue to act upon.
979 * @msqflg contains the operation control flags.
980 * Return 0 if permission is granted.
981 * @msg_queue_msgctl:
982 * Check permission when a message control operation specified by @cmd
983 * is to be performed on the message queue @msq.
984 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
985 * @msq contains the message queue to act upon. May be NULL.
986 * @cmd contains the operation to be performed.
987 * Return 0 if permission is granted.
988 * @msg_queue_msgsnd:
989 * Check permission before a message, @msg, is enqueued on the message
990 * queue, @msq.
991 * @msq contains the message queue to send message to.
992 * @msg contains the message to be enqueued.
993 * @msqflg contains operational flags.
994 * Return 0 if permission is granted.
995 * @msg_queue_msgrcv:
996 * Check permission before a message, @msg, is removed from the message
997 * queue, @msq. The @target task structure contains a pointer to the
998 * process that will be receiving the message (not equal to the current
999 * process when inline receives are being performed).
1000 * @msq contains the message queue to retrieve message from.
1001 * @msg contains the message destination.
1002 * @target contains the task structure for recipient process.
1003 * @type contains the type of message requested.
1004 * @mode contains the operational flags.
1005 * Return 0 if permission is granted.
1006 *
1007 * Security hooks for System V Shared Memory Segments
1008 *
1009 * @shm_alloc_security:
1010 * Allocate and attach a security structure to the shp->shm_perm.security
1011 * field. The security field is initialized to NULL when the structure is
1012 * first created.
1013 * @shp contains the shared memory structure to be modified.
1014 * Return 0 if operation was successful and permission is granted.
1015 * @shm_free_security:
1016 * Deallocate the security struct for this memory segment.
1017 * @shp contains the shared memory structure to be modified.
1018 * @shm_associate:
1019 * Check permission when a shared memory region is requested through the
1020 * shmget system call. This hook is only called when returning the shared
1021 * memory region identifier for an existing region, not when a new shared
1022 * memory region is created.
1023 * @shp contains the shared memory structure to be modified.
1024 * @shmflg contains the operation control flags.
1025 * Return 0 if permission is granted.
1026 * @shm_shmctl:
1027 * Check permission when a shared memory control operation specified by
1028 * @cmd is to be performed on the shared memory region @shp.
1029 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1030 * @shp contains shared memory structure to be modified.
1031 * @cmd contains the operation to be performed.
1032 * Return 0 if permission is granted.
1033 * @shm_shmat:
1034 * Check permissions prior to allowing the shmat system call to attach the
1035 * shared memory segment @shp to the data segment of the calling process.
1036 * The attaching address is specified by @shmaddr.
1037 * @shp contains the shared memory structure to be modified.
1038 * @shmaddr contains the address to attach memory region to.
1039 * @shmflg contains the operational flags.
1040 * Return 0 if permission is granted.
1041 *
1042 * Security hooks for System V Semaphores
1043 *
1044 * @sem_alloc_security:
1045 * Allocate and attach a security structure to the sma->sem_perm.security
1046 * field. The security field is initialized to NULL when the structure is
1047 * first created.
1048 * @sma contains the semaphore structure
1049 * Return 0 if operation was successful and permission is granted.
1050 * @sem_free_security:
1051 * deallocate security struct for this semaphore
1052 * @sma contains the semaphore structure.
1053 * @sem_associate:
1054 * Check permission when a semaphore is requested through the semget
1055 * system call. This hook is only called when returning the semaphore
1056 * identifier for an existing semaphore, not when a new one must be
1057 * created.
1058 * @sma contains the semaphore structure.
1059 * @semflg contains the operation control flags.
1060 * Return 0 if permission is granted.
1061 * @sem_semctl:
1062 * Check permission when a semaphore operation specified by @cmd is to be
1063 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
1064 * IPC_INFO or SEM_INFO.
1065 * @sma contains the semaphore structure. May be NULL.
1066 * @cmd contains the operation to be performed.
1067 * Return 0 if permission is granted.
1068 * @sem_semop
1069 * Check permissions before performing operations on members of the
1070 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1071 * may be modified.
1072 * @sma contains the semaphore structure.
1073 * @sops contains the operations to perform.
1074 * @nsops contains the number of operations to perform.
1075 * @alter contains the flag indicating whether changes are to be made.
1076 * Return 0 if permission is granted.
1077 *
1078 * @ptrace:
1079 * Check permission before allowing the @parent process to trace the
1080 * @child process.
1081 * Security modules may also want to perform a process tracing check
1082 * during an execve in the set_security or apply_creds hooks of
1083 * binprm_security_ops if the process is being traced and its security
1084 * attributes would be changed by the execve.
1085 * @parent contains the task_struct structure for parent process.
1086 * @child contains the task_struct structure for child process.
1087 * Return 0 if permission is granted.
1088 * @capget:
1089 * Get the @effective, @inheritable, and @permitted capability sets for
1090 * the @target process. The hook may also perform permission checking to
1091 * determine if the current process is allowed to see the capability sets
1092 * of the @target process.
1093 * @target contains the task_struct structure for target process.
1094 * @effective contains the effective capability set.
1095 * @inheritable contains the inheritable capability set.
1096 * @permitted contains the permitted capability set.
1097 * Return 0 if the capability sets were successfully obtained.
1098 * @capset_check:
1099 * Check permission before setting the @effective, @inheritable, and
1100 * @permitted capability sets for the @target process.
1101 * Caveat: @target is also set to current if a set of processes is
1102 * specified (i.e. all processes other than current and init or a
1103 * particular process group). Hence, the capset_set hook may need to
1104 * revalidate permission to the actual target process.
1105 * @target contains the task_struct structure for target process.
1106 * @effective contains the effective capability set.
1107 * @inheritable contains the inheritable capability set.
1108 * @permitted contains the permitted capability set.
1109 * Return 0 if permission is granted.
1110 * @capset_set:
1111 * Set the @effective, @inheritable, and @permitted capability sets for
1112 * the @target process. Since capset_check cannot always check permission
1113 * to the real @target process, this hook may also perform permission
1114 * checking to determine if the current process is allowed to set the
1115 * capability sets of the @target process. However, this hook has no way
1116 * of returning an error due to the structure of the sys_capset code.
1117 * @target contains the task_struct structure for target process.
1118 * @effective contains the effective capability set.
1119 * @inheritable contains the inheritable capability set.
1120 * @permitted contains the permitted capability set.
Chris Wright12b59892006-03-25 03:07:41 -08001121 * @capable:
1122 * Check whether the @tsk process has the @cap capability.
1123 * @tsk contains the task_struct for the process.
1124 * @cap contains the capability <include/linux/capability.h>.
1125 * Return 0 if the capability is granted for @tsk.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126 * @acct:
1127 * Check permission before enabling or disabling process accounting. If
1128 * accounting is being enabled, then @file refers to the open file used to
1129 * store accounting records. If accounting is being disabled, then @file
1130 * is NULL.
1131 * @file contains the file structure for the accounting file (may be NULL).
1132 * Return 0 if permission is granted.
1133 * @sysctl:
1134 * Check permission before accessing the @table sysctl variable in the
1135 * manner specified by @op.
1136 * @table contains the ctl_table structure for the sysctl variable.
1137 * @op contains the operation (001 = search, 002 = write, 004 = read).
1138 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139 * @syslog:
1140 * Check permission before accessing the kernel message ring or changing
1141 * logging to the console.
1142 * See the syslog(2) manual page for an explanation of the @type values.
1143 * @type contains the type of action.
1144 * Return 0 if permission is granted.
1145 * @settime:
1146 * Check permission to change the system time.
1147 * struct timespec and timezone are defined in include/linux/time.h
1148 * @ts contains new time
1149 * @tz contains new timezone
1150 * Return 0 if permission is granted.
1151 * @vm_enough_memory:
1152 * Check permissions for allocating a new virtual mapping.
Alan Cox34b4e4a2007-08-22 14:01:28 -07001153 * @mm contains the mm struct it is being added to.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 * @pages contains the number of pages.
1155 * Return 0 if permission is granted.
1156 *
1157 * @register_security:
1158 * allow module stacking.
1159 * @name contains the name of the security module being stacked.
1160 * @ops contains a pointer to the struct security_operations of the module to stack.
1161 * @unregister_security:
1162 * remove a stacked module.
1163 * @name contains the name of the security module being unstacked.
1164 * @ops contains a pointer to the struct security_operations of the module to unstack.
1165 *
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001166 * @secid_to_secctx:
1167 * Convert secid to security context.
1168 * @secid contains the security ID.
1169 * @secdata contains the pointer that stores the converted security context.
1170 *
1171 * @release_secctx:
1172 * Release the security context.
1173 * @secdata contains the security context.
1174 * @seclen contains the length of the security context.
1175 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 * This is the main security structure.
1177 */
1178struct security_operations {
1179 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1180 int (*capget) (struct task_struct * target,
1181 kernel_cap_t * effective,
1182 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1183 int (*capset_check) (struct task_struct * target,
1184 kernel_cap_t * effective,
1185 kernel_cap_t * inheritable,
1186 kernel_cap_t * permitted);
1187 void (*capset_set) (struct task_struct * target,
1188 kernel_cap_t * effective,
1189 kernel_cap_t * inheritable,
1190 kernel_cap_t * permitted);
Chris Wright12b59892006-03-25 03:07:41 -08001191 int (*capable) (struct task_struct * tsk, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 int (*acct) (struct file * file);
1193 int (*sysctl) (struct ctl_table * table, int op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001194 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1195 int (*quota_on) (struct dentry * dentry);
1196 int (*syslog) (int type);
1197 int (*settime) (struct timespec *ts, struct timezone *tz);
Alan Cox34b4e4a2007-08-22 14:01:28 -07001198 int (*vm_enough_memory) (struct mm_struct *mm, long pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199
1200 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1201 void (*bprm_free_security) (struct linux_binprm * bprm);
1202 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1203 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1204 int (*bprm_set_security) (struct linux_binprm * bprm);
1205 int (*bprm_check_security) (struct linux_binprm * bprm);
1206 int (*bprm_secureexec) (struct linux_binprm * bprm);
1207
1208 int (*sb_alloc_security) (struct super_block * sb);
1209 void (*sb_free_security) (struct super_block * sb);
1210 int (*sb_copy_data)(struct file_system_type *type,
1211 void *orig, void *copy);
1212 int (*sb_kern_mount) (struct super_block *sb, void *data);
David Howells726c3342006-06-23 02:02:58 -07001213 int (*sb_statfs) (struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001214 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1215 char *type, unsigned long flags, void *data);
1216 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1217 int (*sb_umount) (struct vfsmount * mnt, int flags);
1218 void (*sb_umount_close) (struct vfsmount * mnt);
1219 void (*sb_umount_busy) (struct vfsmount * mnt);
1220 void (*sb_post_remount) (struct vfsmount * mnt,
1221 unsigned long flags, void *data);
1222 void (*sb_post_mountroot) (void);
1223 void (*sb_post_addmount) (struct vfsmount * mnt,
1224 struct nameidata * mountpoint_nd);
1225 int (*sb_pivotroot) (struct nameidata * old_nd,
1226 struct nameidata * new_nd);
1227 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1228 struct nameidata * new_nd);
1229
1230 int (*inode_alloc_security) (struct inode *inode);
1231 void (*inode_free_security) (struct inode *inode);
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001232 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1233 char **name, void **value, size_t *len);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234 int (*inode_create) (struct inode *dir,
1235 struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001236 int (*inode_link) (struct dentry *old_dentry,
1237 struct inode *dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1239 int (*inode_symlink) (struct inode *dir,
1240 struct dentry *dentry, const char *old_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001242 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1243 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1244 int mode, dev_t dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001245 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1246 struct inode *new_dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001247 int (*inode_readlink) (struct dentry *dentry);
1248 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1249 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1250 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1251 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1252 void (*inode_delete) (struct inode *inode);
1253 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1254 size_t size, int flags);
1255 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1256 size_t size, int flags);
1257 int (*inode_getxattr) (struct dentry *dentry, char *name);
1258 int (*inode_listxattr) (struct dentry *dentry);
1259 int (*inode_removexattr) (struct dentry *dentry, char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -07001260 int (*inode_need_killpriv) (struct dentry *dentry);
1261 int (*inode_killpriv) (struct dentry *dentry);
Dustin Kirkland7306a0b2005-11-16 15:53:13 +00001262 const char *(*inode_xattr_getsuffix) (void);
1263 int (*inode_getsecurity)(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1265 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1266
1267 int (*file_permission) (struct file * file, int mask);
1268 int (*file_alloc_security) (struct file * file);
1269 void (*file_free_security) (struct file * file);
1270 int (*file_ioctl) (struct file * file, unsigned int cmd,
1271 unsigned long arg);
1272 int (*file_mmap) (struct file * file,
Eric Parised032182007-06-28 15:55:21 -04001273 unsigned long reqprot, unsigned long prot,
1274 unsigned long flags, unsigned long addr,
1275 unsigned long addr_only);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276 int (*file_mprotect) (struct vm_area_struct * vma,
1277 unsigned long reqprot,
1278 unsigned long prot);
1279 int (*file_lock) (struct file * file, unsigned int cmd);
1280 int (*file_fcntl) (struct file * file, unsigned int cmd,
1281 unsigned long arg);
1282 int (*file_set_fowner) (struct file * file);
1283 int (*file_send_sigiotask) (struct task_struct * tsk,
1284 struct fown_struct * fown, int sig);
1285 int (*file_receive) (struct file * file);
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +09001286 int (*dentry_open) (struct file *file);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001287
1288 int (*task_create) (unsigned long clone_flags);
1289 int (*task_alloc_security) (struct task_struct * p);
1290 void (*task_free_security) (struct task_struct * p);
1291 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1292 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1293 uid_t old_euid, uid_t old_suid, int flags);
1294 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1295 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1296 int (*task_getpgid) (struct task_struct * p);
1297 int (*task_getsid) (struct task_struct * p);
David Quigleyf9008e42006-06-30 01:55:46 -07001298 void (*task_getsecid) (struct task_struct * p, u32 * secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001299 int (*task_setgroups) (struct group_info *group_info);
1300 int (*task_setnice) (struct task_struct * p, int nice);
James Morris03e68062006-06-23 02:03:58 -07001301 int (*task_setioprio) (struct task_struct * p, int ioprio);
David Quigleya1836a42006-06-30 01:55:49 -07001302 int (*task_getioprio) (struct task_struct * p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1304 int (*task_setscheduler) (struct task_struct * p, int policy,
1305 struct sched_param * lp);
1306 int (*task_getscheduler) (struct task_struct * p);
David Quigley35601542006-06-23 02:04:01 -07001307 int (*task_movememory) (struct task_struct * p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001308 int (*task_kill) (struct task_struct * p,
David Quigleyf9008e42006-06-30 01:55:46 -07001309 struct siginfo * info, int sig, u32 secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310 int (*task_wait) (struct task_struct * p);
1311 int (*task_prctl) (int option, unsigned long arg2,
1312 unsigned long arg3, unsigned long arg4,
1313 unsigned long arg5);
1314 void (*task_reparent_to_init) (struct task_struct * p);
1315 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1316
1317 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1318
1319 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1320 void (*msg_msg_free_security) (struct msg_msg * msg);
1321
1322 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1323 void (*msg_queue_free_security) (struct msg_queue * msq);
1324 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1325 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1326 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1327 struct msg_msg * msg, int msqflg);
1328 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1329 struct msg_msg * msg,
1330 struct task_struct * target,
1331 long type, int mode);
1332
1333 int (*shm_alloc_security) (struct shmid_kernel * shp);
1334 void (*shm_free_security) (struct shmid_kernel * shp);
1335 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1336 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1337 int (*shm_shmat) (struct shmid_kernel * shp,
1338 char __user *shmaddr, int shmflg);
1339
1340 int (*sem_alloc_security) (struct sem_array * sma);
1341 void (*sem_free_security) (struct sem_array * sma);
1342 int (*sem_associate) (struct sem_array * sma, int semflg);
1343 int (*sem_semctl) (struct sem_array * sma, int cmd);
1344 int (*sem_semop) (struct sem_array * sma,
1345 struct sembuf * sops, unsigned nsops, int alter);
1346
1347 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07001348 int (*netlink_recv) (struct sk_buff * skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001349
1350 /* allow module stacking */
1351 int (*register_security) (const char *name,
1352 struct security_operations *ops);
1353 int (*unregister_security) (const char *name,
1354 struct security_operations *ops);
1355
1356 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1357
Al Viro04ff9702007-03-12 16:17:58 +00001358 int (*getprocattr)(struct task_struct *p, char *name, char **value);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001359 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001360 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
1361 void (*release_secctx)(char *secdata, u32 seclen);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362
1363#ifdef CONFIG_SECURITY_NETWORK
1364 int (*unix_stream_connect) (struct socket * sock,
1365 struct socket * other, struct sock * newsk);
1366 int (*unix_may_send) (struct socket * sock, struct socket * other);
1367
1368 int (*socket_create) (int family, int type, int protocol, int kern);
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07001369 int (*socket_post_create) (struct socket * sock, int family,
1370 int type, int protocol, int kern);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001371 int (*socket_bind) (struct socket * sock,
1372 struct sockaddr * address, int addrlen);
1373 int (*socket_connect) (struct socket * sock,
1374 struct sockaddr * address, int addrlen);
1375 int (*socket_listen) (struct socket * sock, int backlog);
1376 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1377 void (*socket_post_accept) (struct socket * sock,
1378 struct socket * newsock);
1379 int (*socket_sendmsg) (struct socket * sock,
1380 struct msghdr * msg, int size);
1381 int (*socket_recvmsg) (struct socket * sock,
1382 struct msghdr * msg, int size, int flags);
1383 int (*socket_getsockname) (struct socket * sock);
1384 int (*socket_getpeername) (struct socket * sock);
1385 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1386 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1387 int (*socket_shutdown) (struct socket * sock, int how);
1388 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
Catherine Zhang2c7946a2006-03-20 22:41:23 -08001389 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001390 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
Al Viro7d877f32005-10-21 03:20:43 -04001391 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 void (*sk_free_security) (struct sock *sk);
Venkat Yekkirala892c1412006-08-04 23:08:56 -07001393 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001394 void (*sk_getsecid) (struct sock *sk, u32 *secid);
Venkat Yekkirala4237c752006-07-24 23:32:50 -07001395 void (*sock_graft)(struct sock* sk, struct socket *parent);
1396 int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb,
1397 struct request_sock *req);
1398 void (*inet_csk_clone)(struct sock *newsk, const struct request_sock *req);
Venkat Yekkirala6b877692006-11-08 17:04:09 -06001399 void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb);
Venkat Yekkirala4237c752006-07-24 23:32:50 -07001400 void (*req_classify_flow)(const struct request_sock *req, struct flowi *fl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401#endif /* CONFIG_SECURITY_NETWORK */
David Howells29db9192005-10-30 15:02:44 -08001402
Trent Jaegerdf718372005-12-13 23:12:27 -08001403#ifdef CONFIG_SECURITY_NETWORK_XFRM
Venkat Yekkiralacb969f02006-07-24 23:32:20 -07001404 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp,
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -06001405 struct xfrm_user_sec_ctx *sec_ctx);
Trent Jaegerdf718372005-12-13 23:12:27 -08001406 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1407 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001408 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001409 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -06001410 struct xfrm_user_sec_ctx *sec_ctx,
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001411 u32 secid);
Trent Jaegerdf718372005-12-13 23:12:27 -08001412 void (*xfrm_state_free_security) (struct xfrm_state *x);
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001413 int (*xfrm_state_delete_security) (struct xfrm_state *x);
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001414 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
1415 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
1416 struct xfrm_policy *xp, struct flowi *fl);
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001417 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
Trent Jaegerdf718372005-12-13 23:12:27 -08001418#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1419
David Howells29db9192005-10-30 15:02:44 -08001420 /* key management security hooks */
1421#ifdef CONFIG_KEYS
David Howells7e047ef2006-06-26 00:24:50 -07001422 int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags);
David Howells29db9192005-10-30 15:02:44 -08001423 void (*key_free)(struct key *key);
1424 int (*key_permission)(key_ref_t key_ref,
1425 struct task_struct *context,
1426 key_perm_t perm);
1427
1428#endif /* CONFIG_KEYS */
1429
Linus Torvalds1da177e2005-04-16 15:20:36 -07001430};
1431
Linus Torvalds1da177e2005-04-16 15:20:36 -07001432/* prototypes */
1433extern int security_init (void);
1434extern int register_security (struct security_operations *ops);
1435extern int unregister_security (struct security_operations *ops);
1436extern int mod_reg_security (const char *name, struct security_operations *ops);
1437extern int mod_unreg_security (const char *name, struct security_operations *ops);
Greg KHb67dbf92005-07-07 14:37:53 -07001438extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
1439 struct dentry *parent, void *data,
Arjan van de Ven54047322007-02-12 00:55:28 -08001440 const struct file_operations *fops);
Greg KHb67dbf92005-07-07 14:37:53 -07001441extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1442extern void securityfs_remove(struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443
1444
James Morris20510f22007-10-16 23:31:32 -07001445/* Security operations */
1446int security_ptrace(struct task_struct *parent, struct task_struct *child);
1447int security_capget(struct task_struct *target,
1448 kernel_cap_t *effective,
1449 kernel_cap_t *inheritable,
1450 kernel_cap_t *permitted);
1451int security_capset_check(struct task_struct *target,
1452 kernel_cap_t *effective,
1453 kernel_cap_t *inheritable,
1454 kernel_cap_t *permitted);
1455void security_capset_set(struct task_struct *target,
1456 kernel_cap_t *effective,
1457 kernel_cap_t *inheritable,
1458 kernel_cap_t *permitted);
1459int security_capable(struct task_struct *tsk, int cap);
1460int security_acct(struct file *file);
1461int security_sysctl(struct ctl_table *table, int op);
1462int security_quotactl(int cmds, int type, int id, struct super_block *sb);
1463int security_quota_on(struct dentry *dentry);
1464int security_syslog(int type);
1465int security_settime(struct timespec *ts, struct timezone *tz);
1466int security_vm_enough_memory(long pages);
1467int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
1468int security_bprm_alloc(struct linux_binprm *bprm);
1469void security_bprm_free(struct linux_binprm *bprm);
1470void security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe);
1471void security_bprm_post_apply_creds(struct linux_binprm *bprm);
1472int security_bprm_set(struct linux_binprm *bprm);
1473int security_bprm_check(struct linux_binprm *bprm);
1474int security_bprm_secureexec(struct linux_binprm *bprm);
1475int security_sb_alloc(struct super_block *sb);
1476void security_sb_free(struct super_block *sb);
1477int security_sb_copy_data(struct file_system_type *type, void *orig, void *copy);
1478int security_sb_kern_mount(struct super_block *sb, void *data);
1479int security_sb_statfs(struct dentry *dentry);
1480int security_sb_mount(char *dev_name, struct nameidata *nd,
1481 char *type, unsigned long flags, void *data);
1482int security_sb_check_sb(struct vfsmount *mnt, struct nameidata *nd);
1483int security_sb_umount(struct vfsmount *mnt, int flags);
1484void security_sb_umount_close(struct vfsmount *mnt);
1485void security_sb_umount_busy(struct vfsmount *mnt);
1486void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data);
1487void security_sb_post_mountroot(void);
1488void security_sb_post_addmount(struct vfsmount *mnt, struct nameidata *mountpoint_nd);
1489int security_sb_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd);
1490void security_sb_post_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd);
1491int security_inode_alloc(struct inode *inode);
1492void security_inode_free(struct inode *inode);
1493int security_inode_init_security(struct inode *inode, struct inode *dir,
1494 char **name, void **value, size_t *len);
1495int security_inode_create(struct inode *dir, struct dentry *dentry, int mode);
1496int security_inode_link(struct dentry *old_dentry, struct inode *dir,
1497 struct dentry *new_dentry);
1498int security_inode_unlink(struct inode *dir, struct dentry *dentry);
1499int security_inode_symlink(struct inode *dir, struct dentry *dentry,
1500 const char *old_name);
1501int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode);
1502int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
1503int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
1504int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1505 struct inode *new_dir, struct dentry *new_dentry);
1506int security_inode_readlink(struct dentry *dentry);
1507int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
1508int security_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
1509int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1510int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1511void security_inode_delete(struct inode *inode);
1512int security_inode_setxattr(struct dentry *dentry, char *name,
1513 void *value, size_t size, int flags);
1514void security_inode_post_setxattr(struct dentry *dentry, char *name,
1515 void *value, size_t size, int flags);
1516int security_inode_getxattr(struct dentry *dentry, char *name);
1517int security_inode_listxattr(struct dentry *dentry);
1518int security_inode_removexattr(struct dentry *dentry, char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -07001519int security_inode_need_killpriv(struct dentry *dentry);
1520int security_inode_killpriv(struct dentry *dentry);
James Morris20510f22007-10-16 23:31:32 -07001521const char *security_inode_xattr_getsuffix(void);
1522int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
1523int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1524int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
1525int security_file_permission(struct file *file, int mask);
1526int security_file_alloc(struct file *file);
1527void security_file_free(struct file *file);
1528int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1529int security_file_mmap(struct file *file, unsigned long reqprot,
1530 unsigned long prot, unsigned long flags,
1531 unsigned long addr, unsigned long addr_only);
1532int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
1533 unsigned long prot);
1534int security_file_lock(struct file *file, unsigned int cmd);
1535int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
1536int security_file_set_fowner(struct file *file);
1537int security_file_send_sigiotask(struct task_struct *tsk,
1538 struct fown_struct *fown, int sig);
1539int security_file_receive(struct file *file);
1540int security_dentry_open(struct file *file);
1541int security_task_create(unsigned long clone_flags);
1542int security_task_alloc(struct task_struct *p);
1543void security_task_free(struct task_struct *p);
1544int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags);
1545int security_task_post_setuid(uid_t old_ruid, uid_t old_euid,
1546 uid_t old_suid, int flags);
1547int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags);
1548int security_task_setpgid(struct task_struct *p, pid_t pgid);
1549int security_task_getpgid(struct task_struct *p);
1550int security_task_getsid(struct task_struct *p);
1551void security_task_getsecid(struct task_struct *p, u32 *secid);
1552int security_task_setgroups(struct group_info *group_info);
1553int security_task_setnice(struct task_struct *p, int nice);
1554int security_task_setioprio(struct task_struct *p, int ioprio);
1555int security_task_getioprio(struct task_struct *p);
1556int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim);
1557int security_task_setscheduler(struct task_struct *p,
1558 int policy, struct sched_param *lp);
1559int security_task_getscheduler(struct task_struct *p);
1560int security_task_movememory(struct task_struct *p);
1561int security_task_kill(struct task_struct *p, struct siginfo *info,
1562 int sig, u32 secid);
1563int security_task_wait(struct task_struct *p);
1564int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
1565 unsigned long arg4, unsigned long arg5);
1566void security_task_reparent_to_init(struct task_struct *p);
1567void security_task_to_inode(struct task_struct *p, struct inode *inode);
1568int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
1569int security_msg_msg_alloc(struct msg_msg *msg);
1570void security_msg_msg_free(struct msg_msg *msg);
1571int security_msg_queue_alloc(struct msg_queue *msq);
1572void security_msg_queue_free(struct msg_queue *msq);
1573int security_msg_queue_associate(struct msg_queue *msq, int msqflg);
1574int security_msg_queue_msgctl(struct msg_queue *msq, int cmd);
1575int security_msg_queue_msgsnd(struct msg_queue *msq,
1576 struct msg_msg *msg, int msqflg);
1577int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
1578 struct task_struct *target, long type, int mode);
1579int security_shm_alloc(struct shmid_kernel *shp);
1580void security_shm_free(struct shmid_kernel *shp);
1581int security_shm_associate(struct shmid_kernel *shp, int shmflg);
1582int security_shm_shmctl(struct shmid_kernel *shp, int cmd);
1583int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg);
1584int security_sem_alloc(struct sem_array *sma);
1585void security_sem_free(struct sem_array *sma);
1586int security_sem_associate(struct sem_array *sma, int semflg);
1587int security_sem_semctl(struct sem_array *sma, int cmd);
1588int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
1589 unsigned nsops, int alter);
1590void security_d_instantiate (struct dentry *dentry, struct inode *inode);
1591int security_getprocattr(struct task_struct *p, char *name, char **value);
1592int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
1593int security_netlink_send(struct sock *sk, struct sk_buff *skb);
1594int security_netlink_recv(struct sk_buff *skb, int cap);
1595int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
1596void security_release_secctx(char *secdata, u32 seclen);
1597
Linus Torvalds1da177e2005-04-16 15:20:36 -07001598#else /* CONFIG_SECURITY */
1599
1600/*
1601 * This is the default capabilities functionality. Most of these functions
1602 * are just stubbed out, but a few must call the proper capable code.
1603 */
1604
1605static inline int security_init(void)
1606{
1607 return 0;
1608}
1609
1610static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
1611{
1612 return cap_ptrace (parent, child);
1613}
1614
1615static inline int security_capget (struct task_struct *target,
1616 kernel_cap_t *effective,
1617 kernel_cap_t *inheritable,
1618 kernel_cap_t *permitted)
1619{
1620 return cap_capget (target, effective, inheritable, permitted);
1621}
1622
1623static inline int security_capset_check (struct task_struct *target,
1624 kernel_cap_t *effective,
1625 kernel_cap_t *inheritable,
1626 kernel_cap_t *permitted)
1627{
1628 return cap_capset_check (target, effective, inheritable, permitted);
1629}
1630
1631static inline void security_capset_set (struct task_struct *target,
1632 kernel_cap_t *effective,
1633 kernel_cap_t *inheritable,
1634 kernel_cap_t *permitted)
1635{
1636 cap_capset_set (target, effective, inheritable, permitted);
1637}
1638
Chris Wright12b59892006-03-25 03:07:41 -08001639static inline int security_capable(struct task_struct *tsk, int cap)
1640{
1641 return cap_capable(tsk, cap);
1642}
1643
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644static inline int security_acct (struct file *file)
1645{
1646 return 0;
1647}
1648
1649static inline int security_sysctl(struct ctl_table *table, int op)
1650{
1651 return 0;
1652}
1653
1654static inline int security_quotactl (int cmds, int type, int id,
1655 struct super_block * sb)
1656{
1657 return 0;
1658}
1659
1660static inline int security_quota_on (struct dentry * dentry)
1661{
1662 return 0;
1663}
1664
1665static inline int security_syslog(int type)
1666{
1667 return cap_syslog(type);
1668}
1669
1670static inline int security_settime(struct timespec *ts, struct timezone *tz)
1671{
1672 return cap_settime(ts, tz);
1673}
1674
1675static inline int security_vm_enough_memory(long pages)
1676{
Alan Cox34b4e4a2007-08-22 14:01:28 -07001677 return cap_vm_enough_memory(current->mm, pages);
1678}
1679
1680static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
1681{
1682 return cap_vm_enough_memory(mm, pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683}
1684
1685static inline int security_bprm_alloc (struct linux_binprm *bprm)
1686{
1687 return 0;
1688}
1689
1690static inline void security_bprm_free (struct linux_binprm *bprm)
1691{ }
1692
1693static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1694{
1695 cap_bprm_apply_creds (bprm, unsafe);
1696}
1697
1698static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1699{
1700 return;
1701}
1702
1703static inline int security_bprm_set (struct linux_binprm *bprm)
1704{
1705 return cap_bprm_set_security (bprm);
1706}
1707
1708static inline int security_bprm_check (struct linux_binprm *bprm)
1709{
1710 return 0;
1711}
1712
1713static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1714{
1715 return cap_bprm_secureexec(bprm);
1716}
1717
1718static inline int security_sb_alloc (struct super_block *sb)
1719{
1720 return 0;
1721}
1722
1723static inline void security_sb_free (struct super_block *sb)
1724{ }
1725
1726static inline int security_sb_copy_data (struct file_system_type *type,
1727 void *orig, void *copy)
1728{
1729 return 0;
1730}
1731
1732static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1733{
1734 return 0;
1735}
1736
David Howells726c3342006-06-23 02:02:58 -07001737static inline int security_sb_statfs (struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738{
1739 return 0;
1740}
1741
1742static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1743 char *type, unsigned long flags,
1744 void *data)
1745{
1746 return 0;
1747}
1748
1749static inline int security_sb_check_sb (struct vfsmount *mnt,
1750 struct nameidata *nd)
1751{
1752 return 0;
1753}
1754
1755static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1756{
1757 return 0;
1758}
1759
1760static inline void security_sb_umount_close (struct vfsmount *mnt)
1761{ }
1762
1763static inline void security_sb_umount_busy (struct vfsmount *mnt)
1764{ }
1765
1766static inline void security_sb_post_remount (struct vfsmount *mnt,
1767 unsigned long flags, void *data)
1768{ }
1769
1770static inline void security_sb_post_mountroot (void)
1771{ }
1772
1773static inline void security_sb_post_addmount (struct vfsmount *mnt,
1774 struct nameidata *mountpoint_nd)
1775{ }
1776
1777static inline int security_sb_pivotroot (struct nameidata *old_nd,
1778 struct nameidata *new_nd)
1779{
1780 return 0;
1781}
1782
1783static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1784 struct nameidata *new_nd)
1785{ }
1786
1787static inline int security_inode_alloc (struct inode *inode)
1788{
1789 return 0;
1790}
1791
1792static inline void security_inode_free (struct inode *inode)
1793{ }
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001794
1795static inline int security_inode_init_security (struct inode *inode,
1796 struct inode *dir,
1797 char **name,
1798 void **value,
1799 size_t *len)
1800{
1801 return -EOPNOTSUPP;
1802}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001803
1804static inline int security_inode_create (struct inode *dir,
1805 struct dentry *dentry,
1806 int mode)
1807{
1808 return 0;
1809}
1810
Linus Torvalds1da177e2005-04-16 15:20:36 -07001811static inline int security_inode_link (struct dentry *old_dentry,
1812 struct inode *dir,
1813 struct dentry *new_dentry)
1814{
1815 return 0;
1816}
1817
Linus Torvalds1da177e2005-04-16 15:20:36 -07001818static inline int security_inode_unlink (struct inode *dir,
1819 struct dentry *dentry)
1820{
1821 return 0;
1822}
1823
1824static inline int security_inode_symlink (struct inode *dir,
1825 struct dentry *dentry,
1826 const char *old_name)
1827{
1828 return 0;
1829}
1830
Linus Torvalds1da177e2005-04-16 15:20:36 -07001831static inline int security_inode_mkdir (struct inode *dir,
1832 struct dentry *dentry,
1833 int mode)
1834{
1835 return 0;
1836}
1837
Linus Torvalds1da177e2005-04-16 15:20:36 -07001838static inline int security_inode_rmdir (struct inode *dir,
1839 struct dentry *dentry)
1840{
1841 return 0;
1842}
1843
1844static inline int security_inode_mknod (struct inode *dir,
1845 struct dentry *dentry,
1846 int mode, dev_t dev)
1847{
1848 return 0;
1849}
1850
Linus Torvalds1da177e2005-04-16 15:20:36 -07001851static inline int security_inode_rename (struct inode *old_dir,
1852 struct dentry *old_dentry,
1853 struct inode *new_dir,
1854 struct dentry *new_dentry)
1855{
1856 return 0;
1857}
1858
Linus Torvalds1da177e2005-04-16 15:20:36 -07001859static inline int security_inode_readlink (struct dentry *dentry)
1860{
1861 return 0;
1862}
1863
1864static inline int security_inode_follow_link (struct dentry *dentry,
1865 struct nameidata *nd)
1866{
1867 return 0;
1868}
1869
1870static inline int security_inode_permission (struct inode *inode, int mask,
1871 struct nameidata *nd)
1872{
1873 return 0;
1874}
1875
1876static inline int security_inode_setattr (struct dentry *dentry,
1877 struct iattr *attr)
1878{
1879 return 0;
1880}
1881
1882static inline int security_inode_getattr (struct vfsmount *mnt,
1883 struct dentry *dentry)
1884{
1885 return 0;
1886}
1887
1888static inline void security_inode_delete (struct inode *inode)
1889{ }
1890
1891static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1892 void *value, size_t size, int flags)
1893{
1894 return cap_inode_setxattr(dentry, name, value, size, flags);
1895}
1896
1897static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1898 void *value, size_t size, int flags)
1899{ }
1900
1901static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1902{
1903 return 0;
1904}
1905
1906static inline int security_inode_listxattr (struct dentry *dentry)
1907{
1908 return 0;
1909}
1910
1911static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1912{
1913 return cap_inode_removexattr(dentry, name);
1914}
1915
Serge E. Hallynb5376772007-10-16 23:31:36 -07001916static inline int security_inode_need_killpriv(struct dentry *dentry)
1917{
1918 return cap_inode_need_killpriv(dentry);
1919}
1920
1921static inline int security_inode_killpriv(struct dentry *dentry)
1922{
1923 return cap_inode_killpriv(dentry);
1924}
1925
Dustin Kirkland8c8570f2005-11-03 17:15:16 +00001926static inline const char *security_inode_xattr_getsuffix (void)
1927{
1928 return NULL ;
1929}
1930
Dustin Kirkland7306a0b2005-11-16 15:53:13 +00001931static 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 -07001932{
1933 return -EOPNOTSUPP;
1934}
1935
1936static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1937{
1938 return -EOPNOTSUPP;
1939}
1940
1941static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1942{
1943 return 0;
1944}
1945
1946static inline int security_file_permission (struct file *file, int mask)
1947{
1948 return 0;
1949}
1950
1951static inline int security_file_alloc (struct file *file)
1952{
1953 return 0;
1954}
1955
1956static inline void security_file_free (struct file *file)
1957{ }
1958
1959static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1960 unsigned long arg)
1961{
1962 return 0;
1963}
1964
1965static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1966 unsigned long prot,
Eric Parised032182007-06-28 15:55:21 -04001967 unsigned long flags,
1968 unsigned long addr,
1969 unsigned long addr_only)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001970{
1971 return 0;
1972}
1973
1974static inline int security_file_mprotect (struct vm_area_struct *vma,
1975 unsigned long reqprot,
1976 unsigned long prot)
1977{
1978 return 0;
1979}
1980
1981static inline int security_file_lock (struct file *file, unsigned int cmd)
1982{
1983 return 0;
1984}
1985
1986static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1987 unsigned long arg)
1988{
1989 return 0;
1990}
1991
1992static inline int security_file_set_fowner (struct file *file)
1993{
1994 return 0;
1995}
1996
1997static inline int security_file_send_sigiotask (struct task_struct *tsk,
1998 struct fown_struct *fown,
1999 int sig)
2000{
2001 return 0;
2002}
2003
2004static inline int security_file_receive (struct file *file)
2005{
2006 return 0;
2007}
2008
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +09002009static inline int security_dentry_open (struct file *file)
2010{
2011 return 0;
2012}
2013
Linus Torvalds1da177e2005-04-16 15:20:36 -07002014static inline int security_task_create (unsigned long clone_flags)
2015{
2016 return 0;
2017}
2018
2019static inline int security_task_alloc (struct task_struct *p)
2020{
2021 return 0;
2022}
2023
2024static inline void security_task_free (struct task_struct *p)
2025{ }
2026
2027static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2028 int flags)
2029{
2030 return 0;
2031}
2032
2033static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2034 uid_t old_suid, int flags)
2035{
2036 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2037}
2038
2039static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2040 int flags)
2041{
2042 return 0;
2043}
2044
2045static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2046{
2047 return 0;
2048}
2049
2050static inline int security_task_getpgid (struct task_struct *p)
2051{
2052 return 0;
2053}
2054
2055static inline int security_task_getsid (struct task_struct *p)
2056{
2057 return 0;
2058}
2059
David Quigleyf9008e42006-06-30 01:55:46 -07002060static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
2061{ }
2062
Linus Torvalds1da177e2005-04-16 15:20:36 -07002063static inline int security_task_setgroups (struct group_info *group_info)
2064{
2065 return 0;
2066}
2067
2068static inline int security_task_setnice (struct task_struct *p, int nice)
2069{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002070 return cap_task_setnice(p, nice);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002071}
2072
James Morris03e68062006-06-23 02:03:58 -07002073static inline int security_task_setioprio (struct task_struct *p, int ioprio)
2074{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002075 return cap_task_setioprio(p, ioprio);
James Morris03e68062006-06-23 02:03:58 -07002076}
2077
David Quigleya1836a42006-06-30 01:55:49 -07002078static inline int security_task_getioprio (struct task_struct *p)
2079{
2080 return 0;
2081}
2082
Linus Torvalds1da177e2005-04-16 15:20:36 -07002083static inline int security_task_setrlimit (unsigned int resource,
2084 struct rlimit *new_rlim)
2085{
2086 return 0;
2087}
2088
2089static inline int security_task_setscheduler (struct task_struct *p,
2090 int policy,
2091 struct sched_param *lp)
2092{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002093 return cap_task_setscheduler(p, policy, lp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002094}
2095
2096static inline int security_task_getscheduler (struct task_struct *p)
2097{
2098 return 0;
2099}
2100
David Quigley35601542006-06-23 02:04:01 -07002101static inline int security_task_movememory (struct task_struct *p)
2102{
2103 return 0;
2104}
2105
Linus Torvalds1da177e2005-04-16 15:20:36 -07002106static inline int security_task_kill (struct task_struct *p,
David Quigleyf9008e42006-06-30 01:55:46 -07002107 struct siginfo *info, int sig,
2108 u32 secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002109{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002110 return cap_task_kill(p, info, sig, secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002111}
2112
2113static inline int security_task_wait (struct task_struct *p)
2114{
2115 return 0;
2116}
2117
2118static inline int security_task_prctl (int option, unsigned long arg2,
2119 unsigned long arg3,
2120 unsigned long arg4,
2121 unsigned long arg5)
2122{
2123 return 0;
2124}
2125
2126static inline void security_task_reparent_to_init (struct task_struct *p)
2127{
2128 cap_task_reparent_to_init (p);
2129}
2130
2131static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2132{ }
2133
2134static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2135 short flag)
2136{
2137 return 0;
2138}
2139
2140static inline int security_msg_msg_alloc (struct msg_msg * msg)
2141{
2142 return 0;
2143}
2144
2145static inline void security_msg_msg_free (struct msg_msg * msg)
2146{ }
2147
2148static inline int security_msg_queue_alloc (struct msg_queue *msq)
2149{
2150 return 0;
2151}
2152
2153static inline void security_msg_queue_free (struct msg_queue *msq)
2154{ }
2155
2156static inline int security_msg_queue_associate (struct msg_queue * msq,
2157 int msqflg)
2158{
2159 return 0;
2160}
2161
2162static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2163{
2164 return 0;
2165}
2166
2167static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2168 struct msg_msg * msg, int msqflg)
2169{
2170 return 0;
2171}
2172
2173static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2174 struct msg_msg * msg,
2175 struct task_struct * target,
2176 long type, int mode)
2177{
2178 return 0;
2179}
2180
2181static inline int security_shm_alloc (struct shmid_kernel *shp)
2182{
2183 return 0;
2184}
2185
2186static inline void security_shm_free (struct shmid_kernel *shp)
2187{ }
2188
2189static inline int security_shm_associate (struct shmid_kernel * shp,
2190 int shmflg)
2191{
2192 return 0;
2193}
2194
2195static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2196{
2197 return 0;
2198}
2199
2200static inline int security_shm_shmat (struct shmid_kernel * shp,
2201 char __user *shmaddr, int shmflg)
2202{
2203 return 0;
2204}
2205
2206static inline int security_sem_alloc (struct sem_array *sma)
2207{
2208 return 0;
2209}
2210
2211static inline void security_sem_free (struct sem_array *sma)
2212{ }
2213
2214static inline int security_sem_associate (struct sem_array * sma, int semflg)
2215{
2216 return 0;
2217}
2218
2219static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2220{
2221 return 0;
2222}
2223
2224static inline int security_sem_semop (struct sem_array * sma,
2225 struct sembuf * sops, unsigned nsops,
2226 int alter)
2227{
2228 return 0;
2229}
2230
2231static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2232{ }
2233
Al Viro04ff9702007-03-12 16:17:58 +00002234static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002235{
2236 return -EINVAL;
2237}
2238
2239static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2240{
2241 return -EINVAL;
2242}
2243
2244static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2245{
2246 return cap_netlink_send (sk, skb);
2247}
2248
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002249static inline int security_netlink_recv (struct sk_buff *skb, int cap)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002250{
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002251 return cap_netlink_recv (skb, cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252}
2253
Randy Dunlaped5a9272006-02-01 03:05:00 -08002254static inline struct dentry *securityfs_create_dir(const char *name,
2255 struct dentry *parent)
2256{
2257 return ERR_PTR(-ENODEV);
2258}
2259
2260static inline struct dentry *securityfs_create_file(const char *name,
2261 mode_t mode,
2262 struct dentry *parent,
2263 void *data,
2264 struct file_operations *fops)
2265{
2266 return ERR_PTR(-ENODEV);
2267}
2268
2269static inline void securityfs_remove(struct dentry *dentry)
2270{
2271}
2272
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002273static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2274{
2275 return -EOPNOTSUPP;
2276}
2277
2278static inline void security_release_secctx(char *secdata, u32 seclen)
2279{
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002280}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281#endif /* CONFIG_SECURITY */
2282
2283#ifdef CONFIG_SECURITY_NETWORK
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284
James Morris20510f22007-10-16 23:31:32 -07002285int security_unix_stream_connect(struct socket *sock, struct socket *other,
2286 struct sock *newsk);
2287int security_unix_may_send(struct socket *sock, struct socket *other);
2288int security_socket_create(int family, int type, int protocol, int kern);
2289int security_socket_post_create(struct socket *sock, int family,
2290 int type, int protocol, int kern);
2291int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
2292int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
2293int security_socket_listen(struct socket *sock, int backlog);
2294int security_socket_accept(struct socket *sock, struct socket *newsock);
2295void security_socket_post_accept(struct socket *sock, struct socket *newsock);
2296int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
2297int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
2298 int size, int flags);
2299int security_socket_getsockname(struct socket *sock);
2300int security_socket_getpeername(struct socket *sock);
2301int security_socket_getsockopt(struct socket *sock, int level, int optname);
2302int security_socket_setsockopt(struct socket *sock, int level, int optname);
2303int security_socket_shutdown(struct socket *sock, int how);
2304int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
2305int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2306 int __user *optlen, unsigned len);
2307int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
2308int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
2309void security_sk_free(struct sock *sk);
2310void security_sk_clone(const struct sock *sk, struct sock *newsk);
2311void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
2312void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
2313void security_sock_graft(struct sock*sk, struct socket *parent);
2314int security_inet_conn_request(struct sock *sk,
2315 struct sk_buff *skb, struct request_sock *req);
2316void security_inet_csk_clone(struct sock *newsk,
2317 const struct request_sock *req);
2318void security_inet_conn_established(struct sock *sk,
2319 struct sk_buff *skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002320
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321#else /* CONFIG_SECURITY_NETWORK */
2322static inline int security_unix_stream_connect(struct socket * sock,
Venkat Yekkirala6b877692006-11-08 17:04:09 -06002323 struct socket * other,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002324 struct sock * newsk)
2325{
2326 return 0;
2327}
2328
2329static inline int security_unix_may_send(struct socket * sock,
2330 struct socket * other)
2331{
2332 return 0;
2333}
2334
2335static inline int security_socket_create (int family, int type,
2336 int protocol, int kern)
2337{
2338 return 0;
2339}
2340
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07002341static inline int security_socket_post_create(struct socket * sock,
2342 int family,
2343 int type,
2344 int protocol, int kern)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002345{
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07002346 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347}
2348
2349static inline int security_socket_bind(struct socket * sock,
2350 struct sockaddr * address,
2351 int addrlen)
2352{
2353 return 0;
2354}
2355
2356static inline int security_socket_connect(struct socket * sock,
2357 struct sockaddr * address,
2358 int addrlen)
2359{
2360 return 0;
2361}
2362
2363static inline int security_socket_listen(struct socket * sock, int backlog)
2364{
2365 return 0;
2366}
2367
2368static inline int security_socket_accept(struct socket * sock,
2369 struct socket * newsock)
2370{
2371 return 0;
2372}
2373
2374static inline void security_socket_post_accept(struct socket * sock,
2375 struct socket * newsock)
2376{
2377}
2378
2379static inline int security_socket_sendmsg(struct socket * sock,
2380 struct msghdr * msg, int size)
2381{
2382 return 0;
2383}
2384
2385static inline int security_socket_recvmsg(struct socket * sock,
2386 struct msghdr * msg, int size,
2387 int flags)
2388{
2389 return 0;
2390}
2391
2392static inline int security_socket_getsockname(struct socket * sock)
2393{
2394 return 0;
2395}
2396
2397static inline int security_socket_getpeername(struct socket * sock)
2398{
2399 return 0;
2400}
2401
2402static inline int security_socket_getsockopt(struct socket * sock,
2403 int level, int optname)
2404{
2405 return 0;
2406}
2407
2408static inline int security_socket_setsockopt(struct socket * sock,
2409 int level, int optname)
2410{
2411 return 0;
2412}
2413
2414static inline int security_socket_shutdown(struct socket * sock, int how)
2415{
2416 return 0;
2417}
2418static inline int security_sock_rcv_skb (struct sock * sk,
2419 struct sk_buff * skb)
2420{
2421 return 0;
2422}
2423
Catherine Zhang2c7946a2006-03-20 22:41:23 -08002424static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2425 int __user *optlen, unsigned len)
2426{
2427 return -ENOPROTOOPT;
2428}
2429
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002430static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431{
2432 return -ENOPROTOOPT;
2433}
2434
Al Virodd0fc662005-10-07 07:46:04 +01002435static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436{
2437 return 0;
2438}
2439
2440static inline void security_sk_free(struct sock *sk)
2441{
2442}
Trent Jaegerdf718372005-12-13 23:12:27 -08002443
Venkat Yekkirala892c1412006-08-04 23:08:56 -07002444static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2445{
2446}
2447
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002448static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
Trent Jaegerdf718372005-12-13 23:12:27 -08002449{
Trent Jaegerdf718372005-12-13 23:12:27 -08002450}
Venkat Yekkirala4237c752006-07-24 23:32:50 -07002451
2452static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2453{
2454}
2455
2456static inline void security_sock_graft(struct sock* sk, struct socket *parent)
2457{
2458}
2459
2460static inline int security_inet_conn_request(struct sock *sk,
2461 struct sk_buff *skb, struct request_sock *req)
2462{
2463 return 0;
2464}
2465
2466static inline void security_inet_csk_clone(struct sock *newsk,
2467 const struct request_sock *req)
2468{
2469}
Venkat Yekkirala6b877692006-11-08 17:04:09 -06002470
2471static inline void security_inet_conn_established(struct sock *sk,
2472 struct sk_buff *skb)
2473{
2474}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475#endif /* CONFIG_SECURITY_NETWORK */
2476
Trent Jaegerdf718372005-12-13 23:12:27 -08002477#ifdef CONFIG_SECURITY_NETWORK_XFRM
Venkat Yekkiralacb969f02006-07-24 23:32:20 -07002478
James Morris20510f22007-10-16 23:31:32 -07002479int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
2480int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new);
2481void security_xfrm_policy_free(struct xfrm_policy *xp);
2482int security_xfrm_policy_delete(struct xfrm_policy *xp);
2483int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
2484int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2485 struct xfrm_sec_ctx *polsec, u32 secid);
2486int security_xfrm_state_delete(struct xfrm_state *x);
2487void security_xfrm_state_free(struct xfrm_state *x);
2488int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
2489int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2490 struct xfrm_policy *xp, struct flowi *fl);
2491int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
2492void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
Trent Jaegerdf718372005-12-13 23:12:27 -08002493
Trent Jaegerdf718372005-12-13 23:12:27 -08002494#else /* CONFIG_SECURITY_NETWORK_XFRM */
James Morris20510f22007-10-16 23:31:32 -07002495
Trent Jaegerdf718372005-12-13 23:12:27 -08002496static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
2497{
2498 return 0;
2499}
2500
2501static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
2502{
2503 return 0;
2504}
2505
2506static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
2507{
2508}
2509
Catherine Zhangc8c05a82006-06-08 23:39:49 -07002510static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
2511{
2512 return 0;
2513}
2514
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002515static inline int security_xfrm_state_alloc(struct xfrm_state *x,
2516 struct xfrm_user_sec_ctx *sec_ctx)
2517{
2518 return 0;
2519}
2520
2521static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2522 struct xfrm_sec_ctx *polsec, u32 secid)
Trent Jaegerdf718372005-12-13 23:12:27 -08002523{
2524 return 0;
2525}
2526
2527static inline void security_xfrm_state_free(struct xfrm_state *x)
2528{
2529}
2530
David S. Miller6f68dc32006-06-08 23:58:52 -07002531static inline int security_xfrm_state_delete(struct xfrm_state *x)
Catherine Zhangc8c05a82006-06-08 23:39:49 -07002532{
2533 return 0;
2534}
2535
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002536static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
Trent Jaegerdf718372005-12-13 23:12:27 -08002537{
2538 return 0;
2539}
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002540
2541static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2542 struct xfrm_policy *xp, struct flowi *fl)
2543{
2544 return 1;
2545}
2546
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002547static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002548{
2549 return 0;
2550}
2551
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002552static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
2553{
2554}
2555
Trent Jaegerdf718372005-12-13 23:12:27 -08002556#endif /* CONFIG_SECURITY_NETWORK_XFRM */
2557
David Howells29db9192005-10-30 15:02:44 -08002558#ifdef CONFIG_KEYS
2559#ifdef CONFIG_SECURITY
David Howells29db9192005-10-30 15:02:44 -08002560
James Morris20510f22007-10-16 23:31:32 -07002561int security_key_alloc(struct key *key, struct task_struct *tsk, unsigned long flags);
2562void security_key_free(struct key *key);
2563int security_key_permission(key_ref_t key_ref,
2564 struct task_struct *context, key_perm_t perm);
David Howells29db9192005-10-30 15:02:44 -08002565
2566#else
2567
Michael LeMayd7200242006-06-22 14:47:17 -07002568static inline int security_key_alloc(struct key *key,
David Howells7e047ef2006-06-26 00:24:50 -07002569 struct task_struct *tsk,
2570 unsigned long flags)
David Howells29db9192005-10-30 15:02:44 -08002571{
2572 return 0;
2573}
2574
2575static inline void security_key_free(struct key *key)
2576{
2577}
2578
2579static inline int security_key_permission(key_ref_t key_ref,
2580 struct task_struct *context,
2581 key_perm_t perm)
2582{
2583 return 0;
2584}
2585
2586#endif
2587#endif /* CONFIG_KEYS */
2588
Linus Torvalds1da177e2005-04-16 15:20:36 -07002589#endif /* ! __LINUX_SECURITY_H */
2590