blob: 9d289e726fd88131fba5d10628e5cedf71135481 [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 -070043/*
44 * Bounding set
45 */
46extern kernel_cap_t cap_bset;
47
48extern unsigned securebits;
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050struct ctl_table;
51
52/*
53 * These functions are in security/capability.c and are used
54 * as the default capabilities functions
55 */
56extern int cap_capable (struct task_struct *tsk, int cap);
57extern int cap_settime (struct timespec *ts, struct timezone *tz);
58extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
59extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
60extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
61extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
62extern int cap_bprm_set_security (struct linux_binprm *bprm);
63extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
64extern int cap_bprm_secureexec(struct linux_binprm *bprm);
65extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
66extern int cap_inode_removexattr(struct dentry *dentry, char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -070067extern int cap_inode_need_killpriv(struct dentry *dentry);
68extern int cap_inode_killpriv(struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
70extern void cap_task_reparent_to_init (struct task_struct *p);
Serge E. Hallynb5376772007-10-16 23:31:36 -070071extern int cap_task_kill(struct task_struct *p, struct siginfo *info, int sig, u32 secid);
72extern int cap_task_setscheduler (struct task_struct *p, int policy, struct sched_param *lp);
73extern int cap_task_setioprio (struct task_struct *p, int ioprio);
74extern int cap_task_setnice (struct task_struct *p, int nice);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075extern int cap_syslog (int type);
James Morris20510f22007-10-16 23:31:32 -070076extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78struct msghdr;
79struct sk_buff;
80struct sock;
81struct sockaddr;
82struct socket;
Trent Jaegerdf718372005-12-13 23:12:27 -080083struct flowi;
84struct dst_entry;
85struct xfrm_selector;
86struct xfrm_policy;
87struct xfrm_state;
88struct xfrm_user_sec_ctx;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
Darrel Goeddelc7bdb542006-06-27 13:26:11 -070091extern int cap_netlink_recv(struct sk_buff *skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Eric Parised032182007-06-28 15:55:21 -040093extern unsigned long mmap_min_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094/*
95 * Values used in the task_security_ops calls
96 */
97/* setuid or setgid, id0 == uid or gid */
98#define LSM_SETID_ID 1
99
100/* setreuid or setregid, id0 == real, id1 == eff */
101#define LSM_SETID_RE 2
102
103/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
104#define LSM_SETID_RES 4
105
106/* setfsuid or setfsgid, id0 == fsuid or fsgid */
107#define LSM_SETID_FS 8
108
109/* forward declares to avoid warnings */
110struct nfsctl_arg;
111struct sched_param;
112struct swap_info_struct;
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700113struct request_sock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
115/* bprm_apply_creds unsafe reasons */
116#define LSM_UNSAFE_SHARE 1
117#define LSM_UNSAFE_PTRACE 2
118#define LSM_UNSAFE_PTRACE_CAP 4
119
120#ifdef CONFIG_SECURITY
121
122/**
123 * struct security_operations - main security structure
124 *
125 * Security hooks for program execution operations.
126 *
127 * @bprm_alloc_security:
128 * Allocate and attach a security structure to the @bprm->security field.
129 * The security field is initialized to NULL when the bprm structure is
130 * allocated.
131 * @bprm contains the linux_binprm structure to be modified.
132 * Return 0 if operation was successful.
133 * @bprm_free_security:
134 * @bprm contains the linux_binprm structure to be modified.
135 * Deallocate and clear the @bprm->security field.
136 * @bprm_apply_creds:
137 * Compute and set the security attributes of a process being transformed
138 * by an execve operation based on the old attributes (current->security)
139 * and the information saved in @bprm->security by the set_security hook.
140 * Since this hook function (and its caller) are void, this hook can not
141 * return an error. However, it can leave the security attributes of the
142 * process unchanged if an access failure occurs at this point.
143 * bprm_apply_creds is called under task_lock. @unsafe indicates various
144 * reasons why it may be unsafe to change security state.
145 * @bprm contains the linux_binprm structure.
146 * @bprm_post_apply_creds:
147 * Runs after bprm_apply_creds with the task_lock dropped, so that
148 * functions which cannot be called safely under the task_lock can
149 * be used. This hook is a good place to perform state changes on
150 * the process such as closing open file descriptors to which access
151 * is no longer granted if the attributes were changed.
152 * Note that a security module might need to save state between
153 * bprm_apply_creds and bprm_post_apply_creds to store the decision
154 * on whether the process may proceed.
155 * @bprm contains the linux_binprm structure.
156 * @bprm_set_security:
157 * Save security information in the bprm->security field, typically based
158 * on information about the bprm->file, for later use by the apply_creds
159 * hook. This hook may also optionally check permissions (e.g. for
160 * transitions between security domains).
161 * This hook may be called multiple times during a single execve, e.g. for
162 * interpreters. The hook can tell whether it has already been called by
163 * checking to see if @bprm->security is non-NULL. If so, then the hook
164 * may decide either to retain the security information saved earlier or
165 * to replace it.
166 * @bprm contains the linux_binprm structure.
167 * Return 0 if the hook is successful and permission is granted.
168 * @bprm_check_security:
169 * This hook mediates the point when a search for a binary handler will
170 * begin. It allows a check the @bprm->security value which is set in
171 * the preceding set_security call. The primary difference from
172 * set_security is that the argv list and envp list are reliably
173 * available in @bprm. This hook may be called multiple times
174 * during a single execve; and in each pass set_security is called
175 * first.
176 * @bprm contains the linux_binprm structure.
177 * Return 0 if the hook is successful and permission is granted.
178 * @bprm_secureexec:
179 * Return a boolean value (0 or 1) indicating whether a "secure exec"
180 * is required. The flag is passed in the auxiliary table
181 * on the initial stack to the ELF interpreter to indicate whether libc
182 * should enable secure mode.
183 * @bprm contains the linux_binprm structure.
184 *
185 * Security hooks for filesystem operations.
186 *
187 * @sb_alloc_security:
188 * Allocate and attach a security structure to the sb->s_security field.
189 * The s_security field is initialized to NULL when the structure is
190 * allocated.
191 * @sb contains the super_block structure to be modified.
192 * Return 0 if operation was successful.
193 * @sb_free_security:
194 * Deallocate and clear the sb->s_security field.
195 * @sb contains the super_block structure to be modified.
196 * @sb_statfs:
David Howells726c3342006-06-23 02:02:58 -0700197 * Check permission before obtaining filesystem statistics for the @mnt
198 * mountpoint.
199 * @dentry is a handle on the superblock for the filesystem.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 * Return 0 if permission is granted.
201 * @sb_mount:
202 * Check permission before an object specified by @dev_name is mounted on
203 * the mount point named by @nd. For an ordinary mount, @dev_name
204 * identifies a device if the file system type requires a device. For a
205 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
206 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
207 * pathname of the object being mounted.
208 * @dev_name contains the name for object being mounted.
209 * @nd contains the nameidata structure for mount point object.
210 * @type contains the filesystem type.
211 * @flags contains the mount flags.
212 * @data contains the filesystem-specific data.
213 * Return 0 if permission is granted.
214 * @sb_copy_data:
215 * Allow mount option data to be copied prior to parsing by the filesystem,
216 * so that the security module can extract security-specific mount
217 * options cleanly (a filesystem may modify the data e.g. with strsep()).
218 * This also allows the original mount data to be stripped of security-
219 * specific options to avoid having to make filesystems aware of them.
220 * @type the type of filesystem being mounted.
221 * @orig the original mount data copied from userspace.
222 * @copy copied data which will be passed to the security module.
223 * Returns 0 if the copy was successful.
224 * @sb_check_sb:
225 * Check permission before the device with superblock @mnt->sb is mounted
226 * on the mount point named by @nd.
227 * @mnt contains the vfsmount for device being mounted.
228 * @nd contains the nameidata object for the mount point.
229 * Return 0 if permission is granted.
230 * @sb_umount:
231 * Check permission before the @mnt file system is unmounted.
232 * @mnt contains the mounted file system.
233 * @flags contains the unmount flags, e.g. MNT_FORCE.
234 * Return 0 if permission is granted.
235 * @sb_umount_close:
236 * Close any files in the @mnt mounted filesystem that are held open by
237 * the security module. This hook is called during an umount operation
238 * prior to checking whether the filesystem is still busy.
239 * @mnt contains the mounted filesystem.
240 * @sb_umount_busy:
241 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
242 * any files that were closed by umount_close. This hook is called during
243 * an umount operation if the umount fails after a call to the
244 * umount_close hook.
245 * @mnt contains the mounted filesystem.
246 * @sb_post_remount:
247 * Update the security module's state when a filesystem is remounted.
248 * This hook is only called if the remount was successful.
249 * @mnt contains the mounted file system.
250 * @flags contains the new filesystem flags.
251 * @data contains the filesystem-specific data.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 * @sb_post_addmount:
253 * Update the security module's state when a filesystem is mounted.
254 * This hook is called any time a mount is successfully grafetd to
255 * the tree.
256 * @mnt contains the mounted filesystem.
257 * @mountpoint_nd contains the nameidata structure for the mount point.
258 * @sb_pivotroot:
259 * Check permission before pivoting the root filesystem.
260 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
261 * @new_nd contains the nameidata structure for the new root (new_root).
262 * Return 0 if permission is granted.
263 * @sb_post_pivotroot:
264 * Update module state after a successful pivot.
265 * @old_nd contains the nameidata structure for the old root.
266 * @new_nd contains the nameidata structure for the new root.
Eric Parisc9180a52007-11-30 13:00:35 -0500267 * @sb_get_mnt_opts:
268 * Get the security relevant mount options used for a superblock
269 * @sb the superblock to get security mount options from
270 * @mount_options array for pointers to mount options
271 * @mount_flags array of ints specifying what each mount options is
272 * @num_opts number of options in the arrays
273 * @sb_set_mnt_opts:
274 * Set the security relevant mount options used for a superblock
275 * @sb the superblock to set security mount options for
276 * @mount_options array for pointers to mount options
277 * @mount_flags array of ints specifying what each mount options is
278 * @num_opts number of options in the arrays
279 * @sb_clone_mnt_opts:
280 * Copy all security options from a given superblock to another
281 * @oldsb old superblock which contain information to clone
282 * @newsb new superblock which needs filled in
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 *
284 * Security hooks for inode operations.
285 *
286 * @inode_alloc_security:
287 * Allocate and attach a security structure to @inode->i_security. The
288 * i_security field is initialized to NULL when the inode structure is
289 * allocated.
290 * @inode contains the inode structure.
291 * Return 0 if operation was successful.
292 * @inode_free_security:
293 * @inode contains the inode structure.
294 * Deallocate the inode security structure and set @inode->i_security to
295 * NULL.
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700296 * @inode_init_security:
297 * Obtain the security attribute name suffix and value to set on a newly
298 * created inode and set up the incore security field for the new inode.
299 * This hook is called by the fs code as part of the inode creation
300 * transaction and provides for atomic labeling of the inode, unlike
301 * the post_create/mkdir/... hooks called by the VFS. The hook function
302 * is expected to allocate the name and value via kmalloc, with the caller
303 * being responsible for calling kfree after using them.
304 * If the security module does not use security attributes or does
305 * not wish to put a security attribute on this particular inode,
306 * then it should return -EOPNOTSUPP to skip this processing.
307 * @inode contains the inode structure of the newly created inode.
308 * @dir contains the inode structure of the parent directory.
309 * @name will be set to the allocated name suffix (e.g. selinux).
310 * @value will be set to the allocated attribute value.
311 * @len will be set to the length of the value.
312 * Returns 0 if @name and @value have been successfully set,
313 * -EOPNOTSUPP if no security attribute is needed, or
314 * -ENOMEM on memory allocation failure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 * @inode_create:
316 * Check permission to create a regular file.
317 * @dir contains inode structure of the parent of the new file.
318 * @dentry contains the dentry structure for the file to be created.
319 * @mode contains the file mode of the file to be created.
320 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 * @inode_link:
322 * Check permission before creating a new hard link to a file.
323 * @old_dentry contains the dentry structure for an existing link to the file.
324 * @dir contains the inode structure of the parent directory of the new link.
325 * @new_dentry contains the dentry structure for the new link.
326 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 * @inode_unlink:
328 * Check the permission to remove a hard link to a file.
329 * @dir contains the inode structure of parent directory of the file.
330 * @dentry contains the dentry structure for file to be unlinked.
331 * Return 0 if permission is granted.
332 * @inode_symlink:
333 * Check the permission to create a symbolic link to a file.
334 * @dir contains the inode structure of parent directory of the symbolic link.
335 * @dentry contains the dentry structure of the symbolic link.
336 * @old_name contains the pathname of file.
337 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 * @inode_mkdir:
339 * Check permissions to create a new directory in the existing directory
340 * associated with inode strcture @dir.
341 * @dir containst the inode structure of parent of the directory to be created.
342 * @dentry contains the dentry structure of new directory.
343 * @mode contains the mode of new directory.
344 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 * @inode_rmdir:
346 * Check the permission to remove a directory.
347 * @dir contains the inode structure of parent of the directory to be removed.
348 * @dentry contains the dentry structure of directory to be removed.
349 * Return 0 if permission is granted.
350 * @inode_mknod:
351 * Check permissions when creating a special file (or a socket or a fifo
352 * file created via the mknod system call). Note that if mknod operation
353 * is being done for a regular file, then the create hook will be called
354 * and not this hook.
355 * @dir contains the inode structure of parent of the new file.
356 * @dentry contains the dentry structure of the new file.
357 * @mode contains the mode of the new file.
Michael Opdenacker59c51592007-05-09 08:57:56 +0200358 * @dev contains the device number.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 * @inode_rename:
361 * Check for permission to rename a file or directory.
362 * @old_dir contains the inode structure for parent of the old link.
363 * @old_dentry contains the dentry structure of the old link.
364 * @new_dir contains the inode structure for parent of the new link.
365 * @new_dentry contains the dentry structure of the new link.
366 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 * @inode_readlink:
368 * Check the permission to read the symbolic link.
369 * @dentry contains the dentry structure for the file link.
370 * Return 0 if permission is granted.
371 * @inode_follow_link:
372 * Check permission to follow a symbolic link when looking up a pathname.
373 * @dentry contains the dentry structure for the link.
374 * @nd contains the nameidata structure for the parent directory.
375 * Return 0 if permission is granted.
376 * @inode_permission:
377 * Check permission before accessing an inode. This hook is called by the
378 * existing Linux permission function, so a security module can use it to
379 * provide additional checking for existing Linux permission checks.
380 * Notice that this hook is called when a file is opened (as well as many
381 * other operations), whereas the file_security_ops permission hook is
382 * called when the actual read/write operations are performed.
383 * @inode contains the inode structure to check.
384 * @mask contains the permission mask.
385 * @nd contains the nameidata (may be NULL).
386 * Return 0 if permission is granted.
387 * @inode_setattr:
388 * Check permission before setting file attributes. Note that the kernel
389 * call to notify_change is performed from several locations, whenever
390 * file attributes change (such as when a file is truncated, chown/chmod
391 * operations, transferring disk quotas, etc).
392 * @dentry contains the dentry structure for the file.
393 * @attr is the iattr structure containing the new file attributes.
394 * Return 0 if permission is granted.
395 * @inode_getattr:
396 * Check permission before obtaining file attributes.
397 * @mnt is the vfsmount where the dentry was looked up
398 * @dentry contains the dentry structure for the file.
399 * Return 0 if permission is granted.
400 * @inode_delete:
401 * @inode contains the inode structure for deleted inode.
402 * This hook is called when a deleted inode is released (i.e. an inode
403 * with no hard links has its use count drop to zero). A security module
404 * can use this hook to release any persistent label associated with the
405 * inode.
406 * @inode_setxattr:
407 * Check permission before setting the extended attributes
408 * @value identified by @name for @dentry.
409 * Return 0 if permission is granted.
410 * @inode_post_setxattr:
411 * Update inode security field after successful setxattr operation.
412 * @value identified by @name for @dentry.
413 * @inode_getxattr:
414 * Check permission before obtaining the extended attributes
415 * identified by @name for @dentry.
416 * Return 0 if permission is granted.
417 * @inode_listxattr:
418 * Check permission before obtaining the list of extended attribute
419 * names for @dentry.
420 * Return 0 if permission is granted.
421 * @inode_removexattr:
422 * Check permission before removing the extended attribute
423 * identified by @name for @dentry.
424 * Return 0 if permission is granted.
425 * @inode_getsecurity:
David P. Quigley42492592008-02-04 22:29:39 -0800426 * Retrieve a copy of the extended attribute representation of the
427 * security label associated with @name for @inode via @buffer. Note that
428 * @name is the remainder of the attribute name after the security prefix
429 * has been removed. @alloc is used to specify of the call should return a
430 * value via the buffer or just the value length Return size of buffer on
431 * success.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 * @inode_setsecurity:
433 * Set the security label associated with @name for @inode from the
434 * extended attribute value @value. @size indicates the size of the
435 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
436 * Note that @name is the remainder of the attribute name after the
437 * security. prefix has been removed.
438 * Return 0 on success.
439 * @inode_listsecurity:
440 * Copy the extended attribute names for the security labels
441 * associated with @inode into @buffer. The maximum size of @buffer
442 * is specified by @buffer_size. @buffer may be NULL to request
443 * the size of the buffer required.
444 * Returns number of bytes used/required on success.
Serge E. Hallynb5376772007-10-16 23:31:36 -0700445 * @inode_need_killpriv:
446 * Called when an inode has been changed.
447 * @dentry is the dentry being changed.
448 * Return <0 on error to abort the inode change operation.
449 * Return 0 if inode_killpriv does not need to be called.
450 * Return >0 if inode_killpriv does need to be called.
451 * @inode_killpriv:
452 * The setuid bit is being removed. Remove similar security labels.
453 * Called with the dentry->d_inode->i_mutex held.
454 * @dentry is the dentry being changed.
455 * Return 0 on success. If error is returned, then the operation
456 * causing setuid bit removal is failed.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 *
458 * Security hooks for file operations
459 *
460 * @file_permission:
461 * Check file permissions before accessing an open file. This hook is
462 * called by various operations that read or write files. A security
463 * module can use this hook to perform additional checking on these
464 * operations, e.g. to revalidate permissions on use to support privilege
465 * bracketing or policy changes. Notice that this hook is used when the
466 * actual read/write operations are performed, whereas the
467 * inode_security_ops hook is called when a file is opened (as well as
468 * many other operations).
469 * Caveat: Although this hook can be used to revalidate permissions for
470 * various system call operations that read or write files, it does not
471 * address the revalidation of permissions for memory-mapped files.
472 * Security modules must handle this separately if they need such
473 * revalidation.
474 * @file contains the file structure being accessed.
475 * @mask contains the requested permissions.
476 * Return 0 if permission is granted.
477 * @file_alloc_security:
478 * Allocate and attach a security structure to the file->f_security field.
479 * The security field is initialized to NULL when the structure is first
480 * created.
481 * @file contains the file structure to secure.
482 * Return 0 if the hook is successful and permission is granted.
483 * @file_free_security:
484 * Deallocate and free any security structures stored in file->f_security.
485 * @file contains the file structure being modified.
486 * @file_ioctl:
487 * @file contains the file structure.
488 * @cmd contains the operation to perform.
489 * @arg contains the operational arguments.
490 * Check permission for an ioctl operation on @file. Note that @arg can
491 * sometimes represents a user space pointer; in other cases, it may be a
492 * simple integer value. When @arg represents a user space pointer, it
493 * should never be used by the security module.
494 * Return 0 if permission is granted.
495 * @file_mmap :
496 * Check permissions for a mmap operation. The @file may be NULL, e.g.
497 * if mapping anonymous memory.
498 * @file contains the file structure for file to map (may be NULL).
499 * @reqprot contains the protection requested by the application.
500 * @prot contains the protection that will be applied by the kernel.
501 * @flags contains the operational flags.
502 * Return 0 if permission is granted.
503 * @file_mprotect:
504 * Check permissions before changing memory access permissions.
505 * @vma contains the memory region to modify.
506 * @reqprot contains the protection requested by the application.
507 * @prot contains the protection that will be applied by the kernel.
508 * Return 0 if permission is granted.
509 * @file_lock:
510 * Check permission before performing file locking operations.
511 * Note: this hook mediates both flock and fcntl style locks.
512 * @file contains the file structure.
513 * @cmd contains the posix-translated lock operation to perform
514 * (e.g. F_RDLCK, F_WRLCK).
515 * Return 0 if permission is granted.
516 * @file_fcntl:
517 * Check permission before allowing the file operation specified by @cmd
518 * from being performed on the file @file. Note that @arg can sometimes
519 * represents a user space pointer; in other cases, it may be a simple
520 * integer value. When @arg represents a user space pointer, it should
521 * never be used by the security module.
522 * @file contains the file structure.
523 * @cmd contains the operation to be performed.
524 * @arg contains the operational arguments.
525 * Return 0 if permission is granted.
526 * @file_set_fowner:
527 * Save owner security information (typically from current->security) in
528 * file->f_security for later use by the send_sigiotask hook.
529 * @file contains the file structure to update.
530 * Return 0 on success.
531 * @file_send_sigiotask:
532 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
533 * process @tsk. Note that this hook is sometimes called from interrupt.
534 * Note that the fown_struct, @fown, is never outside the context of a
535 * struct file, so the file structure (and associated security information)
536 * can always be obtained:
Robert P. J. Dayb385a142007-02-10 01:46:25 -0800537 * container_of(fown, struct file, f_owner)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 * @tsk contains the structure of task receiving signal.
539 * @fown contains the file owner information.
540 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
541 * Return 0 if permission is granted.
542 * @file_receive:
543 * This hook allows security modules to control the ability of a process
544 * to receive an open file descriptor via socket IPC.
545 * @file contains the file structure being received.
546 * Return 0 if permission is granted.
547 *
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +0900548 * Security hook for dentry
549 *
550 * @dentry_open
551 * Save open-time permission checking state for later use upon
552 * file_permission, and recheck access if anything has changed
553 * since inode_permission.
554 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 * Security hooks for task operations.
556 *
557 * @task_create:
558 * Check permission before creating a child process. See the clone(2)
559 * manual page for definitions of the @clone_flags.
560 * @clone_flags contains the flags indicating what should be shared.
561 * Return 0 if permission is granted.
562 * @task_alloc_security:
563 * @p contains the task_struct for child process.
564 * Allocate and attach a security structure to the p->security field. The
565 * security field is initialized to NULL when the task structure is
566 * allocated.
567 * Return 0 if operation was successful.
568 * @task_free_security:
569 * @p contains the task_struct for process.
570 * Deallocate and clear the p->security field.
571 * @task_setuid:
572 * Check permission before setting one or more of the user identity
573 * attributes of the current process. The @flags parameter indicates
574 * which of the set*uid system calls invoked this hook and how to
575 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
576 * definitions at the beginning of this file for the @flags values and
577 * their meanings.
578 * @id0 contains a uid.
579 * @id1 contains a uid.
580 * @id2 contains a uid.
581 * @flags contains one of the LSM_SETID_* values.
582 * Return 0 if permission is granted.
583 * @task_post_setuid:
584 * Update the module's state after setting one or more of the user
585 * identity attributes of the current process. The @flags parameter
586 * indicates which of the set*uid system calls invoked this hook. If
587 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
588 * parameters are not used.
589 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
590 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
591 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
592 * @flags contains one of the LSM_SETID_* values.
593 * Return 0 on success.
594 * @task_setgid:
595 * Check permission before setting one or more of the group identity
596 * attributes of the current process. The @flags parameter indicates
597 * which of the set*gid system calls invoked this hook and how to
598 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
599 * definitions at the beginning of this file for the @flags values and
600 * their meanings.
601 * @id0 contains a gid.
602 * @id1 contains a gid.
603 * @id2 contains a gid.
604 * @flags contains one of the LSM_SETID_* values.
605 * Return 0 if permission is granted.
606 * @task_setpgid:
607 * Check permission before setting the process group identifier of the
608 * process @p to @pgid.
609 * @p contains the task_struct for process being modified.
610 * @pgid contains the new pgid.
611 * Return 0 if permission is granted.
612 * @task_getpgid:
613 * Check permission before getting the process group identifier of the
614 * process @p.
615 * @p contains the task_struct for the process.
616 * Return 0 if permission is granted.
617 * @task_getsid:
618 * Check permission before getting the session identifier of the process
619 * @p.
620 * @p contains the task_struct for the process.
621 * Return 0 if permission is granted.
David Quigleyf9008e42006-06-30 01:55:46 -0700622 * @task_getsecid:
623 * Retrieve the security identifier of the process @p.
624 * @p contains the task_struct for the process and place is into @secid.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 * @task_setgroups:
626 * Check permission before setting the supplementary group set of the
627 * current process.
628 * @group_info contains the new group information.
629 * Return 0 if permission is granted.
630 * @task_setnice:
631 * Check permission before setting the nice value of @p to @nice.
632 * @p contains the task_struct of process.
633 * @nice contains the new nice value.
634 * Return 0 if permission is granted.
James Morris03e68062006-06-23 02:03:58 -0700635 * @task_setioprio
636 * Check permission before setting the ioprio value of @p to @ioprio.
637 * @p contains the task_struct of process.
638 * @ioprio contains the new ioprio value
639 * Return 0 if permission is granted.
David Quigleya1836a42006-06-30 01:55:49 -0700640 * @task_getioprio
641 * Check permission before getting the ioprio value of @p.
642 * @p contains the task_struct of process.
643 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 * @task_setrlimit:
645 * Check permission before setting the resource limits of the current
646 * process for @resource to @new_rlim. The old resource limit values can
647 * be examined by dereferencing (current->signal->rlim + resource).
648 * @resource contains the resource whose limit is being set.
649 * @new_rlim contains the new limits for @resource.
650 * Return 0 if permission is granted.
651 * @task_setscheduler:
652 * Check permission before setting scheduling policy and/or parameters of
653 * process @p based on @policy and @lp.
654 * @p contains the task_struct for process.
655 * @policy contains the scheduling policy.
656 * @lp contains the scheduling parameters.
657 * Return 0 if permission is granted.
658 * @task_getscheduler:
659 * Check permission before obtaining scheduling information for process
660 * @p.
661 * @p contains the task_struct for process.
662 * Return 0 if permission is granted.
David Quigley35601542006-06-23 02:04:01 -0700663 * @task_movememory
664 * Check permission before moving memory owned by process @p.
665 * @p contains the task_struct for process.
666 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 * @task_kill:
668 * Check permission before sending signal @sig to @p. @info can be NULL,
669 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
670 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
671 * from the kernel and should typically be permitted.
672 * SIGIO signals are handled separately by the send_sigiotask hook in
673 * file_security_ops.
674 * @p contains the task_struct for process.
675 * @info contains the signal information.
676 * @sig contains the signal value.
David Quigleyf9008e42006-06-30 01:55:46 -0700677 * @secid contains the sid of the process where the signal originated
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 * Return 0 if permission is granted.
679 * @task_wait:
680 * Check permission before allowing a process to reap a child process @p
681 * and collect its status information.
682 * @p contains the task_struct for process.
683 * Return 0 if permission is granted.
684 * @task_prctl:
685 * Check permission before performing a process control operation on the
686 * current process.
687 * @option contains the operation.
688 * @arg2 contains a argument.
689 * @arg3 contains a argument.
690 * @arg4 contains a argument.
691 * @arg5 contains a argument.
692 * Return 0 if permission is granted.
693 * @task_reparent_to_init:
694 * Set the security attributes in @p->security for a kernel thread that
695 * is being reparented to the init task.
696 * @p contains the task_struct for the kernel thread.
697 * @task_to_inode:
698 * Set the security attributes for an inode based on an associated task's
699 * security attributes, e.g. for /proc/pid inodes.
700 * @p contains the task_struct for the task.
701 * @inode contains the inode structure for the inode.
702 *
703 * Security hooks for Netlink messaging.
704 *
705 * @netlink_send:
706 * Save security information for a netlink message so that permission
707 * checking can be performed when the message is processed. The security
708 * information can be saved using the eff_cap field of the
709 * netlink_skb_parms structure. Also may be used to provide fine
710 * grained control over message transmission.
711 * @sk associated sock of task sending the message.,
712 * @skb contains the sk_buff structure for the netlink message.
713 * Return 0 if the information was successfully saved and message
714 * is allowed to be transmitted.
715 * @netlink_recv:
716 * Check permission before processing the received netlink message in
717 * @skb.
718 * @skb contains the sk_buff structure for the netlink message.
Darrel Goeddelc7bdb542006-06-27 13:26:11 -0700719 * @cap indicates the capability required
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 * Return 0 if permission is granted.
721 *
722 * Security hooks for Unix domain networking.
723 *
724 * @unix_stream_connect:
725 * Check permissions before establishing a Unix domain stream connection
726 * between @sock and @other.
727 * @sock contains the socket structure.
728 * @other contains the peer socket structure.
729 * Return 0 if permission is granted.
730 * @unix_may_send:
731 * Check permissions before connecting or sending datagrams from @sock to
732 * @other.
733 * @sock contains the socket structure.
734 * @sock contains the peer socket structure.
735 * Return 0 if permission is granted.
736 *
737 * The @unix_stream_connect and @unix_may_send hooks were necessary because
738 * Linux provides an alternative to the conventional file name space for Unix
739 * domain sockets. Whereas binding and connecting to sockets in the file name
740 * space is mediated by the typical file permissions (and caught by the mknod
741 * and permission hooks in inode_security_ops), binding and connecting to
742 * sockets in the abstract name space is completely unmediated. Sufficient
743 * control of Unix domain sockets in the abstract name space isn't possible
744 * using only the socket layer hooks, since we need to know the actual target
745 * socket, which is not looked up until we are inside the af_unix code.
746 *
747 * Security hooks for socket operations.
748 *
749 * @socket_create:
750 * Check permissions prior to creating a new socket.
751 * @family contains the requested protocol family.
752 * @type contains the requested communications type.
753 * @protocol contains the requested protocol.
754 * @kern set to 1 if a kernel socket.
755 * Return 0 if permission is granted.
756 * @socket_post_create:
757 * This hook allows a module to update or allocate a per-socket security
758 * structure. Note that the security field was not added directly to the
759 * socket structure, but rather, the socket security information is stored
760 * in the associated inode. Typically, the inode alloc_security hook will
761 * allocate and and attach security information to
762 * sock->inode->i_security. This hook may be used to update the
763 * sock->inode->i_security field with additional information that wasn't
764 * available when the inode was allocated.
765 * @sock contains the newly created socket structure.
766 * @family contains the requested protocol family.
767 * @type contains the requested communications type.
768 * @protocol contains the requested protocol.
769 * @kern set to 1 if a kernel socket.
770 * @socket_bind:
771 * Check permission before socket protocol layer bind operation is
772 * performed and the socket @sock is bound to the address specified in the
773 * @address parameter.
774 * @sock contains the socket structure.
775 * @address contains the address to bind to.
776 * @addrlen contains the length of address.
777 * Return 0 if permission is granted.
778 * @socket_connect:
779 * Check permission before socket protocol layer connect operation
780 * attempts to connect socket @sock to a remote address, @address.
781 * @sock contains the socket structure.
782 * @address contains the address of remote endpoint.
783 * @addrlen contains the length of address.
784 * Return 0 if permission is granted.
785 * @socket_listen:
786 * Check permission before socket protocol layer listen operation.
787 * @sock contains the socket structure.
788 * @backlog contains the maximum length for the pending connection queue.
789 * Return 0 if permission is granted.
790 * @socket_accept:
791 * Check permission before accepting a new connection. Note that the new
792 * socket, @newsock, has been created and some information copied to it,
793 * but the accept operation has not actually been performed.
794 * @sock contains the listening socket structure.
795 * @newsock contains the newly created server socket for connection.
796 * Return 0 if permission is granted.
797 * @socket_post_accept:
798 * This hook allows a security module to copy security
799 * information into the newly created socket's inode.
800 * @sock contains the listening socket structure.
801 * @newsock contains the newly created server socket for connection.
802 * @socket_sendmsg:
803 * Check permission before transmitting a message to another socket.
804 * @sock contains the socket structure.
805 * @msg contains the message to be transmitted.
806 * @size contains the size of message.
807 * Return 0 if permission is granted.
808 * @socket_recvmsg:
809 * Check permission before receiving a message from a socket.
810 * @sock contains the socket structure.
811 * @msg contains the message structure.
812 * @size contains the size of message structure.
813 * @flags contains the operational flags.
814 * Return 0 if permission is granted.
815 * @socket_getsockname:
816 * Check permission before the local address (name) of the socket object
817 * @sock is retrieved.
818 * @sock contains the socket structure.
819 * Return 0 if permission is granted.
820 * @socket_getpeername:
821 * Check permission before the remote address (name) of a socket object
822 * @sock is retrieved.
823 * @sock contains the socket structure.
824 * Return 0 if permission is granted.
825 * @socket_getsockopt:
826 * Check permissions before retrieving the options associated with socket
827 * @sock.
828 * @sock contains the socket structure.
829 * @level contains the protocol level to retrieve option from.
830 * @optname contains the name of option to retrieve.
831 * Return 0 if permission is granted.
832 * @socket_setsockopt:
833 * Check permissions before setting the options associated with socket
834 * @sock.
835 * @sock contains the socket structure.
836 * @level contains the protocol level to set options for.
837 * @optname contains the name of the option to set.
838 * Return 0 if permission is granted.
839 * @socket_shutdown:
840 * Checks permission before all or part of a connection on the socket
841 * @sock is shut down.
842 * @sock contains the socket structure.
843 * @how contains the flag indicating how future sends and receives are handled.
844 * Return 0 if permission is granted.
845 * @socket_sock_rcv_skb:
846 * Check permissions on incoming network packets. This hook is distinct
847 * from Netfilter's IP input hooks since it is the first time that the
848 * incoming sk_buff @skb has been associated with a particular socket, @sk.
849 * @sk contains the sock (not socket) associated with the incoming sk_buff.
850 * @skb contains the incoming network data.
Serge Hallyn6da34ba2007-10-20 00:53:30 +0200851 * @socket_getpeersec_stream:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 * This hook allows the security module to provide peer socket security
Serge Hallyn6da34ba2007-10-20 00:53:30 +0200853 * state for unix or connected tcp sockets to userspace via getsockopt
854 * SO_GETPEERSEC. For tcp sockets this can be meaningful if the
855 * socket is associated with an ipsec SA.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 * @sock is the local socket.
857 * @optval userspace memory where the security state is to be copied.
858 * @optlen userspace int where the module should copy the actual length
859 * of the security state.
860 * @len as input is the maximum length to copy to userspace provided
861 * by the caller.
862 * Return 0 if all is well, otherwise, typical getsockopt return
863 * values.
Serge Hallyn6da34ba2007-10-20 00:53:30 +0200864 * @socket_getpeersec_dgram:
865 * This hook allows the security module to provide peer socket security
866 * state for udp sockets on a per-packet basis to userspace via
867 * getsockopt SO_GETPEERSEC. The application must first have indicated
868 * the IP_PASSSEC option via getsockopt. It can then retrieve the
869 * security state returned by this hook for a packet via the SCM_SECURITY
870 * ancillary message type.
871 * @skb is the skbuff for the packet being queried
872 * @secdata is a pointer to a buffer in which to copy the security data
873 * @seclen is the maximum length for @secdata
874 * Return 0 on success, error on failure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 * @sk_alloc_security:
876 * Allocate and attach a security structure to the sk->sk_security field,
877 * which is used to copy security attributes between local stream sockets.
878 * @sk_free_security:
879 * Deallocate security structure.
Venkat Yekkirala892c1412006-08-04 23:08:56 -0700880 * @sk_clone_security:
881 * Clone/copy security structure.
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -0700882 * @sk_getsecid:
883 * Retrieve the LSM-specific secid for the sock to enable caching of network
Trent Jaegerdf718372005-12-13 23:12:27 -0800884 * authorizations.
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700885 * @sock_graft:
886 * Sets the socket's isec sid to the sock's sid.
887 * @inet_conn_request:
888 * Sets the openreq's sid to socket's sid with MLS portion taken from peer sid.
889 * @inet_csk_clone:
890 * Sets the new child socket's sid to the openreq sid.
Venkat Yekkirala6b877692006-11-08 17:04:09 -0600891 * @inet_conn_established:
892 * Sets the connection's peersid to the secmark on skb.
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700893 * @req_classify_flow:
894 * Sets the flow's sid to the openreq sid.
Trent Jaegerdf718372005-12-13 23:12:27 -0800895 *
896 * Security hooks for XFRM operations.
897 *
898 * @xfrm_policy_alloc_security:
899 * @xp contains the xfrm_policy being added to Security Policy Database
900 * used by the XFRM system.
901 * @sec_ctx contains the security context information being provided by
902 * the user-level policy update program (e.g., setkey).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700903 * Allocate a security structure to the xp->security field; the security
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -0600904 * field is initialized to NULL when the xfrm_policy is allocated.
Trent Jaegerdf718372005-12-13 23:12:27 -0800905 * Return 0 if operation was successful (memory to allocate, legal context)
906 * @xfrm_policy_clone_security:
907 * @old contains an existing xfrm_policy in the SPD.
908 * @new contains a new xfrm_policy being cloned from old.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700909 * Allocate a security structure to the new->security field
910 * that contains the information from the old->security field.
Trent Jaegerdf718372005-12-13 23:12:27 -0800911 * Return 0 if operation was successful (memory to allocate).
912 * @xfrm_policy_free_security:
913 * @xp contains the xfrm_policy
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700914 * Deallocate xp->security.
915 * @xfrm_policy_delete_security:
916 * @xp contains the xfrm_policy.
917 * Authorize deletion of xp->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800918 * @xfrm_state_alloc_security:
919 * @x contains the xfrm_state being added to the Security Association
920 * Database by the XFRM system.
921 * @sec_ctx contains the security context information being provided by
922 * the user-level SA generation program (e.g., setkey or racoon).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700923 * @secid contains the secid from which to take the mls portion of the context.
924 * Allocate a security structure to the x->security field; the security
925 * field is initialized to NULL when the xfrm_state is allocated. Set the
926 * context to correspond to either sec_ctx or polsec, with the mls portion
927 * taken from secid in the latter case.
Trent Jaegerdf718372005-12-13 23:12:27 -0800928 * Return 0 if operation was successful (memory to allocate, legal context).
929 * @xfrm_state_free_security:
930 * @x contains the xfrm_state.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700931 * Deallocate x->security.
932 * @xfrm_state_delete_security:
933 * @x contains the xfrm_state.
934 * Authorize deletion of x->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800935 * @xfrm_policy_lookup:
936 * @xp contains the xfrm_policy for which the access control is being
937 * checked.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700938 * @fl_secid contains the flow security label that is used to authorize
Trent Jaegerdf718372005-12-13 23:12:27 -0800939 * access to the policy xp.
940 * @dir contains the direction of the flow (input or output).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700941 * Check permission when a flow selects a xfrm_policy for processing
Trent Jaegerdf718372005-12-13 23:12:27 -0800942 * XFRMs on a packet. The hook is called when selecting either a
943 * per-socket policy or a generic xfrm policy.
Venkat Yekkirala5b368e62006-10-05 15:42:18 -0500944 * Return 0 if permission is granted, -ESRCH otherwise, or -errno
945 * on other errors.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700946 * @xfrm_state_pol_flow_match:
947 * @x contains the state to match.
948 * @xp contains the policy to check for a match.
949 * @fl contains the flow to check for a match.
950 * Return 1 if there is a match.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700951 * @xfrm_decode_session:
952 * @skb points to skb to decode.
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -0700953 * @secid points to the flow key secid to set.
954 * @ckall says if all xfrms used should be checked for same secid.
955 * Return 0 if ckall is zero or all xfrms used have the same secid.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956 *
David Howells29db9192005-10-30 15:02:44 -0800957 * Security hooks affecting all Key Management operations
958 *
959 * @key_alloc:
960 * Permit allocation of a key and assign security data. Note that key does
961 * not have a serial number assigned at this point.
962 * @key points to the key.
David Howells7e047ef2006-06-26 00:24:50 -0700963 * @flags is the allocation flags
David Howells29db9192005-10-30 15:02:44 -0800964 * Return 0 if permission is granted, -ve error otherwise.
965 * @key_free:
966 * Notification of destruction; free security data.
967 * @key points to the key.
968 * No return value.
969 * @key_permission:
970 * See whether a specific operational right is granted to a process on a
971 * key.
972 * @key_ref refers to the key (key pointer + possession attribute bit).
973 * @context points to the process to provide the context against which to
974 * evaluate the security data on the key.
975 * @perm describes the combination of permissions required of this key.
976 * Return 1 if permission granted, 0 if permission denied and -ve it the
977 * normal permissions model should be effected.
978 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 * Security hooks affecting all System V IPC operations.
980 *
981 * @ipc_permission:
982 * Check permissions for access to IPC
983 * @ipcp contains the kernel IPC permission structure
984 * @flag contains the desired (requested) permission set
985 * Return 0 if permission is granted.
986 *
987 * Security hooks for individual messages held in System V IPC message queues
988 * @msg_msg_alloc_security:
989 * Allocate and attach a security structure to the msg->security field.
990 * The security field is initialized to NULL when the structure is first
991 * created.
992 * @msg contains the message structure to be modified.
993 * Return 0 if operation was successful and permission is granted.
994 * @msg_msg_free_security:
995 * Deallocate the security structure for this message.
996 * @msg contains the message structure to be modified.
997 *
998 * Security hooks for System V IPC Message Queues
999 *
1000 * @msg_queue_alloc_security:
1001 * Allocate and attach a security structure to the
1002 * msq->q_perm.security field. The security field is initialized to
1003 * NULL when the structure is first created.
1004 * @msq contains the message queue structure to be modified.
1005 * Return 0 if operation was successful and permission is granted.
1006 * @msg_queue_free_security:
1007 * Deallocate security structure for this message queue.
1008 * @msq contains the message queue structure to be modified.
1009 * @msg_queue_associate:
1010 * Check permission when a message queue is requested through the
1011 * msgget system call. This hook is only called when returning the
1012 * message queue identifier for an existing message queue, not when a
1013 * new message queue is created.
1014 * @msq contains the message queue to act upon.
1015 * @msqflg contains the operation control flags.
1016 * Return 0 if permission is granted.
1017 * @msg_queue_msgctl:
1018 * Check permission when a message control operation specified by @cmd
1019 * is to be performed on the message queue @msq.
1020 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
1021 * @msq contains the message queue to act upon. May be NULL.
1022 * @cmd contains the operation to be performed.
1023 * Return 0 if permission is granted.
1024 * @msg_queue_msgsnd:
1025 * Check permission before a message, @msg, is enqueued on the message
1026 * queue, @msq.
1027 * @msq contains the message queue to send message to.
1028 * @msg contains the message to be enqueued.
1029 * @msqflg contains operational flags.
1030 * Return 0 if permission is granted.
1031 * @msg_queue_msgrcv:
1032 * Check permission before a message, @msg, is removed from the message
1033 * queue, @msq. The @target task structure contains a pointer to the
1034 * process that will be receiving the message (not equal to the current
1035 * process when inline receives are being performed).
1036 * @msq contains the message queue to retrieve message from.
1037 * @msg contains the message destination.
1038 * @target contains the task structure for recipient process.
1039 * @type contains the type of message requested.
1040 * @mode contains the operational flags.
1041 * Return 0 if permission is granted.
1042 *
1043 * Security hooks for System V Shared Memory Segments
1044 *
1045 * @shm_alloc_security:
1046 * Allocate and attach a security structure to the shp->shm_perm.security
1047 * field. The security field is initialized to NULL when the structure is
1048 * first created.
1049 * @shp contains the shared memory structure to be modified.
1050 * Return 0 if operation was successful and permission is granted.
1051 * @shm_free_security:
1052 * Deallocate the security struct for this memory segment.
1053 * @shp contains the shared memory structure to be modified.
1054 * @shm_associate:
1055 * Check permission when a shared memory region is requested through the
1056 * shmget system call. This hook is only called when returning the shared
1057 * memory region identifier for an existing region, not when a new shared
1058 * memory region is created.
1059 * @shp contains the shared memory structure to be modified.
1060 * @shmflg contains the operation control flags.
1061 * Return 0 if permission is granted.
1062 * @shm_shmctl:
1063 * Check permission when a shared memory control operation specified by
1064 * @cmd is to be performed on the shared memory region @shp.
1065 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1066 * @shp contains shared memory structure to be modified.
1067 * @cmd contains the operation to be performed.
1068 * Return 0 if permission is granted.
1069 * @shm_shmat:
1070 * Check permissions prior to allowing the shmat system call to attach the
1071 * shared memory segment @shp to the data segment of the calling process.
1072 * The attaching address is specified by @shmaddr.
1073 * @shp contains the shared memory structure to be modified.
1074 * @shmaddr contains the address to attach memory region to.
1075 * @shmflg contains the operational flags.
1076 * Return 0 if permission is granted.
1077 *
1078 * Security hooks for System V Semaphores
1079 *
1080 * @sem_alloc_security:
1081 * Allocate and attach a security structure to the sma->sem_perm.security
1082 * field. The security field is initialized to NULL when the structure is
1083 * first created.
1084 * @sma contains the semaphore structure
1085 * Return 0 if operation was successful and permission is granted.
1086 * @sem_free_security:
1087 * deallocate security struct for this semaphore
1088 * @sma contains the semaphore structure.
1089 * @sem_associate:
1090 * Check permission when a semaphore is requested through the semget
1091 * system call. This hook is only called when returning the semaphore
1092 * identifier for an existing semaphore, not when a new one must be
1093 * created.
1094 * @sma contains the semaphore structure.
1095 * @semflg contains the operation control flags.
1096 * Return 0 if permission is granted.
1097 * @sem_semctl:
1098 * Check permission when a semaphore operation specified by @cmd is to be
1099 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
1100 * IPC_INFO or SEM_INFO.
1101 * @sma contains the semaphore structure. May be NULL.
1102 * @cmd contains the operation to be performed.
1103 * Return 0 if permission is granted.
1104 * @sem_semop
1105 * Check permissions before performing operations on members of the
1106 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1107 * may be modified.
1108 * @sma contains the semaphore structure.
1109 * @sops contains the operations to perform.
1110 * @nsops contains the number of operations to perform.
1111 * @alter contains the flag indicating whether changes are to be made.
1112 * Return 0 if permission is granted.
1113 *
1114 * @ptrace:
1115 * Check permission before allowing the @parent process to trace the
1116 * @child process.
1117 * Security modules may also want to perform a process tracing check
1118 * during an execve in the set_security or apply_creds hooks of
1119 * binprm_security_ops if the process is being traced and its security
1120 * attributes would be changed by the execve.
1121 * @parent contains the task_struct structure for parent process.
1122 * @child contains the task_struct structure for child process.
1123 * Return 0 if permission is granted.
1124 * @capget:
1125 * Get the @effective, @inheritable, and @permitted capability sets for
1126 * the @target process. The hook may also perform permission checking to
1127 * determine if the current process is allowed to see the capability sets
1128 * of the @target process.
1129 * @target contains the task_struct structure for target process.
1130 * @effective contains the effective capability set.
1131 * @inheritable contains the inheritable capability set.
1132 * @permitted contains the permitted capability set.
1133 * Return 0 if the capability sets were successfully obtained.
1134 * @capset_check:
1135 * Check permission before setting the @effective, @inheritable, and
1136 * @permitted capability sets for the @target process.
1137 * Caveat: @target is also set to current if a set of processes is
1138 * specified (i.e. all processes other than current and init or a
1139 * particular process group). Hence, the capset_set hook may need to
1140 * revalidate permission to the actual target process.
1141 * @target contains the task_struct structure for target process.
1142 * @effective contains the effective capability set.
1143 * @inheritable contains the inheritable capability set.
1144 * @permitted contains the permitted capability set.
1145 * Return 0 if permission is granted.
1146 * @capset_set:
1147 * Set the @effective, @inheritable, and @permitted capability sets for
1148 * the @target process. Since capset_check cannot always check permission
1149 * to the real @target process, this hook may also perform permission
1150 * checking to determine if the current process is allowed to set the
1151 * capability sets of the @target process. However, this hook has no way
1152 * of returning an error due to the structure of the sys_capset code.
1153 * @target contains the task_struct structure for target process.
1154 * @effective contains the effective capability set.
1155 * @inheritable contains the inheritable capability set.
1156 * @permitted contains the permitted capability set.
Chris Wright12b59892006-03-25 03:07:41 -08001157 * @capable:
1158 * Check whether the @tsk process has the @cap capability.
1159 * @tsk contains the task_struct for the process.
1160 * @cap contains the capability <include/linux/capability.h>.
1161 * Return 0 if the capability is granted for @tsk.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 * @acct:
1163 * Check permission before enabling or disabling process accounting. If
1164 * accounting is being enabled, then @file refers to the open file used to
1165 * store accounting records. If accounting is being disabled, then @file
1166 * is NULL.
1167 * @file contains the file structure for the accounting file (may be NULL).
1168 * Return 0 if permission is granted.
1169 * @sysctl:
1170 * Check permission before accessing the @table sysctl variable in the
1171 * manner specified by @op.
1172 * @table contains the ctl_table structure for the sysctl variable.
1173 * @op contains the operation (001 = search, 002 = write, 004 = read).
1174 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 * @syslog:
1176 * Check permission before accessing the kernel message ring or changing
1177 * logging to the console.
1178 * See the syslog(2) manual page for an explanation of the @type values.
1179 * @type contains the type of action.
1180 * Return 0 if permission is granted.
1181 * @settime:
1182 * Check permission to change the system time.
1183 * struct timespec and timezone are defined in include/linux/time.h
1184 * @ts contains new time
1185 * @tz contains new timezone
1186 * Return 0 if permission is granted.
1187 * @vm_enough_memory:
1188 * Check permissions for allocating a new virtual mapping.
Alan Cox34b4e4a2007-08-22 14:01:28 -07001189 * @mm contains the mm struct it is being added to.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 * @pages contains the number of pages.
1191 * Return 0 if permission is granted.
1192 *
1193 * @register_security:
1194 * allow module stacking.
1195 * @name contains the name of the security module being stacked.
1196 * @ops contains a pointer to the struct security_operations of the module to stack.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001197 *
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001198 * @secid_to_secctx:
1199 * Convert secid to security context.
1200 * @secid contains the security ID.
1201 * @secdata contains the pointer that stores the converted security context.
David Howells63cb3442008-01-15 23:47:35 +00001202 * @secctx_to_secid:
1203 * Convert security context to secid.
1204 * @secid contains the pointer to the generated security ID.
1205 * @secdata contains the security context.
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001206 *
1207 * @release_secctx:
1208 * Release the security context.
1209 * @secdata contains the security context.
1210 * @seclen contains the length of the security context.
1211 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001212 * This is the main security structure.
1213 */
1214struct security_operations {
1215 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1216 int (*capget) (struct task_struct * target,
1217 kernel_cap_t * effective,
1218 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1219 int (*capset_check) (struct task_struct * target,
1220 kernel_cap_t * effective,
1221 kernel_cap_t * inheritable,
1222 kernel_cap_t * permitted);
1223 void (*capset_set) (struct task_struct * target,
1224 kernel_cap_t * effective,
1225 kernel_cap_t * inheritable,
1226 kernel_cap_t * permitted);
Chris Wright12b59892006-03-25 03:07:41 -08001227 int (*capable) (struct task_struct * tsk, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001228 int (*acct) (struct file * file);
1229 int (*sysctl) (struct ctl_table * table, int op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1231 int (*quota_on) (struct dentry * dentry);
1232 int (*syslog) (int type);
1233 int (*settime) (struct timespec *ts, struct timezone *tz);
Alan Cox34b4e4a2007-08-22 14:01:28 -07001234 int (*vm_enough_memory) (struct mm_struct *mm, long pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235
1236 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1237 void (*bprm_free_security) (struct linux_binprm * bprm);
1238 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1239 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1240 int (*bprm_set_security) (struct linux_binprm * bprm);
1241 int (*bprm_check_security) (struct linux_binprm * bprm);
1242 int (*bprm_secureexec) (struct linux_binprm * bprm);
1243
1244 int (*sb_alloc_security) (struct super_block * sb);
1245 void (*sb_free_security) (struct super_block * sb);
1246 int (*sb_copy_data)(struct file_system_type *type,
1247 void *orig, void *copy);
1248 int (*sb_kern_mount) (struct super_block *sb, void *data);
David Howells726c3342006-06-23 02:02:58 -07001249 int (*sb_statfs) (struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001250 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1251 char *type, unsigned long flags, void *data);
1252 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1253 int (*sb_umount) (struct vfsmount * mnt, int flags);
1254 void (*sb_umount_close) (struct vfsmount * mnt);
1255 void (*sb_umount_busy) (struct vfsmount * mnt);
1256 void (*sb_post_remount) (struct vfsmount * mnt,
1257 unsigned long flags, void *data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258 void (*sb_post_addmount) (struct vfsmount * mnt,
1259 struct nameidata * mountpoint_nd);
1260 int (*sb_pivotroot) (struct nameidata * old_nd,
1261 struct nameidata * new_nd);
1262 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1263 struct nameidata * new_nd);
Eric Parisc9180a52007-11-30 13:00:35 -05001264 int (*sb_get_mnt_opts) (const struct super_block *sb,
1265 char ***mount_options, int **flags,
1266 int *num_opts);
1267 int (*sb_set_mnt_opts) (struct super_block *sb, char **mount_options,
1268 int *flags, int num_opts);
1269 void (*sb_clone_mnt_opts) (const struct super_block *oldsb,
1270 struct super_block *newsb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271
1272 int (*inode_alloc_security) (struct inode *inode);
1273 void (*inode_free_security) (struct inode *inode);
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001274 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1275 char **name, void **value, size_t *len);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276 int (*inode_create) (struct inode *dir,
1277 struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278 int (*inode_link) (struct dentry *old_dentry,
1279 struct inode *dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1281 int (*inode_symlink) (struct inode *dir,
1282 struct dentry *dentry, const char *old_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001284 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1285 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1286 int mode, dev_t dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001287 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1288 struct inode *new_dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001289 int (*inode_readlink) (struct dentry *dentry);
1290 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1291 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1292 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1293 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1294 void (*inode_delete) (struct inode *inode);
1295 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1296 size_t size, int flags);
1297 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1298 size_t size, int flags);
1299 int (*inode_getxattr) (struct dentry *dentry, char *name);
1300 int (*inode_listxattr) (struct dentry *dentry);
1301 int (*inode_removexattr) (struct dentry *dentry, char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -07001302 int (*inode_need_killpriv) (struct dentry *dentry);
1303 int (*inode_killpriv) (struct dentry *dentry);
David P. Quigley42492592008-02-04 22:29:39 -08001304 int (*inode_getsecurity)(const struct inode *inode, const char *name, void **buffer, bool alloc);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001305 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1306 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1307
1308 int (*file_permission) (struct file * file, int mask);
1309 int (*file_alloc_security) (struct file * file);
1310 void (*file_free_security) (struct file * file);
1311 int (*file_ioctl) (struct file * file, unsigned int cmd,
1312 unsigned long arg);
1313 int (*file_mmap) (struct file * file,
Eric Parised032182007-06-28 15:55:21 -04001314 unsigned long reqprot, unsigned long prot,
1315 unsigned long flags, unsigned long addr,
1316 unsigned long addr_only);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317 int (*file_mprotect) (struct vm_area_struct * vma,
1318 unsigned long reqprot,
1319 unsigned long prot);
1320 int (*file_lock) (struct file * file, unsigned int cmd);
1321 int (*file_fcntl) (struct file * file, unsigned int cmd,
1322 unsigned long arg);
1323 int (*file_set_fowner) (struct file * file);
1324 int (*file_send_sigiotask) (struct task_struct * tsk,
1325 struct fown_struct * fown, int sig);
1326 int (*file_receive) (struct file * file);
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +09001327 int (*dentry_open) (struct file *file);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001328
1329 int (*task_create) (unsigned long clone_flags);
1330 int (*task_alloc_security) (struct task_struct * p);
1331 void (*task_free_security) (struct task_struct * p);
1332 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1333 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1334 uid_t old_euid, uid_t old_suid, int flags);
1335 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1336 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1337 int (*task_getpgid) (struct task_struct * p);
1338 int (*task_getsid) (struct task_struct * p);
David Quigleyf9008e42006-06-30 01:55:46 -07001339 void (*task_getsecid) (struct task_struct * p, u32 * secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001340 int (*task_setgroups) (struct group_info *group_info);
1341 int (*task_setnice) (struct task_struct * p, int nice);
James Morris03e68062006-06-23 02:03:58 -07001342 int (*task_setioprio) (struct task_struct * p, int ioprio);
David Quigleya1836a42006-06-30 01:55:49 -07001343 int (*task_getioprio) (struct task_struct * p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001344 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1345 int (*task_setscheduler) (struct task_struct * p, int policy,
1346 struct sched_param * lp);
1347 int (*task_getscheduler) (struct task_struct * p);
David Quigley35601542006-06-23 02:04:01 -07001348 int (*task_movememory) (struct task_struct * p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001349 int (*task_kill) (struct task_struct * p,
David Quigleyf9008e42006-06-30 01:55:46 -07001350 struct siginfo * info, int sig, u32 secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351 int (*task_wait) (struct task_struct * p);
1352 int (*task_prctl) (int option, unsigned long arg2,
1353 unsigned long arg3, unsigned long arg4,
1354 unsigned long arg5);
1355 void (*task_reparent_to_init) (struct task_struct * p);
1356 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1357
1358 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1359
1360 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1361 void (*msg_msg_free_security) (struct msg_msg * msg);
1362
1363 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1364 void (*msg_queue_free_security) (struct msg_queue * msq);
1365 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1366 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1367 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1368 struct msg_msg * msg, int msqflg);
1369 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1370 struct msg_msg * msg,
1371 struct task_struct * target,
1372 long type, int mode);
1373
1374 int (*shm_alloc_security) (struct shmid_kernel * shp);
1375 void (*shm_free_security) (struct shmid_kernel * shp);
1376 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1377 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1378 int (*shm_shmat) (struct shmid_kernel * shp,
1379 char __user *shmaddr, int shmflg);
1380
1381 int (*sem_alloc_security) (struct sem_array * sma);
1382 void (*sem_free_security) (struct sem_array * sma);
1383 int (*sem_associate) (struct sem_array * sma, int semflg);
1384 int (*sem_semctl) (struct sem_array * sma, int cmd);
1385 int (*sem_semop) (struct sem_array * sma,
1386 struct sembuf * sops, unsigned nsops, int alter);
1387
1388 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07001389 int (*netlink_recv) (struct sk_buff * skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390
1391 /* allow module stacking */
1392 int (*register_security) (const char *name,
1393 struct security_operations *ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394
1395 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1396
Al Viro04ff9702007-03-12 16:17:58 +00001397 int (*getprocattr)(struct task_struct *p, char *name, char **value);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001398 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001399 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
David Howells63cb3442008-01-15 23:47:35 +00001400 int (*secctx_to_secid)(char *secdata, u32 seclen, u32 *secid);
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001401 void (*release_secctx)(char *secdata, u32 seclen);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001402
1403#ifdef CONFIG_SECURITY_NETWORK
1404 int (*unix_stream_connect) (struct socket * sock,
1405 struct socket * other, struct sock * newsk);
1406 int (*unix_may_send) (struct socket * sock, struct socket * other);
1407
1408 int (*socket_create) (int family, int type, int protocol, int kern);
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07001409 int (*socket_post_create) (struct socket * sock, int family,
1410 int type, int protocol, int kern);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411 int (*socket_bind) (struct socket * sock,
1412 struct sockaddr * address, int addrlen);
1413 int (*socket_connect) (struct socket * sock,
1414 struct sockaddr * address, int addrlen);
1415 int (*socket_listen) (struct socket * sock, int backlog);
1416 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1417 void (*socket_post_accept) (struct socket * sock,
1418 struct socket * newsock);
1419 int (*socket_sendmsg) (struct socket * sock,
1420 struct msghdr * msg, int size);
1421 int (*socket_recvmsg) (struct socket * sock,
1422 struct msghdr * msg, int size, int flags);
1423 int (*socket_getsockname) (struct socket * sock);
1424 int (*socket_getpeername) (struct socket * sock);
1425 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1426 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1427 int (*socket_shutdown) (struct socket * sock, int how);
1428 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
Catherine Zhang2c7946a2006-03-20 22:41:23 -08001429 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001430 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
Al Viro7d877f32005-10-21 03:20:43 -04001431 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001432 void (*sk_free_security) (struct sock *sk);
Venkat Yekkirala892c1412006-08-04 23:08:56 -07001433 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001434 void (*sk_getsecid) (struct sock *sk, u32 *secid);
Venkat Yekkirala4237c752006-07-24 23:32:50 -07001435 void (*sock_graft)(struct sock* sk, struct socket *parent);
1436 int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb,
1437 struct request_sock *req);
1438 void (*inet_csk_clone)(struct sock *newsk, const struct request_sock *req);
Venkat Yekkirala6b877692006-11-08 17:04:09 -06001439 void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb);
Venkat Yekkirala4237c752006-07-24 23:32:50 -07001440 void (*req_classify_flow)(const struct request_sock *req, struct flowi *fl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441#endif /* CONFIG_SECURITY_NETWORK */
David Howells29db9192005-10-30 15:02:44 -08001442
Trent Jaegerdf718372005-12-13 23:12:27 -08001443#ifdef CONFIG_SECURITY_NETWORK_XFRM
Venkat Yekkiralacb969f02006-07-24 23:32:20 -07001444 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp,
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -06001445 struct xfrm_user_sec_ctx *sec_ctx);
Trent Jaegerdf718372005-12-13 23:12:27 -08001446 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1447 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001448 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001449 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -06001450 struct xfrm_user_sec_ctx *sec_ctx,
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001451 u32 secid);
Trent Jaegerdf718372005-12-13 23:12:27 -08001452 void (*xfrm_state_free_security) (struct xfrm_state *x);
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001453 int (*xfrm_state_delete_security) (struct xfrm_state *x);
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001454 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
1455 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
1456 struct xfrm_policy *xp, struct flowi *fl);
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001457 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
Trent Jaegerdf718372005-12-13 23:12:27 -08001458#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1459
David Howells29db9192005-10-30 15:02:44 -08001460 /* key management security hooks */
1461#ifdef CONFIG_KEYS
David Howells7e047ef2006-06-26 00:24:50 -07001462 int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags);
David Howells29db9192005-10-30 15:02:44 -08001463 void (*key_free)(struct key *key);
1464 int (*key_permission)(key_ref_t key_ref,
1465 struct task_struct *context,
1466 key_perm_t perm);
1467
1468#endif /* CONFIG_KEYS */
1469
Linus Torvalds1da177e2005-04-16 15:20:36 -07001470};
1471
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472/* prototypes */
1473extern int security_init (void);
1474extern int register_security (struct security_operations *ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475extern int mod_reg_security (const char *name, struct security_operations *ops);
Greg KHb67dbf92005-07-07 14:37:53 -07001476extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
1477 struct dentry *parent, void *data,
Arjan van de Ven54047322007-02-12 00:55:28 -08001478 const struct file_operations *fops);
Greg KHb67dbf92005-07-07 14:37:53 -07001479extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1480extern void securityfs_remove(struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481
1482
James Morris20510f22007-10-16 23:31:32 -07001483/* Security operations */
1484int security_ptrace(struct task_struct *parent, struct task_struct *child);
1485int security_capget(struct task_struct *target,
1486 kernel_cap_t *effective,
1487 kernel_cap_t *inheritable,
1488 kernel_cap_t *permitted);
1489int security_capset_check(struct task_struct *target,
1490 kernel_cap_t *effective,
1491 kernel_cap_t *inheritable,
1492 kernel_cap_t *permitted);
1493void security_capset_set(struct task_struct *target,
1494 kernel_cap_t *effective,
1495 kernel_cap_t *inheritable,
1496 kernel_cap_t *permitted);
1497int security_capable(struct task_struct *tsk, int cap);
1498int security_acct(struct file *file);
1499int security_sysctl(struct ctl_table *table, int op);
1500int security_quotactl(int cmds, int type, int id, struct super_block *sb);
1501int security_quota_on(struct dentry *dentry);
1502int security_syslog(int type);
1503int security_settime(struct timespec *ts, struct timezone *tz);
1504int security_vm_enough_memory(long pages);
1505int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
1506int security_bprm_alloc(struct linux_binprm *bprm);
1507void security_bprm_free(struct linux_binprm *bprm);
1508void security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe);
1509void security_bprm_post_apply_creds(struct linux_binprm *bprm);
1510int security_bprm_set(struct linux_binprm *bprm);
1511int security_bprm_check(struct linux_binprm *bprm);
1512int security_bprm_secureexec(struct linux_binprm *bprm);
1513int security_sb_alloc(struct super_block *sb);
1514void security_sb_free(struct super_block *sb);
1515int security_sb_copy_data(struct file_system_type *type, void *orig, void *copy);
1516int security_sb_kern_mount(struct super_block *sb, void *data);
1517int security_sb_statfs(struct dentry *dentry);
1518int security_sb_mount(char *dev_name, struct nameidata *nd,
1519 char *type, unsigned long flags, void *data);
1520int security_sb_check_sb(struct vfsmount *mnt, struct nameidata *nd);
1521int security_sb_umount(struct vfsmount *mnt, int flags);
1522void security_sb_umount_close(struct vfsmount *mnt);
1523void security_sb_umount_busy(struct vfsmount *mnt);
1524void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data);
James Morris20510f22007-10-16 23:31:32 -07001525void security_sb_post_addmount(struct vfsmount *mnt, struct nameidata *mountpoint_nd);
1526int security_sb_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd);
1527void security_sb_post_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd);
Eric Parisc9180a52007-11-30 13:00:35 -05001528int security_sb_get_mnt_opts(const struct super_block *sb, char ***mount_options,
1529 int **flags, int *num_opts);
1530int security_sb_set_mnt_opts(struct super_block *sb, char **mount_options,
1531 int *flags, int num_opts);
1532void security_sb_clone_mnt_opts(const struct super_block *oldsb,
1533 struct super_block *newsb);
1534
James Morris20510f22007-10-16 23:31:32 -07001535int security_inode_alloc(struct inode *inode);
1536void security_inode_free(struct inode *inode);
1537int security_inode_init_security(struct inode *inode, struct inode *dir,
1538 char **name, void **value, size_t *len);
1539int security_inode_create(struct inode *dir, struct dentry *dentry, int mode);
1540int security_inode_link(struct dentry *old_dentry, struct inode *dir,
1541 struct dentry *new_dentry);
1542int security_inode_unlink(struct inode *dir, struct dentry *dentry);
1543int security_inode_symlink(struct inode *dir, struct dentry *dentry,
1544 const char *old_name);
1545int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode);
1546int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
1547int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
1548int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1549 struct inode *new_dir, struct dentry *new_dentry);
1550int security_inode_readlink(struct dentry *dentry);
1551int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
1552int security_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
1553int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1554int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1555void security_inode_delete(struct inode *inode);
1556int security_inode_setxattr(struct dentry *dentry, char *name,
1557 void *value, size_t size, int flags);
1558void security_inode_post_setxattr(struct dentry *dentry, char *name,
1559 void *value, size_t size, int flags);
1560int security_inode_getxattr(struct dentry *dentry, char *name);
1561int security_inode_listxattr(struct dentry *dentry);
1562int security_inode_removexattr(struct dentry *dentry, char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -07001563int security_inode_need_killpriv(struct dentry *dentry);
1564int security_inode_killpriv(struct dentry *dentry);
David P. Quigley42492592008-02-04 22:29:39 -08001565int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc);
James Morris20510f22007-10-16 23:31:32 -07001566int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1567int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
1568int security_file_permission(struct file *file, int mask);
1569int security_file_alloc(struct file *file);
1570void security_file_free(struct file *file);
1571int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1572int security_file_mmap(struct file *file, unsigned long reqprot,
1573 unsigned long prot, unsigned long flags,
1574 unsigned long addr, unsigned long addr_only);
1575int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
1576 unsigned long prot);
1577int security_file_lock(struct file *file, unsigned int cmd);
1578int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
1579int security_file_set_fowner(struct file *file);
1580int security_file_send_sigiotask(struct task_struct *tsk,
1581 struct fown_struct *fown, int sig);
1582int security_file_receive(struct file *file);
1583int security_dentry_open(struct file *file);
1584int security_task_create(unsigned long clone_flags);
1585int security_task_alloc(struct task_struct *p);
1586void security_task_free(struct task_struct *p);
1587int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags);
1588int security_task_post_setuid(uid_t old_ruid, uid_t old_euid,
1589 uid_t old_suid, int flags);
1590int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags);
1591int security_task_setpgid(struct task_struct *p, pid_t pgid);
1592int security_task_getpgid(struct task_struct *p);
1593int security_task_getsid(struct task_struct *p);
1594void security_task_getsecid(struct task_struct *p, u32 *secid);
1595int security_task_setgroups(struct group_info *group_info);
1596int security_task_setnice(struct task_struct *p, int nice);
1597int security_task_setioprio(struct task_struct *p, int ioprio);
1598int security_task_getioprio(struct task_struct *p);
1599int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim);
1600int security_task_setscheduler(struct task_struct *p,
1601 int policy, struct sched_param *lp);
1602int security_task_getscheduler(struct task_struct *p);
1603int security_task_movememory(struct task_struct *p);
1604int security_task_kill(struct task_struct *p, struct siginfo *info,
1605 int sig, u32 secid);
1606int security_task_wait(struct task_struct *p);
1607int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
1608 unsigned long arg4, unsigned long arg5);
1609void security_task_reparent_to_init(struct task_struct *p);
1610void security_task_to_inode(struct task_struct *p, struct inode *inode);
1611int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
1612int security_msg_msg_alloc(struct msg_msg *msg);
1613void security_msg_msg_free(struct msg_msg *msg);
1614int security_msg_queue_alloc(struct msg_queue *msq);
1615void security_msg_queue_free(struct msg_queue *msq);
1616int security_msg_queue_associate(struct msg_queue *msq, int msqflg);
1617int security_msg_queue_msgctl(struct msg_queue *msq, int cmd);
1618int security_msg_queue_msgsnd(struct msg_queue *msq,
1619 struct msg_msg *msg, int msqflg);
1620int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
1621 struct task_struct *target, long type, int mode);
1622int security_shm_alloc(struct shmid_kernel *shp);
1623void security_shm_free(struct shmid_kernel *shp);
1624int security_shm_associate(struct shmid_kernel *shp, int shmflg);
1625int security_shm_shmctl(struct shmid_kernel *shp, int cmd);
1626int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg);
1627int security_sem_alloc(struct sem_array *sma);
1628void security_sem_free(struct sem_array *sma);
1629int security_sem_associate(struct sem_array *sma, int semflg);
1630int security_sem_semctl(struct sem_array *sma, int cmd);
1631int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
1632 unsigned nsops, int alter);
1633void security_d_instantiate (struct dentry *dentry, struct inode *inode);
1634int security_getprocattr(struct task_struct *p, char *name, char **value);
1635int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
1636int security_netlink_send(struct sock *sk, struct sk_buff *skb);
1637int security_netlink_recv(struct sk_buff *skb, int cap);
1638int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
David Howells63cb3442008-01-15 23:47:35 +00001639int security_secctx_to_secid(char *secdata, u32 seclen, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -07001640void security_release_secctx(char *secdata, u32 seclen);
1641
Linus Torvalds1da177e2005-04-16 15:20:36 -07001642#else /* CONFIG_SECURITY */
1643
1644/*
1645 * This is the default capabilities functionality. Most of these functions
1646 * are just stubbed out, but a few must call the proper capable code.
1647 */
1648
1649static inline int security_init(void)
1650{
1651 return 0;
1652}
1653
1654static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
1655{
1656 return cap_ptrace (parent, child);
1657}
1658
1659static inline int security_capget (struct task_struct *target,
1660 kernel_cap_t *effective,
1661 kernel_cap_t *inheritable,
1662 kernel_cap_t *permitted)
1663{
1664 return cap_capget (target, effective, inheritable, permitted);
1665}
1666
1667static inline int security_capset_check (struct task_struct *target,
1668 kernel_cap_t *effective,
1669 kernel_cap_t *inheritable,
1670 kernel_cap_t *permitted)
1671{
1672 return cap_capset_check (target, effective, inheritable, permitted);
1673}
1674
1675static inline void security_capset_set (struct task_struct *target,
1676 kernel_cap_t *effective,
1677 kernel_cap_t *inheritable,
1678 kernel_cap_t *permitted)
1679{
1680 cap_capset_set (target, effective, inheritable, permitted);
1681}
1682
Chris Wright12b59892006-03-25 03:07:41 -08001683static inline int security_capable(struct task_struct *tsk, int cap)
1684{
1685 return cap_capable(tsk, cap);
1686}
1687
Linus Torvalds1da177e2005-04-16 15:20:36 -07001688static inline int security_acct (struct file *file)
1689{
1690 return 0;
1691}
1692
1693static inline int security_sysctl(struct ctl_table *table, int op)
1694{
1695 return 0;
1696}
1697
1698static inline int security_quotactl (int cmds, int type, int id,
1699 struct super_block * sb)
1700{
1701 return 0;
1702}
1703
1704static inline int security_quota_on (struct dentry * dentry)
1705{
1706 return 0;
1707}
1708
1709static inline int security_syslog(int type)
1710{
1711 return cap_syslog(type);
1712}
1713
1714static inline int security_settime(struct timespec *ts, struct timezone *tz)
1715{
1716 return cap_settime(ts, tz);
1717}
1718
1719static inline int security_vm_enough_memory(long pages)
1720{
Alan Cox34b4e4a2007-08-22 14:01:28 -07001721 return cap_vm_enough_memory(current->mm, pages);
1722}
1723
1724static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
1725{
1726 return cap_vm_enough_memory(mm, pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001727}
1728
1729static inline int security_bprm_alloc (struct linux_binprm *bprm)
1730{
1731 return 0;
1732}
1733
1734static inline void security_bprm_free (struct linux_binprm *bprm)
1735{ }
1736
1737static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1738{
1739 cap_bprm_apply_creds (bprm, unsafe);
1740}
1741
1742static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1743{
1744 return;
1745}
1746
1747static inline int security_bprm_set (struct linux_binprm *bprm)
1748{
1749 return cap_bprm_set_security (bprm);
1750}
1751
1752static inline int security_bprm_check (struct linux_binprm *bprm)
1753{
1754 return 0;
1755}
1756
1757static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1758{
1759 return cap_bprm_secureexec(bprm);
1760}
1761
1762static inline int security_sb_alloc (struct super_block *sb)
1763{
1764 return 0;
1765}
1766
1767static inline void security_sb_free (struct super_block *sb)
1768{ }
1769
1770static inline int security_sb_copy_data (struct file_system_type *type,
1771 void *orig, void *copy)
1772{
1773 return 0;
1774}
1775
1776static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1777{
1778 return 0;
1779}
1780
David Howells726c3342006-06-23 02:02:58 -07001781static inline int security_sb_statfs (struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001782{
1783 return 0;
1784}
1785
1786static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1787 char *type, unsigned long flags,
1788 void *data)
1789{
1790 return 0;
1791}
1792
1793static inline int security_sb_check_sb (struct vfsmount *mnt,
1794 struct nameidata *nd)
1795{
1796 return 0;
1797}
1798
1799static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1800{
1801 return 0;
1802}
1803
1804static inline void security_sb_umount_close (struct vfsmount *mnt)
1805{ }
1806
1807static inline void security_sb_umount_busy (struct vfsmount *mnt)
1808{ }
1809
1810static inline void security_sb_post_remount (struct vfsmount *mnt,
1811 unsigned long flags, void *data)
1812{ }
1813
Linus Torvalds1da177e2005-04-16 15:20:36 -07001814static inline void security_sb_post_addmount (struct vfsmount *mnt,
1815 struct nameidata *mountpoint_nd)
1816{ }
1817
1818static inline int security_sb_pivotroot (struct nameidata *old_nd,
1819 struct nameidata *new_nd)
1820{
1821 return 0;
1822}
1823
1824static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1825 struct nameidata *new_nd)
1826{ }
1827
1828static inline int security_inode_alloc (struct inode *inode)
1829{
1830 return 0;
1831}
1832
1833static inline void security_inode_free (struct inode *inode)
1834{ }
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001835
1836static inline int security_inode_init_security (struct inode *inode,
1837 struct inode *dir,
1838 char **name,
1839 void **value,
1840 size_t *len)
1841{
1842 return -EOPNOTSUPP;
1843}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001844
1845static inline int security_inode_create (struct inode *dir,
1846 struct dentry *dentry,
1847 int mode)
1848{
1849 return 0;
1850}
1851
Linus Torvalds1da177e2005-04-16 15:20:36 -07001852static inline int security_inode_link (struct dentry *old_dentry,
1853 struct inode *dir,
1854 struct dentry *new_dentry)
1855{
1856 return 0;
1857}
1858
Linus Torvalds1da177e2005-04-16 15:20:36 -07001859static inline int security_inode_unlink (struct inode *dir,
1860 struct dentry *dentry)
1861{
1862 return 0;
1863}
1864
1865static inline int security_inode_symlink (struct inode *dir,
1866 struct dentry *dentry,
1867 const char *old_name)
1868{
1869 return 0;
1870}
1871
Linus Torvalds1da177e2005-04-16 15:20:36 -07001872static inline int security_inode_mkdir (struct inode *dir,
1873 struct dentry *dentry,
1874 int mode)
1875{
1876 return 0;
1877}
1878
Linus Torvalds1da177e2005-04-16 15:20:36 -07001879static inline int security_inode_rmdir (struct inode *dir,
1880 struct dentry *dentry)
1881{
1882 return 0;
1883}
1884
1885static inline int security_inode_mknod (struct inode *dir,
1886 struct dentry *dentry,
1887 int mode, dev_t dev)
1888{
1889 return 0;
1890}
1891
Linus Torvalds1da177e2005-04-16 15:20:36 -07001892static inline int security_inode_rename (struct inode *old_dir,
1893 struct dentry *old_dentry,
1894 struct inode *new_dir,
1895 struct dentry *new_dentry)
1896{
1897 return 0;
1898}
1899
Linus Torvalds1da177e2005-04-16 15:20:36 -07001900static inline int security_inode_readlink (struct dentry *dentry)
1901{
1902 return 0;
1903}
1904
1905static inline int security_inode_follow_link (struct dentry *dentry,
1906 struct nameidata *nd)
1907{
1908 return 0;
1909}
1910
1911static inline int security_inode_permission (struct inode *inode, int mask,
1912 struct nameidata *nd)
1913{
1914 return 0;
1915}
1916
1917static inline int security_inode_setattr (struct dentry *dentry,
1918 struct iattr *attr)
1919{
1920 return 0;
1921}
1922
1923static inline int security_inode_getattr (struct vfsmount *mnt,
1924 struct dentry *dentry)
1925{
1926 return 0;
1927}
1928
1929static inline void security_inode_delete (struct inode *inode)
1930{ }
1931
1932static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1933 void *value, size_t size, int flags)
1934{
1935 return cap_inode_setxattr(dentry, name, value, size, flags);
1936}
1937
1938static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1939 void *value, size_t size, int flags)
1940{ }
1941
1942static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1943{
1944 return 0;
1945}
1946
1947static inline int security_inode_listxattr (struct dentry *dentry)
1948{
1949 return 0;
1950}
1951
1952static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1953{
1954 return cap_inode_removexattr(dentry, name);
1955}
1956
Serge E. Hallynb5376772007-10-16 23:31:36 -07001957static inline int security_inode_need_killpriv(struct dentry *dentry)
1958{
1959 return cap_inode_need_killpriv(dentry);
1960}
1961
1962static inline int security_inode_killpriv(struct dentry *dentry)
1963{
1964 return cap_inode_killpriv(dentry);
1965}
1966
David P. Quigley42492592008-02-04 22:29:39 -08001967static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968{
1969 return -EOPNOTSUPP;
1970}
1971
1972static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1973{
1974 return -EOPNOTSUPP;
1975}
1976
1977static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1978{
1979 return 0;
1980}
1981
1982static inline int security_file_permission (struct file *file, int mask)
1983{
1984 return 0;
1985}
1986
1987static inline int security_file_alloc (struct file *file)
1988{
1989 return 0;
1990}
1991
1992static inline void security_file_free (struct file *file)
1993{ }
1994
1995static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1996 unsigned long arg)
1997{
1998 return 0;
1999}
2000
2001static inline int security_file_mmap (struct file *file, unsigned long reqprot,
2002 unsigned long prot,
Eric Parised032182007-06-28 15:55:21 -04002003 unsigned long flags,
2004 unsigned long addr,
2005 unsigned long addr_only)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002006{
2007 return 0;
2008}
2009
2010static inline int security_file_mprotect (struct vm_area_struct *vma,
2011 unsigned long reqprot,
2012 unsigned long prot)
2013{
2014 return 0;
2015}
2016
2017static inline int security_file_lock (struct file *file, unsigned int cmd)
2018{
2019 return 0;
2020}
2021
2022static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2023 unsigned long arg)
2024{
2025 return 0;
2026}
2027
2028static inline int security_file_set_fowner (struct file *file)
2029{
2030 return 0;
2031}
2032
2033static inline int security_file_send_sigiotask (struct task_struct *tsk,
2034 struct fown_struct *fown,
2035 int sig)
2036{
2037 return 0;
2038}
2039
2040static inline int security_file_receive (struct file *file)
2041{
2042 return 0;
2043}
2044
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +09002045static inline int security_dentry_open (struct file *file)
2046{
2047 return 0;
2048}
2049
Linus Torvalds1da177e2005-04-16 15:20:36 -07002050static inline int security_task_create (unsigned long clone_flags)
2051{
2052 return 0;
2053}
2054
2055static inline int security_task_alloc (struct task_struct *p)
2056{
2057 return 0;
2058}
2059
2060static inline void security_task_free (struct task_struct *p)
2061{ }
2062
2063static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2064 int flags)
2065{
2066 return 0;
2067}
2068
2069static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2070 uid_t old_suid, int flags)
2071{
2072 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2073}
2074
2075static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2076 int flags)
2077{
2078 return 0;
2079}
2080
2081static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2082{
2083 return 0;
2084}
2085
2086static inline int security_task_getpgid (struct task_struct *p)
2087{
2088 return 0;
2089}
2090
2091static inline int security_task_getsid (struct task_struct *p)
2092{
2093 return 0;
2094}
2095
David Quigleyf9008e42006-06-30 01:55:46 -07002096static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
2097{ }
2098
Linus Torvalds1da177e2005-04-16 15:20:36 -07002099static inline int security_task_setgroups (struct group_info *group_info)
2100{
2101 return 0;
2102}
2103
2104static inline int security_task_setnice (struct task_struct *p, int nice)
2105{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002106 return cap_task_setnice(p, nice);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002107}
2108
James Morris03e68062006-06-23 02:03:58 -07002109static inline int security_task_setioprio (struct task_struct *p, int ioprio)
2110{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002111 return cap_task_setioprio(p, ioprio);
James Morris03e68062006-06-23 02:03:58 -07002112}
2113
David Quigleya1836a42006-06-30 01:55:49 -07002114static inline int security_task_getioprio (struct task_struct *p)
2115{
2116 return 0;
2117}
2118
Linus Torvalds1da177e2005-04-16 15:20:36 -07002119static inline int security_task_setrlimit (unsigned int resource,
2120 struct rlimit *new_rlim)
2121{
2122 return 0;
2123}
2124
2125static inline int security_task_setscheduler (struct task_struct *p,
2126 int policy,
2127 struct sched_param *lp)
2128{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002129 return cap_task_setscheduler(p, policy, lp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002130}
2131
2132static inline int security_task_getscheduler (struct task_struct *p)
2133{
2134 return 0;
2135}
2136
David Quigley35601542006-06-23 02:04:01 -07002137static inline int security_task_movememory (struct task_struct *p)
2138{
2139 return 0;
2140}
2141
Linus Torvalds1da177e2005-04-16 15:20:36 -07002142static inline int security_task_kill (struct task_struct *p,
David Quigleyf9008e42006-06-30 01:55:46 -07002143 struct siginfo *info, int sig,
2144 u32 secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002145{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002146 return cap_task_kill(p, info, sig, secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002147}
2148
2149static inline int security_task_wait (struct task_struct *p)
2150{
2151 return 0;
2152}
2153
2154static inline int security_task_prctl (int option, unsigned long arg2,
2155 unsigned long arg3,
2156 unsigned long arg4,
2157 unsigned long arg5)
2158{
2159 return 0;
2160}
2161
2162static inline void security_task_reparent_to_init (struct task_struct *p)
2163{
2164 cap_task_reparent_to_init (p);
2165}
2166
2167static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2168{ }
2169
2170static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2171 short flag)
2172{
2173 return 0;
2174}
2175
2176static inline int security_msg_msg_alloc (struct msg_msg * msg)
2177{
2178 return 0;
2179}
2180
2181static inline void security_msg_msg_free (struct msg_msg * msg)
2182{ }
2183
2184static inline int security_msg_queue_alloc (struct msg_queue *msq)
2185{
2186 return 0;
2187}
2188
2189static inline void security_msg_queue_free (struct msg_queue *msq)
2190{ }
2191
2192static inline int security_msg_queue_associate (struct msg_queue * msq,
2193 int msqflg)
2194{
2195 return 0;
2196}
2197
2198static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2199{
2200 return 0;
2201}
2202
2203static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2204 struct msg_msg * msg, int msqflg)
2205{
2206 return 0;
2207}
2208
2209static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2210 struct msg_msg * msg,
2211 struct task_struct * target,
2212 long type, int mode)
2213{
2214 return 0;
2215}
2216
2217static inline int security_shm_alloc (struct shmid_kernel *shp)
2218{
2219 return 0;
2220}
2221
2222static inline void security_shm_free (struct shmid_kernel *shp)
2223{ }
2224
2225static inline int security_shm_associate (struct shmid_kernel * shp,
2226 int shmflg)
2227{
2228 return 0;
2229}
2230
2231static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2232{
2233 return 0;
2234}
2235
2236static inline int security_shm_shmat (struct shmid_kernel * shp,
2237 char __user *shmaddr, int shmflg)
2238{
2239 return 0;
2240}
2241
2242static inline int security_sem_alloc (struct sem_array *sma)
2243{
2244 return 0;
2245}
2246
2247static inline void security_sem_free (struct sem_array *sma)
2248{ }
2249
2250static inline int security_sem_associate (struct sem_array * sma, int semflg)
2251{
2252 return 0;
2253}
2254
2255static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2256{
2257 return 0;
2258}
2259
2260static inline int security_sem_semop (struct sem_array * sma,
2261 struct sembuf * sops, unsigned nsops,
2262 int alter)
2263{
2264 return 0;
2265}
2266
2267static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2268{ }
2269
Al Viro04ff9702007-03-12 16:17:58 +00002270static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002271{
2272 return -EINVAL;
2273}
2274
2275static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2276{
2277 return -EINVAL;
2278}
2279
2280static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2281{
2282 return cap_netlink_send (sk, skb);
2283}
2284
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002285static inline int security_netlink_recv (struct sk_buff *skb, int cap)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002286{
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002287 return cap_netlink_recv (skb, cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002288}
2289
Randy Dunlaped5a9272006-02-01 03:05:00 -08002290static inline struct dentry *securityfs_create_dir(const char *name,
2291 struct dentry *parent)
2292{
2293 return ERR_PTR(-ENODEV);
2294}
2295
2296static inline struct dentry *securityfs_create_file(const char *name,
2297 mode_t mode,
2298 struct dentry *parent,
2299 void *data,
Jan Engelhardt1996a102008-01-23 00:02:58 +01002300 const struct file_operations *fops)
Randy Dunlaped5a9272006-02-01 03:05:00 -08002301{
2302 return ERR_PTR(-ENODEV);
2303}
2304
2305static inline void securityfs_remove(struct dentry *dentry)
2306{
2307}
2308
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002309static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2310{
2311 return -EOPNOTSUPP;
2312}
2313
David Howells63cb3442008-01-15 23:47:35 +00002314static inline int security_secctx_to_secid(char *secdata,
2315 u32 seclen,
2316 u32 *secid)
2317{
2318 return -EOPNOTSUPP;
2319}
2320
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002321static inline void security_release_secctx(char *secdata, u32 seclen)
2322{
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002323}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002324#endif /* CONFIG_SECURITY */
2325
2326#ifdef CONFIG_SECURITY_NETWORK
Linus Torvalds1da177e2005-04-16 15:20:36 -07002327
James Morris20510f22007-10-16 23:31:32 -07002328int security_unix_stream_connect(struct socket *sock, struct socket *other,
2329 struct sock *newsk);
2330int security_unix_may_send(struct socket *sock, struct socket *other);
2331int security_socket_create(int family, int type, int protocol, int kern);
2332int security_socket_post_create(struct socket *sock, int family,
2333 int type, int protocol, int kern);
2334int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
2335int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
2336int security_socket_listen(struct socket *sock, int backlog);
2337int security_socket_accept(struct socket *sock, struct socket *newsock);
2338void security_socket_post_accept(struct socket *sock, struct socket *newsock);
2339int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
2340int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
2341 int size, int flags);
2342int security_socket_getsockname(struct socket *sock);
2343int security_socket_getpeername(struct socket *sock);
2344int security_socket_getsockopt(struct socket *sock, int level, int optname);
2345int security_socket_setsockopt(struct socket *sock, int level, int optname);
2346int security_socket_shutdown(struct socket *sock, int how);
2347int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
2348int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2349 int __user *optlen, unsigned len);
2350int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
2351int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
2352void security_sk_free(struct sock *sk);
2353void security_sk_clone(const struct sock *sk, struct sock *newsk);
2354void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
2355void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
2356void security_sock_graft(struct sock*sk, struct socket *parent);
2357int security_inet_conn_request(struct sock *sk,
2358 struct sk_buff *skb, struct request_sock *req);
2359void security_inet_csk_clone(struct sock *newsk,
2360 const struct request_sock *req);
2361void security_inet_conn_established(struct sock *sk,
2362 struct sk_buff *skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002363
Linus Torvalds1da177e2005-04-16 15:20:36 -07002364#else /* CONFIG_SECURITY_NETWORK */
2365static inline int security_unix_stream_connect(struct socket * sock,
Venkat Yekkirala6b877692006-11-08 17:04:09 -06002366 struct socket * other,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367 struct sock * newsk)
2368{
2369 return 0;
2370}
2371
2372static inline int security_unix_may_send(struct socket * sock,
2373 struct socket * other)
2374{
2375 return 0;
2376}
2377
2378static inline int security_socket_create (int family, int type,
2379 int protocol, int kern)
2380{
2381 return 0;
2382}
2383
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07002384static inline int security_socket_post_create(struct socket * sock,
2385 int family,
2386 int type,
2387 int protocol, int kern)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388{
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07002389 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390}
2391
2392static inline int security_socket_bind(struct socket * sock,
2393 struct sockaddr * address,
2394 int addrlen)
2395{
2396 return 0;
2397}
2398
2399static inline int security_socket_connect(struct socket * sock,
2400 struct sockaddr * address,
2401 int addrlen)
2402{
2403 return 0;
2404}
2405
2406static inline int security_socket_listen(struct socket * sock, int backlog)
2407{
2408 return 0;
2409}
2410
2411static inline int security_socket_accept(struct socket * sock,
2412 struct socket * newsock)
2413{
2414 return 0;
2415}
2416
2417static inline void security_socket_post_accept(struct socket * sock,
2418 struct socket * newsock)
2419{
2420}
2421
2422static inline int security_socket_sendmsg(struct socket * sock,
2423 struct msghdr * msg, int size)
2424{
2425 return 0;
2426}
2427
2428static inline int security_socket_recvmsg(struct socket * sock,
2429 struct msghdr * msg, int size,
2430 int flags)
2431{
2432 return 0;
2433}
2434
2435static inline int security_socket_getsockname(struct socket * sock)
2436{
2437 return 0;
2438}
2439
2440static inline int security_socket_getpeername(struct socket * sock)
2441{
2442 return 0;
2443}
2444
2445static inline int security_socket_getsockopt(struct socket * sock,
2446 int level, int optname)
2447{
2448 return 0;
2449}
2450
2451static inline int security_socket_setsockopt(struct socket * sock,
2452 int level, int optname)
2453{
2454 return 0;
2455}
2456
2457static inline int security_socket_shutdown(struct socket * sock, int how)
2458{
2459 return 0;
2460}
2461static inline int security_sock_rcv_skb (struct sock * sk,
2462 struct sk_buff * skb)
2463{
2464 return 0;
2465}
2466
Catherine Zhang2c7946a2006-03-20 22:41:23 -08002467static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2468 int __user *optlen, unsigned len)
2469{
2470 return -ENOPROTOOPT;
2471}
2472
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002473static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002474{
2475 return -ENOPROTOOPT;
2476}
2477
Al Virodd0fc662005-10-07 07:46:04 +01002478static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002479{
2480 return 0;
2481}
2482
2483static inline void security_sk_free(struct sock *sk)
2484{
2485}
Trent Jaegerdf718372005-12-13 23:12:27 -08002486
Venkat Yekkirala892c1412006-08-04 23:08:56 -07002487static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2488{
2489}
2490
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002491static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
Trent Jaegerdf718372005-12-13 23:12:27 -08002492{
Trent Jaegerdf718372005-12-13 23:12:27 -08002493}
Venkat Yekkirala4237c752006-07-24 23:32:50 -07002494
2495static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2496{
2497}
2498
2499static inline void security_sock_graft(struct sock* sk, struct socket *parent)
2500{
2501}
2502
2503static inline int security_inet_conn_request(struct sock *sk,
2504 struct sk_buff *skb, struct request_sock *req)
2505{
2506 return 0;
2507}
2508
2509static inline void security_inet_csk_clone(struct sock *newsk,
2510 const struct request_sock *req)
2511{
2512}
Venkat Yekkirala6b877692006-11-08 17:04:09 -06002513
2514static inline void security_inet_conn_established(struct sock *sk,
2515 struct sk_buff *skb)
2516{
2517}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002518#endif /* CONFIG_SECURITY_NETWORK */
2519
Trent Jaegerdf718372005-12-13 23:12:27 -08002520#ifdef CONFIG_SECURITY_NETWORK_XFRM
Venkat Yekkiralacb969f02006-07-24 23:32:20 -07002521
James Morris20510f22007-10-16 23:31:32 -07002522int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
2523int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new);
2524void security_xfrm_policy_free(struct xfrm_policy *xp);
2525int security_xfrm_policy_delete(struct xfrm_policy *xp);
2526int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
2527int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2528 struct xfrm_sec_ctx *polsec, u32 secid);
2529int security_xfrm_state_delete(struct xfrm_state *x);
2530void security_xfrm_state_free(struct xfrm_state *x);
2531int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
2532int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2533 struct xfrm_policy *xp, struct flowi *fl);
2534int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
2535void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
Trent Jaegerdf718372005-12-13 23:12:27 -08002536
Trent Jaegerdf718372005-12-13 23:12:27 -08002537#else /* CONFIG_SECURITY_NETWORK_XFRM */
James Morris20510f22007-10-16 23:31:32 -07002538
Trent Jaegerdf718372005-12-13 23:12:27 -08002539static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
2540{
2541 return 0;
2542}
2543
2544static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
2545{
2546 return 0;
2547}
2548
2549static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
2550{
2551}
2552
Catherine Zhangc8c05a82006-06-08 23:39:49 -07002553static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
2554{
2555 return 0;
2556}
2557
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002558static inline int security_xfrm_state_alloc(struct xfrm_state *x,
2559 struct xfrm_user_sec_ctx *sec_ctx)
2560{
2561 return 0;
2562}
2563
2564static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2565 struct xfrm_sec_ctx *polsec, u32 secid)
Trent Jaegerdf718372005-12-13 23:12:27 -08002566{
2567 return 0;
2568}
2569
2570static inline void security_xfrm_state_free(struct xfrm_state *x)
2571{
2572}
2573
David S. Miller6f68dc32006-06-08 23:58:52 -07002574static inline int security_xfrm_state_delete(struct xfrm_state *x)
Catherine Zhangc8c05a82006-06-08 23:39:49 -07002575{
2576 return 0;
2577}
2578
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002579static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
Trent Jaegerdf718372005-12-13 23:12:27 -08002580{
2581 return 0;
2582}
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002583
2584static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2585 struct xfrm_policy *xp, struct flowi *fl)
2586{
2587 return 1;
2588}
2589
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002590static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002591{
2592 return 0;
2593}
2594
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002595static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
2596{
2597}
2598
Trent Jaegerdf718372005-12-13 23:12:27 -08002599#endif /* CONFIG_SECURITY_NETWORK_XFRM */
2600
David Howells29db9192005-10-30 15:02:44 -08002601#ifdef CONFIG_KEYS
2602#ifdef CONFIG_SECURITY
David Howells29db9192005-10-30 15:02:44 -08002603
James Morris20510f22007-10-16 23:31:32 -07002604int security_key_alloc(struct key *key, struct task_struct *tsk, unsigned long flags);
2605void security_key_free(struct key *key);
2606int security_key_permission(key_ref_t key_ref,
2607 struct task_struct *context, key_perm_t perm);
David Howells29db9192005-10-30 15:02:44 -08002608
2609#else
2610
Michael LeMayd7200242006-06-22 14:47:17 -07002611static inline int security_key_alloc(struct key *key,
David Howells7e047ef2006-06-26 00:24:50 -07002612 struct task_struct *tsk,
2613 unsigned long flags)
David Howells29db9192005-10-30 15:02:44 -08002614{
2615 return 0;
2616}
2617
2618static inline void security_key_free(struct key *key)
2619{
2620}
2621
2622static inline int security_key_permission(key_ref_t key_ref,
2623 struct task_struct *context,
2624 key_perm_t perm)
2625{
2626 return 0;
2627}
2628
2629#endif
2630#endif /* CONFIG_KEYS */
2631
Linus Torvalds1da177e2005-04-16 15:20:36 -07002632#endif /* ! __LINUX_SECURITY_H */
2633