blob: 56a0eed656733945833e82b0cc67997778c37975 [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
Ahmed S. Darwish076c54c2008-03-06 18:09:10 +020037/* Maximum number of letters for an LSM name string */
38#define SECURITY_NAME_MAX 10
39
Eric Paris06112162008-11-11 22:02:50 +110040/* If capable should audit the security request */
41#define SECURITY_CAP_NOAUDIT 0
42#define SECURITY_CAP_AUDIT 1
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044struct ctl_table;
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +020045struct audit_krule;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47/*
48 * These functions are in security/capability.c and are used
49 * as the default capabilities functions
50 */
Eric Paris06112162008-11-11 22:02:50 +110051extern int cap_capable(struct task_struct *tsk, int cap, int audit);
Eric Paris7b41b172008-04-23 14:10:25 -040052extern int cap_settime(struct timespec *ts, struct timezone *tz);
David Howells5cd9c582008-08-14 11:37:28 +010053extern int cap_ptrace_may_access(struct task_struct *child, unsigned int mode);
54extern int cap_ptrace_traceme(struct task_struct *parent);
Eric Paris7b41b172008-04-23 14:10:25 -040055extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
David Howellsd84f4f92008-11-14 10:39:23 +110056extern int cap_capset(struct cred *new, const struct cred *old,
57 const kernel_cap_t *effective,
58 const kernel_cap_t *inheritable,
59 const kernel_cap_t *permitted);
David Howellsa6f76f22008-11-14 10:39:24 +110060extern int cap_bprm_set_creds(struct linux_binprm *bprm);
Linus Torvalds1da177e2005-04-16 15:20:36 -070061extern int cap_bprm_secureexec(struct linux_binprm *bprm);
David Howells8f0cfa52008-04-29 00:59:41 -070062extern int cap_inode_setxattr(struct dentry *dentry, const char *name,
63 const void *value, size_t size, int flags);
64extern int cap_inode_removexattr(struct dentry *dentry, const char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -070065extern int cap_inode_need_killpriv(struct dentry *dentry);
66extern int cap_inode_killpriv(struct dentry *dentry);
David Howellsd84f4f92008-11-14 10:39:23 +110067extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
Andrew G. Morgan3898b1b2008-04-28 02:13:40 -070068extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
David Howellsd84f4f92008-11-14 10:39:23 +110069 unsigned long arg4, unsigned long arg5);
Eric Paris7b41b172008-04-23 14:10:25 -040070extern int cap_task_setscheduler(struct task_struct *p, int policy, struct sched_param *lp);
71extern int cap_task_setioprio(struct task_struct *p, int ioprio);
72extern int cap_task_setnice(struct task_struct *p, int nice);
73extern int cap_syslog(int type);
James Morris20510f22007-10-16 23:31:32 -070074extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
76struct msghdr;
77struct sk_buff;
78struct sock;
79struct sockaddr;
80struct socket;
Trent Jaegerdf718372005-12-13 23:12:27 -080081struct flowi;
82struct dst_entry;
83struct xfrm_selector;
84struct xfrm_policy;
85struct xfrm_state;
86struct xfrm_user_sec_ctx;
Eric Paris2069f452008-07-04 09:47:13 +100087struct seq_file;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
89extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
Darrel Goeddelc7bdb542006-06-27 13:26:11 -070090extern int cap_netlink_recv(struct sk_buff *skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
Eric Parised032182007-06-28 15:55:21 -040092extern unsigned long mmap_min_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093/*
94 * Values used in the task_security_ops calls
95 */
96/* setuid or setgid, id0 == uid or gid */
97#define LSM_SETID_ID 1
98
99/* setreuid or setregid, id0 == real, id1 == eff */
100#define LSM_SETID_RE 2
101
102/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
103#define LSM_SETID_RES 4
104
105/* setfsuid or setfsgid, id0 == fsuid or fsgid */
106#define LSM_SETID_FS 8
107
108/* forward declares to avoid warnings */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109struct sched_param;
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700110struct request_sock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
David Howellsa6f76f22008-11-14 10:39:24 +1100112/* bprm->unsafe reasons */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113#define LSM_UNSAFE_SHARE 1
114#define LSM_UNSAFE_PTRACE 2
115#define LSM_UNSAFE_PTRACE_CAP 4
116
117#ifdef CONFIG_SECURITY
118
Eric Parise0007522008-03-05 10:31:54 -0500119struct security_mnt_opts {
120 char **mnt_opts;
121 int *mnt_opts_flags;
122 int num_mnt_opts;
123};
124
125static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
126{
127 opts->mnt_opts = NULL;
128 opts->mnt_opts_flags = NULL;
129 opts->num_mnt_opts = 0;
130}
131
132static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
133{
134 int i;
135 if (opts->mnt_opts)
Eric Paris7b41b172008-04-23 14:10:25 -0400136 for (i = 0; i < opts->num_mnt_opts; i++)
Eric Parise0007522008-03-05 10:31:54 -0500137 kfree(opts->mnt_opts[i]);
138 kfree(opts->mnt_opts);
139 opts->mnt_opts = NULL;
140 kfree(opts->mnt_opts_flags);
141 opts->mnt_opts_flags = NULL;
142 opts->num_mnt_opts = 0;
143}
144
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145/**
146 * struct security_operations - main security structure
147 *
Ahmed S. Darwish076c54c2008-03-06 18:09:10 +0200148 * Security module identifier.
149 *
150 * @name:
151 * A string that acts as a unique identifeir for the LSM with max number
152 * of characters = SECURITY_NAME_MAX.
153 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 * Security hooks for program execution operations.
155 *
David Howellsa6f76f22008-11-14 10:39:24 +1100156 * @bprm_set_creds:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 * 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:
David Howellsa6f76f22008-11-14 10:39:24 +1100169 * 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 the
171 * preceding set_creds call. The primary difference from set_creds is
172 * that the argv list and envp list are reliably available in @bprm. This
173 * hook may be called multiple times during a single execve; and in each
174 * pass set_creds is called first.
Eric Paris7b41b172008-04-23 14:10:25 -0400175 * @bprm contains the linux_binprm structure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 * Return 0 if the hook is successful and permission is granted.
David Howellsa6f76f22008-11-14 10:39:24 +1100177 * @bprm_committing_creds:
178 * Prepare to install the new security attributes of a process being
179 * transformed by an execve operation, based on the old credentials
180 * pointed to by @current->cred and the information set in @bprm->cred by
181 * the bprm_set_creds hook. @bprm points to the linux_binprm structure.
182 * This hook is a good place to perform state changes on the process such
183 * as closing open file descriptors to which access will no longer be
184 * granted when the attributes are changed. This is called immediately
185 * before commit_creds().
186 * @bprm_committed_creds:
187 * Tidy up after the installation of the new security attributes of a
188 * process being transformed by an execve operation. The new credentials
189 * have, by this point, been set to @current->cred. @bprm points to the
190 * linux_binprm structure. This hook is a good place to perform state
191 * changes on the process such as clearing out non-inheritable signal
192 * state. This is called immediately after commit_creds().
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 * @bprm_secureexec:
Eric Paris7b41b172008-04-23 14:10:25 -0400194 * Return a boolean value (0 or 1) indicating whether a "secure exec"
195 * is required. The flag is passed in the auxiliary table
196 * on the initial stack to the ELF interpreter to indicate whether libc
197 * should enable secure mode.
198 * @bprm contains the linux_binprm structure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 *
200 * Security hooks for filesystem operations.
201 *
202 * @sb_alloc_security:
203 * Allocate and attach a security structure to the sb->s_security field.
204 * The s_security field is initialized to NULL when the structure is
205 * allocated.
206 * @sb contains the super_block structure to be modified.
207 * Return 0 if operation was successful.
208 * @sb_free_security:
209 * Deallocate and clear the sb->s_security field.
210 * @sb contains the super_block structure to be modified.
211 * @sb_statfs:
David Howells726c3342006-06-23 02:02:58 -0700212 * Check permission before obtaining filesystem statistics for the @mnt
213 * mountpoint.
214 * @dentry is a handle on the superblock for the filesystem.
Eric Paris7b41b172008-04-23 14:10:25 -0400215 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 * @sb_mount:
217 * Check permission before an object specified by @dev_name is mounted on
218 * the mount point named by @nd. For an ordinary mount, @dev_name
219 * identifies a device if the file system type requires a device. For a
220 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
221 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
222 * pathname of the object being mounted.
223 * @dev_name contains the name for object being mounted.
Al Virob5266eb2008-03-22 17:48:24 -0400224 * @path contains the path for mount point object.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 * @type contains the filesystem type.
226 * @flags contains the mount flags.
227 * @data contains the filesystem-specific data.
228 * Return 0 if permission is granted.
229 * @sb_copy_data:
230 * Allow mount option data to be copied prior to parsing by the filesystem,
231 * so that the security module can extract security-specific mount
232 * options cleanly (a filesystem may modify the data e.g. with strsep()).
233 * This also allows the original mount data to be stripped of security-
234 * specific options to avoid having to make filesystems aware of them.
235 * @type the type of filesystem being mounted.
236 * @orig the original mount data copied from userspace.
237 * @copy copied data which will be passed to the security module.
238 * Returns 0 if the copy was successful.
239 * @sb_check_sb:
240 * Check permission before the device with superblock @mnt->sb is mounted
241 * on the mount point named by @nd.
242 * @mnt contains the vfsmount for device being mounted.
Al Virob5266eb2008-03-22 17:48:24 -0400243 * @path contains the path for the mount point.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 * Return 0 if permission is granted.
245 * @sb_umount:
246 * Check permission before the @mnt file system is unmounted.
247 * @mnt contains the mounted file system.
248 * @flags contains the unmount flags, e.g. MNT_FORCE.
249 * Return 0 if permission is granted.
250 * @sb_umount_close:
251 * Close any files in the @mnt mounted filesystem that are held open by
252 * the security module. This hook is called during an umount operation
253 * prior to checking whether the filesystem is still busy.
254 * @mnt contains the mounted filesystem.
255 * @sb_umount_busy:
256 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
257 * any files that were closed by umount_close. This hook is called during
258 * an umount operation if the umount fails after a call to the
259 * umount_close hook.
260 * @mnt contains the mounted filesystem.
261 * @sb_post_remount:
262 * Update the security module's state when a filesystem is remounted.
263 * This hook is only called if the remount was successful.
264 * @mnt contains the mounted file system.
265 * @flags contains the new filesystem flags.
266 * @data contains the filesystem-specific data.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 * @sb_post_addmount:
268 * Update the security module's state when a filesystem is mounted.
269 * This hook is called any time a mount is successfully grafetd to
270 * the tree.
271 * @mnt contains the mounted filesystem.
Al Virob5266eb2008-03-22 17:48:24 -0400272 * @mountpoint contains the path for the mount point.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 * @sb_pivotroot:
274 * Check permission before pivoting the root filesystem.
Al Virob5266eb2008-03-22 17:48:24 -0400275 * @old_path contains the path for the new location of the current root (put_old).
Eric Paris7b41b172008-04-23 14:10:25 -0400276 * @new_path contains the path for the new root (new_root).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 * Return 0 if permission is granted.
278 * @sb_post_pivotroot:
279 * Update module state after a successful pivot.
Al Virob5266eb2008-03-22 17:48:24 -0400280 * @old_path contains the path for the old root.
Eric Paris7b41b172008-04-23 14:10:25 -0400281 * @new_path contains the path for the new root.
Eric Parisc9180a52007-11-30 13:00:35 -0500282 * @sb_set_mnt_opts:
283 * Set the security relevant mount options used for a superblock
284 * @sb the superblock to set security mount options for
Eric Parise0007522008-03-05 10:31:54 -0500285 * @opts binary data structure containing all lsm mount data
Eric Parisc9180a52007-11-30 13:00:35 -0500286 * @sb_clone_mnt_opts:
287 * Copy all security options from a given superblock to another
288 * @oldsb old superblock which contain information to clone
289 * @newsb new superblock which needs filled in
Eric Parise0007522008-03-05 10:31:54 -0500290 * @sb_parse_opts_str:
291 * Parse a string of security data filling in the opts structure
292 * @options string containing all mount options known by the LSM
293 * @opts binary data structure usable by the LSM
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 *
295 * Security hooks for inode operations.
296 *
297 * @inode_alloc_security:
298 * Allocate and attach a security structure to @inode->i_security. The
299 * i_security field is initialized to NULL when the inode structure is
300 * allocated.
301 * @inode contains the inode structure.
302 * Return 0 if operation was successful.
303 * @inode_free_security:
304 * @inode contains the inode structure.
305 * Deallocate the inode security structure and set @inode->i_security to
Eric Paris7b41b172008-04-23 14:10:25 -0400306 * NULL.
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700307 * @inode_init_security:
Eric Paris7b41b172008-04-23 14:10:25 -0400308 * Obtain the security attribute name suffix and value to set on a newly
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700309 * created inode and set up the incore security field for the new inode.
310 * This hook is called by the fs code as part of the inode creation
311 * transaction and provides for atomic labeling of the inode, unlike
312 * the post_create/mkdir/... hooks called by the VFS. The hook function
313 * is expected to allocate the name and value via kmalloc, with the caller
314 * being responsible for calling kfree after using them.
315 * If the security module does not use security attributes or does
316 * not wish to put a security attribute on this particular inode,
317 * then it should return -EOPNOTSUPP to skip this processing.
318 * @inode contains the inode structure of the newly created inode.
319 * @dir contains the inode structure of the parent directory.
320 * @name will be set to the allocated name suffix (e.g. selinux).
321 * @value will be set to the allocated attribute value.
322 * @len will be set to the length of the value.
323 * Returns 0 if @name and @value have been successfully set,
324 * -EOPNOTSUPP if no security attribute is needed, or
325 * -ENOMEM on memory allocation failure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 * @inode_create:
327 * Check permission to create a regular file.
328 * @dir contains inode structure of the parent of the new file.
329 * @dentry contains the dentry structure for the file to be created.
330 * @mode contains the file mode of the file to be created.
331 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 * @inode_link:
333 * Check permission before creating a new hard link to a file.
334 * @old_dentry contains the dentry structure for an existing link to the file.
335 * @dir contains the inode structure of the parent directory of the new link.
336 * @new_dentry contains the dentry structure for the new link.
337 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 * @inode_unlink:
Eric Paris7b41b172008-04-23 14:10:25 -0400339 * Check the permission to remove a hard link to a file.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 * @dir contains the inode structure of parent directory of the file.
341 * @dentry contains the dentry structure for file to be unlinked.
342 * Return 0 if permission is granted.
343 * @inode_symlink:
344 * Check the permission to create a symbolic link to a file.
345 * @dir contains the inode structure of parent directory of the symbolic link.
346 * @dentry contains the dentry structure of the symbolic link.
347 * @old_name contains the pathname of file.
348 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 * @inode_mkdir:
350 * Check permissions to create a new directory in the existing directory
Eric Paris7b41b172008-04-23 14:10:25 -0400351 * associated with inode strcture @dir.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 * @dir containst the inode structure of parent of the directory to be created.
353 * @dentry contains the dentry structure of new directory.
354 * @mode contains the mode of new directory.
355 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 * @inode_rmdir:
357 * Check the permission to remove a directory.
358 * @dir contains the inode structure of parent of the directory to be removed.
359 * @dentry contains the dentry structure of directory to be removed.
360 * Return 0 if permission is granted.
361 * @inode_mknod:
362 * Check permissions when creating a special file (or a socket or a fifo
363 * file created via the mknod system call). Note that if mknod operation
364 * is being done for a regular file, then the create hook will be called
365 * and not this hook.
366 * @dir contains the inode structure of parent of the new file.
367 * @dentry contains the dentry structure of the new file.
368 * @mode contains the mode of the new file.
Michael Opdenacker59c51592007-05-09 08:57:56 +0200369 * @dev contains the device number.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 * @inode_rename:
372 * Check for permission to rename a file or directory.
373 * @old_dir contains the inode structure for parent of the old link.
374 * @old_dentry contains the dentry structure of the old link.
375 * @new_dir contains the inode structure for parent of the new link.
376 * @new_dentry contains the dentry structure of the new link.
377 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 * @inode_readlink:
379 * Check the permission to read the symbolic link.
380 * @dentry contains the dentry structure for the file link.
381 * Return 0 if permission is granted.
382 * @inode_follow_link:
383 * Check permission to follow a symbolic link when looking up a pathname.
384 * @dentry contains the dentry structure for the link.
385 * @nd contains the nameidata structure for the parent directory.
386 * Return 0 if permission is granted.
387 * @inode_permission:
388 * Check permission before accessing an inode. This hook is called by the
389 * existing Linux permission function, so a security module can use it to
390 * provide additional checking for existing Linux permission checks.
391 * Notice that this hook is called when a file is opened (as well as many
392 * other operations), whereas the file_security_ops permission hook is
393 * called when the actual read/write operations are performed.
394 * @inode contains the inode structure to check.
395 * @mask contains the permission mask.
Eric Paris7b41b172008-04-23 14:10:25 -0400396 * @nd contains the nameidata (may be NULL).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 * Return 0 if permission is granted.
398 * @inode_setattr:
399 * Check permission before setting file attributes. Note that the kernel
400 * call to notify_change is performed from several locations, whenever
401 * file attributes change (such as when a file is truncated, chown/chmod
402 * operations, transferring disk quotas, etc).
403 * @dentry contains the dentry structure for the file.
404 * @attr is the iattr structure containing the new file attributes.
405 * Return 0 if permission is granted.
406 * @inode_getattr:
407 * Check permission before obtaining file attributes.
408 * @mnt is the vfsmount where the dentry was looked up
409 * @dentry contains the dentry structure for the file.
410 * Return 0 if permission is granted.
411 * @inode_delete:
412 * @inode contains the inode structure for deleted inode.
413 * This hook is called when a deleted inode is released (i.e. an inode
414 * with no hard links has its use count drop to zero). A security module
415 * can use this hook to release any persistent label associated with the
416 * inode.
417 * @inode_setxattr:
Eric Paris7b41b172008-04-23 14:10:25 -0400418 * Check permission before setting the extended attributes
419 * @value identified by @name for @dentry.
420 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 * @inode_post_setxattr:
Eric Paris7b41b172008-04-23 14:10:25 -0400422 * Update inode security field after successful setxattr operation.
423 * @value identified by @name for @dentry.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 * @inode_getxattr:
Eric Paris7b41b172008-04-23 14:10:25 -0400425 * Check permission before obtaining the extended attributes
426 * identified by @name for @dentry.
427 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 * @inode_listxattr:
Eric Paris7b41b172008-04-23 14:10:25 -0400429 * Check permission before obtaining the list of extended attribute
430 * names for @dentry.
431 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 * @inode_removexattr:
Eric Paris7b41b172008-04-23 14:10:25 -0400433 * Check permission before removing the extended attribute
434 * identified by @name for @dentry.
435 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 * @inode_getsecurity:
David P. Quigley42492592008-02-04 22:29:39 -0800437 * Retrieve a copy of the extended attribute representation of the
438 * security label associated with @name for @inode via @buffer. Note that
439 * @name is the remainder of the attribute name after the security prefix
440 * has been removed. @alloc is used to specify of the call should return a
441 * value via the buffer or just the value length Return size of buffer on
442 * success.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 * @inode_setsecurity:
444 * Set the security label associated with @name for @inode from the
445 * extended attribute value @value. @size indicates the size of the
446 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
Eric Paris7b41b172008-04-23 14:10:25 -0400447 * Note that @name is the remainder of the attribute name after the
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 * security. prefix has been removed.
449 * Return 0 on success.
450 * @inode_listsecurity:
451 * Copy the extended attribute names for the security labels
452 * associated with @inode into @buffer. The maximum size of @buffer
453 * is specified by @buffer_size. @buffer may be NULL to request
454 * the size of the buffer required.
455 * Returns number of bytes used/required on success.
Serge E. Hallynb5376772007-10-16 23:31:36 -0700456 * @inode_need_killpriv:
457 * Called when an inode has been changed.
458 * @dentry is the dentry being changed.
459 * Return <0 on error to abort the inode change operation.
460 * Return 0 if inode_killpriv does not need to be called.
461 * Return >0 if inode_killpriv does need to be called.
462 * @inode_killpriv:
463 * The setuid bit is being removed. Remove similar security labels.
464 * Called with the dentry->d_inode->i_mutex held.
465 * @dentry is the dentry being changed.
466 * Return 0 on success. If error is returned, then the operation
467 * causing setuid bit removal is failed.
Ahmed S. Darwish8a076192008-03-01 21:51:09 +0200468 * @inode_getsecid:
469 * Get the secid associated with the node.
470 * @inode contains a pointer to the inode.
471 * @secid contains a pointer to the location where result will be saved.
472 * In case of failure, @secid will be set to zero.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 *
474 * Security hooks for file operations
475 *
476 * @file_permission:
477 * Check file permissions before accessing an open file. This hook is
478 * called by various operations that read or write files. A security
479 * module can use this hook to perform additional checking on these
480 * operations, e.g. to revalidate permissions on use to support privilege
481 * bracketing or policy changes. Notice that this hook is used when the
482 * actual read/write operations are performed, whereas the
483 * inode_security_ops hook is called when a file is opened (as well as
484 * many other operations).
485 * Caveat: Although this hook can be used to revalidate permissions for
486 * various system call operations that read or write files, it does not
487 * address the revalidation of permissions for memory-mapped files.
488 * Security modules must handle this separately if they need such
489 * revalidation.
490 * @file contains the file structure being accessed.
491 * @mask contains the requested permissions.
492 * Return 0 if permission is granted.
493 * @file_alloc_security:
494 * Allocate and attach a security structure to the file->f_security field.
495 * The security field is initialized to NULL when the structure is first
496 * created.
497 * @file contains the file structure to secure.
498 * Return 0 if the hook is successful and permission is granted.
499 * @file_free_security:
500 * Deallocate and free any security structures stored in file->f_security.
501 * @file contains the file structure being modified.
502 * @file_ioctl:
503 * @file contains the file structure.
504 * @cmd contains the operation to perform.
505 * @arg contains the operational arguments.
506 * Check permission for an ioctl operation on @file. Note that @arg can
507 * sometimes represents a user space pointer; in other cases, it may be a
508 * simple integer value. When @arg represents a user space pointer, it
509 * should never be used by the security module.
510 * Return 0 if permission is granted.
511 * @file_mmap :
512 * Check permissions for a mmap operation. The @file may be NULL, e.g.
513 * if mapping anonymous memory.
514 * @file contains the file structure for file to map (may be NULL).
515 * @reqprot contains the protection requested by the application.
516 * @prot contains the protection that will be applied by the kernel.
517 * @flags contains the operational flags.
518 * Return 0 if permission is granted.
519 * @file_mprotect:
520 * Check permissions before changing memory access permissions.
521 * @vma contains the memory region to modify.
522 * @reqprot contains the protection requested by the application.
523 * @prot contains the protection that will be applied by the kernel.
524 * Return 0 if permission is granted.
525 * @file_lock:
526 * Check permission before performing file locking operations.
527 * Note: this hook mediates both flock and fcntl style locks.
528 * @file contains the file structure.
529 * @cmd contains the posix-translated lock operation to perform
530 * (e.g. F_RDLCK, F_WRLCK).
531 * Return 0 if permission is granted.
532 * @file_fcntl:
533 * Check permission before allowing the file operation specified by @cmd
534 * from being performed on the file @file. Note that @arg can sometimes
535 * represents a user space pointer; in other cases, it may be a simple
536 * integer value. When @arg represents a user space pointer, it should
537 * never be used by the security module.
538 * @file contains the file structure.
539 * @cmd contains the operation to be performed.
540 * @arg contains the operational arguments.
541 * Return 0 if permission is granted.
542 * @file_set_fowner:
543 * Save owner security information (typically from current->security) in
544 * file->f_security for later use by the send_sigiotask hook.
545 * @file contains the file structure to update.
546 * Return 0 on success.
547 * @file_send_sigiotask:
548 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
549 * process @tsk. Note that this hook is sometimes called from interrupt.
550 * Note that the fown_struct, @fown, is never outside the context of a
551 * struct file, so the file structure (and associated security information)
552 * can always be obtained:
Robert P. J. Dayb385a142007-02-10 01:46:25 -0800553 * container_of(fown, struct file, f_owner)
Eric Paris7b41b172008-04-23 14:10:25 -0400554 * @tsk contains the structure of task receiving signal.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 * @fown contains the file owner information.
556 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
557 * Return 0 if permission is granted.
558 * @file_receive:
559 * This hook allows security modules to control the ability of a process
560 * to receive an open file descriptor via socket IPC.
561 * @file contains the file structure being received.
562 * Return 0 if permission is granted.
563 *
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +0900564 * Security hook for dentry
565 *
566 * @dentry_open
567 * Save open-time permission checking state for later use upon
568 * file_permission, and recheck access if anything has changed
569 * since inode_permission.
570 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 * Security hooks for task operations.
572 *
573 * @task_create:
574 * Check permission before creating a child process. See the clone(2)
575 * manual page for definitions of the @clone_flags.
576 * @clone_flags contains the flags indicating what should be shared.
577 * Return 0 if permission is granted.
David Howellsf1752ee2008-11-14 10:39:17 +1100578 * @cred_free:
579 * @cred points to the credentials.
580 * Deallocate and clear the cred->security field in a set of credentials.
David Howellsd84f4f92008-11-14 10:39:23 +1100581 * @cred_prepare:
582 * @new points to the new credentials.
583 * @old points to the original credentials.
584 * @gfp indicates the atomicity of any memory allocations.
585 * Prepare a new set of credentials by copying the data from the old set.
586 * @cred_commit:
587 * @new points to the new credentials.
588 * @old points to the original credentials.
589 * Install a new set of credentials.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 * @task_setuid:
591 * Check permission before setting one or more of the user identity
592 * attributes of the current process. The @flags parameter indicates
593 * which of the set*uid system calls invoked this hook and how to
594 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
595 * definitions at the beginning of this file for the @flags values and
596 * their meanings.
597 * @id0 contains a uid.
598 * @id1 contains a uid.
599 * @id2 contains a uid.
600 * @flags contains one of the LSM_SETID_* values.
601 * Return 0 if permission is granted.
David Howellsd84f4f92008-11-14 10:39:23 +1100602 * @task_fix_setuid:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 * Update the module's state after setting one or more of the user
604 * identity attributes of the current process. The @flags parameter
605 * indicates which of the set*uid system calls invoked this hook. If
David Howellsd84f4f92008-11-14 10:39:23 +1100606 * @new is the set of credentials that will be installed. Modifications
607 * should be made to this rather than to @current->cred.
608 * @old is the set of credentials that are being replaces
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 * @flags contains one of the LSM_SETID_* values.
610 * Return 0 on success.
611 * @task_setgid:
612 * Check permission before setting one or more of the group identity
613 * attributes of the current process. The @flags parameter indicates
614 * which of the set*gid system calls invoked this hook and how to
615 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
616 * definitions at the beginning of this file for the @flags values and
617 * their meanings.
618 * @id0 contains a gid.
619 * @id1 contains a gid.
620 * @id2 contains a gid.
621 * @flags contains one of the LSM_SETID_* values.
622 * Return 0 if permission is granted.
623 * @task_setpgid:
624 * Check permission before setting the process group identifier of the
625 * process @p to @pgid.
626 * @p contains the task_struct for process being modified.
627 * @pgid contains the new pgid.
628 * Return 0 if permission is granted.
629 * @task_getpgid:
630 * Check permission before getting the process group identifier of the
631 * process @p.
632 * @p contains the task_struct for the process.
633 * Return 0 if permission is granted.
634 * @task_getsid:
635 * Check permission before getting the session identifier of the process
636 * @p.
637 * @p contains the task_struct for the process.
638 * Return 0 if permission is granted.
David Quigleyf9008e42006-06-30 01:55:46 -0700639 * @task_getsecid:
640 * Retrieve the security identifier of the process @p.
641 * @p contains the task_struct for the process and place is into @secid.
Ahmed S. Darwish8a076192008-03-01 21:51:09 +0200642 * In case of failure, @secid will be set to zero.
643 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 * @task_setgroups:
645 * Check permission before setting the supplementary group set of the
646 * current process.
647 * @group_info contains the new group information.
648 * Return 0 if permission is granted.
649 * @task_setnice:
650 * Check permission before setting the nice value of @p to @nice.
651 * @p contains the task_struct of process.
652 * @nice contains the new nice value.
653 * Return 0 if permission is granted.
James Morris03e68062006-06-23 02:03:58 -0700654 * @task_setioprio
655 * Check permission before setting the ioprio value of @p to @ioprio.
656 * @p contains the task_struct of process.
657 * @ioprio contains the new ioprio value
658 * Return 0 if permission is granted.
David Quigleya1836a42006-06-30 01:55:49 -0700659 * @task_getioprio
660 * Check permission before getting the ioprio value of @p.
661 * @p contains the task_struct of process.
662 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 * @task_setrlimit:
664 * Check permission before setting the resource limits of the current
665 * process for @resource to @new_rlim. The old resource limit values can
666 * be examined by dereferencing (current->signal->rlim + resource).
667 * @resource contains the resource whose limit is being set.
668 * @new_rlim contains the new limits for @resource.
669 * Return 0 if permission is granted.
670 * @task_setscheduler:
671 * Check permission before setting scheduling policy and/or parameters of
672 * process @p based on @policy and @lp.
673 * @p contains the task_struct for process.
674 * @policy contains the scheduling policy.
675 * @lp contains the scheduling parameters.
676 * Return 0 if permission is granted.
677 * @task_getscheduler:
678 * Check permission before obtaining scheduling information for process
679 * @p.
680 * @p contains the task_struct for process.
681 * Return 0 if permission is granted.
David Quigley35601542006-06-23 02:04:01 -0700682 * @task_movememory
683 * Check permission before moving memory owned by process @p.
684 * @p contains the task_struct for process.
685 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 * @task_kill:
687 * Check permission before sending signal @sig to @p. @info can be NULL,
688 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
689 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
690 * from the kernel and should typically be permitted.
691 * SIGIO signals are handled separately by the send_sigiotask hook in
692 * file_security_ops.
693 * @p contains the task_struct for process.
694 * @info contains the signal information.
695 * @sig contains the signal value.
David Quigleyf9008e42006-06-30 01:55:46 -0700696 * @secid contains the sid of the process where the signal originated
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 * Return 0 if permission is granted.
698 * @task_wait:
699 * Check permission before allowing a process to reap a child process @p
700 * and collect its status information.
701 * @p contains the task_struct for process.
702 * Return 0 if permission is granted.
703 * @task_prctl:
704 * Check permission before performing a process control operation on the
705 * current process.
706 * @option contains the operation.
707 * @arg2 contains a argument.
708 * @arg3 contains a argument.
709 * @arg4 contains a argument.
710 * @arg5 contains a argument.
David Howellsd84f4f92008-11-14 10:39:23 +1100711 * Return -ENOSYS if no-one wanted to handle this op, any other value to
712 * cause prctl() to return immediately with that value.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 * @task_to_inode:
Eric Paris7b41b172008-04-23 14:10:25 -0400714 * Set the security attributes for an inode based on an associated task's
715 * security attributes, e.g. for /proc/pid inodes.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 * @p contains the task_struct for the task.
717 * @inode contains the inode structure for the inode.
718 *
719 * Security hooks for Netlink messaging.
720 *
721 * @netlink_send:
722 * Save security information for a netlink message so that permission
723 * checking can be performed when the message is processed. The security
724 * information can be saved using the eff_cap field of the
Eric Paris7b41b172008-04-23 14:10:25 -0400725 * netlink_skb_parms structure. Also may be used to provide fine
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 * grained control over message transmission.
727 * @sk associated sock of task sending the message.,
728 * @skb contains the sk_buff structure for the netlink message.
729 * Return 0 if the information was successfully saved and message
730 * is allowed to be transmitted.
731 * @netlink_recv:
732 * Check permission before processing the received netlink message in
733 * @skb.
734 * @skb contains the sk_buff structure for the netlink message.
Darrel Goeddelc7bdb542006-06-27 13:26:11 -0700735 * @cap indicates the capability required
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 * Return 0 if permission is granted.
737 *
738 * Security hooks for Unix domain networking.
739 *
740 * @unix_stream_connect:
741 * Check permissions before establishing a Unix domain stream connection
742 * between @sock and @other.
743 * @sock contains the socket structure.
744 * @other contains the peer socket structure.
745 * Return 0 if permission is granted.
746 * @unix_may_send:
747 * Check permissions before connecting or sending datagrams from @sock to
748 * @other.
749 * @sock contains the socket structure.
750 * @sock contains the peer socket structure.
751 * Return 0 if permission is granted.
752 *
753 * The @unix_stream_connect and @unix_may_send hooks were necessary because
754 * Linux provides an alternative to the conventional file name space for Unix
755 * domain sockets. Whereas binding and connecting to sockets in the file name
756 * space is mediated by the typical file permissions (and caught by the mknod
757 * and permission hooks in inode_security_ops), binding and connecting to
758 * sockets in the abstract name space is completely unmediated. Sufficient
759 * control of Unix domain sockets in the abstract name space isn't possible
760 * using only the socket layer hooks, since we need to know the actual target
761 * socket, which is not looked up until we are inside the af_unix code.
762 *
763 * Security hooks for socket operations.
764 *
765 * @socket_create:
766 * Check permissions prior to creating a new socket.
767 * @family contains the requested protocol family.
768 * @type contains the requested communications type.
769 * @protocol contains the requested protocol.
770 * @kern set to 1 if a kernel socket.
771 * Return 0 if permission is granted.
772 * @socket_post_create:
773 * This hook allows a module to update or allocate a per-socket security
774 * structure. Note that the security field was not added directly to the
775 * socket structure, but rather, the socket security information is stored
776 * in the associated inode. Typically, the inode alloc_security hook will
777 * allocate and and attach security information to
778 * sock->inode->i_security. This hook may be used to update the
779 * sock->inode->i_security field with additional information that wasn't
780 * available when the inode was allocated.
781 * @sock contains the newly created socket structure.
782 * @family contains the requested protocol family.
783 * @type contains the requested communications type.
784 * @protocol contains the requested protocol.
785 * @kern set to 1 if a kernel socket.
786 * @socket_bind:
787 * Check permission before socket protocol layer bind operation is
788 * performed and the socket @sock is bound to the address specified in the
789 * @address parameter.
790 * @sock contains the socket structure.
791 * @address contains the address to bind to.
792 * @addrlen contains the length of address.
Eric Paris7b41b172008-04-23 14:10:25 -0400793 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 * @socket_connect:
795 * Check permission before socket protocol layer connect operation
796 * attempts to connect socket @sock to a remote address, @address.
797 * @sock contains the socket structure.
798 * @address contains the address of remote endpoint.
799 * @addrlen contains the length of address.
Eric Paris7b41b172008-04-23 14:10:25 -0400800 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 * @socket_listen:
802 * Check permission before socket protocol layer listen operation.
803 * @sock contains the socket structure.
804 * @backlog contains the maximum length for the pending connection queue.
805 * Return 0 if permission is granted.
806 * @socket_accept:
807 * Check permission before accepting a new connection. Note that the new
808 * socket, @newsock, has been created and some information copied to it,
809 * but the accept operation has not actually been performed.
810 * @sock contains the listening socket structure.
811 * @newsock contains the newly created server socket for connection.
812 * Return 0 if permission is granted.
813 * @socket_post_accept:
814 * This hook allows a security module to copy security
815 * information into the newly created socket's inode.
816 * @sock contains the listening socket structure.
817 * @newsock contains the newly created server socket for connection.
818 * @socket_sendmsg:
819 * Check permission before transmitting a message to another socket.
820 * @sock contains the socket structure.
821 * @msg contains the message to be transmitted.
822 * @size contains the size of message.
823 * Return 0 if permission is granted.
824 * @socket_recvmsg:
825 * Check permission before receiving a message from a socket.
826 * @sock contains the socket structure.
827 * @msg contains the message structure.
828 * @size contains the size of message structure.
829 * @flags contains the operational flags.
Eric Paris7b41b172008-04-23 14:10:25 -0400830 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 * @socket_getsockname:
832 * Check permission before the local address (name) of the socket object
833 * @sock is retrieved.
834 * @sock contains the socket structure.
835 * Return 0 if permission is granted.
836 * @socket_getpeername:
837 * Check permission before the remote address (name) of a socket object
838 * @sock is retrieved.
839 * @sock contains the socket structure.
840 * Return 0 if permission is granted.
841 * @socket_getsockopt:
842 * Check permissions before retrieving the options associated with socket
843 * @sock.
844 * @sock contains the socket structure.
845 * @level contains the protocol level to retrieve option from.
846 * @optname contains the name of option to retrieve.
847 * Return 0 if permission is granted.
848 * @socket_setsockopt:
849 * Check permissions before setting the options associated with socket
850 * @sock.
851 * @sock contains the socket structure.
852 * @level contains the protocol level to set options for.
853 * @optname contains the name of the option to set.
Eric Paris7b41b172008-04-23 14:10:25 -0400854 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855 * @socket_shutdown:
856 * Checks permission before all or part of a connection on the socket
857 * @sock is shut down.
858 * @sock contains the socket structure.
859 * @how contains the flag indicating how future sends and receives are handled.
860 * Return 0 if permission is granted.
861 * @socket_sock_rcv_skb:
862 * Check permissions on incoming network packets. This hook is distinct
863 * from Netfilter's IP input hooks since it is the first time that the
864 * incoming sk_buff @skb has been associated with a particular socket, @sk.
865 * @sk contains the sock (not socket) associated with the incoming sk_buff.
866 * @skb contains the incoming network data.
Serge Hallyn6da34ba2007-10-20 00:53:30 +0200867 * @socket_getpeersec_stream:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 * This hook allows the security module to provide peer socket security
Serge Hallyn6da34ba2007-10-20 00:53:30 +0200869 * state for unix or connected tcp sockets to userspace via getsockopt
870 * SO_GETPEERSEC. For tcp sockets this can be meaningful if the
871 * socket is associated with an ipsec SA.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872 * @sock is the local socket.
873 * @optval userspace memory where the security state is to be copied.
874 * @optlen userspace int where the module should copy the actual length
875 * of the security state.
876 * @len as input is the maximum length to copy to userspace provided
877 * by the caller.
878 * Return 0 if all is well, otherwise, typical getsockopt return
879 * values.
Serge Hallyn6da34ba2007-10-20 00:53:30 +0200880 * @socket_getpeersec_dgram:
Eric Paris7b41b172008-04-23 14:10:25 -0400881 * This hook allows the security module to provide peer socket security
882 * state for udp sockets on a per-packet basis to userspace via
883 * getsockopt SO_GETPEERSEC. The application must first have indicated
884 * the IP_PASSSEC option via getsockopt. It can then retrieve the
885 * security state returned by this hook for a packet via the SCM_SECURITY
886 * ancillary message type.
887 * @skb is the skbuff for the packet being queried
888 * @secdata is a pointer to a buffer in which to copy the security data
889 * @seclen is the maximum length for @secdata
890 * Return 0 on success, error on failure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 * @sk_alloc_security:
Eric Paris7b41b172008-04-23 14:10:25 -0400892 * Allocate and attach a security structure to the sk->sk_security field,
893 * which is used to copy security attributes between local stream sockets.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894 * @sk_free_security:
895 * Deallocate security structure.
Venkat Yekkirala892c1412006-08-04 23:08:56 -0700896 * @sk_clone_security:
897 * Clone/copy security structure.
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -0700898 * @sk_getsecid:
899 * Retrieve the LSM-specific secid for the sock to enable caching of network
Trent Jaegerdf718372005-12-13 23:12:27 -0800900 * authorizations.
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700901 * @sock_graft:
902 * Sets the socket's isec sid to the sock's sid.
903 * @inet_conn_request:
904 * Sets the openreq's sid to socket's sid with MLS portion taken from peer sid.
905 * @inet_csk_clone:
906 * Sets the new child socket's sid to the openreq sid.
Venkat Yekkirala6b877692006-11-08 17:04:09 -0600907 * @inet_conn_established:
Eric Paris7b41b172008-04-23 14:10:25 -0400908 * Sets the connection's peersid to the secmark on skb.
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700909 * @req_classify_flow:
910 * Sets the flow's sid to the openreq sid.
Trent Jaegerdf718372005-12-13 23:12:27 -0800911 *
912 * Security hooks for XFRM operations.
913 *
914 * @xfrm_policy_alloc_security:
Paul Moore03e1ad72008-04-12 19:07:52 -0700915 * @ctxp is a pointer to the xfrm_sec_ctx being added to Security Policy
916 * Database used by the XFRM system.
Trent Jaegerdf718372005-12-13 23:12:27 -0800917 * @sec_ctx contains the security context information being provided by
918 * the user-level policy update program (e.g., setkey).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700919 * Allocate a security structure to the xp->security field; the security
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -0600920 * field is initialized to NULL when the xfrm_policy is allocated.
Trent Jaegerdf718372005-12-13 23:12:27 -0800921 * Return 0 if operation was successful (memory to allocate, legal context)
922 * @xfrm_policy_clone_security:
Paul Moore03e1ad72008-04-12 19:07:52 -0700923 * @old_ctx contains an existing xfrm_sec_ctx.
924 * @new_ctxp contains a new xfrm_sec_ctx being cloned from old.
925 * Allocate a security structure in new_ctxp that contains the
926 * information from the old_ctx structure.
Trent Jaegerdf718372005-12-13 23:12:27 -0800927 * Return 0 if operation was successful (memory to allocate).
928 * @xfrm_policy_free_security:
Paul Moore03e1ad72008-04-12 19:07:52 -0700929 * @ctx contains the xfrm_sec_ctx
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700930 * Deallocate xp->security.
931 * @xfrm_policy_delete_security:
Paul Moore03e1ad72008-04-12 19:07:52 -0700932 * @ctx contains the xfrm_sec_ctx.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700933 * Authorize deletion of xp->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800934 * @xfrm_state_alloc_security:
935 * @x contains the xfrm_state being added to the Security Association
936 * Database by the XFRM system.
937 * @sec_ctx contains the security context information being provided by
938 * the user-level SA generation program (e.g., setkey or racoon).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700939 * @secid contains the secid from which to take the mls portion of the context.
940 * Allocate a security structure to the x->security field; the security
941 * field is initialized to NULL when the xfrm_state is allocated. Set the
942 * context to correspond to either sec_ctx or polsec, with the mls portion
943 * taken from secid in the latter case.
Trent Jaegerdf718372005-12-13 23:12:27 -0800944 * Return 0 if operation was successful (memory to allocate, legal context).
945 * @xfrm_state_free_security:
946 * @x contains the xfrm_state.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700947 * Deallocate x->security.
948 * @xfrm_state_delete_security:
949 * @x contains the xfrm_state.
950 * Authorize deletion of x->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800951 * @xfrm_policy_lookup:
Paul Moore03e1ad72008-04-12 19:07:52 -0700952 * @ctx contains the xfrm_sec_ctx for which the access control is being
Trent Jaegerdf718372005-12-13 23:12:27 -0800953 * checked.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700954 * @fl_secid contains the flow security label that is used to authorize
Trent Jaegerdf718372005-12-13 23:12:27 -0800955 * access to the policy xp.
956 * @dir contains the direction of the flow (input or output).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700957 * Check permission when a flow selects a xfrm_policy for processing
Trent Jaegerdf718372005-12-13 23:12:27 -0800958 * XFRMs on a packet. The hook is called when selecting either a
959 * per-socket policy or a generic xfrm policy.
Venkat Yekkirala5b368e62006-10-05 15:42:18 -0500960 * Return 0 if permission is granted, -ESRCH otherwise, or -errno
961 * on other errors.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700962 * @xfrm_state_pol_flow_match:
963 * @x contains the state to match.
964 * @xp contains the policy to check for a match.
965 * @fl contains the flow to check for a match.
966 * Return 1 if there is a match.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700967 * @xfrm_decode_session:
968 * @skb points to skb to decode.
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -0700969 * @secid points to the flow key secid to set.
970 * @ckall says if all xfrms used should be checked for same secid.
971 * Return 0 if ckall is zero or all xfrms used have the same secid.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700972 *
David Howells29db9192005-10-30 15:02:44 -0800973 * Security hooks affecting all Key Management operations
974 *
975 * @key_alloc:
976 * Permit allocation of a key and assign security data. Note that key does
977 * not have a serial number assigned at this point.
978 * @key points to the key.
David Howells7e047ef2006-06-26 00:24:50 -0700979 * @flags is the allocation flags
David Howells29db9192005-10-30 15:02:44 -0800980 * Return 0 if permission is granted, -ve error otherwise.
981 * @key_free:
982 * Notification of destruction; free security data.
983 * @key points to the key.
984 * No return value.
985 * @key_permission:
986 * See whether a specific operational right is granted to a process on a
Eric Paris7b41b172008-04-23 14:10:25 -0400987 * key.
David Howells29db9192005-10-30 15:02:44 -0800988 * @key_ref refers to the key (key pointer + possession attribute bit).
David Howellsd84f4f92008-11-14 10:39:23 +1100989 * @cred points to the credentials to provide the context against which to
Eric Paris7b41b172008-04-23 14:10:25 -0400990 * evaluate the security data on the key.
David Howells29db9192005-10-30 15:02:44 -0800991 * @perm describes the combination of permissions required of this key.
992 * Return 1 if permission granted, 0 if permission denied and -ve it the
Eric Paris7b41b172008-04-23 14:10:25 -0400993 * normal permissions model should be effected.
David Howells70a5bb72008-04-29 01:01:26 -0700994 * @key_getsecurity:
995 * Get a textual representation of the security context attached to a key
996 * for the purposes of honouring KEYCTL_GETSECURITY. This function
997 * allocates the storage for the NUL-terminated string and the caller
998 * should free it.
999 * @key points to the key to be queried.
1000 * @_buffer points to a pointer that should be set to point to the
1001 * resulting string (if no label or an error occurs).
1002 * Return the length of the string (including terminating NUL) or -ve if
1003 * an error.
1004 * May also return 0 (and a NULL buffer pointer) if there is no label.
David Howells29db9192005-10-30 15:02:44 -08001005 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006 * Security hooks affecting all System V IPC operations.
1007 *
1008 * @ipc_permission:
1009 * Check permissions for access to IPC
1010 * @ipcp contains the kernel IPC permission structure
1011 * @flag contains the desired (requested) permission set
1012 * Return 0 if permission is granted.
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02001013 * @ipc_getsecid:
1014 * Get the secid associated with the ipc object.
1015 * @ipcp contains the kernel IPC permission structure.
1016 * @secid contains a pointer to the location where result will be saved.
1017 * In case of failure, @secid will be set to zero.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018 *
1019 * Security hooks for individual messages held in System V IPC message queues
1020 * @msg_msg_alloc_security:
1021 * Allocate and attach a security structure to the msg->security field.
1022 * The security field is initialized to NULL when the structure is first
1023 * created.
1024 * @msg contains the message structure to be modified.
1025 * Return 0 if operation was successful and permission is granted.
1026 * @msg_msg_free_security:
1027 * Deallocate the security structure for this message.
1028 * @msg contains the message structure to be modified.
1029 *
1030 * Security hooks for System V IPC Message Queues
1031 *
1032 * @msg_queue_alloc_security:
1033 * Allocate and attach a security structure to the
1034 * msq->q_perm.security field. The security field is initialized to
1035 * NULL when the structure is first created.
1036 * @msq contains the message queue structure to be modified.
1037 * Return 0 if operation was successful and permission is granted.
1038 * @msg_queue_free_security:
1039 * Deallocate security structure for this message queue.
1040 * @msq contains the message queue structure to be modified.
1041 * @msg_queue_associate:
1042 * Check permission when a message queue is requested through the
1043 * msgget system call. This hook is only called when returning the
1044 * message queue identifier for an existing message queue, not when a
1045 * new message queue is created.
1046 * @msq contains the message queue to act upon.
1047 * @msqflg contains the operation control flags.
1048 * Return 0 if permission is granted.
1049 * @msg_queue_msgctl:
1050 * Check permission when a message control operation specified by @cmd
1051 * is to be performed on the message queue @msq.
1052 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
1053 * @msq contains the message queue to act upon. May be NULL.
1054 * @cmd contains the operation to be performed.
Eric Paris7b41b172008-04-23 14:10:25 -04001055 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 * @msg_queue_msgsnd:
1057 * Check permission before a message, @msg, is enqueued on the message
1058 * queue, @msq.
1059 * @msq contains the message queue to send message to.
1060 * @msg contains the message to be enqueued.
1061 * @msqflg contains operational flags.
1062 * Return 0 if permission is granted.
1063 * @msg_queue_msgrcv:
1064 * Check permission before a message, @msg, is removed from the message
Eric Paris7b41b172008-04-23 14:10:25 -04001065 * queue, @msq. The @target task structure contains a pointer to the
1066 * process that will be receiving the message (not equal to the current
Linus Torvalds1da177e2005-04-16 15:20:36 -07001067 * process when inline receives are being performed).
1068 * @msq contains the message queue to retrieve message from.
1069 * @msg contains the message destination.
1070 * @target contains the task structure for recipient process.
1071 * @type contains the type of message requested.
1072 * @mode contains the operational flags.
1073 * Return 0 if permission is granted.
1074 *
1075 * Security hooks for System V Shared Memory Segments
1076 *
1077 * @shm_alloc_security:
1078 * Allocate and attach a security structure to the shp->shm_perm.security
1079 * field. The security field is initialized to NULL when the structure is
1080 * first created.
1081 * @shp contains the shared memory structure to be modified.
1082 * Return 0 if operation was successful and permission is granted.
1083 * @shm_free_security:
1084 * Deallocate the security struct for this memory segment.
1085 * @shp contains the shared memory structure to be modified.
1086 * @shm_associate:
1087 * Check permission when a shared memory region is requested through the
1088 * shmget system call. This hook is only called when returning the shared
1089 * memory region identifier for an existing region, not when a new shared
1090 * memory region is created.
1091 * @shp contains the shared memory structure to be modified.
1092 * @shmflg contains the operation control flags.
1093 * Return 0 if permission is granted.
1094 * @shm_shmctl:
1095 * Check permission when a shared memory control operation specified by
1096 * @cmd is to be performed on the shared memory region @shp.
1097 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1098 * @shp contains shared memory structure to be modified.
1099 * @cmd contains the operation to be performed.
1100 * Return 0 if permission is granted.
1101 * @shm_shmat:
1102 * Check permissions prior to allowing the shmat system call to attach the
1103 * shared memory segment @shp to the data segment of the calling process.
1104 * The attaching address is specified by @shmaddr.
1105 * @shp contains the shared memory structure to be modified.
1106 * @shmaddr contains the address to attach memory region to.
1107 * @shmflg contains the operational flags.
1108 * Return 0 if permission is granted.
1109 *
1110 * Security hooks for System V Semaphores
1111 *
1112 * @sem_alloc_security:
1113 * Allocate and attach a security structure to the sma->sem_perm.security
1114 * field. The security field is initialized to NULL when the structure is
1115 * first created.
1116 * @sma contains the semaphore structure
1117 * Return 0 if operation was successful and permission is granted.
1118 * @sem_free_security:
1119 * deallocate security struct for this semaphore
1120 * @sma contains the semaphore structure.
1121 * @sem_associate:
1122 * Check permission when a semaphore is requested through the semget
1123 * system call. This hook is only called when returning the semaphore
1124 * identifier for an existing semaphore, not when a new one must be
1125 * created.
1126 * @sma contains the semaphore structure.
1127 * @semflg contains the operation control flags.
1128 * Return 0 if permission is granted.
1129 * @sem_semctl:
1130 * Check permission when a semaphore operation specified by @cmd is to be
Eric Paris7b41b172008-04-23 14:10:25 -04001131 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132 * IPC_INFO or SEM_INFO.
1133 * @sma contains the semaphore structure. May be NULL.
1134 * @cmd contains the operation to be performed.
1135 * Return 0 if permission is granted.
1136 * @sem_semop
1137 * Check permissions before performing operations on members of the
Eric Paris7b41b172008-04-23 14:10:25 -04001138 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1139 * may be modified.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 * @sma contains the semaphore structure.
1141 * @sops contains the operations to perform.
1142 * @nsops contains the number of operations to perform.
1143 * @alter contains the flag indicating whether changes are to be made.
1144 * Return 0 if permission is granted.
1145 *
David Howells5cd9c582008-08-14 11:37:28 +01001146 * @ptrace_may_access:
1147 * Check permission before allowing the current process to trace the
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148 * @child process.
1149 * Security modules may also want to perform a process tracing check
1150 * during an execve in the set_security or apply_creds hooks of
David Howellsd84f4f92008-11-14 10:39:23 +11001151 * tracing check during an execve in the bprm_set_creds hook of
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 * binprm_security_ops if the process is being traced and its security
1153 * attributes would be changed by the execve.
David Howells5cd9c582008-08-14 11:37:28 +01001154 * @child contains the task_struct structure for the target process.
Stephen Smalley006ebb42008-05-19 08:32:49 -04001155 * @mode contains the PTRACE_MODE flags indicating the form of access.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156 * Return 0 if permission is granted.
David Howells5cd9c582008-08-14 11:37:28 +01001157 * @ptrace_traceme:
1158 * Check that the @parent process has sufficient permission to trace the
1159 * current process before allowing the current process to present itself
1160 * to the @parent process for tracing.
1161 * The parent process will still have to undergo the ptrace_may_access
1162 * checks before it is allowed to trace this one.
1163 * @parent contains the task_struct structure for debugger process.
1164 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 * @capget:
1166 * Get the @effective, @inheritable, and @permitted capability sets for
1167 * the @target process. The hook may also perform permission checking to
1168 * determine if the current process is allowed to see the capability sets
1169 * of the @target process.
1170 * @target contains the task_struct structure for target process.
1171 * @effective contains the effective capability set.
1172 * @inheritable contains the inheritable capability set.
1173 * @permitted contains the permitted capability set.
1174 * Return 0 if the capability sets were successfully obtained.
David Howellsd84f4f92008-11-14 10:39:23 +11001175 * @capset:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 * Set the @effective, @inheritable, and @permitted capability sets for
David Howells1cdcbec2008-11-14 10:39:14 +11001177 * the current process.
David Howellsd84f4f92008-11-14 10:39:23 +11001178 * @new contains the new credentials structure for target process.
1179 * @old contains the current credentials structure for target process.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 * @effective contains the effective capability set.
1181 * @inheritable contains the inheritable capability set.
1182 * @permitted contains the permitted capability set.
David Howellsd84f4f92008-11-14 10:39:23 +11001183 * Return 0 and update @new if permission is granted.
Chris Wright12b59892006-03-25 03:07:41 -08001184 * @capable:
1185 * Check whether the @tsk process has the @cap capability.
1186 * @tsk contains the task_struct for the process.
1187 * @cap contains the capability <include/linux/capability.h>.
1188 * Return 0 if the capability is granted for @tsk.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001189 * @acct:
1190 * Check permission before enabling or disabling process accounting. If
1191 * accounting is being enabled, then @file refers to the open file used to
1192 * store accounting records. If accounting is being disabled, then @file
1193 * is NULL.
1194 * @file contains the file structure for the accounting file (may be NULL).
1195 * Return 0 if permission is granted.
1196 * @sysctl:
1197 * Check permission before accessing the @table sysctl variable in the
1198 * manner specified by @op.
1199 * @table contains the ctl_table structure for the sysctl variable.
1200 * @op contains the operation (001 = search, 002 = write, 004 = read).
1201 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202 * @syslog:
1203 * Check permission before accessing the kernel message ring or changing
1204 * logging to the console.
Eric Paris7b41b172008-04-23 14:10:25 -04001205 * See the syslog(2) manual page for an explanation of the @type values.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206 * @type contains the type of action.
1207 * Return 0 if permission is granted.
1208 * @settime:
1209 * Check permission to change the system time.
1210 * struct timespec and timezone are defined in include/linux/time.h
1211 * @ts contains new time
1212 * @tz contains new timezone
1213 * Return 0 if permission is granted.
1214 * @vm_enough_memory:
1215 * Check permissions for allocating a new virtual mapping.
Alan Cox34b4e4a2007-08-22 14:01:28 -07001216 * @mm contains the mm struct it is being added to.
Eric Paris7b41b172008-04-23 14:10:25 -04001217 * @pages contains the number of pages.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218 * Return 0 if permission is granted.
1219 *
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001220 * @secid_to_secctx:
1221 * Convert secid to security context.
1222 * @secid contains the security ID.
1223 * @secdata contains the pointer that stores the converted security context.
David Howells63cb3442008-01-15 23:47:35 +00001224 * @secctx_to_secid:
Eric Paris7b41b172008-04-23 14:10:25 -04001225 * Convert security context to secid.
1226 * @secid contains the pointer to the generated security ID.
1227 * @secdata contains the security context.
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001228 *
1229 * @release_secctx:
1230 * Release the security context.
1231 * @secdata contains the security context.
1232 * @seclen contains the length of the security context.
1233 *
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02001234 * Security hooks for Audit
1235 *
1236 * @audit_rule_init:
1237 * Allocate and initialize an LSM audit rule structure.
1238 * @field contains the required Audit action. Fields flags are defined in include/linux/audit.h
1239 * @op contains the operator the rule uses.
1240 * @rulestr contains the context where the rule will be applied to.
1241 * @lsmrule contains a pointer to receive the result.
1242 * Return 0 if @lsmrule has been successfully set,
1243 * -EINVAL in case of an invalid rule.
1244 *
1245 * @audit_rule_known:
1246 * Specifies whether given @rule contains any fields related to current LSM.
1247 * @rule contains the audit rule of interest.
1248 * Return 1 in case of relation found, 0 otherwise.
1249 *
1250 * @audit_rule_match:
1251 * Determine if given @secid matches a rule previously approved
1252 * by @audit_rule_known.
1253 * @secid contains the security id in question.
1254 * @field contains the field which relates to current LSM.
1255 * @op contains the operator that will be used for matching.
1256 * @rule points to the audit rule that will be checked against.
1257 * @actx points to the audit context associated with the check.
1258 * Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure.
1259 *
1260 * @audit_rule_free:
1261 * Deallocate the LSM audit rule structure previously allocated by
1262 * audit_rule_init.
1263 * @rule contains the allocated rule
1264 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001265 * This is the main security structure.
1266 */
1267struct security_operations {
Ahmed S. Darwish076c54c2008-03-06 18:09:10 +02001268 char name[SECURITY_NAME_MAX + 1];
1269
David Howells5cd9c582008-08-14 11:37:28 +01001270 int (*ptrace_may_access) (struct task_struct *child, unsigned int mode);
1271 int (*ptrace_traceme) (struct task_struct *parent);
Eric Paris7b41b172008-04-23 14:10:25 -04001272 int (*capget) (struct task_struct *target,
1273 kernel_cap_t *effective,
1274 kernel_cap_t *inheritable, kernel_cap_t *permitted);
David Howellsd84f4f92008-11-14 10:39:23 +11001275 int (*capset) (struct cred *new,
1276 const struct cred *old,
1277 const kernel_cap_t *effective,
1278 const kernel_cap_t *inheritable,
1279 const kernel_cap_t *permitted);
Eric Paris06112162008-11-11 22:02:50 +11001280 int (*capable) (struct task_struct *tsk, int cap, int audit);
Eric Paris7b41b172008-04-23 14:10:25 -04001281 int (*acct) (struct file *file);
1282 int (*sysctl) (struct ctl_table *table, int op);
1283 int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
1284 int (*quota_on) (struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001285 int (*syslog) (int type);
1286 int (*settime) (struct timespec *ts, struct timezone *tz);
Alan Cox34b4e4a2007-08-22 14:01:28 -07001287 int (*vm_enough_memory) (struct mm_struct *mm, long pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001288
David Howellsa6f76f22008-11-14 10:39:24 +11001289 int (*bprm_set_creds) (struct linux_binprm *bprm);
Eric Paris7b41b172008-04-23 14:10:25 -04001290 int (*bprm_check_security) (struct linux_binprm *bprm);
1291 int (*bprm_secureexec) (struct linux_binprm *bprm);
David Howellsa6f76f22008-11-14 10:39:24 +11001292 void (*bprm_committing_creds) (struct linux_binprm *bprm);
1293 void (*bprm_committed_creds) (struct linux_binprm *bprm);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294
Eric Paris7b41b172008-04-23 14:10:25 -04001295 int (*sb_alloc_security) (struct super_block *sb);
1296 void (*sb_free_security) (struct super_block *sb);
1297 int (*sb_copy_data) (char *orig, char *copy);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001298 int (*sb_kern_mount) (struct super_block *sb, void *data);
Eric Paris2069f452008-07-04 09:47:13 +10001299 int (*sb_show_options) (struct seq_file *m, struct super_block *sb);
David Howells726c3342006-06-23 02:02:58 -07001300 int (*sb_statfs) (struct dentry *dentry);
Al Virob5266eb2008-03-22 17:48:24 -04001301 int (*sb_mount) (char *dev_name, struct path *path,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302 char *type, unsigned long flags, void *data);
Eric Paris7b41b172008-04-23 14:10:25 -04001303 int (*sb_check_sb) (struct vfsmount *mnt, struct path *path);
1304 int (*sb_umount) (struct vfsmount *mnt, int flags);
1305 void (*sb_umount_close) (struct vfsmount *mnt);
1306 void (*sb_umount_busy) (struct vfsmount *mnt);
1307 void (*sb_post_remount) (struct vfsmount *mnt,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001308 unsigned long flags, void *data);
Eric Paris7b41b172008-04-23 14:10:25 -04001309 void (*sb_post_addmount) (struct vfsmount *mnt,
Al Virob5266eb2008-03-22 17:48:24 -04001310 struct path *mountpoint);
1311 int (*sb_pivotroot) (struct path *old_path,
1312 struct path *new_path);
1313 void (*sb_post_pivotroot) (struct path *old_path,
1314 struct path *new_path);
Eric Parise0007522008-03-05 10:31:54 -05001315 int (*sb_set_mnt_opts) (struct super_block *sb,
1316 struct security_mnt_opts *opts);
Eric Parisc9180a52007-11-30 13:00:35 -05001317 void (*sb_clone_mnt_opts) (const struct super_block *oldsb,
1318 struct super_block *newsb);
Eric Parise0007522008-03-05 10:31:54 -05001319 int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320
Eric Paris7b41b172008-04-23 14:10:25 -04001321 int (*inode_alloc_security) (struct inode *inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001322 void (*inode_free_security) (struct inode *inode);
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001323 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1324 char **name, void **value, size_t *len);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 int (*inode_create) (struct inode *dir,
Eric Paris7b41b172008-04-23 14:10:25 -04001326 struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001327 int (*inode_link) (struct dentry *old_dentry,
Eric Paris7b41b172008-04-23 14:10:25 -04001328 struct inode *dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1330 int (*inode_symlink) (struct inode *dir,
Eric Paris7b41b172008-04-23 14:10:25 -04001331 struct dentry *dentry, const char *old_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001332 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001333 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1334 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
Eric Paris7b41b172008-04-23 14:10:25 -04001335 int mode, dev_t dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001336 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
Eric Paris7b41b172008-04-23 14:10:25 -04001337 struct inode *new_dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001338 int (*inode_readlink) (struct dentry *dentry);
1339 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
Al Virob77b0642008-07-17 09:37:02 -04001340 int (*inode_permission) (struct inode *inode, int mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001341 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1342 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
Eric Paris7b41b172008-04-23 14:10:25 -04001343 void (*inode_delete) (struct inode *inode);
David Howells8f0cfa52008-04-29 00:59:41 -07001344 int (*inode_setxattr) (struct dentry *dentry, const char *name,
1345 const void *value, size_t size, int flags);
1346 void (*inode_post_setxattr) (struct dentry *dentry, const char *name,
1347 const void *value, size_t size, int flags);
1348 int (*inode_getxattr) (struct dentry *dentry, const char *name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001349 int (*inode_listxattr) (struct dentry *dentry);
David Howells8f0cfa52008-04-29 00:59:41 -07001350 int (*inode_removexattr) (struct dentry *dentry, const char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -07001351 int (*inode_need_killpriv) (struct dentry *dentry);
1352 int (*inode_killpriv) (struct dentry *dentry);
Eric Paris7b41b172008-04-23 14:10:25 -04001353 int (*inode_getsecurity) (const struct inode *inode, const char *name, void **buffer, bool alloc);
1354 int (*inode_setsecurity) (struct inode *inode, const char *name, const void *value, size_t size, int flags);
1355 int (*inode_listsecurity) (struct inode *inode, char *buffer, size_t buffer_size);
1356 void (*inode_getsecid) (const struct inode *inode, u32 *secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001357
Eric Paris7b41b172008-04-23 14:10:25 -04001358 int (*file_permission) (struct file *file, int mask);
1359 int (*file_alloc_security) (struct file *file);
1360 void (*file_free_security) (struct file *file);
1361 int (*file_ioctl) (struct file *file, unsigned int cmd,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362 unsigned long arg);
Eric Paris7b41b172008-04-23 14:10:25 -04001363 int (*file_mmap) (struct file *file,
Eric Parised032182007-06-28 15:55:21 -04001364 unsigned long reqprot, unsigned long prot,
1365 unsigned long flags, unsigned long addr,
1366 unsigned long addr_only);
Eric Paris7b41b172008-04-23 14:10:25 -04001367 int (*file_mprotect) (struct vm_area_struct *vma,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001368 unsigned long reqprot,
1369 unsigned long prot);
Eric Paris7b41b172008-04-23 14:10:25 -04001370 int (*file_lock) (struct file *file, unsigned int cmd);
1371 int (*file_fcntl) (struct file *file, unsigned int cmd,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 unsigned long arg);
Eric Paris7b41b172008-04-23 14:10:25 -04001373 int (*file_set_fowner) (struct file *file);
1374 int (*file_send_sigiotask) (struct task_struct *tsk,
1375 struct fown_struct *fown, int sig);
1376 int (*file_receive) (struct file *file);
David Howells745ca242008-11-14 10:39:22 +11001377 int (*dentry_open) (struct file *file, const struct cred *cred);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378
1379 int (*task_create) (unsigned long clone_flags);
David Howellsf1752ee2008-11-14 10:39:17 +11001380 void (*cred_free) (struct cred *cred);
David Howellsd84f4f92008-11-14 10:39:23 +11001381 int (*cred_prepare)(struct cred *new, const struct cred *old,
1382 gfp_t gfp);
1383 void (*cred_commit)(struct cred *new, const struct cred *old);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
David Howellsd84f4f92008-11-14 10:39:23 +11001385 int (*task_fix_setuid) (struct cred *new, const struct cred *old,
1386 int flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
Eric Paris7b41b172008-04-23 14:10:25 -04001388 int (*task_setpgid) (struct task_struct *p, pid_t pgid);
1389 int (*task_getpgid) (struct task_struct *p);
1390 int (*task_getsid) (struct task_struct *p);
1391 void (*task_getsecid) (struct task_struct *p, u32 *secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 int (*task_setgroups) (struct group_info *group_info);
Eric Paris7b41b172008-04-23 14:10:25 -04001393 int (*task_setnice) (struct task_struct *p, int nice);
1394 int (*task_setioprio) (struct task_struct *p, int ioprio);
1395 int (*task_getioprio) (struct task_struct *p);
1396 int (*task_setrlimit) (unsigned int resource, struct rlimit *new_rlim);
1397 int (*task_setscheduler) (struct task_struct *p, int policy,
1398 struct sched_param *lp);
1399 int (*task_getscheduler) (struct task_struct *p);
1400 int (*task_movememory) (struct task_struct *p);
1401 int (*task_kill) (struct task_struct *p,
1402 struct siginfo *info, int sig, u32 secid);
1403 int (*task_wait) (struct task_struct *p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001404 int (*task_prctl) (int option, unsigned long arg2,
1405 unsigned long arg3, unsigned long arg4,
David Howellsd84f4f92008-11-14 10:39:23 +11001406 unsigned long arg5);
Eric Paris7b41b172008-04-23 14:10:25 -04001407 void (*task_to_inode) (struct task_struct *p, struct inode *inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408
Eric Paris7b41b172008-04-23 14:10:25 -04001409 int (*ipc_permission) (struct kern_ipc_perm *ipcp, short flag);
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02001410 void (*ipc_getsecid) (struct kern_ipc_perm *ipcp, u32 *secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411
Eric Paris7b41b172008-04-23 14:10:25 -04001412 int (*msg_msg_alloc_security) (struct msg_msg *msg);
1413 void (*msg_msg_free_security) (struct msg_msg *msg);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001414
Eric Paris7b41b172008-04-23 14:10:25 -04001415 int (*msg_queue_alloc_security) (struct msg_queue *msq);
1416 void (*msg_queue_free_security) (struct msg_queue *msq);
1417 int (*msg_queue_associate) (struct msg_queue *msq, int msqflg);
1418 int (*msg_queue_msgctl) (struct msg_queue *msq, int cmd);
1419 int (*msg_queue_msgsnd) (struct msg_queue *msq,
1420 struct msg_msg *msg, int msqflg);
1421 int (*msg_queue_msgrcv) (struct msg_queue *msq,
1422 struct msg_msg *msg,
1423 struct task_struct *target,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424 long type, int mode);
1425
Eric Paris7b41b172008-04-23 14:10:25 -04001426 int (*shm_alloc_security) (struct shmid_kernel *shp);
1427 void (*shm_free_security) (struct shmid_kernel *shp);
1428 int (*shm_associate) (struct shmid_kernel *shp, int shmflg);
1429 int (*shm_shmctl) (struct shmid_kernel *shp, int cmd);
1430 int (*shm_shmat) (struct shmid_kernel *shp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431 char __user *shmaddr, int shmflg);
1432
Eric Paris7b41b172008-04-23 14:10:25 -04001433 int (*sem_alloc_security) (struct sem_array *sma);
1434 void (*sem_free_security) (struct sem_array *sma);
1435 int (*sem_associate) (struct sem_array *sma, int semflg);
1436 int (*sem_semctl) (struct sem_array *sma, int cmd);
1437 int (*sem_semop) (struct sem_array *sma,
1438 struct sembuf *sops, unsigned nsops, int alter);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439
Eric Paris7b41b172008-04-23 14:10:25 -04001440 int (*netlink_send) (struct sock *sk, struct sk_buff *skb);
1441 int (*netlink_recv) (struct sk_buff *skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001442
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1444
Eric Paris7b41b172008-04-23 14:10:25 -04001445 int (*getprocattr) (struct task_struct *p, char *name, char **value);
1446 int (*setprocattr) (struct task_struct *p, char *name, void *value, size_t size);
1447 int (*secid_to_secctx) (u32 secid, char **secdata, u32 *seclen);
David Howells7bf570d2008-04-29 20:52:51 +01001448 int (*secctx_to_secid) (const char *secdata, u32 seclen, u32 *secid);
Eric Paris7b41b172008-04-23 14:10:25 -04001449 void (*release_secctx) (char *secdata, u32 seclen);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450
1451#ifdef CONFIG_SECURITY_NETWORK
Eric Paris7b41b172008-04-23 14:10:25 -04001452 int (*unix_stream_connect) (struct socket *sock,
1453 struct socket *other, struct sock *newsk);
1454 int (*unix_may_send) (struct socket *sock, struct socket *other);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455
1456 int (*socket_create) (int family, int type, int protocol, int kern);
Eric Paris7b41b172008-04-23 14:10:25 -04001457 int (*socket_post_create) (struct socket *sock, int family,
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07001458 int type, int protocol, int kern);
Eric Paris7b41b172008-04-23 14:10:25 -04001459 int (*socket_bind) (struct socket *sock,
1460 struct sockaddr *address, int addrlen);
1461 int (*socket_connect) (struct socket *sock,
1462 struct sockaddr *address, int addrlen);
1463 int (*socket_listen) (struct socket *sock, int backlog);
1464 int (*socket_accept) (struct socket *sock, struct socket *newsock);
1465 void (*socket_post_accept) (struct socket *sock,
1466 struct socket *newsock);
1467 int (*socket_sendmsg) (struct socket *sock,
1468 struct msghdr *msg, int size);
1469 int (*socket_recvmsg) (struct socket *sock,
1470 struct msghdr *msg, int size, int flags);
1471 int (*socket_getsockname) (struct socket *sock);
1472 int (*socket_getpeername) (struct socket *sock);
1473 int (*socket_getsockopt) (struct socket *sock, int level, int optname);
1474 int (*socket_setsockopt) (struct socket *sock, int level, int optname);
1475 int (*socket_shutdown) (struct socket *sock, int how);
1476 int (*socket_sock_rcv_skb) (struct sock *sk, struct sk_buff *skb);
Catherine Zhang2c7946a2006-03-20 22:41:23 -08001477 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001478 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
Al Viro7d877f32005-10-21 03:20:43 -04001479 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480 void (*sk_free_security) (struct sock *sk);
Venkat Yekkirala892c1412006-08-04 23:08:56 -07001481 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001482 void (*sk_getsecid) (struct sock *sk, u32 *secid);
Eric Paris7b41b172008-04-23 14:10:25 -04001483 void (*sock_graft) (struct sock *sk, struct socket *parent);
1484 int (*inet_conn_request) (struct sock *sk, struct sk_buff *skb,
1485 struct request_sock *req);
1486 void (*inet_csk_clone) (struct sock *newsk, const struct request_sock *req);
1487 void (*inet_conn_established) (struct sock *sk, struct sk_buff *skb);
1488 void (*req_classify_flow) (const struct request_sock *req, struct flowi *fl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001489#endif /* CONFIG_SECURITY_NETWORK */
David Howells29db9192005-10-30 15:02:44 -08001490
Trent Jaegerdf718372005-12-13 23:12:27 -08001491#ifdef CONFIG_SECURITY_NETWORK_XFRM
Paul Moore03e1ad72008-04-12 19:07:52 -07001492 int (*xfrm_policy_alloc_security) (struct xfrm_sec_ctx **ctxp,
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -06001493 struct xfrm_user_sec_ctx *sec_ctx);
Paul Moore03e1ad72008-04-12 19:07:52 -07001494 int (*xfrm_policy_clone_security) (struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctx);
1495 void (*xfrm_policy_free_security) (struct xfrm_sec_ctx *ctx);
1496 int (*xfrm_policy_delete_security) (struct xfrm_sec_ctx *ctx);
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001497 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -06001498 struct xfrm_user_sec_ctx *sec_ctx,
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001499 u32 secid);
Trent Jaegerdf718372005-12-13 23:12:27 -08001500 void (*xfrm_state_free_security) (struct xfrm_state *x);
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001501 int (*xfrm_state_delete_security) (struct xfrm_state *x);
Eric Paris7b41b172008-04-23 14:10:25 -04001502 int (*xfrm_policy_lookup) (struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
1503 int (*xfrm_state_pol_flow_match) (struct xfrm_state *x,
1504 struct xfrm_policy *xp,
1505 struct flowi *fl);
1506 int (*xfrm_decode_session) (struct sk_buff *skb, u32 *secid, int ckall);
Trent Jaegerdf718372005-12-13 23:12:27 -08001507#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1508
David Howells29db9192005-10-30 15:02:44 -08001509 /* key management security hooks */
1510#ifdef CONFIG_KEYS
David Howellsd84f4f92008-11-14 10:39:23 +11001511 int (*key_alloc) (struct key *key, const struct cred *cred, unsigned long flags);
Eric Paris7b41b172008-04-23 14:10:25 -04001512 void (*key_free) (struct key *key);
1513 int (*key_permission) (key_ref_t key_ref,
David Howellsd84f4f92008-11-14 10:39:23 +11001514 const struct cred *cred,
Eric Paris7b41b172008-04-23 14:10:25 -04001515 key_perm_t perm);
David Howells70a5bb72008-04-29 01:01:26 -07001516 int (*key_getsecurity)(struct key *key, char **_buffer);
David Howells29db9192005-10-30 15:02:44 -08001517#endif /* CONFIG_KEYS */
1518
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02001519#ifdef CONFIG_AUDIT
Eric Paris7b41b172008-04-23 14:10:25 -04001520 int (*audit_rule_init) (u32 field, u32 op, char *rulestr, void **lsmrule);
1521 int (*audit_rule_known) (struct audit_krule *krule);
1522 int (*audit_rule_match) (u32 secid, u32 field, u32 op, void *lsmrule,
1523 struct audit_context *actx);
1524 void (*audit_rule_free) (void *lsmrule);
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02001525#endif /* CONFIG_AUDIT */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526};
1527
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528/* prototypes */
Eric Paris7b41b172008-04-23 14:10:25 -04001529extern int security_init(void);
Ahmed S. Darwish076c54c2008-03-06 18:09:10 +02001530extern int security_module_enable(struct security_operations *ops);
Eric Paris7b41b172008-04-23 14:10:25 -04001531extern int register_security(struct security_operations *ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532
James Morris20510f22007-10-16 23:31:32 -07001533/* Security operations */
David Howells5cd9c582008-08-14 11:37:28 +01001534int security_ptrace_may_access(struct task_struct *child, unsigned int mode);
1535int security_ptrace_traceme(struct task_struct *parent);
James Morris20510f22007-10-16 23:31:32 -07001536int security_capget(struct task_struct *target,
Eric Paris7b41b172008-04-23 14:10:25 -04001537 kernel_cap_t *effective,
1538 kernel_cap_t *inheritable,
1539 kernel_cap_t *permitted);
David Howellsd84f4f92008-11-14 10:39:23 +11001540int security_capset(struct cred *new, const struct cred *old,
1541 const kernel_cap_t *effective,
1542 const kernel_cap_t *inheritable,
1543 const kernel_cap_t *permitted);
James Morris20510f22007-10-16 23:31:32 -07001544int security_capable(struct task_struct *tsk, int cap);
Eric Paris06112162008-11-11 22:02:50 +11001545int security_capable_noaudit(struct task_struct *tsk, int cap);
James Morris20510f22007-10-16 23:31:32 -07001546int security_acct(struct file *file);
1547int security_sysctl(struct ctl_table *table, int op);
1548int security_quotactl(int cmds, int type, int id, struct super_block *sb);
1549int security_quota_on(struct dentry *dentry);
1550int security_syslog(int type);
1551int security_settime(struct timespec *ts, struct timezone *tz);
1552int security_vm_enough_memory(long pages);
1553int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
Alan Cox731572d2008-10-29 14:01:20 -07001554int security_vm_enough_memory_kern(long pages);
David Howellsa6f76f22008-11-14 10:39:24 +11001555int security_bprm_set_creds(struct linux_binprm *bprm);
James Morris20510f22007-10-16 23:31:32 -07001556int security_bprm_check(struct linux_binprm *bprm);
David Howellsa6f76f22008-11-14 10:39:24 +11001557void security_bprm_committing_creds(struct linux_binprm *bprm);
1558void security_bprm_committed_creds(struct linux_binprm *bprm);
James Morris20510f22007-10-16 23:31:32 -07001559int security_bprm_secureexec(struct linux_binprm *bprm);
1560int security_sb_alloc(struct super_block *sb);
1561void security_sb_free(struct super_block *sb);
Eric Parise0007522008-03-05 10:31:54 -05001562int security_sb_copy_data(char *orig, char *copy);
James Morris20510f22007-10-16 23:31:32 -07001563int security_sb_kern_mount(struct super_block *sb, void *data);
Eric Paris2069f452008-07-04 09:47:13 +10001564int security_sb_show_options(struct seq_file *m, struct super_block *sb);
James Morris20510f22007-10-16 23:31:32 -07001565int security_sb_statfs(struct dentry *dentry);
Al Virob5266eb2008-03-22 17:48:24 -04001566int security_sb_mount(char *dev_name, struct path *path,
Eric Paris7b41b172008-04-23 14:10:25 -04001567 char *type, unsigned long flags, void *data);
Al Virob5266eb2008-03-22 17:48:24 -04001568int security_sb_check_sb(struct vfsmount *mnt, struct path *path);
James Morris20510f22007-10-16 23:31:32 -07001569int security_sb_umount(struct vfsmount *mnt, int flags);
1570void security_sb_umount_close(struct vfsmount *mnt);
1571void security_sb_umount_busy(struct vfsmount *mnt);
1572void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data);
Al Virob5266eb2008-03-22 17:48:24 -04001573void security_sb_post_addmount(struct vfsmount *mnt, struct path *mountpoint);
1574int security_sb_pivotroot(struct path *old_path, struct path *new_path);
1575void security_sb_post_pivotroot(struct path *old_path, struct path *new_path);
Eric Parise0007522008-03-05 10:31:54 -05001576int security_sb_set_mnt_opts(struct super_block *sb, struct security_mnt_opts *opts);
Eric Parisc9180a52007-11-30 13:00:35 -05001577void security_sb_clone_mnt_opts(const struct super_block *oldsb,
1578 struct super_block *newsb);
Eric Parise0007522008-03-05 10:31:54 -05001579int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts);
Eric Parisc9180a52007-11-30 13:00:35 -05001580
James Morris20510f22007-10-16 23:31:32 -07001581int security_inode_alloc(struct inode *inode);
1582void security_inode_free(struct inode *inode);
1583int security_inode_init_security(struct inode *inode, struct inode *dir,
1584 char **name, void **value, size_t *len);
1585int security_inode_create(struct inode *dir, struct dentry *dentry, int mode);
1586int security_inode_link(struct dentry *old_dentry, struct inode *dir,
1587 struct dentry *new_dentry);
1588int security_inode_unlink(struct inode *dir, struct dentry *dentry);
1589int security_inode_symlink(struct inode *dir, struct dentry *dentry,
Eric Paris7b41b172008-04-23 14:10:25 -04001590 const char *old_name);
James Morris20510f22007-10-16 23:31:32 -07001591int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode);
1592int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
1593int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
1594int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
Eric Paris7b41b172008-04-23 14:10:25 -04001595 struct inode *new_dir, struct dentry *new_dentry);
James Morris20510f22007-10-16 23:31:32 -07001596int security_inode_readlink(struct dentry *dentry);
1597int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
Al Virob77b0642008-07-17 09:37:02 -04001598int security_inode_permission(struct inode *inode, int mask);
James Morris20510f22007-10-16 23:31:32 -07001599int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1600int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1601void security_inode_delete(struct inode *inode);
David Howells8f0cfa52008-04-29 00:59:41 -07001602int security_inode_setxattr(struct dentry *dentry, const char *name,
1603 const void *value, size_t size, int flags);
1604void security_inode_post_setxattr(struct dentry *dentry, const char *name,
1605 const void *value, size_t size, int flags);
1606int security_inode_getxattr(struct dentry *dentry, const char *name);
James Morris20510f22007-10-16 23:31:32 -07001607int security_inode_listxattr(struct dentry *dentry);
David Howells8f0cfa52008-04-29 00:59:41 -07001608int security_inode_removexattr(struct dentry *dentry, const char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -07001609int security_inode_need_killpriv(struct dentry *dentry);
1610int security_inode_killpriv(struct dentry *dentry);
David P. Quigley42492592008-02-04 22:29:39 -08001611int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc);
James Morris20510f22007-10-16 23:31:32 -07001612int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1613int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02001614void security_inode_getsecid(const struct inode *inode, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -07001615int security_file_permission(struct file *file, int mask);
1616int security_file_alloc(struct file *file);
1617void security_file_free(struct file *file);
1618int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1619int security_file_mmap(struct file *file, unsigned long reqprot,
1620 unsigned long prot, unsigned long flags,
1621 unsigned long addr, unsigned long addr_only);
1622int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
Eric Paris7b41b172008-04-23 14:10:25 -04001623 unsigned long prot);
James Morris20510f22007-10-16 23:31:32 -07001624int security_file_lock(struct file *file, unsigned int cmd);
1625int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
1626int security_file_set_fowner(struct file *file);
1627int security_file_send_sigiotask(struct task_struct *tsk,
Eric Paris7b41b172008-04-23 14:10:25 -04001628 struct fown_struct *fown, int sig);
James Morris20510f22007-10-16 23:31:32 -07001629int security_file_receive(struct file *file);
David Howells745ca242008-11-14 10:39:22 +11001630int security_dentry_open(struct file *file, const struct cred *cred);
James Morris20510f22007-10-16 23:31:32 -07001631int security_task_create(unsigned long clone_flags);
David Howellsf1752ee2008-11-14 10:39:17 +11001632void security_cred_free(struct cred *cred);
David Howellsd84f4f92008-11-14 10:39:23 +11001633int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
1634void security_commit_creds(struct cred *new, const struct cred *old);
James Morris20510f22007-10-16 23:31:32 -07001635int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags);
David Howellsd84f4f92008-11-14 10:39:23 +11001636int security_task_fix_setuid(struct cred *new, const struct cred *old,
1637 int flags);
James Morris20510f22007-10-16 23:31:32 -07001638int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags);
1639int security_task_setpgid(struct task_struct *p, pid_t pgid);
1640int security_task_getpgid(struct task_struct *p);
1641int security_task_getsid(struct task_struct *p);
1642void security_task_getsecid(struct task_struct *p, u32 *secid);
1643int security_task_setgroups(struct group_info *group_info);
1644int security_task_setnice(struct task_struct *p, int nice);
1645int security_task_setioprio(struct task_struct *p, int ioprio);
1646int security_task_getioprio(struct task_struct *p);
1647int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim);
1648int security_task_setscheduler(struct task_struct *p,
1649 int policy, struct sched_param *lp);
1650int security_task_getscheduler(struct task_struct *p);
1651int security_task_movememory(struct task_struct *p);
1652int security_task_kill(struct task_struct *p, struct siginfo *info,
1653 int sig, u32 secid);
1654int security_task_wait(struct task_struct *p);
1655int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
David Howellsd84f4f92008-11-14 10:39:23 +11001656 unsigned long arg4, unsigned long arg5);
James Morris20510f22007-10-16 23:31:32 -07001657void security_task_to_inode(struct task_struct *p, struct inode *inode);
1658int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02001659void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -07001660int security_msg_msg_alloc(struct msg_msg *msg);
1661void security_msg_msg_free(struct msg_msg *msg);
1662int security_msg_queue_alloc(struct msg_queue *msq);
1663void security_msg_queue_free(struct msg_queue *msq);
1664int security_msg_queue_associate(struct msg_queue *msq, int msqflg);
1665int security_msg_queue_msgctl(struct msg_queue *msq, int cmd);
1666int security_msg_queue_msgsnd(struct msg_queue *msq,
Eric Paris7b41b172008-04-23 14:10:25 -04001667 struct msg_msg *msg, int msqflg);
James Morris20510f22007-10-16 23:31:32 -07001668int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
Eric Paris7b41b172008-04-23 14:10:25 -04001669 struct task_struct *target, long type, int mode);
James Morris20510f22007-10-16 23:31:32 -07001670int security_shm_alloc(struct shmid_kernel *shp);
1671void security_shm_free(struct shmid_kernel *shp);
1672int security_shm_associate(struct shmid_kernel *shp, int shmflg);
1673int security_shm_shmctl(struct shmid_kernel *shp, int cmd);
1674int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg);
1675int security_sem_alloc(struct sem_array *sma);
1676void security_sem_free(struct sem_array *sma);
1677int security_sem_associate(struct sem_array *sma, int semflg);
1678int security_sem_semctl(struct sem_array *sma, int cmd);
1679int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
1680 unsigned nsops, int alter);
Eric Paris7b41b172008-04-23 14:10:25 -04001681void security_d_instantiate(struct dentry *dentry, struct inode *inode);
James Morris20510f22007-10-16 23:31:32 -07001682int security_getprocattr(struct task_struct *p, char *name, char **value);
1683int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
1684int security_netlink_send(struct sock *sk, struct sk_buff *skb);
1685int security_netlink_recv(struct sk_buff *skb, int cap);
1686int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
David Howells7bf570d2008-04-29 20:52:51 +01001687int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -07001688void security_release_secctx(char *secdata, u32 seclen);
1689
Linus Torvalds1da177e2005-04-16 15:20:36 -07001690#else /* CONFIG_SECURITY */
Eric Parise0007522008-03-05 10:31:54 -05001691struct security_mnt_opts {
1692};
1693
1694static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
1695{
1696}
1697
1698static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1699{
1700}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001701
1702/*
1703 * This is the default capabilities functionality. Most of these functions
1704 * are just stubbed out, but a few must call the proper capable code.
1705 */
1706
1707static inline int security_init(void)
1708{
1709 return 0;
1710}
1711
David Howells5cd9c582008-08-14 11:37:28 +01001712static inline int security_ptrace_may_access(struct task_struct *child,
1713 unsigned int mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001714{
David Howells5cd9c582008-08-14 11:37:28 +01001715 return cap_ptrace_may_access(child, mode);
1716}
1717
Alexander Beregalov5e186b52008-08-17 05:34:20 +04001718static inline int security_ptrace_traceme(struct task_struct *parent)
David Howells5cd9c582008-08-14 11:37:28 +01001719{
1720 return cap_ptrace_traceme(parent);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001721}
1722
Eric Paris7b41b172008-04-23 14:10:25 -04001723static inline int security_capget(struct task_struct *target,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001724 kernel_cap_t *effective,
1725 kernel_cap_t *inheritable,
1726 kernel_cap_t *permitted)
1727{
Eric Paris7b41b172008-04-23 14:10:25 -04001728 return cap_capget(target, effective, inheritable, permitted);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729}
1730
David Howellsd84f4f92008-11-14 10:39:23 +11001731static inline int security_capset(struct cred *new,
1732 const struct cred *old,
1733 const kernel_cap_t *effective,
1734 const kernel_cap_t *inheritable,
1735 const kernel_cap_t *permitted)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736{
David Howellsd84f4f92008-11-14 10:39:23 +11001737 return cap_capset(new, old, effective, inheritable, permitted);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738}
1739
Chris Wright12b59892006-03-25 03:07:41 -08001740static inline int security_capable(struct task_struct *tsk, int cap)
1741{
Eric Paris06112162008-11-11 22:02:50 +11001742 return cap_capable(tsk, cap, SECURITY_CAP_AUDIT);
1743}
1744
1745static inline int security_capable_noaudit(struct task_struct *tsk, int cap)
1746{
1747 return cap_capable(tsk, cap, SECURITY_CAP_NOAUDIT);
Chris Wright12b59892006-03-25 03:07:41 -08001748}
1749
Eric Paris7b41b172008-04-23 14:10:25 -04001750static inline int security_acct(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001751{
1752 return 0;
1753}
1754
1755static inline int security_sysctl(struct ctl_table *table, int op)
1756{
1757 return 0;
1758}
1759
Eric Paris7b41b172008-04-23 14:10:25 -04001760static inline int security_quotactl(int cmds, int type, int id,
1761 struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762{
1763 return 0;
1764}
1765
Eric Paris7b41b172008-04-23 14:10:25 -04001766static inline int security_quota_on(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001767{
1768 return 0;
1769}
1770
1771static inline int security_syslog(int type)
1772{
1773 return cap_syslog(type);
1774}
1775
1776static inline int security_settime(struct timespec *ts, struct timezone *tz)
1777{
1778 return cap_settime(ts, tz);
1779}
1780
1781static inline int security_vm_enough_memory(long pages)
1782{
Alan Cox34b4e4a2007-08-22 14:01:28 -07001783 return cap_vm_enough_memory(current->mm, pages);
1784}
1785
Alan Cox731572d2008-10-29 14:01:20 -07001786static inline int security_vm_enough_memory_kern(long pages)
1787{
1788 return cap_vm_enough_memory(current->mm, pages);
1789}
1790
Alan Cox34b4e4a2007-08-22 14:01:28 -07001791static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
1792{
1793 return cap_vm_enough_memory(mm, pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001794}
1795
David Howellsa6f76f22008-11-14 10:39:24 +11001796static inline int security_bprm_set_creds(struct linux_binprm *bprm)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001797{
David Howellsa6f76f22008-11-14 10:39:24 +11001798 return cap_bprm_set_creds(bprm);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001799}
1800
Eric Paris7b41b172008-04-23 14:10:25 -04001801static inline int security_bprm_check(struct linux_binprm *bprm)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001802{
1803 return 0;
1804}
1805
David Howellsa6f76f22008-11-14 10:39:24 +11001806static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
1807{
1808}
1809
1810static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
1811{
1812}
1813
Eric Paris7b41b172008-04-23 14:10:25 -04001814static inline int security_bprm_secureexec(struct linux_binprm *bprm)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001815{
1816 return cap_bprm_secureexec(bprm);
1817}
1818
Eric Paris7b41b172008-04-23 14:10:25 -04001819static inline int security_sb_alloc(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001820{
1821 return 0;
1822}
1823
Eric Paris7b41b172008-04-23 14:10:25 -04001824static inline void security_sb_free(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001825{ }
1826
Eric Paris7b41b172008-04-23 14:10:25 -04001827static inline int security_sb_copy_data(char *orig, char *copy)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001828{
1829 return 0;
1830}
1831
Eric Paris7b41b172008-04-23 14:10:25 -04001832static inline int security_sb_kern_mount(struct super_block *sb, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001833{
1834 return 0;
1835}
1836
Eric Paris2069f452008-07-04 09:47:13 +10001837static inline int security_sb_show_options(struct seq_file *m,
1838 struct super_block *sb)
1839{
1840 return 0;
1841}
1842
Eric Paris7b41b172008-04-23 14:10:25 -04001843static inline int security_sb_statfs(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001844{
1845 return 0;
1846}
1847
Eric Paris7b41b172008-04-23 14:10:25 -04001848static inline int security_sb_mount(char *dev_name, struct path *path,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001849 char *type, unsigned long flags,
1850 void *data)
1851{
1852 return 0;
1853}
1854
Eric Paris7b41b172008-04-23 14:10:25 -04001855static inline int security_sb_check_sb(struct vfsmount *mnt,
1856 struct path *path)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001857{
1858 return 0;
1859}
1860
Eric Paris7b41b172008-04-23 14:10:25 -04001861static inline int security_sb_umount(struct vfsmount *mnt, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862{
1863 return 0;
1864}
1865
Eric Paris7b41b172008-04-23 14:10:25 -04001866static inline void security_sb_umount_close(struct vfsmount *mnt)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001867{ }
1868
Eric Paris7b41b172008-04-23 14:10:25 -04001869static inline void security_sb_umount_busy(struct vfsmount *mnt)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001870{ }
1871
Eric Paris7b41b172008-04-23 14:10:25 -04001872static inline void security_sb_post_remount(struct vfsmount *mnt,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001873 unsigned long flags, void *data)
1874{ }
1875
Eric Paris7b41b172008-04-23 14:10:25 -04001876static inline void security_sb_post_addmount(struct vfsmount *mnt,
1877 struct path *mountpoint)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001878{ }
1879
Eric Paris7b41b172008-04-23 14:10:25 -04001880static inline int security_sb_pivotroot(struct path *old_path,
1881 struct path *new_path)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001882{
1883 return 0;
1884}
1885
Eric Paris7b41b172008-04-23 14:10:25 -04001886static inline void security_sb_post_pivotroot(struct path *old_path,
1887 struct path *new_path)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888{ }
Eric Parise0007522008-03-05 10:31:54 -05001889
1890static inline int security_sb_set_mnt_opts(struct super_block *sb,
1891 struct security_mnt_opts *opts)
1892{
1893 return 0;
1894}
1895
1896static inline void security_sb_clone_mnt_opts(const struct super_block *oldsb,
1897 struct super_block *newsb)
1898{ }
1899
1900static inline int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts)
1901{
1902 return 0;
1903}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001904
Eric Paris7b41b172008-04-23 14:10:25 -04001905static inline int security_inode_alloc(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001906{
1907 return 0;
1908}
1909
Eric Paris7b41b172008-04-23 14:10:25 -04001910static inline void security_inode_free(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001911{ }
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001912
Eric Paris7b41b172008-04-23 14:10:25 -04001913static inline int security_inode_init_security(struct inode *inode,
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001914 struct inode *dir,
1915 char **name,
1916 void **value,
1917 size_t *len)
1918{
1919 return -EOPNOTSUPP;
1920}
Eric Paris7b41b172008-04-23 14:10:25 -04001921
1922static inline int security_inode_create(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001923 struct dentry *dentry,
1924 int mode)
1925{
1926 return 0;
1927}
1928
Eric Paris7b41b172008-04-23 14:10:25 -04001929static inline int security_inode_link(struct dentry *old_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001930 struct inode *dir,
1931 struct dentry *new_dentry)
1932{
1933 return 0;
1934}
1935
Eric Paris7b41b172008-04-23 14:10:25 -04001936static inline int security_inode_unlink(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001937 struct dentry *dentry)
1938{
1939 return 0;
1940}
1941
Eric Paris7b41b172008-04-23 14:10:25 -04001942static inline int security_inode_symlink(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001943 struct dentry *dentry,
1944 const char *old_name)
1945{
1946 return 0;
1947}
1948
Eric Paris7b41b172008-04-23 14:10:25 -04001949static inline int security_inode_mkdir(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950 struct dentry *dentry,
1951 int mode)
1952{
1953 return 0;
1954}
1955
Eric Paris7b41b172008-04-23 14:10:25 -04001956static inline int security_inode_rmdir(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001957 struct dentry *dentry)
1958{
1959 return 0;
1960}
1961
Eric Paris7b41b172008-04-23 14:10:25 -04001962static inline int security_inode_mknod(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001963 struct dentry *dentry,
1964 int mode, dev_t dev)
1965{
1966 return 0;
1967}
1968
Eric Paris7b41b172008-04-23 14:10:25 -04001969static inline int security_inode_rename(struct inode *old_dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001970 struct dentry *old_dentry,
1971 struct inode *new_dir,
1972 struct dentry *new_dentry)
1973{
1974 return 0;
1975}
1976
Eric Paris7b41b172008-04-23 14:10:25 -04001977static inline int security_inode_readlink(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001978{
1979 return 0;
1980}
1981
Eric Paris7b41b172008-04-23 14:10:25 -04001982static inline int security_inode_follow_link(struct dentry *dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001983 struct nameidata *nd)
1984{
1985 return 0;
1986}
1987
Al Virob77b0642008-07-17 09:37:02 -04001988static inline int security_inode_permission(struct inode *inode, int mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001989{
1990 return 0;
1991}
1992
Eric Paris7b41b172008-04-23 14:10:25 -04001993static inline int security_inode_setattr(struct dentry *dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001994 struct iattr *attr)
1995{
1996 return 0;
1997}
1998
Eric Paris7b41b172008-04-23 14:10:25 -04001999static inline int security_inode_getattr(struct vfsmount *mnt,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002000 struct dentry *dentry)
2001{
2002 return 0;
2003}
2004
Eric Paris7b41b172008-04-23 14:10:25 -04002005static inline void security_inode_delete(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002006{ }
2007
David Howells8f0cfa52008-04-29 00:59:41 -07002008static inline int security_inode_setxattr(struct dentry *dentry,
2009 const char *name, const void *value, size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002010{
2011 return cap_inode_setxattr(dentry, name, value, size, flags);
2012}
2013
David Howells8f0cfa52008-04-29 00:59:41 -07002014static inline void security_inode_post_setxattr(struct dentry *dentry,
2015 const char *name, const void *value, size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002016{ }
2017
David Howells8f0cfa52008-04-29 00:59:41 -07002018static inline int security_inode_getxattr(struct dentry *dentry,
2019 const char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002020{
2021 return 0;
2022}
2023
Eric Paris7b41b172008-04-23 14:10:25 -04002024static inline int security_inode_listxattr(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002025{
2026 return 0;
2027}
2028
David Howells8f0cfa52008-04-29 00:59:41 -07002029static inline int security_inode_removexattr(struct dentry *dentry,
2030 const char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002031{
2032 return cap_inode_removexattr(dentry, name);
2033}
2034
Serge E. Hallynb5376772007-10-16 23:31:36 -07002035static inline int security_inode_need_killpriv(struct dentry *dentry)
2036{
2037 return cap_inode_need_killpriv(dentry);
2038}
2039
2040static inline int security_inode_killpriv(struct dentry *dentry)
2041{
2042 return cap_inode_killpriv(dentry);
2043}
2044
David P. Quigley42492592008-02-04 22:29:39 -08002045static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002046{
2047 return -EOPNOTSUPP;
2048}
2049
2050static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2051{
2052 return -EOPNOTSUPP;
2053}
2054
2055static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2056{
2057 return 0;
2058}
2059
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02002060static inline void security_inode_getsecid(const struct inode *inode, u32 *secid)
2061{
2062 *secid = 0;
2063}
2064
Eric Paris7b41b172008-04-23 14:10:25 -04002065static inline int security_file_permission(struct file *file, int mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002066{
2067 return 0;
2068}
2069
Eric Paris7b41b172008-04-23 14:10:25 -04002070static inline int security_file_alloc(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002071{
2072 return 0;
2073}
2074
Eric Paris7b41b172008-04-23 14:10:25 -04002075static inline void security_file_free(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002076{ }
2077
Eric Paris7b41b172008-04-23 14:10:25 -04002078static inline int security_file_ioctl(struct file *file, unsigned int cmd,
2079 unsigned long arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002080{
2081 return 0;
2082}
2083
Eric Paris7b41b172008-04-23 14:10:25 -04002084static inline int security_file_mmap(struct file *file, unsigned long reqprot,
2085 unsigned long prot,
2086 unsigned long flags,
2087 unsigned long addr,
2088 unsigned long addr_only)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002089{
2090 return 0;
2091}
2092
Eric Paris7b41b172008-04-23 14:10:25 -04002093static inline int security_file_mprotect(struct vm_area_struct *vma,
2094 unsigned long reqprot,
2095 unsigned long prot)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002096{
2097 return 0;
2098}
2099
Eric Paris7b41b172008-04-23 14:10:25 -04002100static inline int security_file_lock(struct file *file, unsigned int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002101{
2102 return 0;
2103}
2104
Eric Paris7b41b172008-04-23 14:10:25 -04002105static inline int security_file_fcntl(struct file *file, unsigned int cmd,
2106 unsigned long arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002107{
2108 return 0;
2109}
2110
Eric Paris7b41b172008-04-23 14:10:25 -04002111static inline int security_file_set_fowner(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002112{
2113 return 0;
2114}
2115
Eric Paris7b41b172008-04-23 14:10:25 -04002116static inline int security_file_send_sigiotask(struct task_struct *tsk,
2117 struct fown_struct *fown,
2118 int sig)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002119{
2120 return 0;
2121}
2122
Eric Paris7b41b172008-04-23 14:10:25 -04002123static inline int security_file_receive(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002124{
2125 return 0;
2126}
2127
David Howells745ca242008-11-14 10:39:22 +11002128static inline int security_dentry_open(struct file *file,
2129 const struct cred *cred)
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +09002130{
2131 return 0;
2132}
2133
Eric Paris7b41b172008-04-23 14:10:25 -04002134static inline int security_task_create(unsigned long clone_flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002135{
2136 return 0;
2137}
2138
David Howellsd84f4f92008-11-14 10:39:23 +11002139static inline void security_cred_free(struct cred *cred)
2140{ }
2141
2142static inline int security_prepare_creds(struct cred *new,
2143 const struct cred *old,
2144 gfp_t gfp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002145{
2146 return 0;
2147}
2148
David Howellsd84f4f92008-11-14 10:39:23 +11002149static inline void security_commit_creds(struct cred *new,
2150 const struct cred *old)
2151{
2152}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002153
Eric Paris7b41b172008-04-23 14:10:25 -04002154static inline int security_task_setuid(uid_t id0, uid_t id1, uid_t id2,
2155 int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002156{
2157 return 0;
2158}
2159
David Howellsd84f4f92008-11-14 10:39:23 +11002160static inline int security_task_fix_setuid(struct cred *new,
2161 const struct cred *old,
2162 int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002163{
David Howellsd84f4f92008-11-14 10:39:23 +11002164 return cap_task_fix_setuid(new, old, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002165}
2166
Eric Paris7b41b172008-04-23 14:10:25 -04002167static inline int security_task_setgid(gid_t id0, gid_t id1, gid_t id2,
2168 int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002169{
2170 return 0;
2171}
2172
Eric Paris7b41b172008-04-23 14:10:25 -04002173static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174{
2175 return 0;
2176}
2177
Eric Paris7b41b172008-04-23 14:10:25 -04002178static inline int security_task_getpgid(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002179{
2180 return 0;
2181}
2182
Eric Paris7b41b172008-04-23 14:10:25 -04002183static inline int security_task_getsid(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002184{
2185 return 0;
2186}
2187
Eric Paris7b41b172008-04-23 14:10:25 -04002188static inline void security_task_getsecid(struct task_struct *p, u32 *secid)
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02002189{
2190 *secid = 0;
2191}
David Quigleyf9008e42006-06-30 01:55:46 -07002192
Eric Paris7b41b172008-04-23 14:10:25 -04002193static inline int security_task_setgroups(struct group_info *group_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194{
2195 return 0;
2196}
2197
Eric Paris7b41b172008-04-23 14:10:25 -04002198static inline int security_task_setnice(struct task_struct *p, int nice)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002199{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002200 return cap_task_setnice(p, nice);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002201}
2202
Eric Paris7b41b172008-04-23 14:10:25 -04002203static inline int security_task_setioprio(struct task_struct *p, int ioprio)
James Morris03e68062006-06-23 02:03:58 -07002204{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002205 return cap_task_setioprio(p, ioprio);
James Morris03e68062006-06-23 02:03:58 -07002206}
2207
Eric Paris7b41b172008-04-23 14:10:25 -04002208static inline int security_task_getioprio(struct task_struct *p)
David Quigleya1836a42006-06-30 01:55:49 -07002209{
2210 return 0;
2211}
2212
Eric Paris7b41b172008-04-23 14:10:25 -04002213static inline int security_task_setrlimit(unsigned int resource,
2214 struct rlimit *new_rlim)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002215{
2216 return 0;
2217}
2218
Eric Paris7b41b172008-04-23 14:10:25 -04002219static inline int security_task_setscheduler(struct task_struct *p,
2220 int policy,
2221 struct sched_param *lp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002222{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002223 return cap_task_setscheduler(p, policy, lp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002224}
2225
Eric Paris7b41b172008-04-23 14:10:25 -04002226static inline int security_task_getscheduler(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002227{
2228 return 0;
2229}
2230
Eric Paris7b41b172008-04-23 14:10:25 -04002231static inline int security_task_movememory(struct task_struct *p)
David Quigley35601542006-06-23 02:04:01 -07002232{
2233 return 0;
2234}
2235
Eric Paris7b41b172008-04-23 14:10:25 -04002236static inline int security_task_kill(struct task_struct *p,
2237 struct siginfo *info, int sig,
2238 u32 secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239{
Serge Hallynaedb60a2008-02-29 15:14:57 +00002240 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002241}
2242
Eric Paris7b41b172008-04-23 14:10:25 -04002243static inline int security_task_wait(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002244{
2245 return 0;
2246}
2247
Eric Paris7b41b172008-04-23 14:10:25 -04002248static inline int security_task_prctl(int option, unsigned long arg2,
2249 unsigned long arg3,
2250 unsigned long arg4,
David Howellsd84f4f92008-11-14 10:39:23 +11002251 unsigned long arg5)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252{
David Howellsd84f4f92008-11-14 10:39:23 +11002253 return cap_task_prctl(option, arg2, arg3, arg3, arg5);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002254}
2255
2256static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2257{ }
2258
Eric Paris7b41b172008-04-23 14:10:25 -04002259static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
2260 short flag)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002261{
2262 return 0;
2263}
2264
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02002265static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
2266{
2267 *secid = 0;
2268}
2269
Eric Paris7b41b172008-04-23 14:10:25 -04002270static inline int security_msg_msg_alloc(struct msg_msg *msg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002271{
2272 return 0;
2273}
2274
Eric Paris7b41b172008-04-23 14:10:25 -04002275static inline void security_msg_msg_free(struct msg_msg *msg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002276{ }
2277
Eric Paris7b41b172008-04-23 14:10:25 -04002278static inline int security_msg_queue_alloc(struct msg_queue *msq)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002279{
2280 return 0;
2281}
2282
Eric Paris7b41b172008-04-23 14:10:25 -04002283static inline void security_msg_queue_free(struct msg_queue *msq)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284{ }
2285
Eric Paris7b41b172008-04-23 14:10:25 -04002286static inline int security_msg_queue_associate(struct msg_queue *msq,
2287 int msqflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002288{
2289 return 0;
2290}
2291
Eric Paris7b41b172008-04-23 14:10:25 -04002292static inline int security_msg_queue_msgctl(struct msg_queue *msq, int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002293{
2294 return 0;
2295}
2296
Eric Paris7b41b172008-04-23 14:10:25 -04002297static inline int security_msg_queue_msgsnd(struct msg_queue *msq,
2298 struct msg_msg *msg, int msqflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299{
2300 return 0;
2301}
2302
Eric Paris7b41b172008-04-23 14:10:25 -04002303static inline int security_msg_queue_msgrcv(struct msg_queue *msq,
2304 struct msg_msg *msg,
2305 struct task_struct *target,
2306 long type, int mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002307{
2308 return 0;
2309}
2310
Eric Paris7b41b172008-04-23 14:10:25 -04002311static inline int security_shm_alloc(struct shmid_kernel *shp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002312{
2313 return 0;
2314}
2315
Eric Paris7b41b172008-04-23 14:10:25 -04002316static inline void security_shm_free(struct shmid_kernel *shp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002317{ }
2318
Eric Paris7b41b172008-04-23 14:10:25 -04002319static inline int security_shm_associate(struct shmid_kernel *shp,
2320 int shmflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321{
2322 return 0;
2323}
2324
Eric Paris7b41b172008-04-23 14:10:25 -04002325static inline int security_shm_shmctl(struct shmid_kernel *shp, int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002326{
2327 return 0;
2328}
2329
Eric Paris7b41b172008-04-23 14:10:25 -04002330static inline int security_shm_shmat(struct shmid_kernel *shp,
2331 char __user *shmaddr, int shmflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002332{
2333 return 0;
2334}
2335
Eric Paris7b41b172008-04-23 14:10:25 -04002336static inline int security_sem_alloc(struct sem_array *sma)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337{
2338 return 0;
2339}
2340
Eric Paris7b41b172008-04-23 14:10:25 -04002341static inline void security_sem_free(struct sem_array *sma)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002342{ }
2343
Eric Paris7b41b172008-04-23 14:10:25 -04002344static inline int security_sem_associate(struct sem_array *sma, int semflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002345{
2346 return 0;
2347}
2348
Eric Paris7b41b172008-04-23 14:10:25 -04002349static inline int security_sem_semctl(struct sem_array *sma, int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002350{
2351 return 0;
2352}
2353
Eric Paris7b41b172008-04-23 14:10:25 -04002354static inline int security_sem_semop(struct sem_array *sma,
2355 struct sembuf *sops, unsigned nsops,
2356 int alter)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002357{
2358 return 0;
2359}
2360
Eric Paris7b41b172008-04-23 14:10:25 -04002361static inline void security_d_instantiate(struct dentry *dentry, struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362{ }
2363
Al Viro04ff9702007-03-12 16:17:58 +00002364static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365{
2366 return -EINVAL;
2367}
2368
2369static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2370{
2371 return -EINVAL;
2372}
2373
Eric Paris7b41b172008-04-23 14:10:25 -04002374static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002375{
Eric Paris7b41b172008-04-23 14:10:25 -04002376 return cap_netlink_send(sk, skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377}
2378
Eric Paris7b41b172008-04-23 14:10:25 -04002379static inline int security_netlink_recv(struct sk_buff *skb, int cap)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002380{
Eric Paris7b41b172008-04-23 14:10:25 -04002381 return cap_netlink_recv(skb, cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002382}
2383
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002384static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2385{
2386 return -EOPNOTSUPP;
2387}
2388
David Howells7bf570d2008-04-29 20:52:51 +01002389static inline int security_secctx_to_secid(const char *secdata,
David Howells63cb3442008-01-15 23:47:35 +00002390 u32 seclen,
2391 u32 *secid)
2392{
2393 return -EOPNOTSUPP;
2394}
2395
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002396static inline void security_release_secctx(char *secdata, u32 seclen)
2397{
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002398}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002399#endif /* CONFIG_SECURITY */
2400
2401#ifdef CONFIG_SECURITY_NETWORK
Linus Torvalds1da177e2005-04-16 15:20:36 -07002402
James Morris20510f22007-10-16 23:31:32 -07002403int security_unix_stream_connect(struct socket *sock, struct socket *other,
2404 struct sock *newsk);
2405int security_unix_may_send(struct socket *sock, struct socket *other);
2406int security_socket_create(int family, int type, int protocol, int kern);
2407int security_socket_post_create(struct socket *sock, int family,
2408 int type, int protocol, int kern);
2409int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
2410int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
2411int security_socket_listen(struct socket *sock, int backlog);
2412int security_socket_accept(struct socket *sock, struct socket *newsock);
2413void security_socket_post_accept(struct socket *sock, struct socket *newsock);
2414int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
2415int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
2416 int size, int flags);
2417int security_socket_getsockname(struct socket *sock);
2418int security_socket_getpeername(struct socket *sock);
2419int security_socket_getsockopt(struct socket *sock, int level, int optname);
2420int security_socket_setsockopt(struct socket *sock, int level, int optname);
2421int security_socket_shutdown(struct socket *sock, int how);
2422int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
2423int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2424 int __user *optlen, unsigned len);
2425int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
2426int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
2427void security_sk_free(struct sock *sk);
2428void security_sk_clone(const struct sock *sk, struct sock *newsk);
2429void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
2430void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
2431void security_sock_graft(struct sock*sk, struct socket *parent);
2432int security_inet_conn_request(struct sock *sk,
2433 struct sk_buff *skb, struct request_sock *req);
2434void security_inet_csk_clone(struct sock *newsk,
2435 const struct request_sock *req);
2436void security_inet_conn_established(struct sock *sk,
2437 struct sk_buff *skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439#else /* CONFIG_SECURITY_NETWORK */
Eric Paris7b41b172008-04-23 14:10:25 -04002440static inline int security_unix_stream_connect(struct socket *sock,
2441 struct socket *other,
2442 struct sock *newsk)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002443{
2444 return 0;
2445}
2446
Eric Paris7b41b172008-04-23 14:10:25 -04002447static inline int security_unix_may_send(struct socket *sock,
2448 struct socket *other)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449{
2450 return 0;
2451}
2452
Eric Paris7b41b172008-04-23 14:10:25 -04002453static inline int security_socket_create(int family, int type,
2454 int protocol, int kern)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002455{
2456 return 0;
2457}
2458
Eric Paris7b41b172008-04-23 14:10:25 -04002459static inline int security_socket_post_create(struct socket *sock,
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07002460 int family,
2461 int type,
2462 int protocol, int kern)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002463{
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07002464 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002465}
2466
Eric Paris7b41b172008-04-23 14:10:25 -04002467static inline int security_socket_bind(struct socket *sock,
2468 struct sockaddr *address,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002469 int addrlen)
2470{
2471 return 0;
2472}
2473
Eric Paris7b41b172008-04-23 14:10:25 -04002474static inline int security_socket_connect(struct socket *sock,
2475 struct sockaddr *address,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002476 int addrlen)
2477{
2478 return 0;
2479}
2480
Eric Paris7b41b172008-04-23 14:10:25 -04002481static inline int security_socket_listen(struct socket *sock, int backlog)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002482{
2483 return 0;
2484}
2485
Eric Paris7b41b172008-04-23 14:10:25 -04002486static inline int security_socket_accept(struct socket *sock,
2487 struct socket *newsock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002488{
2489 return 0;
2490}
2491
Eric Paris7b41b172008-04-23 14:10:25 -04002492static inline void security_socket_post_accept(struct socket *sock,
2493 struct socket *newsock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494{
2495}
2496
Eric Paris7b41b172008-04-23 14:10:25 -04002497static inline int security_socket_sendmsg(struct socket *sock,
2498 struct msghdr *msg, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002499{
2500 return 0;
2501}
2502
Eric Paris7b41b172008-04-23 14:10:25 -04002503static inline int security_socket_recvmsg(struct socket *sock,
2504 struct msghdr *msg, int size,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002505 int flags)
2506{
2507 return 0;
2508}
2509
Eric Paris7b41b172008-04-23 14:10:25 -04002510static inline int security_socket_getsockname(struct socket *sock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002511{
2512 return 0;
2513}
2514
Eric Paris7b41b172008-04-23 14:10:25 -04002515static inline int security_socket_getpeername(struct socket *sock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002516{
2517 return 0;
2518}
2519
Eric Paris7b41b172008-04-23 14:10:25 -04002520static inline int security_socket_getsockopt(struct socket *sock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002521 int level, int optname)
2522{
2523 return 0;
2524}
2525
Eric Paris7b41b172008-04-23 14:10:25 -04002526static inline int security_socket_setsockopt(struct socket *sock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002527 int level, int optname)
2528{
2529 return 0;
2530}
2531
Eric Paris7b41b172008-04-23 14:10:25 -04002532static inline int security_socket_shutdown(struct socket *sock, int how)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002533{
2534 return 0;
2535}
Eric Paris7b41b172008-04-23 14:10:25 -04002536static inline int security_sock_rcv_skb(struct sock *sk,
2537 struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002538{
2539 return 0;
2540}
2541
Catherine Zhang2c7946a2006-03-20 22:41:23 -08002542static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2543 int __user *optlen, unsigned len)
2544{
2545 return -ENOPROTOOPT;
2546}
2547
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002548static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002549{
2550 return -ENOPROTOOPT;
2551}
2552
Al Virodd0fc662005-10-07 07:46:04 +01002553static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002554{
2555 return 0;
2556}
2557
2558static inline void security_sk_free(struct sock *sk)
2559{
2560}
Trent Jaegerdf718372005-12-13 23:12:27 -08002561
Venkat Yekkirala892c1412006-08-04 23:08:56 -07002562static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2563{
2564}
2565
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002566static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
Trent Jaegerdf718372005-12-13 23:12:27 -08002567{
Trent Jaegerdf718372005-12-13 23:12:27 -08002568}
Venkat Yekkirala4237c752006-07-24 23:32:50 -07002569
2570static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2571{
2572}
2573
Eric Paris7b41b172008-04-23 14:10:25 -04002574static inline void security_sock_graft(struct sock *sk, struct socket *parent)
Venkat Yekkirala4237c752006-07-24 23:32:50 -07002575{
2576}
2577
2578static inline int security_inet_conn_request(struct sock *sk,
2579 struct sk_buff *skb, struct request_sock *req)
2580{
2581 return 0;
2582}
2583
2584static inline void security_inet_csk_clone(struct sock *newsk,
2585 const struct request_sock *req)
2586{
2587}
Venkat Yekkirala6b877692006-11-08 17:04:09 -06002588
2589static inline void security_inet_conn_established(struct sock *sk,
2590 struct sk_buff *skb)
2591{
2592}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593#endif /* CONFIG_SECURITY_NETWORK */
2594
Trent Jaegerdf718372005-12-13 23:12:27 -08002595#ifdef CONFIG_SECURITY_NETWORK_XFRM
Venkat Yekkiralacb969f02006-07-24 23:32:20 -07002596
Paul Moore03e1ad72008-04-12 19:07:52 -07002597int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *sec_ctx);
2598int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
2599void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
2600int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
James Morris20510f22007-10-16 23:31:32 -07002601int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
2602int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2603 struct xfrm_sec_ctx *polsec, u32 secid);
2604int security_xfrm_state_delete(struct xfrm_state *x);
2605void security_xfrm_state_free(struct xfrm_state *x);
Paul Moore03e1ad72008-04-12 19:07:52 -07002606int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
James Morris20510f22007-10-16 23:31:32 -07002607int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2608 struct xfrm_policy *xp, struct flowi *fl);
2609int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
2610void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
Trent Jaegerdf718372005-12-13 23:12:27 -08002611
Trent Jaegerdf718372005-12-13 23:12:27 -08002612#else /* CONFIG_SECURITY_NETWORK_XFRM */
James Morris20510f22007-10-16 23:31:32 -07002613
Paul Moore03e1ad72008-04-12 19:07:52 -07002614static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *sec_ctx)
Trent Jaegerdf718372005-12-13 23:12:27 -08002615{
2616 return 0;
2617}
2618
Paul Moore03e1ad72008-04-12 19:07:52 -07002619static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
Trent Jaegerdf718372005-12-13 23:12:27 -08002620{
2621 return 0;
2622}
2623
Paul Moore03e1ad72008-04-12 19:07:52 -07002624static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
Trent Jaegerdf718372005-12-13 23:12:27 -08002625{
2626}
2627
Paul Moore03e1ad72008-04-12 19:07:52 -07002628static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
Catherine Zhangc8c05a82006-06-08 23:39:49 -07002629{
2630 return 0;
2631}
2632
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002633static inline int security_xfrm_state_alloc(struct xfrm_state *x,
2634 struct xfrm_user_sec_ctx *sec_ctx)
2635{
2636 return 0;
2637}
2638
2639static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2640 struct xfrm_sec_ctx *polsec, u32 secid)
Trent Jaegerdf718372005-12-13 23:12:27 -08002641{
2642 return 0;
2643}
2644
2645static inline void security_xfrm_state_free(struct xfrm_state *x)
2646{
2647}
2648
David S. Miller6f68dc32006-06-08 23:58:52 -07002649static inline int security_xfrm_state_delete(struct xfrm_state *x)
Catherine Zhangc8c05a82006-06-08 23:39:49 -07002650{
2651 return 0;
2652}
2653
Paul Moore03e1ad72008-04-12 19:07:52 -07002654static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
Trent Jaegerdf718372005-12-13 23:12:27 -08002655{
2656 return 0;
2657}
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002658
2659static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2660 struct xfrm_policy *xp, struct flowi *fl)
2661{
2662 return 1;
2663}
2664
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002665static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002666{
2667 return 0;
2668}
2669
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002670static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
2671{
2672}
2673
Trent Jaegerdf718372005-12-13 23:12:27 -08002674#endif /* CONFIG_SECURITY_NETWORK_XFRM */
2675
David Howells29db9192005-10-30 15:02:44 -08002676#ifdef CONFIG_KEYS
2677#ifdef CONFIG_SECURITY
David Howells29db9192005-10-30 15:02:44 -08002678
David Howellsd84f4f92008-11-14 10:39:23 +11002679int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
James Morris20510f22007-10-16 23:31:32 -07002680void security_key_free(struct key *key);
2681int security_key_permission(key_ref_t key_ref,
David Howellsd84f4f92008-11-14 10:39:23 +11002682 const struct cred *cred, key_perm_t perm);
David Howells70a5bb72008-04-29 01:01:26 -07002683int security_key_getsecurity(struct key *key, char **_buffer);
David Howells29db9192005-10-30 15:02:44 -08002684
2685#else
2686
Michael LeMayd7200242006-06-22 14:47:17 -07002687static inline int security_key_alloc(struct key *key,
David Howellsd84f4f92008-11-14 10:39:23 +11002688 const struct cred *cred,
David Howells7e047ef2006-06-26 00:24:50 -07002689 unsigned long flags)
David Howells29db9192005-10-30 15:02:44 -08002690{
2691 return 0;
2692}
2693
2694static inline void security_key_free(struct key *key)
2695{
2696}
2697
2698static inline int security_key_permission(key_ref_t key_ref,
David Howellsd84f4f92008-11-14 10:39:23 +11002699 const struct cred *cred,
David Howells29db9192005-10-30 15:02:44 -08002700 key_perm_t perm)
2701{
2702 return 0;
2703}
2704
David Howells70a5bb72008-04-29 01:01:26 -07002705static inline int security_key_getsecurity(struct key *key, char **_buffer)
2706{
2707 *_buffer = NULL;
2708 return 0;
2709}
2710
David Howells29db9192005-10-30 15:02:44 -08002711#endif
2712#endif /* CONFIG_KEYS */
2713
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02002714#ifdef CONFIG_AUDIT
2715#ifdef CONFIG_SECURITY
2716int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
2717int security_audit_rule_known(struct audit_krule *krule);
2718int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
2719 struct audit_context *actx);
2720void security_audit_rule_free(void *lsmrule);
2721
2722#else
2723
2724static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
2725 void **lsmrule)
2726{
2727 return 0;
2728}
2729
2730static inline int security_audit_rule_known(struct audit_krule *krule)
2731{
2732 return 0;
2733}
2734
2735static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
2736 void *lsmrule, struct audit_context *actx)
2737{
2738 return 0;
2739}
2740
2741static inline void security_audit_rule_free(void *lsmrule)
2742{ }
2743
2744#endif /* CONFIG_SECURITY */
2745#endif /* CONFIG_AUDIT */
2746
Eric Parisda318942008-08-22 11:35:57 -04002747#ifdef CONFIG_SECURITYFS
2748
2749extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
2750 struct dentry *parent, void *data,
2751 const struct file_operations *fops);
2752extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2753extern void securityfs_remove(struct dentry *dentry);
2754
2755#else /* CONFIG_SECURITYFS */
2756
2757static inline struct dentry *securityfs_create_dir(const char *name,
2758 struct dentry *parent)
2759{
2760 return ERR_PTR(-ENODEV);
2761}
2762
2763static inline struct dentry *securityfs_create_file(const char *name,
2764 mode_t mode,
2765 struct dentry *parent,
2766 void *data,
2767 const struct file_operations *fops)
2768{
2769 return ERR_PTR(-ENODEV);
2770}
2771
2772static inline void securityfs_remove(struct dentry *dentry)
2773{}
2774
2775#endif
2776
Linus Torvalds1da177e2005-04-16 15:20:36 -07002777#endif /* ! __LINUX_SECURITY_H */
2778