blob: fe52cdeab0a67ba5cd1220383b9bd0872efd78e1 [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
Eric Parisc9180a52007-11-30 13:00:35 -050037/* only a char in selinux superblock security struct flags */
38#define FSCONTEXT_MNT 0x01
39#define CONTEXT_MNT 0x02
40#define ROOTCONTEXT_MNT 0x04
41#define DEFCONTEXT_MNT 0x08
42
Andrew Morgan72c2d582007-10-18 03:05:59 -070043extern unsigned securebits;
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045struct ctl_table;
46
47/*
48 * These functions are in security/capability.c and are used
49 * as the default capabilities functions
50 */
51extern int cap_capable (struct task_struct *tsk, int cap);
52extern int cap_settime (struct timespec *ts, struct timezone *tz);
53extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
54extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
55extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
56extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
57extern int cap_bprm_set_security (struct linux_binprm *bprm);
58extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
59extern int cap_bprm_secureexec(struct linux_binprm *bprm);
60extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
61extern int cap_inode_removexattr(struct dentry *dentry, char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -070062extern int cap_inode_need_killpriv(struct dentry *dentry);
63extern int cap_inode_killpriv(struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
65extern void cap_task_reparent_to_init (struct task_struct *p);
Serge E. Hallynb5376772007-10-16 23:31:36 -070066extern int cap_task_kill(struct task_struct *p, struct siginfo *info, int sig, u32 secid);
67extern int cap_task_setscheduler (struct task_struct *p, int policy, struct sched_param *lp);
68extern int cap_task_setioprio (struct task_struct *p, int ioprio);
69extern int cap_task_setnice (struct task_struct *p, int nice);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070extern int cap_syslog (int type);
James Morris20510f22007-10-16 23:31:32 -070071extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73struct msghdr;
74struct sk_buff;
75struct sock;
76struct sockaddr;
77struct socket;
Trent Jaegerdf718372005-12-13 23:12:27 -080078struct flowi;
79struct dst_entry;
80struct xfrm_selector;
81struct xfrm_policy;
82struct xfrm_state;
83struct xfrm_user_sec_ctx;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
85extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
Darrel Goeddelc7bdb542006-06-27 13:26:11 -070086extern int cap_netlink_recv(struct sk_buff *skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Eric Parised032182007-06-28 15:55:21 -040088extern unsigned long mmap_min_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089/*
90 * Values used in the task_security_ops calls
91 */
92/* setuid or setgid, id0 == uid or gid */
93#define LSM_SETID_ID 1
94
95/* setreuid or setregid, id0 == real, id1 == eff */
96#define LSM_SETID_RE 2
97
98/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
99#define LSM_SETID_RES 4
100
101/* setfsuid or setfsgid, id0 == fsuid or fsgid */
102#define LSM_SETID_FS 8
103
104/* forward declares to avoid warnings */
105struct nfsctl_arg;
106struct sched_param;
107struct swap_info_struct;
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700108struct request_sock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
110/* bprm_apply_creds unsafe reasons */
111#define LSM_UNSAFE_SHARE 1
112#define LSM_UNSAFE_PTRACE 2
113#define LSM_UNSAFE_PTRACE_CAP 4
114
115#ifdef CONFIG_SECURITY
116
117/**
118 * struct security_operations - main security structure
119 *
120 * Security hooks for program execution operations.
121 *
122 * @bprm_alloc_security:
123 * Allocate and attach a security structure to the @bprm->security field.
124 * The security field is initialized to NULL when the bprm structure is
125 * allocated.
126 * @bprm contains the linux_binprm structure to be modified.
127 * Return 0 if operation was successful.
128 * @bprm_free_security:
129 * @bprm contains the linux_binprm structure to be modified.
130 * Deallocate and clear the @bprm->security field.
131 * @bprm_apply_creds:
132 * Compute and set the security attributes of a process being transformed
133 * by an execve operation based on the old attributes (current->security)
134 * and the information saved in @bprm->security by the set_security hook.
135 * Since this hook function (and its caller) are void, this hook can not
136 * return an error. However, it can leave the security attributes of the
137 * process unchanged if an access failure occurs at this point.
138 * bprm_apply_creds is called under task_lock. @unsafe indicates various
139 * reasons why it may be unsafe to change security state.
140 * @bprm contains the linux_binprm structure.
141 * @bprm_post_apply_creds:
142 * Runs after bprm_apply_creds with the task_lock dropped, so that
143 * functions which cannot be called safely under the task_lock can
144 * be used. This hook is a good place to perform state changes on
145 * the process such as closing open file descriptors to which access
146 * is no longer granted if the attributes were changed.
147 * Note that a security module might need to save state between
148 * bprm_apply_creds and bprm_post_apply_creds to store the decision
149 * on whether the process may proceed.
150 * @bprm contains the linux_binprm structure.
151 * @bprm_set_security:
152 * Save security information in the bprm->security field, typically based
153 * on information about the bprm->file, for later use by the apply_creds
154 * hook. This hook may also optionally check permissions (e.g. for
155 * transitions between security domains).
156 * This hook may be called multiple times during a single execve, e.g. for
157 * interpreters. The hook can tell whether it has already been called by
158 * checking to see if @bprm->security is non-NULL. If so, then the hook
159 * may decide either to retain the security information saved earlier or
160 * to replace it.
161 * @bprm contains the linux_binprm structure.
162 * Return 0 if the hook is successful and permission is granted.
163 * @bprm_check_security:
164 * This hook mediates the point when a search for a binary handler will
165 * begin. It allows a check the @bprm->security value which is set in
166 * the preceding set_security call. The primary difference from
167 * set_security is that the argv list and envp list are reliably
168 * available in @bprm. This hook may be called multiple times
169 * during a single execve; and in each pass set_security is called
170 * first.
171 * @bprm contains the linux_binprm structure.
172 * Return 0 if the hook is successful and permission is granted.
173 * @bprm_secureexec:
174 * Return a boolean value (0 or 1) indicating whether a "secure exec"
175 * is required. The flag is passed in the auxiliary table
176 * on the initial stack to the ELF interpreter to indicate whether libc
177 * should enable secure mode.
178 * @bprm contains the linux_binprm structure.
179 *
180 * Security hooks for filesystem operations.
181 *
182 * @sb_alloc_security:
183 * Allocate and attach a security structure to the sb->s_security field.
184 * The s_security field is initialized to NULL when the structure is
185 * allocated.
186 * @sb contains the super_block structure to be modified.
187 * Return 0 if operation was successful.
188 * @sb_free_security:
189 * Deallocate and clear the sb->s_security field.
190 * @sb contains the super_block structure to be modified.
191 * @sb_statfs:
David Howells726c3342006-06-23 02:02:58 -0700192 * Check permission before obtaining filesystem statistics for the @mnt
193 * mountpoint.
194 * @dentry is a handle on the superblock for the filesystem.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 * Return 0 if permission is granted.
196 * @sb_mount:
197 * Check permission before an object specified by @dev_name is mounted on
198 * the mount point named by @nd. For an ordinary mount, @dev_name
199 * identifies a device if the file system type requires a device. For a
200 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
201 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
202 * pathname of the object being mounted.
203 * @dev_name contains the name for object being mounted.
204 * @nd contains the nameidata structure for mount point object.
205 * @type contains the filesystem type.
206 * @flags contains the mount flags.
207 * @data contains the filesystem-specific data.
208 * Return 0 if permission is granted.
209 * @sb_copy_data:
210 * Allow mount option data to be copied prior to parsing by the filesystem,
211 * so that the security module can extract security-specific mount
212 * options cleanly (a filesystem may modify the data e.g. with strsep()).
213 * This also allows the original mount data to be stripped of security-
214 * specific options to avoid having to make filesystems aware of them.
215 * @type the type of filesystem being mounted.
216 * @orig the original mount data copied from userspace.
217 * @copy copied data which will be passed to the security module.
218 * Returns 0 if the copy was successful.
219 * @sb_check_sb:
220 * Check permission before the device with superblock @mnt->sb is mounted
221 * on the mount point named by @nd.
222 * @mnt contains the vfsmount for device being mounted.
223 * @nd contains the nameidata object for the mount point.
224 * Return 0 if permission is granted.
225 * @sb_umount:
226 * Check permission before the @mnt file system is unmounted.
227 * @mnt contains the mounted file system.
228 * @flags contains the unmount flags, e.g. MNT_FORCE.
229 * Return 0 if permission is granted.
230 * @sb_umount_close:
231 * Close any files in the @mnt mounted filesystem that are held open by
232 * the security module. This hook is called during an umount operation
233 * prior to checking whether the filesystem is still busy.
234 * @mnt contains the mounted filesystem.
235 * @sb_umount_busy:
236 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
237 * any files that were closed by umount_close. This hook is called during
238 * an umount operation if the umount fails after a call to the
239 * umount_close hook.
240 * @mnt contains the mounted filesystem.
241 * @sb_post_remount:
242 * Update the security module's state when a filesystem is remounted.
243 * This hook is only called if the remount was successful.
244 * @mnt contains the mounted file system.
245 * @flags contains the new filesystem flags.
246 * @data contains the filesystem-specific data.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 * @sb_post_addmount:
248 * Update the security module's state when a filesystem is mounted.
249 * This hook is called any time a mount is successfully grafetd to
250 * the tree.
251 * @mnt contains the mounted filesystem.
252 * @mountpoint_nd contains the nameidata structure for the mount point.
253 * @sb_pivotroot:
254 * Check permission before pivoting the root filesystem.
255 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
256 * @new_nd contains the nameidata structure for the new root (new_root).
257 * Return 0 if permission is granted.
258 * @sb_post_pivotroot:
259 * Update module state after a successful pivot.
260 * @old_nd contains the nameidata structure for the old root.
261 * @new_nd contains the nameidata structure for the new root.
Eric Parisc9180a52007-11-30 13:00:35 -0500262 * @sb_get_mnt_opts:
263 * Get the security relevant mount options used for a superblock
264 * @sb the superblock to get security mount options from
265 * @mount_options array for pointers to mount options
266 * @mount_flags array of ints specifying what each mount options is
267 * @num_opts number of options in the arrays
268 * @sb_set_mnt_opts:
269 * Set the security relevant mount options used for a superblock
270 * @sb the superblock to set security mount options for
271 * @mount_options array for pointers to mount options
272 * @mount_flags array of ints specifying what each mount options is
273 * @num_opts number of options in the arrays
274 * @sb_clone_mnt_opts:
275 * Copy all security options from a given superblock to another
276 * @oldsb old superblock which contain information to clone
277 * @newsb new superblock which needs filled in
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 *
279 * Security hooks for inode operations.
280 *
281 * @inode_alloc_security:
282 * Allocate and attach a security structure to @inode->i_security. The
283 * i_security field is initialized to NULL when the inode structure is
284 * allocated.
285 * @inode contains the inode structure.
286 * Return 0 if operation was successful.
287 * @inode_free_security:
288 * @inode contains the inode structure.
289 * Deallocate the inode security structure and set @inode->i_security to
290 * NULL.
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700291 * @inode_init_security:
292 * Obtain the security attribute name suffix and value to set on a newly
293 * created inode and set up the incore security field for the new inode.
294 * This hook is called by the fs code as part of the inode creation
295 * transaction and provides for atomic labeling of the inode, unlike
296 * the post_create/mkdir/... hooks called by the VFS. The hook function
297 * is expected to allocate the name and value via kmalloc, with the caller
298 * being responsible for calling kfree after using them.
299 * If the security module does not use security attributes or does
300 * not wish to put a security attribute on this particular inode,
301 * then it should return -EOPNOTSUPP to skip this processing.
302 * @inode contains the inode structure of the newly created inode.
303 * @dir contains the inode structure of the parent directory.
304 * @name will be set to the allocated name suffix (e.g. selinux).
305 * @value will be set to the allocated attribute value.
306 * @len will be set to the length of the value.
307 * Returns 0 if @name and @value have been successfully set,
308 * -EOPNOTSUPP if no security attribute is needed, or
309 * -ENOMEM on memory allocation failure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 * @inode_create:
311 * Check permission to create a regular file.
312 * @dir contains inode structure of the parent of the new file.
313 * @dentry contains the dentry structure for the file to be created.
314 * @mode contains the file mode of the file to be created.
315 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 * @inode_link:
317 * Check permission before creating a new hard link to a file.
318 * @old_dentry contains the dentry structure for an existing link to the file.
319 * @dir contains the inode structure of the parent directory of the new link.
320 * @new_dentry contains the dentry structure for the new link.
321 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 * @inode_unlink:
323 * Check the permission to remove a hard link to a file.
324 * @dir contains the inode structure of parent directory of the file.
325 * @dentry contains the dentry structure for file to be unlinked.
326 * Return 0 if permission is granted.
327 * @inode_symlink:
328 * Check the permission to create a symbolic link to a file.
329 * @dir contains the inode structure of parent directory of the symbolic link.
330 * @dentry contains the dentry structure of the symbolic link.
331 * @old_name contains the pathname of file.
332 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 * @inode_mkdir:
334 * Check permissions to create a new directory in the existing directory
335 * associated with inode strcture @dir.
336 * @dir containst the inode structure of parent of the directory to be created.
337 * @dentry contains the dentry structure of new directory.
338 * @mode contains the mode of new directory.
339 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 * @inode_rmdir:
341 * Check the permission to remove a directory.
342 * @dir contains the inode structure of parent of the directory to be removed.
343 * @dentry contains the dentry structure of directory to be removed.
344 * Return 0 if permission is granted.
345 * @inode_mknod:
346 * Check permissions when creating a special file (or a socket or a fifo
347 * file created via the mknod system call). Note that if mknod operation
348 * is being done for a regular file, then the create hook will be called
349 * and not this hook.
350 * @dir contains the inode structure of parent of the new file.
351 * @dentry contains the dentry structure of the new file.
352 * @mode contains the mode of the new file.
Michael Opdenacker59c51592007-05-09 08:57:56 +0200353 * @dev contains the device number.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 * @inode_rename:
356 * Check for permission to rename a file or directory.
357 * @old_dir contains the inode structure for parent of the old link.
358 * @old_dentry contains the dentry structure of the old link.
359 * @new_dir contains the inode structure for parent of the new link.
360 * @new_dentry contains the dentry structure of the new link.
361 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 * @inode_readlink:
363 * Check the permission to read the symbolic link.
364 * @dentry contains the dentry structure for the file link.
365 * Return 0 if permission is granted.
366 * @inode_follow_link:
367 * Check permission to follow a symbolic link when looking up a pathname.
368 * @dentry contains the dentry structure for the link.
369 * @nd contains the nameidata structure for the parent directory.
370 * Return 0 if permission is granted.
371 * @inode_permission:
372 * Check permission before accessing an inode. This hook is called by the
373 * existing Linux permission function, so a security module can use it to
374 * provide additional checking for existing Linux permission checks.
375 * Notice that this hook is called when a file is opened (as well as many
376 * other operations), whereas the file_security_ops permission hook is
377 * called when the actual read/write operations are performed.
378 * @inode contains the inode structure to check.
379 * @mask contains the permission mask.
380 * @nd contains the nameidata (may be NULL).
381 * Return 0 if permission is granted.
382 * @inode_setattr:
383 * Check permission before setting file attributes. Note that the kernel
384 * call to notify_change is performed from several locations, whenever
385 * file attributes change (such as when a file is truncated, chown/chmod
386 * operations, transferring disk quotas, etc).
387 * @dentry contains the dentry structure for the file.
388 * @attr is the iattr structure containing the new file attributes.
389 * Return 0 if permission is granted.
390 * @inode_getattr:
391 * Check permission before obtaining file attributes.
392 * @mnt is the vfsmount where the dentry was looked up
393 * @dentry contains the dentry structure for the file.
394 * Return 0 if permission is granted.
395 * @inode_delete:
396 * @inode contains the inode structure for deleted inode.
397 * This hook is called when a deleted inode is released (i.e. an inode
398 * with no hard links has its use count drop to zero). A security module
399 * can use this hook to release any persistent label associated with the
400 * inode.
401 * @inode_setxattr:
402 * Check permission before setting the extended attributes
403 * @value identified by @name for @dentry.
404 * Return 0 if permission is granted.
405 * @inode_post_setxattr:
406 * Update inode security field after successful setxattr operation.
407 * @value identified by @name for @dentry.
408 * @inode_getxattr:
409 * Check permission before obtaining the extended attributes
410 * identified by @name for @dentry.
411 * Return 0 if permission is granted.
412 * @inode_listxattr:
413 * Check permission before obtaining the list of extended attribute
414 * names for @dentry.
415 * Return 0 if permission is granted.
416 * @inode_removexattr:
417 * Check permission before removing the extended attribute
418 * identified by @name for @dentry.
419 * Return 0 if permission is granted.
420 * @inode_getsecurity:
David P. Quigley42492592008-02-04 22:29:39 -0800421 * Retrieve a copy of the extended attribute representation of the
422 * security label associated with @name for @inode via @buffer. Note that
423 * @name is the remainder of the attribute name after the security prefix
424 * has been removed. @alloc is used to specify of the call should return a
425 * value via the buffer or just the value length Return size of buffer on
426 * success.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 * @inode_setsecurity:
428 * Set the security label associated with @name for @inode from the
429 * extended attribute value @value. @size indicates the size of the
430 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
431 * Note that @name is the remainder of the attribute name after the
432 * security. prefix has been removed.
433 * Return 0 on success.
434 * @inode_listsecurity:
435 * Copy the extended attribute names for the security labels
436 * associated with @inode into @buffer. The maximum size of @buffer
437 * is specified by @buffer_size. @buffer may be NULL to request
438 * the size of the buffer required.
439 * Returns number of bytes used/required on success.
Serge E. Hallynb5376772007-10-16 23:31:36 -0700440 * @inode_need_killpriv:
441 * Called when an inode has been changed.
442 * @dentry is the dentry being changed.
443 * Return <0 on error to abort the inode change operation.
444 * Return 0 if inode_killpriv does not need to be called.
445 * Return >0 if inode_killpriv does need to be called.
446 * @inode_killpriv:
447 * The setuid bit is being removed. Remove similar security labels.
448 * Called with the dentry->d_inode->i_mutex held.
449 * @dentry is the dentry being changed.
450 * Return 0 on success. If error is returned, then the operation
451 * causing setuid bit removal is failed.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 *
453 * Security hooks for file operations
454 *
455 * @file_permission:
456 * Check file permissions before accessing an open file. This hook is
457 * called by various operations that read or write files. A security
458 * module can use this hook to perform additional checking on these
459 * operations, e.g. to revalidate permissions on use to support privilege
460 * bracketing or policy changes. Notice that this hook is used when the
461 * actual read/write operations are performed, whereas the
462 * inode_security_ops hook is called when a file is opened (as well as
463 * many other operations).
464 * Caveat: Although this hook can be used to revalidate permissions for
465 * various system call operations that read or write files, it does not
466 * address the revalidation of permissions for memory-mapped files.
467 * Security modules must handle this separately if they need such
468 * revalidation.
469 * @file contains the file structure being accessed.
470 * @mask contains the requested permissions.
471 * Return 0 if permission is granted.
472 * @file_alloc_security:
473 * Allocate and attach a security structure to the file->f_security field.
474 * The security field is initialized to NULL when the structure is first
475 * created.
476 * @file contains the file structure to secure.
477 * Return 0 if the hook is successful and permission is granted.
478 * @file_free_security:
479 * Deallocate and free any security structures stored in file->f_security.
480 * @file contains the file structure being modified.
481 * @file_ioctl:
482 * @file contains the file structure.
483 * @cmd contains the operation to perform.
484 * @arg contains the operational arguments.
485 * Check permission for an ioctl operation on @file. Note that @arg can
486 * sometimes represents a user space pointer; in other cases, it may be a
487 * simple integer value. When @arg represents a user space pointer, it
488 * should never be used by the security module.
489 * Return 0 if permission is granted.
490 * @file_mmap :
491 * Check permissions for a mmap operation. The @file may be NULL, e.g.
492 * if mapping anonymous memory.
493 * @file contains the file structure for file to map (may be NULL).
494 * @reqprot contains the protection requested by the application.
495 * @prot contains the protection that will be applied by the kernel.
496 * @flags contains the operational flags.
497 * Return 0 if permission is granted.
498 * @file_mprotect:
499 * Check permissions before changing memory access permissions.
500 * @vma contains the memory region to modify.
501 * @reqprot contains the protection requested by the application.
502 * @prot contains the protection that will be applied by the kernel.
503 * Return 0 if permission is granted.
504 * @file_lock:
505 * Check permission before performing file locking operations.
506 * Note: this hook mediates both flock and fcntl style locks.
507 * @file contains the file structure.
508 * @cmd contains the posix-translated lock operation to perform
509 * (e.g. F_RDLCK, F_WRLCK).
510 * Return 0 if permission is granted.
511 * @file_fcntl:
512 * Check permission before allowing the file operation specified by @cmd
513 * from being performed on the file @file. Note that @arg can sometimes
514 * represents a user space pointer; in other cases, it may be a simple
515 * integer value. When @arg represents a user space pointer, it should
516 * never be used by the security module.
517 * @file contains the file structure.
518 * @cmd contains the operation to be performed.
519 * @arg contains the operational arguments.
520 * Return 0 if permission is granted.
521 * @file_set_fowner:
522 * Save owner security information (typically from current->security) in
523 * file->f_security for later use by the send_sigiotask hook.
524 * @file contains the file structure to update.
525 * Return 0 on success.
526 * @file_send_sigiotask:
527 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
528 * process @tsk. Note that this hook is sometimes called from interrupt.
529 * Note that the fown_struct, @fown, is never outside the context of a
530 * struct file, so the file structure (and associated security information)
531 * can always be obtained:
Robert P. J. Dayb385a142007-02-10 01:46:25 -0800532 * container_of(fown, struct file, f_owner)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 * @tsk contains the structure of task receiving signal.
534 * @fown contains the file owner information.
535 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
536 * Return 0 if permission is granted.
537 * @file_receive:
538 * This hook allows security modules to control the ability of a process
539 * to receive an open file descriptor via socket IPC.
540 * @file contains the file structure being received.
541 * Return 0 if permission is granted.
542 *
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +0900543 * Security hook for dentry
544 *
545 * @dentry_open
546 * Save open-time permission checking state for later use upon
547 * file_permission, and recheck access if anything has changed
548 * since inode_permission.
549 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 * Security hooks for task operations.
551 *
552 * @task_create:
553 * Check permission before creating a child process. See the clone(2)
554 * manual page for definitions of the @clone_flags.
555 * @clone_flags contains the flags indicating what should be shared.
556 * Return 0 if permission is granted.
557 * @task_alloc_security:
558 * @p contains the task_struct for child process.
559 * Allocate and attach a security structure to the p->security field. The
560 * security field is initialized to NULL when the task structure is
561 * allocated.
562 * Return 0 if operation was successful.
563 * @task_free_security:
564 * @p contains the task_struct for process.
565 * Deallocate and clear the p->security field.
566 * @task_setuid:
567 * Check permission before setting one or more of the user identity
568 * attributes of the current process. The @flags parameter indicates
569 * which of the set*uid system calls invoked this hook and how to
570 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
571 * definitions at the beginning of this file for the @flags values and
572 * their meanings.
573 * @id0 contains a uid.
574 * @id1 contains a uid.
575 * @id2 contains a uid.
576 * @flags contains one of the LSM_SETID_* values.
577 * Return 0 if permission is granted.
578 * @task_post_setuid:
579 * Update the module's state after setting one or more of the user
580 * identity attributes of the current process. The @flags parameter
581 * indicates which of the set*uid system calls invoked this hook. If
582 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
583 * parameters are not used.
584 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
585 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
586 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
587 * @flags contains one of the LSM_SETID_* values.
588 * Return 0 on success.
589 * @task_setgid:
590 * Check permission before setting one or more of the group identity
591 * attributes of the current process. The @flags parameter indicates
592 * which of the set*gid system calls invoked this hook and how to
593 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
594 * definitions at the beginning of this file for the @flags values and
595 * their meanings.
596 * @id0 contains a gid.
597 * @id1 contains a gid.
598 * @id2 contains a gid.
599 * @flags contains one of the LSM_SETID_* values.
600 * Return 0 if permission is granted.
601 * @task_setpgid:
602 * Check permission before setting the process group identifier of the
603 * process @p to @pgid.
604 * @p contains the task_struct for process being modified.
605 * @pgid contains the new pgid.
606 * Return 0 if permission is granted.
607 * @task_getpgid:
608 * Check permission before getting the process group identifier of the
609 * process @p.
610 * @p contains the task_struct for the process.
611 * Return 0 if permission is granted.
612 * @task_getsid:
613 * Check permission before getting the session identifier of the process
614 * @p.
615 * @p contains the task_struct for the process.
616 * Return 0 if permission is granted.
David Quigleyf9008e42006-06-30 01:55:46 -0700617 * @task_getsecid:
618 * Retrieve the security identifier of the process @p.
619 * @p contains the task_struct for the process and place is into @secid.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 * @task_setgroups:
621 * Check permission before setting the supplementary group set of the
622 * current process.
623 * @group_info contains the new group information.
624 * Return 0 if permission is granted.
625 * @task_setnice:
626 * Check permission before setting the nice value of @p to @nice.
627 * @p contains the task_struct of process.
628 * @nice contains the new nice value.
629 * Return 0 if permission is granted.
James Morris03e68062006-06-23 02:03:58 -0700630 * @task_setioprio
631 * Check permission before setting the ioprio value of @p to @ioprio.
632 * @p contains the task_struct of process.
633 * @ioprio contains the new ioprio value
634 * Return 0 if permission is granted.
David Quigleya1836a42006-06-30 01:55:49 -0700635 * @task_getioprio
636 * Check permission before getting the ioprio value of @p.
637 * @p contains the task_struct of process.
638 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 * @task_setrlimit:
640 * Check permission before setting the resource limits of the current
641 * process for @resource to @new_rlim. The old resource limit values can
642 * be examined by dereferencing (current->signal->rlim + resource).
643 * @resource contains the resource whose limit is being set.
644 * @new_rlim contains the new limits for @resource.
645 * Return 0 if permission is granted.
646 * @task_setscheduler:
647 * Check permission before setting scheduling policy and/or parameters of
648 * process @p based on @policy and @lp.
649 * @p contains the task_struct for process.
650 * @policy contains the scheduling policy.
651 * @lp contains the scheduling parameters.
652 * Return 0 if permission is granted.
653 * @task_getscheduler:
654 * Check permission before obtaining scheduling information for process
655 * @p.
656 * @p contains the task_struct for process.
657 * Return 0 if permission is granted.
David Quigley35601542006-06-23 02:04:01 -0700658 * @task_movememory
659 * Check permission before moving memory owned by process @p.
660 * @p contains the task_struct for process.
661 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 * @task_kill:
663 * Check permission before sending signal @sig to @p. @info can be NULL,
664 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
665 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
666 * from the kernel and should typically be permitted.
667 * SIGIO signals are handled separately by the send_sigiotask hook in
668 * file_security_ops.
669 * @p contains the task_struct for process.
670 * @info contains the signal information.
671 * @sig contains the signal value.
David Quigleyf9008e42006-06-30 01:55:46 -0700672 * @secid contains the sid of the process where the signal originated
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 * Return 0 if permission is granted.
674 * @task_wait:
675 * Check permission before allowing a process to reap a child process @p
676 * and collect its status information.
677 * @p contains the task_struct for process.
678 * Return 0 if permission is granted.
679 * @task_prctl:
680 * Check permission before performing a process control operation on the
681 * current process.
682 * @option contains the operation.
683 * @arg2 contains a argument.
684 * @arg3 contains a argument.
685 * @arg4 contains a argument.
686 * @arg5 contains a argument.
687 * Return 0 if permission is granted.
688 * @task_reparent_to_init:
689 * Set the security attributes in @p->security for a kernel thread that
690 * is being reparented to the init task.
691 * @p contains the task_struct for the kernel thread.
692 * @task_to_inode:
693 * Set the security attributes for an inode based on an associated task's
694 * security attributes, e.g. for /proc/pid inodes.
695 * @p contains the task_struct for the task.
696 * @inode contains the inode structure for the inode.
697 *
698 * Security hooks for Netlink messaging.
699 *
700 * @netlink_send:
701 * Save security information for a netlink message so that permission
702 * checking can be performed when the message is processed. The security
703 * information can be saved using the eff_cap field of the
704 * netlink_skb_parms structure. Also may be used to provide fine
705 * grained control over message transmission.
706 * @sk associated sock of task sending the message.,
707 * @skb contains the sk_buff structure for the netlink message.
708 * Return 0 if the information was successfully saved and message
709 * is allowed to be transmitted.
710 * @netlink_recv:
711 * Check permission before processing the received netlink message in
712 * @skb.
713 * @skb contains the sk_buff structure for the netlink message.
Darrel Goeddelc7bdb542006-06-27 13:26:11 -0700714 * @cap indicates the capability required
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 * Return 0 if permission is granted.
716 *
717 * Security hooks for Unix domain networking.
718 *
719 * @unix_stream_connect:
720 * Check permissions before establishing a Unix domain stream connection
721 * between @sock and @other.
722 * @sock contains the socket structure.
723 * @other contains the peer socket structure.
724 * Return 0 if permission is granted.
725 * @unix_may_send:
726 * Check permissions before connecting or sending datagrams from @sock to
727 * @other.
728 * @sock contains the socket structure.
729 * @sock contains the peer socket structure.
730 * Return 0 if permission is granted.
731 *
732 * The @unix_stream_connect and @unix_may_send hooks were necessary because
733 * Linux provides an alternative to the conventional file name space for Unix
734 * domain sockets. Whereas binding and connecting to sockets in the file name
735 * space is mediated by the typical file permissions (and caught by the mknod
736 * and permission hooks in inode_security_ops), binding and connecting to
737 * sockets in the abstract name space is completely unmediated. Sufficient
738 * control of Unix domain sockets in the abstract name space isn't possible
739 * using only the socket layer hooks, since we need to know the actual target
740 * socket, which is not looked up until we are inside the af_unix code.
741 *
742 * Security hooks for socket operations.
743 *
744 * @socket_create:
745 * Check permissions prior to creating a new socket.
746 * @family contains the requested protocol family.
747 * @type contains the requested communications type.
748 * @protocol contains the requested protocol.
749 * @kern set to 1 if a kernel socket.
750 * Return 0 if permission is granted.
751 * @socket_post_create:
752 * This hook allows a module to update or allocate a per-socket security
753 * structure. Note that the security field was not added directly to the
754 * socket structure, but rather, the socket security information is stored
755 * in the associated inode. Typically, the inode alloc_security hook will
756 * allocate and and attach security information to
757 * sock->inode->i_security. This hook may be used to update the
758 * sock->inode->i_security field with additional information that wasn't
759 * available when the inode was allocated.
760 * @sock contains the newly created socket structure.
761 * @family contains the requested protocol family.
762 * @type contains the requested communications type.
763 * @protocol contains the requested protocol.
764 * @kern set to 1 if a kernel socket.
765 * @socket_bind:
766 * Check permission before socket protocol layer bind operation is
767 * performed and the socket @sock is bound to the address specified in the
768 * @address parameter.
769 * @sock contains the socket structure.
770 * @address contains the address to bind to.
771 * @addrlen contains the length of address.
772 * Return 0 if permission is granted.
773 * @socket_connect:
774 * Check permission before socket protocol layer connect operation
775 * attempts to connect socket @sock to a remote address, @address.
776 * @sock contains the socket structure.
777 * @address contains the address of remote endpoint.
778 * @addrlen contains the length of address.
779 * Return 0 if permission is granted.
780 * @socket_listen:
781 * Check permission before socket protocol layer listen operation.
782 * @sock contains the socket structure.
783 * @backlog contains the maximum length for the pending connection queue.
784 * Return 0 if permission is granted.
785 * @socket_accept:
786 * Check permission before accepting a new connection. Note that the new
787 * socket, @newsock, has been created and some information copied to it,
788 * but the accept operation has not actually been performed.
789 * @sock contains the listening socket structure.
790 * @newsock contains the newly created server socket for connection.
791 * Return 0 if permission is granted.
792 * @socket_post_accept:
793 * This hook allows a security module to copy security
794 * information into the newly created socket's inode.
795 * @sock contains the listening socket structure.
796 * @newsock contains the newly created server socket for connection.
797 * @socket_sendmsg:
798 * Check permission before transmitting a message to another socket.
799 * @sock contains the socket structure.
800 * @msg contains the message to be transmitted.
801 * @size contains the size of message.
802 * Return 0 if permission is granted.
803 * @socket_recvmsg:
804 * Check permission before receiving a message from a socket.
805 * @sock contains the socket structure.
806 * @msg contains the message structure.
807 * @size contains the size of message structure.
808 * @flags contains the operational flags.
809 * Return 0 if permission is granted.
810 * @socket_getsockname:
811 * Check permission before the local address (name) of the socket object
812 * @sock is retrieved.
813 * @sock contains the socket structure.
814 * Return 0 if permission is granted.
815 * @socket_getpeername:
816 * Check permission before the remote address (name) of a socket object
817 * @sock is retrieved.
818 * @sock contains the socket structure.
819 * Return 0 if permission is granted.
820 * @socket_getsockopt:
821 * Check permissions before retrieving the options associated with socket
822 * @sock.
823 * @sock contains the socket structure.
824 * @level contains the protocol level to retrieve option from.
825 * @optname contains the name of option to retrieve.
826 * Return 0 if permission is granted.
827 * @socket_setsockopt:
828 * Check permissions before setting the options associated with socket
829 * @sock.
830 * @sock contains the socket structure.
831 * @level contains the protocol level to set options for.
832 * @optname contains the name of the option to set.
833 * Return 0 if permission is granted.
834 * @socket_shutdown:
835 * Checks permission before all or part of a connection on the socket
836 * @sock is shut down.
837 * @sock contains the socket structure.
838 * @how contains the flag indicating how future sends and receives are handled.
839 * Return 0 if permission is granted.
840 * @socket_sock_rcv_skb:
841 * Check permissions on incoming network packets. This hook is distinct
842 * from Netfilter's IP input hooks since it is the first time that the
843 * incoming sk_buff @skb has been associated with a particular socket, @sk.
844 * @sk contains the sock (not socket) associated with the incoming sk_buff.
845 * @skb contains the incoming network data.
Serge Hallyn6da34ba2007-10-20 00:53:30 +0200846 * @socket_getpeersec_stream:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 * This hook allows the security module to provide peer socket security
Serge Hallyn6da34ba2007-10-20 00:53:30 +0200848 * state for unix or connected tcp sockets to userspace via getsockopt
849 * SO_GETPEERSEC. For tcp sockets this can be meaningful if the
850 * socket is associated with an ipsec SA.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851 * @sock is the local socket.
852 * @optval userspace memory where the security state is to be copied.
853 * @optlen userspace int where the module should copy the actual length
854 * of the security state.
855 * @len as input is the maximum length to copy to userspace provided
856 * by the caller.
857 * Return 0 if all is well, otherwise, typical getsockopt return
858 * values.
Serge Hallyn6da34ba2007-10-20 00:53:30 +0200859 * @socket_getpeersec_dgram:
860 * This hook allows the security module to provide peer socket security
861 * state for udp sockets on a per-packet basis to userspace via
862 * getsockopt SO_GETPEERSEC. The application must first have indicated
863 * the IP_PASSSEC option via getsockopt. It can then retrieve the
864 * security state returned by this hook for a packet via the SCM_SECURITY
865 * ancillary message type.
866 * @skb is the skbuff for the packet being queried
867 * @secdata is a pointer to a buffer in which to copy the security data
868 * @seclen is the maximum length for @secdata
869 * Return 0 on success, error on failure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 * @sk_alloc_security:
871 * Allocate and attach a security structure to the sk->sk_security field,
872 * which is used to copy security attributes between local stream sockets.
873 * @sk_free_security:
874 * Deallocate security structure.
Venkat Yekkirala892c1412006-08-04 23:08:56 -0700875 * @sk_clone_security:
876 * Clone/copy security structure.
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -0700877 * @sk_getsecid:
878 * Retrieve the LSM-specific secid for the sock to enable caching of network
Trent Jaegerdf718372005-12-13 23:12:27 -0800879 * authorizations.
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700880 * @sock_graft:
881 * Sets the socket's isec sid to the sock's sid.
882 * @inet_conn_request:
883 * Sets the openreq's sid to socket's sid with MLS portion taken from peer sid.
884 * @inet_csk_clone:
885 * Sets the new child socket's sid to the openreq sid.
Venkat Yekkirala6b877692006-11-08 17:04:09 -0600886 * @inet_conn_established:
887 * Sets the connection's peersid to the secmark on skb.
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700888 * @req_classify_flow:
889 * Sets the flow's sid to the openreq sid.
Trent Jaegerdf718372005-12-13 23:12:27 -0800890 *
891 * Security hooks for XFRM operations.
892 *
893 * @xfrm_policy_alloc_security:
894 * @xp contains the xfrm_policy being added to Security Policy Database
895 * used by the XFRM system.
896 * @sec_ctx contains the security context information being provided by
897 * the user-level policy update program (e.g., setkey).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700898 * Allocate a security structure to the xp->security field; the security
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -0600899 * field is initialized to NULL when the xfrm_policy is allocated.
Trent Jaegerdf718372005-12-13 23:12:27 -0800900 * Return 0 if operation was successful (memory to allocate, legal context)
901 * @xfrm_policy_clone_security:
902 * @old contains an existing xfrm_policy in the SPD.
903 * @new contains a new xfrm_policy being cloned from old.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700904 * Allocate a security structure to the new->security field
905 * that contains the information from the old->security field.
Trent Jaegerdf718372005-12-13 23:12:27 -0800906 * Return 0 if operation was successful (memory to allocate).
907 * @xfrm_policy_free_security:
908 * @xp contains the xfrm_policy
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700909 * Deallocate xp->security.
910 * @xfrm_policy_delete_security:
911 * @xp contains the xfrm_policy.
912 * Authorize deletion of xp->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800913 * @xfrm_state_alloc_security:
914 * @x contains the xfrm_state being added to the Security Association
915 * Database by the XFRM system.
916 * @sec_ctx contains the security context information being provided by
917 * the user-level SA generation program (e.g., setkey or racoon).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700918 * @secid contains the secid from which to take the mls portion of the context.
919 * Allocate a security structure to the x->security field; the security
920 * field is initialized to NULL when the xfrm_state is allocated. Set the
921 * context to correspond to either sec_ctx or polsec, with the mls portion
922 * taken from secid in the latter case.
Trent Jaegerdf718372005-12-13 23:12:27 -0800923 * Return 0 if operation was successful (memory to allocate, legal context).
924 * @xfrm_state_free_security:
925 * @x contains the xfrm_state.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700926 * Deallocate x->security.
927 * @xfrm_state_delete_security:
928 * @x contains the xfrm_state.
929 * Authorize deletion of x->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800930 * @xfrm_policy_lookup:
931 * @xp contains the xfrm_policy for which the access control is being
932 * checked.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700933 * @fl_secid contains the flow security label that is used to authorize
Trent Jaegerdf718372005-12-13 23:12:27 -0800934 * access to the policy xp.
935 * @dir contains the direction of the flow (input or output).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700936 * Check permission when a flow selects a xfrm_policy for processing
Trent Jaegerdf718372005-12-13 23:12:27 -0800937 * XFRMs on a packet. The hook is called when selecting either a
938 * per-socket policy or a generic xfrm policy.
Venkat Yekkirala5b368e62006-10-05 15:42:18 -0500939 * Return 0 if permission is granted, -ESRCH otherwise, or -errno
940 * on other errors.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700941 * @xfrm_state_pol_flow_match:
942 * @x contains the state to match.
943 * @xp contains the policy to check for a match.
944 * @fl contains the flow to check for a match.
945 * Return 1 if there is a match.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700946 * @xfrm_decode_session:
947 * @skb points to skb to decode.
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -0700948 * @secid points to the flow key secid to set.
949 * @ckall says if all xfrms used should be checked for same secid.
950 * Return 0 if ckall is zero or all xfrms used have the same secid.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951 *
David Howells29db9192005-10-30 15:02:44 -0800952 * Security hooks affecting all Key Management operations
953 *
954 * @key_alloc:
955 * Permit allocation of a key and assign security data. Note that key does
956 * not have a serial number assigned at this point.
957 * @key points to the key.
David Howells7e047ef2006-06-26 00:24:50 -0700958 * @flags is the allocation flags
David Howells29db9192005-10-30 15:02:44 -0800959 * Return 0 if permission is granted, -ve error otherwise.
960 * @key_free:
961 * Notification of destruction; free security data.
962 * @key points to the key.
963 * No return value.
964 * @key_permission:
965 * See whether a specific operational right is granted to a process on a
966 * key.
967 * @key_ref refers to the key (key pointer + possession attribute bit).
968 * @context points to the process to provide the context against which to
969 * evaluate the security data on the key.
970 * @perm describes the combination of permissions required of this key.
971 * Return 1 if permission granted, 0 if permission denied and -ve it the
972 * normal permissions model should be effected.
973 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 * Security hooks affecting all System V IPC operations.
975 *
976 * @ipc_permission:
977 * Check permissions for access to IPC
978 * @ipcp contains the kernel IPC permission structure
979 * @flag contains the desired (requested) permission set
980 * Return 0 if permission is granted.
981 *
982 * Security hooks for individual messages held in System V IPC message queues
983 * @msg_msg_alloc_security:
984 * Allocate and attach a security structure to the msg->security field.
985 * The security field is initialized to NULL when the structure is first
986 * created.
987 * @msg contains the message structure to be modified.
988 * Return 0 if operation was successful and permission is granted.
989 * @msg_msg_free_security:
990 * Deallocate the security structure for this message.
991 * @msg contains the message structure to be modified.
992 *
993 * Security hooks for System V IPC Message Queues
994 *
995 * @msg_queue_alloc_security:
996 * Allocate and attach a security structure to the
997 * msq->q_perm.security field. The security field is initialized to
998 * NULL when the structure is first created.
999 * @msq contains the message queue structure to be modified.
1000 * Return 0 if operation was successful and permission is granted.
1001 * @msg_queue_free_security:
1002 * Deallocate security structure for this message queue.
1003 * @msq contains the message queue structure to be modified.
1004 * @msg_queue_associate:
1005 * Check permission when a message queue is requested through the
1006 * msgget system call. This hook is only called when returning the
1007 * message queue identifier for an existing message queue, not when a
1008 * new message queue is created.
1009 * @msq contains the message queue to act upon.
1010 * @msqflg contains the operation control flags.
1011 * Return 0 if permission is granted.
1012 * @msg_queue_msgctl:
1013 * Check permission when a message control operation specified by @cmd
1014 * is to be performed on the message queue @msq.
1015 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
1016 * @msq contains the message queue to act upon. May be NULL.
1017 * @cmd contains the operation to be performed.
1018 * Return 0 if permission is granted.
1019 * @msg_queue_msgsnd:
1020 * Check permission before a message, @msg, is enqueued on the message
1021 * queue, @msq.
1022 * @msq contains the message queue to send message to.
1023 * @msg contains the message to be enqueued.
1024 * @msqflg contains operational flags.
1025 * Return 0 if permission is granted.
1026 * @msg_queue_msgrcv:
1027 * Check permission before a message, @msg, is removed from the message
1028 * queue, @msq. The @target task structure contains a pointer to the
1029 * process that will be receiving the message (not equal to the current
1030 * process when inline receives are being performed).
1031 * @msq contains the message queue to retrieve message from.
1032 * @msg contains the message destination.
1033 * @target contains the task structure for recipient process.
1034 * @type contains the type of message requested.
1035 * @mode contains the operational flags.
1036 * Return 0 if permission is granted.
1037 *
1038 * Security hooks for System V Shared Memory Segments
1039 *
1040 * @shm_alloc_security:
1041 * Allocate and attach a security structure to the shp->shm_perm.security
1042 * field. The security field is initialized to NULL when the structure is
1043 * first created.
1044 * @shp contains the shared memory structure to be modified.
1045 * Return 0 if operation was successful and permission is granted.
1046 * @shm_free_security:
1047 * Deallocate the security struct for this memory segment.
1048 * @shp contains the shared memory structure to be modified.
1049 * @shm_associate:
1050 * Check permission when a shared memory region is requested through the
1051 * shmget system call. This hook is only called when returning the shared
1052 * memory region identifier for an existing region, not when a new shared
1053 * memory region is created.
1054 * @shp contains the shared memory structure to be modified.
1055 * @shmflg contains the operation control flags.
1056 * Return 0 if permission is granted.
1057 * @shm_shmctl:
1058 * Check permission when a shared memory control operation specified by
1059 * @cmd is to be performed on the shared memory region @shp.
1060 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1061 * @shp contains shared memory structure to be modified.
1062 * @cmd contains the operation to be performed.
1063 * Return 0 if permission is granted.
1064 * @shm_shmat:
1065 * Check permissions prior to allowing the shmat system call to attach the
1066 * shared memory segment @shp to the data segment of the calling process.
1067 * The attaching address is specified by @shmaddr.
1068 * @shp contains the shared memory structure to be modified.
1069 * @shmaddr contains the address to attach memory region to.
1070 * @shmflg contains the operational flags.
1071 * Return 0 if permission is granted.
1072 *
1073 * Security hooks for System V Semaphores
1074 *
1075 * @sem_alloc_security:
1076 * Allocate and attach a security structure to the sma->sem_perm.security
1077 * field. The security field is initialized to NULL when the structure is
1078 * first created.
1079 * @sma contains the semaphore structure
1080 * Return 0 if operation was successful and permission is granted.
1081 * @sem_free_security:
1082 * deallocate security struct for this semaphore
1083 * @sma contains the semaphore structure.
1084 * @sem_associate:
1085 * Check permission when a semaphore is requested through the semget
1086 * system call. This hook is only called when returning the semaphore
1087 * identifier for an existing semaphore, not when a new one must be
1088 * created.
1089 * @sma contains the semaphore structure.
1090 * @semflg contains the operation control flags.
1091 * Return 0 if permission is granted.
1092 * @sem_semctl:
1093 * Check permission when a semaphore operation specified by @cmd is to be
1094 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
1095 * IPC_INFO or SEM_INFO.
1096 * @sma contains the semaphore structure. May be NULL.
1097 * @cmd contains the operation to be performed.
1098 * Return 0 if permission is granted.
1099 * @sem_semop
1100 * Check permissions before performing operations on members of the
1101 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1102 * may be modified.
1103 * @sma contains the semaphore structure.
1104 * @sops contains the operations to perform.
1105 * @nsops contains the number of operations to perform.
1106 * @alter contains the flag indicating whether changes are to be made.
1107 * Return 0 if permission is granted.
1108 *
1109 * @ptrace:
1110 * Check permission before allowing the @parent process to trace the
1111 * @child process.
1112 * Security modules may also want to perform a process tracing check
1113 * during an execve in the set_security or apply_creds hooks of
1114 * binprm_security_ops if the process is being traced and its security
1115 * attributes would be changed by the execve.
1116 * @parent contains the task_struct structure for parent process.
1117 * @child contains the task_struct structure for child process.
1118 * Return 0 if permission is granted.
1119 * @capget:
1120 * Get the @effective, @inheritable, and @permitted capability sets for
1121 * the @target process. The hook may also perform permission checking to
1122 * determine if the current process is allowed to see the capability sets
1123 * of the @target process.
1124 * @target contains the task_struct structure for target process.
1125 * @effective contains the effective capability set.
1126 * @inheritable contains the inheritable capability set.
1127 * @permitted contains the permitted capability set.
1128 * Return 0 if the capability sets were successfully obtained.
1129 * @capset_check:
1130 * Check permission before setting the @effective, @inheritable, and
1131 * @permitted capability sets for the @target process.
1132 * Caveat: @target is also set to current if a set of processes is
1133 * specified (i.e. all processes other than current and init or a
1134 * particular process group). Hence, the capset_set hook may need to
1135 * revalidate permission to the actual target process.
1136 * @target contains the task_struct structure for target process.
1137 * @effective contains the effective capability set.
1138 * @inheritable contains the inheritable capability set.
1139 * @permitted contains the permitted capability set.
1140 * Return 0 if permission is granted.
1141 * @capset_set:
1142 * Set the @effective, @inheritable, and @permitted capability sets for
1143 * the @target process. Since capset_check cannot always check permission
1144 * to the real @target process, this hook may also perform permission
1145 * checking to determine if the current process is allowed to set the
1146 * capability sets of the @target process. However, this hook has no way
1147 * of returning an error due to the structure of the sys_capset code.
1148 * @target contains the task_struct structure for target process.
1149 * @effective contains the effective capability set.
1150 * @inheritable contains the inheritable capability set.
1151 * @permitted contains the permitted capability set.
Chris Wright12b59892006-03-25 03:07:41 -08001152 * @capable:
1153 * Check whether the @tsk process has the @cap capability.
1154 * @tsk contains the task_struct for the process.
1155 * @cap contains the capability <include/linux/capability.h>.
1156 * Return 0 if the capability is granted for @tsk.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 * @acct:
1158 * Check permission before enabling or disabling process accounting. If
1159 * accounting is being enabled, then @file refers to the open file used to
1160 * store accounting records. If accounting is being disabled, then @file
1161 * is NULL.
1162 * @file contains the file structure for the accounting file (may be NULL).
1163 * Return 0 if permission is granted.
1164 * @sysctl:
1165 * Check permission before accessing the @table sysctl variable in the
1166 * manner specified by @op.
1167 * @table contains the ctl_table structure for the sysctl variable.
1168 * @op contains the operation (001 = search, 002 = write, 004 = read).
1169 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 * @syslog:
1171 * Check permission before accessing the kernel message ring or changing
1172 * logging to the console.
1173 * See the syslog(2) manual page for an explanation of the @type values.
1174 * @type contains the type of action.
1175 * Return 0 if permission is granted.
1176 * @settime:
1177 * Check permission to change the system time.
1178 * struct timespec and timezone are defined in include/linux/time.h
1179 * @ts contains new time
1180 * @tz contains new timezone
1181 * Return 0 if permission is granted.
1182 * @vm_enough_memory:
1183 * Check permissions for allocating a new virtual mapping.
Alan Cox34b4e4a2007-08-22 14:01:28 -07001184 * @mm contains the mm struct it is being added to.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185 * @pages contains the number of pages.
1186 * Return 0 if permission is granted.
1187 *
1188 * @register_security:
1189 * allow module stacking.
1190 * @name contains the name of the security module being stacked.
1191 * @ops contains a pointer to the struct security_operations of the module to stack.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 *
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001193 * @secid_to_secctx:
1194 * Convert secid to security context.
1195 * @secid contains the security ID.
1196 * @secdata contains the pointer that stores the converted security context.
David Howells63cb3442008-01-15 23:47:35 +00001197 * @secctx_to_secid:
1198 * Convert security context to secid.
1199 * @secid contains the pointer to the generated security ID.
1200 * @secdata contains the security context.
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001201 *
1202 * @release_secctx:
1203 * Release the security context.
1204 * @secdata contains the security context.
1205 * @seclen contains the length of the security context.
1206 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207 * This is the main security structure.
1208 */
1209struct security_operations {
1210 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1211 int (*capget) (struct task_struct * target,
1212 kernel_cap_t * effective,
1213 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1214 int (*capset_check) (struct task_struct * target,
1215 kernel_cap_t * effective,
1216 kernel_cap_t * inheritable,
1217 kernel_cap_t * permitted);
1218 void (*capset_set) (struct task_struct * target,
1219 kernel_cap_t * effective,
1220 kernel_cap_t * inheritable,
1221 kernel_cap_t * permitted);
Chris Wright12b59892006-03-25 03:07:41 -08001222 int (*capable) (struct task_struct * tsk, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001223 int (*acct) (struct file * file);
1224 int (*sysctl) (struct ctl_table * table, int op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1226 int (*quota_on) (struct dentry * dentry);
1227 int (*syslog) (int type);
1228 int (*settime) (struct timespec *ts, struct timezone *tz);
Alan Cox34b4e4a2007-08-22 14:01:28 -07001229 int (*vm_enough_memory) (struct mm_struct *mm, long pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230
1231 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1232 void (*bprm_free_security) (struct linux_binprm * bprm);
1233 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1234 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1235 int (*bprm_set_security) (struct linux_binprm * bprm);
1236 int (*bprm_check_security) (struct linux_binprm * bprm);
1237 int (*bprm_secureexec) (struct linux_binprm * bprm);
1238
1239 int (*sb_alloc_security) (struct super_block * sb);
1240 void (*sb_free_security) (struct super_block * sb);
1241 int (*sb_copy_data)(struct file_system_type *type,
1242 void *orig, void *copy);
1243 int (*sb_kern_mount) (struct super_block *sb, void *data);
David Howells726c3342006-06-23 02:02:58 -07001244 int (*sb_statfs) (struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001245 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1246 char *type, unsigned long flags, void *data);
1247 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1248 int (*sb_umount) (struct vfsmount * mnt, int flags);
1249 void (*sb_umount_close) (struct vfsmount * mnt);
1250 void (*sb_umount_busy) (struct vfsmount * mnt);
1251 void (*sb_post_remount) (struct vfsmount * mnt,
1252 unsigned long flags, void *data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253 void (*sb_post_addmount) (struct vfsmount * mnt,
1254 struct nameidata * mountpoint_nd);
1255 int (*sb_pivotroot) (struct nameidata * old_nd,
1256 struct nameidata * new_nd);
1257 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1258 struct nameidata * new_nd);
Eric Parisc9180a52007-11-30 13:00:35 -05001259 int (*sb_get_mnt_opts) (const struct super_block *sb,
1260 char ***mount_options, int **flags,
1261 int *num_opts);
1262 int (*sb_set_mnt_opts) (struct super_block *sb, char **mount_options,
1263 int *flags, int num_opts);
1264 void (*sb_clone_mnt_opts) (const struct super_block *oldsb,
1265 struct super_block *newsb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001266
1267 int (*inode_alloc_security) (struct inode *inode);
1268 void (*inode_free_security) (struct inode *inode);
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001269 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1270 char **name, void **value, size_t *len);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 int (*inode_create) (struct inode *dir,
1272 struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273 int (*inode_link) (struct dentry *old_dentry,
1274 struct inode *dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001275 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1276 int (*inode_symlink) (struct inode *dir,
1277 struct dentry *dentry, const char *old_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1280 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1281 int mode, dev_t dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001282 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1283 struct inode *new_dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001284 int (*inode_readlink) (struct dentry *dentry);
1285 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1286 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1287 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1288 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1289 void (*inode_delete) (struct inode *inode);
1290 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1291 size_t size, int flags);
1292 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1293 size_t size, int flags);
1294 int (*inode_getxattr) (struct dentry *dentry, char *name);
1295 int (*inode_listxattr) (struct dentry *dentry);
1296 int (*inode_removexattr) (struct dentry *dentry, char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -07001297 int (*inode_need_killpriv) (struct dentry *dentry);
1298 int (*inode_killpriv) (struct dentry *dentry);
David P. Quigley42492592008-02-04 22:29:39 -08001299 int (*inode_getsecurity)(const struct inode *inode, const char *name, void **buffer, bool alloc);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1301 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1302
1303 int (*file_permission) (struct file * file, int mask);
1304 int (*file_alloc_security) (struct file * file);
1305 void (*file_free_security) (struct file * file);
1306 int (*file_ioctl) (struct file * file, unsigned int cmd,
1307 unsigned long arg);
1308 int (*file_mmap) (struct file * file,
Eric Parised032182007-06-28 15:55:21 -04001309 unsigned long reqprot, unsigned long prot,
1310 unsigned long flags, unsigned long addr,
1311 unsigned long addr_only);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 int (*file_mprotect) (struct vm_area_struct * vma,
1313 unsigned long reqprot,
1314 unsigned long prot);
1315 int (*file_lock) (struct file * file, unsigned int cmd);
1316 int (*file_fcntl) (struct file * file, unsigned int cmd,
1317 unsigned long arg);
1318 int (*file_set_fowner) (struct file * file);
1319 int (*file_send_sigiotask) (struct task_struct * tsk,
1320 struct fown_struct * fown, int sig);
1321 int (*file_receive) (struct file * file);
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +09001322 int (*dentry_open) (struct file *file);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323
1324 int (*task_create) (unsigned long clone_flags);
1325 int (*task_alloc_security) (struct task_struct * p);
1326 void (*task_free_security) (struct task_struct * p);
1327 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1328 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1329 uid_t old_euid, uid_t old_suid, int flags);
1330 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1331 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1332 int (*task_getpgid) (struct task_struct * p);
1333 int (*task_getsid) (struct task_struct * p);
David Quigleyf9008e42006-06-30 01:55:46 -07001334 void (*task_getsecid) (struct task_struct * p, u32 * secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001335 int (*task_setgroups) (struct group_info *group_info);
1336 int (*task_setnice) (struct task_struct * p, int nice);
James Morris03e68062006-06-23 02:03:58 -07001337 int (*task_setioprio) (struct task_struct * p, int ioprio);
David Quigleya1836a42006-06-30 01:55:49 -07001338 int (*task_getioprio) (struct task_struct * p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1340 int (*task_setscheduler) (struct task_struct * p, int policy,
1341 struct sched_param * lp);
1342 int (*task_getscheduler) (struct task_struct * p);
David Quigley35601542006-06-23 02:04:01 -07001343 int (*task_movememory) (struct task_struct * p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001344 int (*task_kill) (struct task_struct * p,
David Quigleyf9008e42006-06-30 01:55:46 -07001345 struct siginfo * info, int sig, u32 secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346 int (*task_wait) (struct task_struct * p);
1347 int (*task_prctl) (int option, unsigned long arg2,
1348 unsigned long arg3, unsigned long arg4,
1349 unsigned long arg5);
1350 void (*task_reparent_to_init) (struct task_struct * p);
1351 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1352
1353 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1354
1355 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1356 void (*msg_msg_free_security) (struct msg_msg * msg);
1357
1358 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1359 void (*msg_queue_free_security) (struct msg_queue * msq);
1360 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1361 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1362 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1363 struct msg_msg * msg, int msqflg);
1364 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1365 struct msg_msg * msg,
1366 struct task_struct * target,
1367 long type, int mode);
1368
1369 int (*shm_alloc_security) (struct shmid_kernel * shp);
1370 void (*shm_free_security) (struct shmid_kernel * shp);
1371 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1372 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1373 int (*shm_shmat) (struct shmid_kernel * shp,
1374 char __user *shmaddr, int shmflg);
1375
1376 int (*sem_alloc_security) (struct sem_array * sma);
1377 void (*sem_free_security) (struct sem_array * sma);
1378 int (*sem_associate) (struct sem_array * sma, int semflg);
1379 int (*sem_semctl) (struct sem_array * sma, int cmd);
1380 int (*sem_semop) (struct sem_array * sma,
1381 struct sembuf * sops, unsigned nsops, int alter);
1382
1383 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07001384 int (*netlink_recv) (struct sk_buff * skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385
1386 /* allow module stacking */
1387 int (*register_security) (const char *name,
1388 struct security_operations *ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389
1390 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1391
Al Viro04ff9702007-03-12 16:17:58 +00001392 int (*getprocattr)(struct task_struct *p, char *name, char **value);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001393 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001394 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
David Howells63cb3442008-01-15 23:47:35 +00001395 int (*secctx_to_secid)(char *secdata, u32 seclen, u32 *secid);
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001396 void (*release_secctx)(char *secdata, u32 seclen);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397
1398#ifdef CONFIG_SECURITY_NETWORK
1399 int (*unix_stream_connect) (struct socket * sock,
1400 struct socket * other, struct sock * newsk);
1401 int (*unix_may_send) (struct socket * sock, struct socket * other);
1402
1403 int (*socket_create) (int family, int type, int protocol, int kern);
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07001404 int (*socket_post_create) (struct socket * sock, int family,
1405 int type, int protocol, int kern);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406 int (*socket_bind) (struct socket * sock,
1407 struct sockaddr * address, int addrlen);
1408 int (*socket_connect) (struct socket * sock,
1409 struct sockaddr * address, int addrlen);
1410 int (*socket_listen) (struct socket * sock, int backlog);
1411 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1412 void (*socket_post_accept) (struct socket * sock,
1413 struct socket * newsock);
1414 int (*socket_sendmsg) (struct socket * sock,
1415 struct msghdr * msg, int size);
1416 int (*socket_recvmsg) (struct socket * sock,
1417 struct msghdr * msg, int size, int flags);
1418 int (*socket_getsockname) (struct socket * sock);
1419 int (*socket_getpeername) (struct socket * sock);
1420 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1421 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1422 int (*socket_shutdown) (struct socket * sock, int how);
1423 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
Catherine Zhang2c7946a2006-03-20 22:41:23 -08001424 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001425 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
Al Viro7d877f32005-10-21 03:20:43 -04001426 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001427 void (*sk_free_security) (struct sock *sk);
Venkat Yekkirala892c1412006-08-04 23:08:56 -07001428 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001429 void (*sk_getsecid) (struct sock *sk, u32 *secid);
Venkat Yekkirala4237c752006-07-24 23:32:50 -07001430 void (*sock_graft)(struct sock* sk, struct socket *parent);
1431 int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb,
1432 struct request_sock *req);
1433 void (*inet_csk_clone)(struct sock *newsk, const struct request_sock *req);
Venkat Yekkirala6b877692006-11-08 17:04:09 -06001434 void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb);
Venkat Yekkirala4237c752006-07-24 23:32:50 -07001435 void (*req_classify_flow)(const struct request_sock *req, struct flowi *fl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001436#endif /* CONFIG_SECURITY_NETWORK */
David Howells29db9192005-10-30 15:02:44 -08001437
Trent Jaegerdf718372005-12-13 23:12:27 -08001438#ifdef CONFIG_SECURITY_NETWORK_XFRM
Venkat Yekkiralacb969f02006-07-24 23:32:20 -07001439 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp,
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -06001440 struct xfrm_user_sec_ctx *sec_ctx);
Trent Jaegerdf718372005-12-13 23:12:27 -08001441 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1442 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001443 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001444 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -06001445 struct xfrm_user_sec_ctx *sec_ctx,
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001446 u32 secid);
Trent Jaegerdf718372005-12-13 23:12:27 -08001447 void (*xfrm_state_free_security) (struct xfrm_state *x);
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001448 int (*xfrm_state_delete_security) (struct xfrm_state *x);
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001449 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
1450 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
1451 struct xfrm_policy *xp, struct flowi *fl);
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001452 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
Trent Jaegerdf718372005-12-13 23:12:27 -08001453#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1454
David Howells29db9192005-10-30 15:02:44 -08001455 /* key management security hooks */
1456#ifdef CONFIG_KEYS
David Howells7e047ef2006-06-26 00:24:50 -07001457 int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags);
David Howells29db9192005-10-30 15:02:44 -08001458 void (*key_free)(struct key *key);
1459 int (*key_permission)(key_ref_t key_ref,
1460 struct task_struct *context,
1461 key_perm_t perm);
1462
1463#endif /* CONFIG_KEYS */
1464
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465};
1466
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467/* prototypes */
1468extern int security_init (void);
1469extern int register_security (struct security_operations *ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001470extern int mod_reg_security (const char *name, struct security_operations *ops);
Greg KHb67dbf92005-07-07 14:37:53 -07001471extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
1472 struct dentry *parent, void *data,
Arjan van de Ven54047322007-02-12 00:55:28 -08001473 const struct file_operations *fops);
Greg KHb67dbf92005-07-07 14:37:53 -07001474extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1475extern void securityfs_remove(struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476
1477
James Morris20510f22007-10-16 23:31:32 -07001478/* Security operations */
1479int security_ptrace(struct task_struct *parent, struct task_struct *child);
1480int security_capget(struct task_struct *target,
1481 kernel_cap_t *effective,
1482 kernel_cap_t *inheritable,
1483 kernel_cap_t *permitted);
1484int security_capset_check(struct task_struct *target,
1485 kernel_cap_t *effective,
1486 kernel_cap_t *inheritable,
1487 kernel_cap_t *permitted);
1488void security_capset_set(struct task_struct *target,
1489 kernel_cap_t *effective,
1490 kernel_cap_t *inheritable,
1491 kernel_cap_t *permitted);
1492int security_capable(struct task_struct *tsk, int cap);
1493int security_acct(struct file *file);
1494int security_sysctl(struct ctl_table *table, int op);
1495int security_quotactl(int cmds, int type, int id, struct super_block *sb);
1496int security_quota_on(struct dentry *dentry);
1497int security_syslog(int type);
1498int security_settime(struct timespec *ts, struct timezone *tz);
1499int security_vm_enough_memory(long pages);
1500int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
1501int security_bprm_alloc(struct linux_binprm *bprm);
1502void security_bprm_free(struct linux_binprm *bprm);
1503void security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe);
1504void security_bprm_post_apply_creds(struct linux_binprm *bprm);
1505int security_bprm_set(struct linux_binprm *bprm);
1506int security_bprm_check(struct linux_binprm *bprm);
1507int security_bprm_secureexec(struct linux_binprm *bprm);
1508int security_sb_alloc(struct super_block *sb);
1509void security_sb_free(struct super_block *sb);
1510int security_sb_copy_data(struct file_system_type *type, void *orig, void *copy);
1511int security_sb_kern_mount(struct super_block *sb, void *data);
1512int security_sb_statfs(struct dentry *dentry);
1513int security_sb_mount(char *dev_name, struct nameidata *nd,
1514 char *type, unsigned long flags, void *data);
1515int security_sb_check_sb(struct vfsmount *mnt, struct nameidata *nd);
1516int security_sb_umount(struct vfsmount *mnt, int flags);
1517void security_sb_umount_close(struct vfsmount *mnt);
1518void security_sb_umount_busy(struct vfsmount *mnt);
1519void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data);
James Morris20510f22007-10-16 23:31:32 -07001520void security_sb_post_addmount(struct vfsmount *mnt, struct nameidata *mountpoint_nd);
1521int security_sb_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd);
1522void security_sb_post_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd);
Eric Parisc9180a52007-11-30 13:00:35 -05001523int security_sb_get_mnt_opts(const struct super_block *sb, char ***mount_options,
1524 int **flags, int *num_opts);
1525int security_sb_set_mnt_opts(struct super_block *sb, char **mount_options,
1526 int *flags, int num_opts);
1527void security_sb_clone_mnt_opts(const struct super_block *oldsb,
1528 struct super_block *newsb);
1529
James Morris20510f22007-10-16 23:31:32 -07001530int security_inode_alloc(struct inode *inode);
1531void security_inode_free(struct inode *inode);
1532int security_inode_init_security(struct inode *inode, struct inode *dir,
1533 char **name, void **value, size_t *len);
1534int security_inode_create(struct inode *dir, struct dentry *dentry, int mode);
1535int security_inode_link(struct dentry *old_dentry, struct inode *dir,
1536 struct dentry *new_dentry);
1537int security_inode_unlink(struct inode *dir, struct dentry *dentry);
1538int security_inode_symlink(struct inode *dir, struct dentry *dentry,
1539 const char *old_name);
1540int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode);
1541int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
1542int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
1543int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1544 struct inode *new_dir, struct dentry *new_dentry);
1545int security_inode_readlink(struct dentry *dentry);
1546int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
1547int security_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
1548int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1549int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1550void security_inode_delete(struct inode *inode);
1551int security_inode_setxattr(struct dentry *dentry, char *name,
1552 void *value, size_t size, int flags);
1553void security_inode_post_setxattr(struct dentry *dentry, char *name,
1554 void *value, size_t size, int flags);
1555int security_inode_getxattr(struct dentry *dentry, char *name);
1556int security_inode_listxattr(struct dentry *dentry);
1557int security_inode_removexattr(struct dentry *dentry, char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -07001558int security_inode_need_killpriv(struct dentry *dentry);
1559int security_inode_killpriv(struct dentry *dentry);
David P. Quigley42492592008-02-04 22:29:39 -08001560int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc);
James Morris20510f22007-10-16 23:31:32 -07001561int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1562int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
1563int security_file_permission(struct file *file, int mask);
1564int security_file_alloc(struct file *file);
1565void security_file_free(struct file *file);
1566int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1567int security_file_mmap(struct file *file, unsigned long reqprot,
1568 unsigned long prot, unsigned long flags,
1569 unsigned long addr, unsigned long addr_only);
1570int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
1571 unsigned long prot);
1572int security_file_lock(struct file *file, unsigned int cmd);
1573int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
1574int security_file_set_fowner(struct file *file);
1575int security_file_send_sigiotask(struct task_struct *tsk,
1576 struct fown_struct *fown, int sig);
1577int security_file_receive(struct file *file);
1578int security_dentry_open(struct file *file);
1579int security_task_create(unsigned long clone_flags);
1580int security_task_alloc(struct task_struct *p);
1581void security_task_free(struct task_struct *p);
1582int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags);
1583int security_task_post_setuid(uid_t old_ruid, uid_t old_euid,
1584 uid_t old_suid, int flags);
1585int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags);
1586int security_task_setpgid(struct task_struct *p, pid_t pgid);
1587int security_task_getpgid(struct task_struct *p);
1588int security_task_getsid(struct task_struct *p);
1589void security_task_getsecid(struct task_struct *p, u32 *secid);
1590int security_task_setgroups(struct group_info *group_info);
1591int security_task_setnice(struct task_struct *p, int nice);
1592int security_task_setioprio(struct task_struct *p, int ioprio);
1593int security_task_getioprio(struct task_struct *p);
1594int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim);
1595int security_task_setscheduler(struct task_struct *p,
1596 int policy, struct sched_param *lp);
1597int security_task_getscheduler(struct task_struct *p);
1598int security_task_movememory(struct task_struct *p);
1599int security_task_kill(struct task_struct *p, struct siginfo *info,
1600 int sig, u32 secid);
1601int security_task_wait(struct task_struct *p);
1602int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
1603 unsigned long arg4, unsigned long arg5);
1604void security_task_reparent_to_init(struct task_struct *p);
1605void security_task_to_inode(struct task_struct *p, struct inode *inode);
1606int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
1607int security_msg_msg_alloc(struct msg_msg *msg);
1608void security_msg_msg_free(struct msg_msg *msg);
1609int security_msg_queue_alloc(struct msg_queue *msq);
1610void security_msg_queue_free(struct msg_queue *msq);
1611int security_msg_queue_associate(struct msg_queue *msq, int msqflg);
1612int security_msg_queue_msgctl(struct msg_queue *msq, int cmd);
1613int security_msg_queue_msgsnd(struct msg_queue *msq,
1614 struct msg_msg *msg, int msqflg);
1615int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
1616 struct task_struct *target, long type, int mode);
1617int security_shm_alloc(struct shmid_kernel *shp);
1618void security_shm_free(struct shmid_kernel *shp);
1619int security_shm_associate(struct shmid_kernel *shp, int shmflg);
1620int security_shm_shmctl(struct shmid_kernel *shp, int cmd);
1621int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg);
1622int security_sem_alloc(struct sem_array *sma);
1623void security_sem_free(struct sem_array *sma);
1624int security_sem_associate(struct sem_array *sma, int semflg);
1625int security_sem_semctl(struct sem_array *sma, int cmd);
1626int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
1627 unsigned nsops, int alter);
1628void security_d_instantiate (struct dentry *dentry, struct inode *inode);
1629int security_getprocattr(struct task_struct *p, char *name, char **value);
1630int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
1631int security_netlink_send(struct sock *sk, struct sk_buff *skb);
1632int security_netlink_recv(struct sk_buff *skb, int cap);
1633int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
David Howells63cb3442008-01-15 23:47:35 +00001634int security_secctx_to_secid(char *secdata, u32 seclen, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -07001635void security_release_secctx(char *secdata, u32 seclen);
1636
Linus Torvalds1da177e2005-04-16 15:20:36 -07001637#else /* CONFIG_SECURITY */
1638
1639/*
1640 * This is the default capabilities functionality. Most of these functions
1641 * are just stubbed out, but a few must call the proper capable code.
1642 */
1643
1644static inline int security_init(void)
1645{
1646 return 0;
1647}
1648
1649static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
1650{
1651 return cap_ptrace (parent, child);
1652}
1653
1654static inline int security_capget (struct task_struct *target,
1655 kernel_cap_t *effective,
1656 kernel_cap_t *inheritable,
1657 kernel_cap_t *permitted)
1658{
1659 return cap_capget (target, effective, inheritable, permitted);
1660}
1661
1662static inline int security_capset_check (struct task_struct *target,
1663 kernel_cap_t *effective,
1664 kernel_cap_t *inheritable,
1665 kernel_cap_t *permitted)
1666{
1667 return cap_capset_check (target, effective, inheritable, permitted);
1668}
1669
1670static inline void security_capset_set (struct task_struct *target,
1671 kernel_cap_t *effective,
1672 kernel_cap_t *inheritable,
1673 kernel_cap_t *permitted)
1674{
1675 cap_capset_set (target, effective, inheritable, permitted);
1676}
1677
Chris Wright12b59892006-03-25 03:07:41 -08001678static inline int security_capable(struct task_struct *tsk, int cap)
1679{
1680 return cap_capable(tsk, cap);
1681}
1682
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683static inline int security_acct (struct file *file)
1684{
1685 return 0;
1686}
1687
1688static inline int security_sysctl(struct ctl_table *table, int op)
1689{
1690 return 0;
1691}
1692
1693static inline int security_quotactl (int cmds, int type, int id,
1694 struct super_block * sb)
1695{
1696 return 0;
1697}
1698
1699static inline int security_quota_on (struct dentry * dentry)
1700{
1701 return 0;
1702}
1703
1704static inline int security_syslog(int type)
1705{
1706 return cap_syslog(type);
1707}
1708
1709static inline int security_settime(struct timespec *ts, struct timezone *tz)
1710{
1711 return cap_settime(ts, tz);
1712}
1713
1714static inline int security_vm_enough_memory(long pages)
1715{
Alan Cox34b4e4a2007-08-22 14:01:28 -07001716 return cap_vm_enough_memory(current->mm, pages);
1717}
1718
1719static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
1720{
1721 return cap_vm_enough_memory(mm, pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722}
1723
1724static inline int security_bprm_alloc (struct linux_binprm *bprm)
1725{
1726 return 0;
1727}
1728
1729static inline void security_bprm_free (struct linux_binprm *bprm)
1730{ }
1731
1732static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1733{
1734 cap_bprm_apply_creds (bprm, unsafe);
1735}
1736
1737static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1738{
1739 return;
1740}
1741
1742static inline int security_bprm_set (struct linux_binprm *bprm)
1743{
1744 return cap_bprm_set_security (bprm);
1745}
1746
1747static inline int security_bprm_check (struct linux_binprm *bprm)
1748{
1749 return 0;
1750}
1751
1752static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1753{
1754 return cap_bprm_secureexec(bprm);
1755}
1756
1757static inline int security_sb_alloc (struct super_block *sb)
1758{
1759 return 0;
1760}
1761
1762static inline void security_sb_free (struct super_block *sb)
1763{ }
1764
1765static inline int security_sb_copy_data (struct file_system_type *type,
1766 void *orig, void *copy)
1767{
1768 return 0;
1769}
1770
1771static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1772{
1773 return 0;
1774}
1775
David Howells726c3342006-06-23 02:02:58 -07001776static inline int security_sb_statfs (struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001777{
1778 return 0;
1779}
1780
1781static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1782 char *type, unsigned long flags,
1783 void *data)
1784{
1785 return 0;
1786}
1787
1788static inline int security_sb_check_sb (struct vfsmount *mnt,
1789 struct nameidata *nd)
1790{
1791 return 0;
1792}
1793
1794static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1795{
1796 return 0;
1797}
1798
1799static inline void security_sb_umount_close (struct vfsmount *mnt)
1800{ }
1801
1802static inline void security_sb_umount_busy (struct vfsmount *mnt)
1803{ }
1804
1805static inline void security_sb_post_remount (struct vfsmount *mnt,
1806 unsigned long flags, void *data)
1807{ }
1808
Linus Torvalds1da177e2005-04-16 15:20:36 -07001809static inline void security_sb_post_addmount (struct vfsmount *mnt,
1810 struct nameidata *mountpoint_nd)
1811{ }
1812
1813static inline int security_sb_pivotroot (struct nameidata *old_nd,
1814 struct nameidata *new_nd)
1815{
1816 return 0;
1817}
1818
1819static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1820 struct nameidata *new_nd)
1821{ }
1822
1823static inline int security_inode_alloc (struct inode *inode)
1824{
1825 return 0;
1826}
1827
1828static inline void security_inode_free (struct inode *inode)
1829{ }
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001830
1831static inline int security_inode_init_security (struct inode *inode,
1832 struct inode *dir,
1833 char **name,
1834 void **value,
1835 size_t *len)
1836{
1837 return -EOPNOTSUPP;
1838}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001839
1840static inline int security_inode_create (struct inode *dir,
1841 struct dentry *dentry,
1842 int mode)
1843{
1844 return 0;
1845}
1846
Linus Torvalds1da177e2005-04-16 15:20:36 -07001847static inline int security_inode_link (struct dentry *old_dentry,
1848 struct inode *dir,
1849 struct dentry *new_dentry)
1850{
1851 return 0;
1852}
1853
Linus Torvalds1da177e2005-04-16 15:20:36 -07001854static inline int security_inode_unlink (struct inode *dir,
1855 struct dentry *dentry)
1856{
1857 return 0;
1858}
1859
1860static inline int security_inode_symlink (struct inode *dir,
1861 struct dentry *dentry,
1862 const char *old_name)
1863{
1864 return 0;
1865}
1866
Linus Torvalds1da177e2005-04-16 15:20:36 -07001867static inline int security_inode_mkdir (struct inode *dir,
1868 struct dentry *dentry,
1869 int mode)
1870{
1871 return 0;
1872}
1873
Linus Torvalds1da177e2005-04-16 15:20:36 -07001874static inline int security_inode_rmdir (struct inode *dir,
1875 struct dentry *dentry)
1876{
1877 return 0;
1878}
1879
1880static inline int security_inode_mknod (struct inode *dir,
1881 struct dentry *dentry,
1882 int mode, dev_t dev)
1883{
1884 return 0;
1885}
1886
Linus Torvalds1da177e2005-04-16 15:20:36 -07001887static inline int security_inode_rename (struct inode *old_dir,
1888 struct dentry *old_dentry,
1889 struct inode *new_dir,
1890 struct dentry *new_dentry)
1891{
1892 return 0;
1893}
1894
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895static inline int security_inode_readlink (struct dentry *dentry)
1896{
1897 return 0;
1898}
1899
1900static inline int security_inode_follow_link (struct dentry *dentry,
1901 struct nameidata *nd)
1902{
1903 return 0;
1904}
1905
1906static inline int security_inode_permission (struct inode *inode, int mask,
1907 struct nameidata *nd)
1908{
1909 return 0;
1910}
1911
1912static inline int security_inode_setattr (struct dentry *dentry,
1913 struct iattr *attr)
1914{
1915 return 0;
1916}
1917
1918static inline int security_inode_getattr (struct vfsmount *mnt,
1919 struct dentry *dentry)
1920{
1921 return 0;
1922}
1923
1924static inline void security_inode_delete (struct inode *inode)
1925{ }
1926
1927static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1928 void *value, size_t size, int flags)
1929{
1930 return cap_inode_setxattr(dentry, name, value, size, flags);
1931}
1932
1933static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1934 void *value, size_t size, int flags)
1935{ }
1936
1937static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1938{
1939 return 0;
1940}
1941
1942static inline int security_inode_listxattr (struct dentry *dentry)
1943{
1944 return 0;
1945}
1946
1947static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1948{
1949 return cap_inode_removexattr(dentry, name);
1950}
1951
Serge E. Hallynb5376772007-10-16 23:31:36 -07001952static inline int security_inode_need_killpriv(struct dentry *dentry)
1953{
1954 return cap_inode_need_killpriv(dentry);
1955}
1956
1957static inline int security_inode_killpriv(struct dentry *dentry)
1958{
1959 return cap_inode_killpriv(dentry);
1960}
1961
David P. Quigley42492592008-02-04 22:29:39 -08001962static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001963{
1964 return -EOPNOTSUPP;
1965}
1966
1967static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1968{
1969 return -EOPNOTSUPP;
1970}
1971
1972static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1973{
1974 return 0;
1975}
1976
1977static inline int security_file_permission (struct file *file, int mask)
1978{
1979 return 0;
1980}
1981
1982static inline int security_file_alloc (struct file *file)
1983{
1984 return 0;
1985}
1986
1987static inline void security_file_free (struct file *file)
1988{ }
1989
1990static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1991 unsigned long arg)
1992{
1993 return 0;
1994}
1995
1996static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1997 unsigned long prot,
Eric Parised032182007-06-28 15:55:21 -04001998 unsigned long flags,
1999 unsigned long addr,
2000 unsigned long addr_only)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002001{
2002 return 0;
2003}
2004
2005static inline int security_file_mprotect (struct vm_area_struct *vma,
2006 unsigned long reqprot,
2007 unsigned long prot)
2008{
2009 return 0;
2010}
2011
2012static inline int security_file_lock (struct file *file, unsigned int cmd)
2013{
2014 return 0;
2015}
2016
2017static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2018 unsigned long arg)
2019{
2020 return 0;
2021}
2022
2023static inline int security_file_set_fowner (struct file *file)
2024{
2025 return 0;
2026}
2027
2028static inline int security_file_send_sigiotask (struct task_struct *tsk,
2029 struct fown_struct *fown,
2030 int sig)
2031{
2032 return 0;
2033}
2034
2035static inline int security_file_receive (struct file *file)
2036{
2037 return 0;
2038}
2039
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +09002040static inline int security_dentry_open (struct file *file)
2041{
2042 return 0;
2043}
2044
Linus Torvalds1da177e2005-04-16 15:20:36 -07002045static inline int security_task_create (unsigned long clone_flags)
2046{
2047 return 0;
2048}
2049
2050static inline int security_task_alloc (struct task_struct *p)
2051{
2052 return 0;
2053}
2054
2055static inline void security_task_free (struct task_struct *p)
2056{ }
2057
2058static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2059 int flags)
2060{
2061 return 0;
2062}
2063
2064static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2065 uid_t old_suid, int flags)
2066{
2067 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2068}
2069
2070static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2071 int flags)
2072{
2073 return 0;
2074}
2075
2076static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2077{
2078 return 0;
2079}
2080
2081static inline int security_task_getpgid (struct task_struct *p)
2082{
2083 return 0;
2084}
2085
2086static inline int security_task_getsid (struct task_struct *p)
2087{
2088 return 0;
2089}
2090
David Quigleyf9008e42006-06-30 01:55:46 -07002091static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
2092{ }
2093
Linus Torvalds1da177e2005-04-16 15:20:36 -07002094static inline int security_task_setgroups (struct group_info *group_info)
2095{
2096 return 0;
2097}
2098
2099static inline int security_task_setnice (struct task_struct *p, int nice)
2100{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002101 return cap_task_setnice(p, nice);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002102}
2103
James Morris03e68062006-06-23 02:03:58 -07002104static inline int security_task_setioprio (struct task_struct *p, int ioprio)
2105{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002106 return cap_task_setioprio(p, ioprio);
James Morris03e68062006-06-23 02:03:58 -07002107}
2108
David Quigleya1836a42006-06-30 01:55:49 -07002109static inline int security_task_getioprio (struct task_struct *p)
2110{
2111 return 0;
2112}
2113
Linus Torvalds1da177e2005-04-16 15:20:36 -07002114static inline int security_task_setrlimit (unsigned int resource,
2115 struct rlimit *new_rlim)
2116{
2117 return 0;
2118}
2119
2120static inline int security_task_setscheduler (struct task_struct *p,
2121 int policy,
2122 struct sched_param *lp)
2123{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002124 return cap_task_setscheduler(p, policy, lp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002125}
2126
2127static inline int security_task_getscheduler (struct task_struct *p)
2128{
2129 return 0;
2130}
2131
David Quigley35601542006-06-23 02:04:01 -07002132static inline int security_task_movememory (struct task_struct *p)
2133{
2134 return 0;
2135}
2136
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137static inline int security_task_kill (struct task_struct *p,
David Quigleyf9008e42006-06-30 01:55:46 -07002138 struct siginfo *info, int sig,
2139 u32 secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002140{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002141 return cap_task_kill(p, info, sig, secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002142}
2143
2144static inline int security_task_wait (struct task_struct *p)
2145{
2146 return 0;
2147}
2148
2149static inline int security_task_prctl (int option, unsigned long arg2,
2150 unsigned long arg3,
2151 unsigned long arg4,
2152 unsigned long arg5)
2153{
2154 return 0;
2155}
2156
2157static inline void security_task_reparent_to_init (struct task_struct *p)
2158{
2159 cap_task_reparent_to_init (p);
2160}
2161
2162static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2163{ }
2164
2165static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2166 short flag)
2167{
2168 return 0;
2169}
2170
2171static inline int security_msg_msg_alloc (struct msg_msg * msg)
2172{
2173 return 0;
2174}
2175
2176static inline void security_msg_msg_free (struct msg_msg * msg)
2177{ }
2178
2179static inline int security_msg_queue_alloc (struct msg_queue *msq)
2180{
2181 return 0;
2182}
2183
2184static inline void security_msg_queue_free (struct msg_queue *msq)
2185{ }
2186
2187static inline int security_msg_queue_associate (struct msg_queue * msq,
2188 int msqflg)
2189{
2190 return 0;
2191}
2192
2193static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2194{
2195 return 0;
2196}
2197
2198static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2199 struct msg_msg * msg, int msqflg)
2200{
2201 return 0;
2202}
2203
2204static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2205 struct msg_msg * msg,
2206 struct task_struct * target,
2207 long type, int mode)
2208{
2209 return 0;
2210}
2211
2212static inline int security_shm_alloc (struct shmid_kernel *shp)
2213{
2214 return 0;
2215}
2216
2217static inline void security_shm_free (struct shmid_kernel *shp)
2218{ }
2219
2220static inline int security_shm_associate (struct shmid_kernel * shp,
2221 int shmflg)
2222{
2223 return 0;
2224}
2225
2226static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2227{
2228 return 0;
2229}
2230
2231static inline int security_shm_shmat (struct shmid_kernel * shp,
2232 char __user *shmaddr, int shmflg)
2233{
2234 return 0;
2235}
2236
2237static inline int security_sem_alloc (struct sem_array *sma)
2238{
2239 return 0;
2240}
2241
2242static inline void security_sem_free (struct sem_array *sma)
2243{ }
2244
2245static inline int security_sem_associate (struct sem_array * sma, int semflg)
2246{
2247 return 0;
2248}
2249
2250static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2251{
2252 return 0;
2253}
2254
2255static inline int security_sem_semop (struct sem_array * sma,
2256 struct sembuf * sops, unsigned nsops,
2257 int alter)
2258{
2259 return 0;
2260}
2261
2262static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2263{ }
2264
Al Viro04ff9702007-03-12 16:17:58 +00002265static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002266{
2267 return -EINVAL;
2268}
2269
2270static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2271{
2272 return -EINVAL;
2273}
2274
2275static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2276{
2277 return cap_netlink_send (sk, skb);
2278}
2279
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002280static inline int security_netlink_recv (struct sk_buff *skb, int cap)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281{
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002282 return cap_netlink_recv (skb, cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283}
2284
Randy Dunlaped5a9272006-02-01 03:05:00 -08002285static inline struct dentry *securityfs_create_dir(const char *name,
2286 struct dentry *parent)
2287{
2288 return ERR_PTR(-ENODEV);
2289}
2290
2291static inline struct dentry *securityfs_create_file(const char *name,
2292 mode_t mode,
2293 struct dentry *parent,
2294 void *data,
Jan Engelhardt1996a102008-01-23 00:02:58 +01002295 const struct file_operations *fops)
Randy Dunlaped5a9272006-02-01 03:05:00 -08002296{
2297 return ERR_PTR(-ENODEV);
2298}
2299
2300static inline void securityfs_remove(struct dentry *dentry)
2301{
2302}
2303
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002304static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2305{
2306 return -EOPNOTSUPP;
2307}
2308
David Howells63cb3442008-01-15 23:47:35 +00002309static inline int security_secctx_to_secid(char *secdata,
2310 u32 seclen,
2311 u32 *secid)
2312{
2313 return -EOPNOTSUPP;
2314}
2315
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002316static inline void security_release_secctx(char *secdata, u32 seclen)
2317{
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002318}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319#endif /* CONFIG_SECURITY */
2320
2321#ifdef CONFIG_SECURITY_NETWORK
Linus Torvalds1da177e2005-04-16 15:20:36 -07002322
James Morris20510f22007-10-16 23:31:32 -07002323int security_unix_stream_connect(struct socket *sock, struct socket *other,
2324 struct sock *newsk);
2325int security_unix_may_send(struct socket *sock, struct socket *other);
2326int security_socket_create(int family, int type, int protocol, int kern);
2327int security_socket_post_create(struct socket *sock, int family,
2328 int type, int protocol, int kern);
2329int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
2330int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
2331int security_socket_listen(struct socket *sock, int backlog);
2332int security_socket_accept(struct socket *sock, struct socket *newsock);
2333void security_socket_post_accept(struct socket *sock, struct socket *newsock);
2334int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
2335int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
2336 int size, int flags);
2337int security_socket_getsockname(struct socket *sock);
2338int security_socket_getpeername(struct socket *sock);
2339int security_socket_getsockopt(struct socket *sock, int level, int optname);
2340int security_socket_setsockopt(struct socket *sock, int level, int optname);
2341int security_socket_shutdown(struct socket *sock, int how);
2342int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
2343int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2344 int __user *optlen, unsigned len);
2345int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
2346int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
2347void security_sk_free(struct sock *sk);
2348void security_sk_clone(const struct sock *sk, struct sock *newsk);
2349void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
2350void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
2351void security_sock_graft(struct sock*sk, struct socket *parent);
2352int security_inet_conn_request(struct sock *sk,
2353 struct sk_buff *skb, struct request_sock *req);
2354void security_inet_csk_clone(struct sock *newsk,
2355 const struct request_sock *req);
2356void security_inet_conn_established(struct sock *sk,
2357 struct sk_buff *skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002358
Linus Torvalds1da177e2005-04-16 15:20:36 -07002359#else /* CONFIG_SECURITY_NETWORK */
2360static inline int security_unix_stream_connect(struct socket * sock,
Venkat Yekkirala6b877692006-11-08 17:04:09 -06002361 struct socket * other,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362 struct sock * newsk)
2363{
2364 return 0;
2365}
2366
2367static inline int security_unix_may_send(struct socket * sock,
2368 struct socket * other)
2369{
2370 return 0;
2371}
2372
2373static inline int security_socket_create (int family, int type,
2374 int protocol, int kern)
2375{
2376 return 0;
2377}
2378
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07002379static inline int security_socket_post_create(struct socket * sock,
2380 int family,
2381 int type,
2382 int protocol, int kern)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002383{
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07002384 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385}
2386
2387static inline int security_socket_bind(struct socket * sock,
2388 struct sockaddr * address,
2389 int addrlen)
2390{
2391 return 0;
2392}
2393
2394static inline int security_socket_connect(struct socket * sock,
2395 struct sockaddr * address,
2396 int addrlen)
2397{
2398 return 0;
2399}
2400
2401static inline int security_socket_listen(struct socket * sock, int backlog)
2402{
2403 return 0;
2404}
2405
2406static inline int security_socket_accept(struct socket * sock,
2407 struct socket * newsock)
2408{
2409 return 0;
2410}
2411
2412static inline void security_socket_post_accept(struct socket * sock,
2413 struct socket * newsock)
2414{
2415}
2416
2417static inline int security_socket_sendmsg(struct socket * sock,
2418 struct msghdr * msg, int size)
2419{
2420 return 0;
2421}
2422
2423static inline int security_socket_recvmsg(struct socket * sock,
2424 struct msghdr * msg, int size,
2425 int flags)
2426{
2427 return 0;
2428}
2429
2430static inline int security_socket_getsockname(struct socket * sock)
2431{
2432 return 0;
2433}
2434
2435static inline int security_socket_getpeername(struct socket * sock)
2436{
2437 return 0;
2438}
2439
2440static inline int security_socket_getsockopt(struct socket * sock,
2441 int level, int optname)
2442{
2443 return 0;
2444}
2445
2446static inline int security_socket_setsockopt(struct socket * sock,
2447 int level, int optname)
2448{
2449 return 0;
2450}
2451
2452static inline int security_socket_shutdown(struct socket * sock, int how)
2453{
2454 return 0;
2455}
2456static inline int security_sock_rcv_skb (struct sock * sk,
2457 struct sk_buff * skb)
2458{
2459 return 0;
2460}
2461
Catherine Zhang2c7946a2006-03-20 22:41:23 -08002462static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2463 int __user *optlen, unsigned len)
2464{
2465 return -ENOPROTOOPT;
2466}
2467
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002468static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002469{
2470 return -ENOPROTOOPT;
2471}
2472
Al Virodd0fc662005-10-07 07:46:04 +01002473static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002474{
2475 return 0;
2476}
2477
2478static inline void security_sk_free(struct sock *sk)
2479{
2480}
Trent Jaegerdf718372005-12-13 23:12:27 -08002481
Venkat Yekkirala892c1412006-08-04 23:08:56 -07002482static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2483{
2484}
2485
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002486static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
Trent Jaegerdf718372005-12-13 23:12:27 -08002487{
Trent Jaegerdf718372005-12-13 23:12:27 -08002488}
Venkat Yekkirala4237c752006-07-24 23:32:50 -07002489
2490static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2491{
2492}
2493
2494static inline void security_sock_graft(struct sock* sk, struct socket *parent)
2495{
2496}
2497
2498static inline int security_inet_conn_request(struct sock *sk,
2499 struct sk_buff *skb, struct request_sock *req)
2500{
2501 return 0;
2502}
2503
2504static inline void security_inet_csk_clone(struct sock *newsk,
2505 const struct request_sock *req)
2506{
2507}
Venkat Yekkirala6b877692006-11-08 17:04:09 -06002508
2509static inline void security_inet_conn_established(struct sock *sk,
2510 struct sk_buff *skb)
2511{
2512}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002513#endif /* CONFIG_SECURITY_NETWORK */
2514
Trent Jaegerdf718372005-12-13 23:12:27 -08002515#ifdef CONFIG_SECURITY_NETWORK_XFRM
Venkat Yekkiralacb969f02006-07-24 23:32:20 -07002516
James Morris20510f22007-10-16 23:31:32 -07002517int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
2518int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new);
2519void security_xfrm_policy_free(struct xfrm_policy *xp);
2520int security_xfrm_policy_delete(struct xfrm_policy *xp);
2521int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
2522int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2523 struct xfrm_sec_ctx *polsec, u32 secid);
2524int security_xfrm_state_delete(struct xfrm_state *x);
2525void security_xfrm_state_free(struct xfrm_state *x);
2526int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
2527int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2528 struct xfrm_policy *xp, struct flowi *fl);
2529int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
2530void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
Trent Jaegerdf718372005-12-13 23:12:27 -08002531
Trent Jaegerdf718372005-12-13 23:12:27 -08002532#else /* CONFIG_SECURITY_NETWORK_XFRM */
James Morris20510f22007-10-16 23:31:32 -07002533
Trent Jaegerdf718372005-12-13 23:12:27 -08002534static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
2535{
2536 return 0;
2537}
2538
2539static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
2540{
2541 return 0;
2542}
2543
2544static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
2545{
2546}
2547
Catherine Zhangc8c05a82006-06-08 23:39:49 -07002548static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
2549{
2550 return 0;
2551}
2552
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002553static inline int security_xfrm_state_alloc(struct xfrm_state *x,
2554 struct xfrm_user_sec_ctx *sec_ctx)
2555{
2556 return 0;
2557}
2558
2559static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2560 struct xfrm_sec_ctx *polsec, u32 secid)
Trent Jaegerdf718372005-12-13 23:12:27 -08002561{
2562 return 0;
2563}
2564
2565static inline void security_xfrm_state_free(struct xfrm_state *x)
2566{
2567}
2568
David S. Miller6f68dc32006-06-08 23:58:52 -07002569static inline int security_xfrm_state_delete(struct xfrm_state *x)
Catherine Zhangc8c05a82006-06-08 23:39:49 -07002570{
2571 return 0;
2572}
2573
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002574static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
Trent Jaegerdf718372005-12-13 23:12:27 -08002575{
2576 return 0;
2577}
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002578
2579static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2580 struct xfrm_policy *xp, struct flowi *fl)
2581{
2582 return 1;
2583}
2584
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002585static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002586{
2587 return 0;
2588}
2589
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002590static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
2591{
2592}
2593
Trent Jaegerdf718372005-12-13 23:12:27 -08002594#endif /* CONFIG_SECURITY_NETWORK_XFRM */
2595
David Howells29db9192005-10-30 15:02:44 -08002596#ifdef CONFIG_KEYS
2597#ifdef CONFIG_SECURITY
David Howells29db9192005-10-30 15:02:44 -08002598
James Morris20510f22007-10-16 23:31:32 -07002599int security_key_alloc(struct key *key, struct task_struct *tsk, unsigned long flags);
2600void security_key_free(struct key *key);
2601int security_key_permission(key_ref_t key_ref,
2602 struct task_struct *context, key_perm_t perm);
David Howells29db9192005-10-30 15:02:44 -08002603
2604#else
2605
Michael LeMayd7200242006-06-22 14:47:17 -07002606static inline int security_key_alloc(struct key *key,
David Howells7e047ef2006-06-26 00:24:50 -07002607 struct task_struct *tsk,
2608 unsigned long flags)
David Howells29db9192005-10-30 15:02:44 -08002609{
2610 return 0;
2611}
2612
2613static inline void security_key_free(struct key *key)
2614{
2615}
2616
2617static inline int security_key_permission(key_ref_t key_ref,
2618 struct task_struct *context,
2619 key_perm_t perm)
2620{
2621 return 0;
2622}
2623
2624#endif
2625#endif /* CONFIG_KEYS */
2626
Linus Torvalds1da177e2005-04-16 15:20:36 -07002627#endif /* ! __LINUX_SECURITY_H */
2628