blob: 68be1125144753c84d44bf7fbf376afe94ed9649 [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);
Eric Paris7b41b172008-04-23 14:10:25 -040060extern int cap_bprm_set_security(struct linux_binprm *bprm);
David Howellsd84f4f92008-11-14 10:39:23 +110061extern int cap_bprm_apply_creds(struct linux_binprm *bprm, int unsafe);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062extern int cap_bprm_secureexec(struct linux_binprm *bprm);
David Howells8f0cfa52008-04-29 00:59:41 -070063extern int cap_inode_setxattr(struct dentry *dentry, const char *name,
64 const void *value, size_t size, int flags);
65extern int cap_inode_removexattr(struct dentry *dentry, const char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -070066extern int cap_inode_need_killpriv(struct dentry *dentry);
67extern int cap_inode_killpriv(struct dentry *dentry);
David Howellsd84f4f92008-11-14 10:39:23 +110068extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
Andrew G. Morgan3898b1b2008-04-28 02:13:40 -070069extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
David Howellsd84f4f92008-11-14 10:39:23 +110070 unsigned long arg4, unsigned long arg5);
Eric Paris7b41b172008-04-23 14:10:25 -040071extern int cap_task_setscheduler(struct task_struct *p, int policy, struct sched_param *lp);
72extern int cap_task_setioprio(struct task_struct *p, int ioprio);
73extern int cap_task_setnice(struct task_struct *p, int nice);
74extern int cap_syslog(int type);
James Morris20510f22007-10-16 23:31:32 -070075extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77struct msghdr;
78struct sk_buff;
79struct sock;
80struct sockaddr;
81struct socket;
Trent Jaegerdf718372005-12-13 23:12:27 -080082struct flowi;
83struct dst_entry;
84struct xfrm_selector;
85struct xfrm_policy;
86struct xfrm_state;
87struct xfrm_user_sec_ctx;
Eric Paris2069f452008-07-04 09:47:13 +100088struct seq_file;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
Darrel Goeddelc7bdb542006-06-27 13:26:11 -070091extern int cap_netlink_recv(struct sk_buff *skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Eric Parised032182007-06-28 15:55:21 -040093extern unsigned long mmap_min_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094/*
95 * Values used in the task_security_ops calls
96 */
97/* setuid or setgid, id0 == uid or gid */
98#define LSM_SETID_ID 1
99
100/* setreuid or setregid, id0 == real, id1 == eff */
101#define LSM_SETID_RE 2
102
103/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
104#define LSM_SETID_RES 4
105
106/* setfsuid or setfsgid, id0 == fsuid or fsgid */
107#define LSM_SETID_FS 8
108
109/* forward declares to avoid warnings */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110struct sched_param;
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700111struct request_sock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113/* bprm_apply_creds unsafe reasons */
114#define LSM_UNSAFE_SHARE 1
115#define LSM_UNSAFE_PTRACE 2
116#define LSM_UNSAFE_PTRACE_CAP 4
117
118#ifdef CONFIG_SECURITY
119
Eric Parise0007522008-03-05 10:31:54 -0500120struct security_mnt_opts {
121 char **mnt_opts;
122 int *mnt_opts_flags;
123 int num_mnt_opts;
124};
125
126static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
127{
128 opts->mnt_opts = NULL;
129 opts->mnt_opts_flags = NULL;
130 opts->num_mnt_opts = 0;
131}
132
133static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
134{
135 int i;
136 if (opts->mnt_opts)
Eric Paris7b41b172008-04-23 14:10:25 -0400137 for (i = 0; i < opts->num_mnt_opts; i++)
Eric Parise0007522008-03-05 10:31:54 -0500138 kfree(opts->mnt_opts[i]);
139 kfree(opts->mnt_opts);
140 opts->mnt_opts = NULL;
141 kfree(opts->mnt_opts_flags);
142 opts->mnt_opts_flags = NULL;
143 opts->num_mnt_opts = 0;
144}
145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146/**
147 * struct security_operations - main security structure
148 *
Ahmed S. Darwish076c54c2008-03-06 18:09:10 +0200149 * Security module identifier.
150 *
151 * @name:
152 * A string that acts as a unique identifeir for the LSM with max number
153 * of characters = SECURITY_NAME_MAX.
154 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 * Security hooks for program execution operations.
156 *
157 * @bprm_alloc_security:
158 * Allocate and attach a security structure to the @bprm->security field.
159 * The security field is initialized to NULL when the bprm structure is
160 * allocated.
161 * @bprm contains the linux_binprm structure to be modified.
162 * Return 0 if operation was successful.
163 * @bprm_free_security:
164 * @bprm contains the linux_binprm structure to be modified.
165 * Deallocate and clear the @bprm->security field.
166 * @bprm_apply_creds:
167 * Compute and set the security attributes of a process being transformed
168 * by an execve operation based on the old attributes (current->security)
169 * and the information saved in @bprm->security by the set_security hook.
David Howellsd84f4f92008-11-14 10:39:23 +1100170 * Since this function may return an error, in which case the process will
171 * be killed. However, it can leave the security attributes of the
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 * process unchanged if an access failure occurs at this point.
173 * bprm_apply_creds is called under task_lock. @unsafe indicates various
174 * reasons why it may be unsafe to change security state.
175 * @bprm contains the linux_binprm structure.
176 * @bprm_post_apply_creds:
177 * Runs after bprm_apply_creds with the task_lock dropped, so that
178 * functions which cannot be called safely under the task_lock can
179 * be used. This hook is a good place to perform state changes on
180 * the process such as closing open file descriptors to which access
181 * is no longer granted if the attributes were changed.
182 * Note that a security module might need to save state between
183 * bprm_apply_creds and bprm_post_apply_creds to store the decision
184 * on whether the process may proceed.
185 * @bprm contains the linux_binprm structure.
186 * @bprm_set_security:
187 * Save security information in the bprm->security field, typically based
188 * on information about the bprm->file, for later use by the apply_creds
189 * hook. This hook may also optionally check permissions (e.g. for
190 * transitions between security domains).
191 * This hook may be called multiple times during a single execve, e.g. for
192 * interpreters. The hook can tell whether it has already been called by
193 * checking to see if @bprm->security is non-NULL. If so, then the hook
194 * may decide either to retain the security information saved earlier or
195 * to replace it.
196 * @bprm contains the linux_binprm structure.
197 * Return 0 if the hook is successful and permission is granted.
198 * @bprm_check_security:
Eric Paris7b41b172008-04-23 14:10:25 -0400199 * This hook mediates the point when a search for a binary handler will
200 * begin. It allows a check the @bprm->security value which is set in
201 * the preceding set_security call. The primary difference from
202 * set_security is that the argv list and envp list are reliably
203 * available in @bprm. This hook may be called multiple times
204 * during a single execve; and in each pass set_security is called
205 * first.
206 * @bprm contains the linux_binprm structure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 * Return 0 if the hook is successful and permission is granted.
208 * @bprm_secureexec:
Eric Paris7b41b172008-04-23 14:10:25 -0400209 * Return a boolean value (0 or 1) indicating whether a "secure exec"
210 * is required. The flag is passed in the auxiliary table
211 * on the initial stack to the ELF interpreter to indicate whether libc
212 * should enable secure mode.
213 * @bprm contains the linux_binprm structure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 *
215 * Security hooks for filesystem operations.
216 *
217 * @sb_alloc_security:
218 * Allocate and attach a security structure to the sb->s_security field.
219 * The s_security field is initialized to NULL when the structure is
220 * allocated.
221 * @sb contains the super_block structure to be modified.
222 * Return 0 if operation was successful.
223 * @sb_free_security:
224 * Deallocate and clear the sb->s_security field.
225 * @sb contains the super_block structure to be modified.
226 * @sb_statfs:
David Howells726c3342006-06-23 02:02:58 -0700227 * Check permission before obtaining filesystem statistics for the @mnt
228 * mountpoint.
229 * @dentry is a handle on the superblock for the filesystem.
Eric Paris7b41b172008-04-23 14:10:25 -0400230 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 * @sb_mount:
232 * Check permission before an object specified by @dev_name is mounted on
233 * the mount point named by @nd. For an ordinary mount, @dev_name
234 * identifies a device if the file system type requires a device. For a
235 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
236 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
237 * pathname of the object being mounted.
238 * @dev_name contains the name for object being mounted.
Al Virob5266eb2008-03-22 17:48:24 -0400239 * @path contains the path for mount point object.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 * @type contains the filesystem type.
241 * @flags contains the mount flags.
242 * @data contains the filesystem-specific data.
243 * Return 0 if permission is granted.
244 * @sb_copy_data:
245 * Allow mount option data to be copied prior to parsing by the filesystem,
246 * so that the security module can extract security-specific mount
247 * options cleanly (a filesystem may modify the data e.g. with strsep()).
248 * This also allows the original mount data to be stripped of security-
249 * specific options to avoid having to make filesystems aware of them.
250 * @type the type of filesystem being mounted.
251 * @orig the original mount data copied from userspace.
252 * @copy copied data which will be passed to the security module.
253 * Returns 0 if the copy was successful.
254 * @sb_check_sb:
255 * Check permission before the device with superblock @mnt->sb is mounted
256 * on the mount point named by @nd.
257 * @mnt contains the vfsmount for device being mounted.
Al Virob5266eb2008-03-22 17:48:24 -0400258 * @path contains the path for the mount point.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 * Return 0 if permission is granted.
260 * @sb_umount:
261 * Check permission before the @mnt file system is unmounted.
262 * @mnt contains the mounted file system.
263 * @flags contains the unmount flags, e.g. MNT_FORCE.
264 * Return 0 if permission is granted.
265 * @sb_umount_close:
266 * Close any files in the @mnt mounted filesystem that are held open by
267 * the security module. This hook is called during an umount operation
268 * prior to checking whether the filesystem is still busy.
269 * @mnt contains the mounted filesystem.
270 * @sb_umount_busy:
271 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
272 * any files that were closed by umount_close. This hook is called during
273 * an umount operation if the umount fails after a call to the
274 * umount_close hook.
275 * @mnt contains the mounted filesystem.
276 * @sb_post_remount:
277 * Update the security module's state when a filesystem is remounted.
278 * This hook is only called if the remount was successful.
279 * @mnt contains the mounted file system.
280 * @flags contains the new filesystem flags.
281 * @data contains the filesystem-specific data.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 * @sb_post_addmount:
283 * Update the security module's state when a filesystem is mounted.
284 * This hook is called any time a mount is successfully grafetd to
285 * the tree.
286 * @mnt contains the mounted filesystem.
Al Virob5266eb2008-03-22 17:48:24 -0400287 * @mountpoint contains the path for the mount point.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 * @sb_pivotroot:
289 * Check permission before pivoting the root filesystem.
Al Virob5266eb2008-03-22 17:48:24 -0400290 * @old_path contains the path for the new location of the current root (put_old).
Eric Paris7b41b172008-04-23 14:10:25 -0400291 * @new_path contains the path for the new root (new_root).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 * Return 0 if permission is granted.
293 * @sb_post_pivotroot:
294 * Update module state after a successful pivot.
Al Virob5266eb2008-03-22 17:48:24 -0400295 * @old_path contains the path for the old root.
Eric Paris7b41b172008-04-23 14:10:25 -0400296 * @new_path contains the path for the new root.
Eric Parisc9180a52007-11-30 13:00:35 -0500297 * @sb_set_mnt_opts:
298 * Set the security relevant mount options used for a superblock
299 * @sb the superblock to set security mount options for
Eric Parise0007522008-03-05 10:31:54 -0500300 * @opts binary data structure containing all lsm mount data
Eric Parisc9180a52007-11-30 13:00:35 -0500301 * @sb_clone_mnt_opts:
302 * Copy all security options from a given superblock to another
303 * @oldsb old superblock which contain information to clone
304 * @newsb new superblock which needs filled in
Eric Parise0007522008-03-05 10:31:54 -0500305 * @sb_parse_opts_str:
306 * Parse a string of security data filling in the opts structure
307 * @options string containing all mount options known by the LSM
308 * @opts binary data structure usable by the LSM
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 *
310 * Security hooks for inode operations.
311 *
312 * @inode_alloc_security:
313 * Allocate and attach a security structure to @inode->i_security. The
314 * i_security field is initialized to NULL when the inode structure is
315 * allocated.
316 * @inode contains the inode structure.
317 * Return 0 if operation was successful.
318 * @inode_free_security:
319 * @inode contains the inode structure.
320 * Deallocate the inode security structure and set @inode->i_security to
Eric Paris7b41b172008-04-23 14:10:25 -0400321 * NULL.
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700322 * @inode_init_security:
Eric Paris7b41b172008-04-23 14:10:25 -0400323 * Obtain the security attribute name suffix and value to set on a newly
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700324 * created inode and set up the incore security field for the new inode.
325 * This hook is called by the fs code as part of the inode creation
326 * transaction and provides for atomic labeling of the inode, unlike
327 * the post_create/mkdir/... hooks called by the VFS. The hook function
328 * is expected to allocate the name and value via kmalloc, with the caller
329 * being responsible for calling kfree after using them.
330 * If the security module does not use security attributes or does
331 * not wish to put a security attribute on this particular inode,
332 * then it should return -EOPNOTSUPP to skip this processing.
333 * @inode contains the inode structure of the newly created inode.
334 * @dir contains the inode structure of the parent directory.
335 * @name will be set to the allocated name suffix (e.g. selinux).
336 * @value will be set to the allocated attribute value.
337 * @len will be set to the length of the value.
338 * Returns 0 if @name and @value have been successfully set,
339 * -EOPNOTSUPP if no security attribute is needed, or
340 * -ENOMEM on memory allocation failure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 * @inode_create:
342 * Check permission to create a regular file.
343 * @dir contains inode structure of the parent of the new file.
344 * @dentry contains the dentry structure for the file to be created.
345 * @mode contains the file mode of the file to be created.
346 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 * @inode_link:
348 * Check permission before creating a new hard link to a file.
349 * @old_dentry contains the dentry structure for an existing link to the file.
350 * @dir contains the inode structure of the parent directory of the new link.
351 * @new_dentry contains the dentry structure for the new link.
352 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 * @inode_unlink:
Eric Paris7b41b172008-04-23 14:10:25 -0400354 * Check the permission to remove a hard link to a file.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 * @dir contains the inode structure of parent directory of the file.
356 * @dentry contains the dentry structure for file to be unlinked.
357 * Return 0 if permission is granted.
358 * @inode_symlink:
359 * Check the permission to create a symbolic link to a file.
360 * @dir contains the inode structure of parent directory of the symbolic link.
361 * @dentry contains the dentry structure of the symbolic link.
362 * @old_name contains the pathname of file.
363 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 * @inode_mkdir:
365 * Check permissions to create a new directory in the existing directory
Eric Paris7b41b172008-04-23 14:10:25 -0400366 * associated with inode strcture @dir.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 * @dir containst the inode structure of parent of the directory to be created.
368 * @dentry contains the dentry structure of new directory.
369 * @mode contains the mode of new directory.
370 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 * @inode_rmdir:
372 * Check the permission to remove a directory.
373 * @dir contains the inode structure of parent of the directory to be removed.
374 * @dentry contains the dentry structure of directory to be removed.
375 * Return 0 if permission is granted.
376 * @inode_mknod:
377 * Check permissions when creating a special file (or a socket or a fifo
378 * file created via the mknod system call). Note that if mknod operation
379 * is being done for a regular file, then the create hook will be called
380 * and not this hook.
381 * @dir contains the inode structure of parent of the new file.
382 * @dentry contains the dentry structure of the new file.
383 * @mode contains the mode of the new file.
Michael Opdenacker59c51592007-05-09 08:57:56 +0200384 * @dev contains the device number.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 * @inode_rename:
387 * Check for permission to rename a file or directory.
388 * @old_dir contains the inode structure for parent of the old link.
389 * @old_dentry contains the dentry structure of the old link.
390 * @new_dir contains the inode structure for parent of the new link.
391 * @new_dentry contains the dentry structure of the new link.
392 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 * @inode_readlink:
394 * Check the permission to read the symbolic link.
395 * @dentry contains the dentry structure for the file link.
396 * Return 0 if permission is granted.
397 * @inode_follow_link:
398 * Check permission to follow a symbolic link when looking up a pathname.
399 * @dentry contains the dentry structure for the link.
400 * @nd contains the nameidata structure for the parent directory.
401 * Return 0 if permission is granted.
402 * @inode_permission:
403 * Check permission before accessing an inode. This hook is called by the
404 * existing Linux permission function, so a security module can use it to
405 * provide additional checking for existing Linux permission checks.
406 * Notice that this hook is called when a file is opened (as well as many
407 * other operations), whereas the file_security_ops permission hook is
408 * called when the actual read/write operations are performed.
409 * @inode contains the inode structure to check.
410 * @mask contains the permission mask.
Eric Paris7b41b172008-04-23 14:10:25 -0400411 * @nd contains the nameidata (may be NULL).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 * Return 0 if permission is granted.
413 * @inode_setattr:
414 * Check permission before setting file attributes. Note that the kernel
415 * call to notify_change is performed from several locations, whenever
416 * file attributes change (such as when a file is truncated, chown/chmod
417 * operations, transferring disk quotas, etc).
418 * @dentry contains the dentry structure for the file.
419 * @attr is the iattr structure containing the new file attributes.
420 * Return 0 if permission is granted.
421 * @inode_getattr:
422 * Check permission before obtaining file attributes.
423 * @mnt is the vfsmount where the dentry was looked up
424 * @dentry contains the dentry structure for the file.
425 * Return 0 if permission is granted.
426 * @inode_delete:
427 * @inode contains the inode structure for deleted inode.
428 * This hook is called when a deleted inode is released (i.e. an inode
429 * with no hard links has its use count drop to zero). A security module
430 * can use this hook to release any persistent label associated with the
431 * inode.
432 * @inode_setxattr:
Eric Paris7b41b172008-04-23 14:10:25 -0400433 * Check permission before setting the extended attributes
434 * @value identified by @name for @dentry.
435 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 * @inode_post_setxattr:
Eric Paris7b41b172008-04-23 14:10:25 -0400437 * Update inode security field after successful setxattr operation.
438 * @value identified by @name for @dentry.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 * @inode_getxattr:
Eric Paris7b41b172008-04-23 14:10:25 -0400440 * Check permission before obtaining the extended attributes
441 * identified by @name for @dentry.
442 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 * @inode_listxattr:
Eric Paris7b41b172008-04-23 14:10:25 -0400444 * Check permission before obtaining the list of extended attribute
445 * names for @dentry.
446 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 * @inode_removexattr:
Eric Paris7b41b172008-04-23 14:10:25 -0400448 * Check permission before removing the extended attribute
449 * identified by @name for @dentry.
450 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 * @inode_getsecurity:
David P. Quigley42492592008-02-04 22:29:39 -0800452 * Retrieve a copy of the extended attribute representation of the
453 * security label associated with @name for @inode via @buffer. Note that
454 * @name is the remainder of the attribute name after the security prefix
455 * has been removed. @alloc is used to specify of the call should return a
456 * value via the buffer or just the value length Return size of buffer on
457 * success.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 * @inode_setsecurity:
459 * Set the security label associated with @name for @inode from the
460 * extended attribute value @value. @size indicates the size of the
461 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
Eric Paris7b41b172008-04-23 14:10:25 -0400462 * Note that @name is the remainder of the attribute name after the
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 * security. prefix has been removed.
464 * Return 0 on success.
465 * @inode_listsecurity:
466 * Copy the extended attribute names for the security labels
467 * associated with @inode into @buffer. The maximum size of @buffer
468 * is specified by @buffer_size. @buffer may be NULL to request
469 * the size of the buffer required.
470 * Returns number of bytes used/required on success.
Serge E. Hallynb5376772007-10-16 23:31:36 -0700471 * @inode_need_killpriv:
472 * Called when an inode has been changed.
473 * @dentry is the dentry being changed.
474 * Return <0 on error to abort the inode change operation.
475 * Return 0 if inode_killpriv does not need to be called.
476 * Return >0 if inode_killpriv does need to be called.
477 * @inode_killpriv:
478 * The setuid bit is being removed. Remove similar security labels.
479 * Called with the dentry->d_inode->i_mutex held.
480 * @dentry is the dentry being changed.
481 * Return 0 on success. If error is returned, then the operation
482 * causing setuid bit removal is failed.
Ahmed S. Darwish8a076192008-03-01 21:51:09 +0200483 * @inode_getsecid:
484 * Get the secid associated with the node.
485 * @inode contains a pointer to the inode.
486 * @secid contains a pointer to the location where result will be saved.
487 * In case of failure, @secid will be set to zero.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 *
489 * Security hooks for file operations
490 *
491 * @file_permission:
492 * Check file permissions before accessing an open file. This hook is
493 * called by various operations that read or write files. A security
494 * module can use this hook to perform additional checking on these
495 * operations, e.g. to revalidate permissions on use to support privilege
496 * bracketing or policy changes. Notice that this hook is used when the
497 * actual read/write operations are performed, whereas the
498 * inode_security_ops hook is called when a file is opened (as well as
499 * many other operations).
500 * Caveat: Although this hook can be used to revalidate permissions for
501 * various system call operations that read or write files, it does not
502 * address the revalidation of permissions for memory-mapped files.
503 * Security modules must handle this separately if they need such
504 * revalidation.
505 * @file contains the file structure being accessed.
506 * @mask contains the requested permissions.
507 * Return 0 if permission is granted.
508 * @file_alloc_security:
509 * Allocate and attach a security structure to the file->f_security field.
510 * The security field is initialized to NULL when the structure is first
511 * created.
512 * @file contains the file structure to secure.
513 * Return 0 if the hook is successful and permission is granted.
514 * @file_free_security:
515 * Deallocate and free any security structures stored in file->f_security.
516 * @file contains the file structure being modified.
517 * @file_ioctl:
518 * @file contains the file structure.
519 * @cmd contains the operation to perform.
520 * @arg contains the operational arguments.
521 * Check permission for an ioctl operation on @file. Note that @arg can
522 * sometimes represents a user space pointer; in other cases, it may be a
523 * simple integer value. When @arg represents a user space pointer, it
524 * should never be used by the security module.
525 * Return 0 if permission is granted.
526 * @file_mmap :
527 * Check permissions for a mmap operation. The @file may be NULL, e.g.
528 * if mapping anonymous memory.
529 * @file contains the file structure for file to map (may be NULL).
530 * @reqprot contains the protection requested by the application.
531 * @prot contains the protection that will be applied by the kernel.
532 * @flags contains the operational flags.
533 * Return 0 if permission is granted.
534 * @file_mprotect:
535 * Check permissions before changing memory access permissions.
536 * @vma contains the memory region to modify.
537 * @reqprot contains the protection requested by the application.
538 * @prot contains the protection that will be applied by the kernel.
539 * Return 0 if permission is granted.
540 * @file_lock:
541 * Check permission before performing file locking operations.
542 * Note: this hook mediates both flock and fcntl style locks.
543 * @file contains the file structure.
544 * @cmd contains the posix-translated lock operation to perform
545 * (e.g. F_RDLCK, F_WRLCK).
546 * Return 0 if permission is granted.
547 * @file_fcntl:
548 * Check permission before allowing the file operation specified by @cmd
549 * from being performed on the file @file. Note that @arg can sometimes
550 * represents a user space pointer; in other cases, it may be a simple
551 * integer value. When @arg represents a user space pointer, it should
552 * never be used by the security module.
553 * @file contains the file structure.
554 * @cmd contains the operation to be performed.
555 * @arg contains the operational arguments.
556 * Return 0 if permission is granted.
557 * @file_set_fowner:
558 * Save owner security information (typically from current->security) in
559 * file->f_security for later use by the send_sigiotask hook.
560 * @file contains the file structure to update.
561 * Return 0 on success.
562 * @file_send_sigiotask:
563 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
564 * process @tsk. Note that this hook is sometimes called from interrupt.
565 * Note that the fown_struct, @fown, is never outside the context of a
566 * struct file, so the file structure (and associated security information)
567 * can always be obtained:
Robert P. J. Dayb385a142007-02-10 01:46:25 -0800568 * container_of(fown, struct file, f_owner)
Eric Paris7b41b172008-04-23 14:10:25 -0400569 * @tsk contains the structure of task receiving signal.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 * @fown contains the file owner information.
571 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
572 * Return 0 if permission is granted.
573 * @file_receive:
574 * This hook allows security modules to control the ability of a process
575 * to receive an open file descriptor via socket IPC.
576 * @file contains the file structure being received.
577 * Return 0 if permission is granted.
578 *
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +0900579 * Security hook for dentry
580 *
581 * @dentry_open
582 * Save open-time permission checking state for later use upon
583 * file_permission, and recheck access if anything has changed
584 * since inode_permission.
585 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 * Security hooks for task operations.
587 *
588 * @task_create:
589 * Check permission before creating a child process. See the clone(2)
590 * manual page for definitions of the @clone_flags.
591 * @clone_flags contains the flags indicating what should be shared.
592 * Return 0 if permission is granted.
David Howellsf1752ee2008-11-14 10:39:17 +1100593 * @cred_free:
594 * @cred points to the credentials.
595 * Deallocate and clear the cred->security field in a set of credentials.
David Howellsd84f4f92008-11-14 10:39:23 +1100596 * @cred_prepare:
597 * @new points to the new credentials.
598 * @old points to the original credentials.
599 * @gfp indicates the atomicity of any memory allocations.
600 * Prepare a new set of credentials by copying the data from the old set.
601 * @cred_commit:
602 * @new points to the new credentials.
603 * @old points to the original credentials.
604 * Install a new set of credentials.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 * @task_setuid:
606 * Check permission before setting one or more of the user identity
607 * attributes of the current process. The @flags parameter indicates
608 * which of the set*uid system calls invoked this hook and how to
609 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
610 * definitions at the beginning of this file for the @flags values and
611 * their meanings.
612 * @id0 contains a uid.
613 * @id1 contains a uid.
614 * @id2 contains a uid.
615 * @flags contains one of the LSM_SETID_* values.
616 * Return 0 if permission is granted.
David Howellsd84f4f92008-11-14 10:39:23 +1100617 * @task_fix_setuid:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 * Update the module's state after setting one or more of the user
619 * identity attributes of the current process. The @flags parameter
620 * indicates which of the set*uid system calls invoked this hook. If
David Howellsd84f4f92008-11-14 10:39:23 +1100621 * @new is the set of credentials that will be installed. Modifications
622 * should be made to this rather than to @current->cred.
623 * @old is the set of credentials that are being replaces
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 * @flags contains one of the LSM_SETID_* values.
625 * Return 0 on success.
626 * @task_setgid:
627 * Check permission before setting one or more of the group identity
628 * attributes of the current process. The @flags parameter indicates
629 * which of the set*gid system calls invoked this hook and how to
630 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
631 * definitions at the beginning of this file for the @flags values and
632 * their meanings.
633 * @id0 contains a gid.
634 * @id1 contains a gid.
635 * @id2 contains a gid.
636 * @flags contains one of the LSM_SETID_* values.
637 * Return 0 if permission is granted.
638 * @task_setpgid:
639 * Check permission before setting the process group identifier of the
640 * process @p to @pgid.
641 * @p contains the task_struct for process being modified.
642 * @pgid contains the new pgid.
643 * Return 0 if permission is granted.
644 * @task_getpgid:
645 * Check permission before getting the process group identifier of the
646 * process @p.
647 * @p contains the task_struct for the process.
648 * Return 0 if permission is granted.
649 * @task_getsid:
650 * Check permission before getting the session identifier of the process
651 * @p.
652 * @p contains the task_struct for the process.
653 * Return 0 if permission is granted.
David Quigleyf9008e42006-06-30 01:55:46 -0700654 * @task_getsecid:
655 * Retrieve the security identifier of the process @p.
656 * @p contains the task_struct for the process and place is into @secid.
Ahmed S. Darwish8a076192008-03-01 21:51:09 +0200657 * In case of failure, @secid will be set to zero.
658 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 * @task_setgroups:
660 * Check permission before setting the supplementary group set of the
661 * current process.
662 * @group_info contains the new group information.
663 * Return 0 if permission is granted.
664 * @task_setnice:
665 * Check permission before setting the nice value of @p to @nice.
666 * @p contains the task_struct of process.
667 * @nice contains the new nice value.
668 * Return 0 if permission is granted.
James Morris03e68062006-06-23 02:03:58 -0700669 * @task_setioprio
670 * Check permission before setting the ioprio value of @p to @ioprio.
671 * @p contains the task_struct of process.
672 * @ioprio contains the new ioprio value
673 * Return 0 if permission is granted.
David Quigleya1836a42006-06-30 01:55:49 -0700674 * @task_getioprio
675 * Check permission before getting the ioprio value of @p.
676 * @p contains the task_struct of process.
677 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 * @task_setrlimit:
679 * Check permission before setting the resource limits of the current
680 * process for @resource to @new_rlim. The old resource limit values can
681 * be examined by dereferencing (current->signal->rlim + resource).
682 * @resource contains the resource whose limit is being set.
683 * @new_rlim contains the new limits for @resource.
684 * Return 0 if permission is granted.
685 * @task_setscheduler:
686 * Check permission before setting scheduling policy and/or parameters of
687 * process @p based on @policy and @lp.
688 * @p contains the task_struct for process.
689 * @policy contains the scheduling policy.
690 * @lp contains the scheduling parameters.
691 * Return 0 if permission is granted.
692 * @task_getscheduler:
693 * Check permission before obtaining scheduling information for process
694 * @p.
695 * @p contains the task_struct for process.
696 * Return 0 if permission is granted.
David Quigley35601542006-06-23 02:04:01 -0700697 * @task_movememory
698 * Check permission before moving memory owned by process @p.
699 * @p contains the task_struct for process.
700 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 * @task_kill:
702 * Check permission before sending signal @sig to @p. @info can be NULL,
703 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
704 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
705 * from the kernel and should typically be permitted.
706 * SIGIO signals are handled separately by the send_sigiotask hook in
707 * file_security_ops.
708 * @p contains the task_struct for process.
709 * @info contains the signal information.
710 * @sig contains the signal value.
David Quigleyf9008e42006-06-30 01:55:46 -0700711 * @secid contains the sid of the process where the signal originated
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 * Return 0 if permission is granted.
713 * @task_wait:
714 * Check permission before allowing a process to reap a child process @p
715 * and collect its status information.
716 * @p contains the task_struct for process.
717 * Return 0 if permission is granted.
718 * @task_prctl:
719 * Check permission before performing a process control operation on the
720 * current process.
721 * @option contains the operation.
722 * @arg2 contains a argument.
723 * @arg3 contains a argument.
724 * @arg4 contains a argument.
725 * @arg5 contains a argument.
David Howellsd84f4f92008-11-14 10:39:23 +1100726 * Return -ENOSYS if no-one wanted to handle this op, any other value to
727 * cause prctl() to return immediately with that value.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 * @task_to_inode:
Eric Paris7b41b172008-04-23 14:10:25 -0400729 * Set the security attributes for an inode based on an associated task's
730 * security attributes, e.g. for /proc/pid inodes.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 * @p contains the task_struct for the task.
732 * @inode contains the inode structure for the inode.
733 *
734 * Security hooks for Netlink messaging.
735 *
736 * @netlink_send:
737 * Save security information for a netlink message so that permission
738 * checking can be performed when the message is processed. The security
739 * information can be saved using the eff_cap field of the
Eric Paris7b41b172008-04-23 14:10:25 -0400740 * netlink_skb_parms structure. Also may be used to provide fine
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 * grained control over message transmission.
742 * @sk associated sock of task sending the message.,
743 * @skb contains the sk_buff structure for the netlink message.
744 * Return 0 if the information was successfully saved and message
745 * is allowed to be transmitted.
746 * @netlink_recv:
747 * Check permission before processing the received netlink message in
748 * @skb.
749 * @skb contains the sk_buff structure for the netlink message.
Darrel Goeddelc7bdb542006-06-27 13:26:11 -0700750 * @cap indicates the capability required
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 * Return 0 if permission is granted.
752 *
753 * Security hooks for Unix domain networking.
754 *
755 * @unix_stream_connect:
756 * Check permissions before establishing a Unix domain stream connection
757 * between @sock and @other.
758 * @sock contains the socket structure.
759 * @other contains the peer socket structure.
760 * Return 0 if permission is granted.
761 * @unix_may_send:
762 * Check permissions before connecting or sending datagrams from @sock to
763 * @other.
764 * @sock contains the socket structure.
765 * @sock contains the peer socket structure.
766 * Return 0 if permission is granted.
767 *
768 * The @unix_stream_connect and @unix_may_send hooks were necessary because
769 * Linux provides an alternative to the conventional file name space for Unix
770 * domain sockets. Whereas binding and connecting to sockets in the file name
771 * space is mediated by the typical file permissions (and caught by the mknod
772 * and permission hooks in inode_security_ops), binding and connecting to
773 * sockets in the abstract name space is completely unmediated. Sufficient
774 * control of Unix domain sockets in the abstract name space isn't possible
775 * using only the socket layer hooks, since we need to know the actual target
776 * socket, which is not looked up until we are inside the af_unix code.
777 *
778 * Security hooks for socket operations.
779 *
780 * @socket_create:
781 * Check permissions prior to creating a new socket.
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 * Return 0 if permission is granted.
787 * @socket_post_create:
788 * This hook allows a module to update or allocate a per-socket security
789 * structure. Note that the security field was not added directly to the
790 * socket structure, but rather, the socket security information is stored
791 * in the associated inode. Typically, the inode alloc_security hook will
792 * allocate and and attach security information to
793 * sock->inode->i_security. This hook may be used to update the
794 * sock->inode->i_security field with additional information that wasn't
795 * available when the inode was allocated.
796 * @sock contains the newly created socket structure.
797 * @family contains the requested protocol family.
798 * @type contains the requested communications type.
799 * @protocol contains the requested protocol.
800 * @kern set to 1 if a kernel socket.
801 * @socket_bind:
802 * Check permission before socket protocol layer bind operation is
803 * performed and the socket @sock is bound to the address specified in the
804 * @address parameter.
805 * @sock contains the socket structure.
806 * @address contains the address to bind to.
807 * @addrlen contains the length of address.
Eric Paris7b41b172008-04-23 14:10:25 -0400808 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 * @socket_connect:
810 * Check permission before socket protocol layer connect operation
811 * attempts to connect socket @sock to a remote address, @address.
812 * @sock contains the socket structure.
813 * @address contains the address of remote endpoint.
814 * @addrlen contains the length of address.
Eric Paris7b41b172008-04-23 14:10:25 -0400815 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 * @socket_listen:
817 * Check permission before socket protocol layer listen operation.
818 * @sock contains the socket structure.
819 * @backlog contains the maximum length for the pending connection queue.
820 * Return 0 if permission is granted.
821 * @socket_accept:
822 * Check permission before accepting a new connection. Note that the new
823 * socket, @newsock, has been created and some information copied to it,
824 * but the accept operation has not actually been performed.
825 * @sock contains the listening socket structure.
826 * @newsock contains the newly created server socket for connection.
827 * Return 0 if permission is granted.
828 * @socket_post_accept:
829 * This hook allows a security module to copy security
830 * information into the newly created socket's inode.
831 * @sock contains the listening socket structure.
832 * @newsock contains the newly created server socket for connection.
833 * @socket_sendmsg:
834 * Check permission before transmitting a message to another socket.
835 * @sock contains the socket structure.
836 * @msg contains the message to be transmitted.
837 * @size contains the size of message.
838 * Return 0 if permission is granted.
839 * @socket_recvmsg:
840 * Check permission before receiving a message from a socket.
841 * @sock contains the socket structure.
842 * @msg contains the message structure.
843 * @size contains the size of message structure.
844 * @flags contains the operational flags.
Eric Paris7b41b172008-04-23 14:10:25 -0400845 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 * @socket_getsockname:
847 * Check permission before the local address (name) of the socket object
848 * @sock is retrieved.
849 * @sock contains the socket structure.
850 * Return 0 if permission is granted.
851 * @socket_getpeername:
852 * Check permission before the remote address (name) of a socket object
853 * @sock is retrieved.
854 * @sock contains the socket structure.
855 * Return 0 if permission is granted.
856 * @socket_getsockopt:
857 * Check permissions before retrieving the options associated with socket
858 * @sock.
859 * @sock contains the socket structure.
860 * @level contains the protocol level to retrieve option from.
861 * @optname contains the name of option to retrieve.
862 * Return 0 if permission is granted.
863 * @socket_setsockopt:
864 * Check permissions before setting the options associated with socket
865 * @sock.
866 * @sock contains the socket structure.
867 * @level contains the protocol level to set options for.
868 * @optname contains the name of the option to set.
Eric Paris7b41b172008-04-23 14:10:25 -0400869 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 * @socket_shutdown:
871 * Checks permission before all or part of a connection on the socket
872 * @sock is shut down.
873 * @sock contains the socket structure.
874 * @how contains the flag indicating how future sends and receives are handled.
875 * Return 0 if permission is granted.
876 * @socket_sock_rcv_skb:
877 * Check permissions on incoming network packets. This hook is distinct
878 * from Netfilter's IP input hooks since it is the first time that the
879 * incoming sk_buff @skb has been associated with a particular socket, @sk.
880 * @sk contains the sock (not socket) associated with the incoming sk_buff.
881 * @skb contains the incoming network data.
Serge Hallyn6da34ba2007-10-20 00:53:30 +0200882 * @socket_getpeersec_stream:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883 * This hook allows the security module to provide peer socket security
Serge Hallyn6da34ba2007-10-20 00:53:30 +0200884 * state for unix or connected tcp sockets to userspace via getsockopt
885 * SO_GETPEERSEC. For tcp sockets this can be meaningful if the
886 * socket is associated with an ipsec SA.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 * @sock is the local socket.
888 * @optval userspace memory where the security state is to be copied.
889 * @optlen userspace int where the module should copy the actual length
890 * of the security state.
891 * @len as input is the maximum length to copy to userspace provided
892 * by the caller.
893 * Return 0 if all is well, otherwise, typical getsockopt return
894 * values.
Serge Hallyn6da34ba2007-10-20 00:53:30 +0200895 * @socket_getpeersec_dgram:
Eric Paris7b41b172008-04-23 14:10:25 -0400896 * This hook allows the security module to provide peer socket security
897 * state for udp sockets on a per-packet basis to userspace via
898 * getsockopt SO_GETPEERSEC. The application must first have indicated
899 * the IP_PASSSEC option via getsockopt. It can then retrieve the
900 * security state returned by this hook for a packet via the SCM_SECURITY
901 * ancillary message type.
902 * @skb is the skbuff for the packet being queried
903 * @secdata is a pointer to a buffer in which to copy the security data
904 * @seclen is the maximum length for @secdata
905 * Return 0 on success, error on failure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 * @sk_alloc_security:
Eric Paris7b41b172008-04-23 14:10:25 -0400907 * Allocate and attach a security structure to the sk->sk_security field,
908 * which is used to copy security attributes between local stream sockets.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 * @sk_free_security:
910 * Deallocate security structure.
Venkat Yekkirala892c1412006-08-04 23:08:56 -0700911 * @sk_clone_security:
912 * Clone/copy security structure.
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -0700913 * @sk_getsecid:
914 * Retrieve the LSM-specific secid for the sock to enable caching of network
Trent Jaegerdf718372005-12-13 23:12:27 -0800915 * authorizations.
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700916 * @sock_graft:
917 * Sets the socket's isec sid to the sock's sid.
918 * @inet_conn_request:
919 * Sets the openreq's sid to socket's sid with MLS portion taken from peer sid.
920 * @inet_csk_clone:
921 * Sets the new child socket's sid to the openreq sid.
Venkat Yekkirala6b877692006-11-08 17:04:09 -0600922 * @inet_conn_established:
Eric Paris7b41b172008-04-23 14:10:25 -0400923 * Sets the connection's peersid to the secmark on skb.
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700924 * @req_classify_flow:
925 * Sets the flow's sid to the openreq sid.
Trent Jaegerdf718372005-12-13 23:12:27 -0800926 *
927 * Security hooks for XFRM operations.
928 *
929 * @xfrm_policy_alloc_security:
Paul Moore03e1ad72008-04-12 19:07:52 -0700930 * @ctxp is a pointer to the xfrm_sec_ctx being added to Security Policy
931 * Database used by the XFRM system.
Trent Jaegerdf718372005-12-13 23:12:27 -0800932 * @sec_ctx contains the security context information being provided by
933 * the user-level policy update program (e.g., setkey).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700934 * Allocate a security structure to the xp->security field; the security
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -0600935 * field is initialized to NULL when the xfrm_policy is allocated.
Trent Jaegerdf718372005-12-13 23:12:27 -0800936 * Return 0 if operation was successful (memory to allocate, legal context)
937 * @xfrm_policy_clone_security:
Paul Moore03e1ad72008-04-12 19:07:52 -0700938 * @old_ctx contains an existing xfrm_sec_ctx.
939 * @new_ctxp contains a new xfrm_sec_ctx being cloned from old.
940 * Allocate a security structure in new_ctxp that contains the
941 * information from the old_ctx structure.
Trent Jaegerdf718372005-12-13 23:12:27 -0800942 * Return 0 if operation was successful (memory to allocate).
943 * @xfrm_policy_free_security:
Paul Moore03e1ad72008-04-12 19:07:52 -0700944 * @ctx contains the xfrm_sec_ctx
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700945 * Deallocate xp->security.
946 * @xfrm_policy_delete_security:
Paul Moore03e1ad72008-04-12 19:07:52 -0700947 * @ctx contains the xfrm_sec_ctx.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700948 * Authorize deletion of xp->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800949 * @xfrm_state_alloc_security:
950 * @x contains the xfrm_state being added to the Security Association
951 * Database by the XFRM system.
952 * @sec_ctx contains the security context information being provided by
953 * the user-level SA generation program (e.g., setkey or racoon).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700954 * @secid contains the secid from which to take the mls portion of the context.
955 * Allocate a security structure to the x->security field; the security
956 * field is initialized to NULL when the xfrm_state is allocated. Set the
957 * context to correspond to either sec_ctx or polsec, with the mls portion
958 * taken from secid in the latter case.
Trent Jaegerdf718372005-12-13 23:12:27 -0800959 * Return 0 if operation was successful (memory to allocate, legal context).
960 * @xfrm_state_free_security:
961 * @x contains the xfrm_state.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700962 * Deallocate x->security.
963 * @xfrm_state_delete_security:
964 * @x contains the xfrm_state.
965 * Authorize deletion of x->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800966 * @xfrm_policy_lookup:
Paul Moore03e1ad72008-04-12 19:07:52 -0700967 * @ctx contains the xfrm_sec_ctx for which the access control is being
Trent Jaegerdf718372005-12-13 23:12:27 -0800968 * checked.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700969 * @fl_secid contains the flow security label that is used to authorize
Trent Jaegerdf718372005-12-13 23:12:27 -0800970 * access to the policy xp.
971 * @dir contains the direction of the flow (input or output).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700972 * Check permission when a flow selects a xfrm_policy for processing
Trent Jaegerdf718372005-12-13 23:12:27 -0800973 * XFRMs on a packet. The hook is called when selecting either a
974 * per-socket policy or a generic xfrm policy.
Venkat Yekkirala5b368e62006-10-05 15:42:18 -0500975 * Return 0 if permission is granted, -ESRCH otherwise, or -errno
976 * on other errors.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700977 * @xfrm_state_pol_flow_match:
978 * @x contains the state to match.
979 * @xp contains the policy to check for a match.
980 * @fl contains the flow to check for a match.
981 * Return 1 if there is a match.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700982 * @xfrm_decode_session:
983 * @skb points to skb to decode.
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -0700984 * @secid points to the flow key secid to set.
985 * @ckall says if all xfrms used should be checked for same secid.
986 * Return 0 if ckall is zero or all xfrms used have the same secid.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 *
David Howells29db9192005-10-30 15:02:44 -0800988 * Security hooks affecting all Key Management operations
989 *
990 * @key_alloc:
991 * Permit allocation of a key and assign security data. Note that key does
992 * not have a serial number assigned at this point.
993 * @key points to the key.
David Howells7e047ef2006-06-26 00:24:50 -0700994 * @flags is the allocation flags
David Howells29db9192005-10-30 15:02:44 -0800995 * Return 0 if permission is granted, -ve error otherwise.
996 * @key_free:
997 * Notification of destruction; free security data.
998 * @key points to the key.
999 * No return value.
1000 * @key_permission:
1001 * See whether a specific operational right is granted to a process on a
Eric Paris7b41b172008-04-23 14:10:25 -04001002 * key.
David Howells29db9192005-10-30 15:02:44 -08001003 * @key_ref refers to the key (key pointer + possession attribute bit).
David Howellsd84f4f92008-11-14 10:39:23 +11001004 * @cred points to the credentials to provide the context against which to
Eric Paris7b41b172008-04-23 14:10:25 -04001005 * evaluate the security data on the key.
David Howells29db9192005-10-30 15:02:44 -08001006 * @perm describes the combination of permissions required of this key.
1007 * Return 1 if permission granted, 0 if permission denied and -ve it the
Eric Paris7b41b172008-04-23 14:10:25 -04001008 * normal permissions model should be effected.
David Howells70a5bb72008-04-29 01:01:26 -07001009 * @key_getsecurity:
1010 * Get a textual representation of the security context attached to a key
1011 * for the purposes of honouring KEYCTL_GETSECURITY. This function
1012 * allocates the storage for the NUL-terminated string and the caller
1013 * should free it.
1014 * @key points to the key to be queried.
1015 * @_buffer points to a pointer that should be set to point to the
1016 * resulting string (if no label or an error occurs).
1017 * Return the length of the string (including terminating NUL) or -ve if
1018 * an error.
1019 * May also return 0 (and a NULL buffer pointer) if there is no label.
David Howells29db9192005-10-30 15:02:44 -08001020 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021 * Security hooks affecting all System V IPC operations.
1022 *
1023 * @ipc_permission:
1024 * Check permissions for access to IPC
1025 * @ipcp contains the kernel IPC permission structure
1026 * @flag contains the desired (requested) permission set
1027 * Return 0 if permission is granted.
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02001028 * @ipc_getsecid:
1029 * Get the secid associated with the ipc object.
1030 * @ipcp contains the kernel IPC permission structure.
1031 * @secid contains a pointer to the location where result will be saved.
1032 * In case of failure, @secid will be set to zero.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001033 *
1034 * Security hooks for individual messages held in System V IPC message queues
1035 * @msg_msg_alloc_security:
1036 * Allocate and attach a security structure to the msg->security field.
1037 * The security field is initialized to NULL when the structure is first
1038 * created.
1039 * @msg contains the message structure to be modified.
1040 * Return 0 if operation was successful and permission is granted.
1041 * @msg_msg_free_security:
1042 * Deallocate the security structure for this message.
1043 * @msg contains the message structure to be modified.
1044 *
1045 * Security hooks for System V IPC Message Queues
1046 *
1047 * @msg_queue_alloc_security:
1048 * Allocate and attach a security structure to the
1049 * msq->q_perm.security field. The security field is initialized to
1050 * NULL when the structure is first created.
1051 * @msq contains the message queue structure to be modified.
1052 * Return 0 if operation was successful and permission is granted.
1053 * @msg_queue_free_security:
1054 * Deallocate security structure for this message queue.
1055 * @msq contains the message queue structure to be modified.
1056 * @msg_queue_associate:
1057 * Check permission when a message queue is requested through the
1058 * msgget system call. This hook is only called when returning the
1059 * message queue identifier for an existing message queue, not when a
1060 * new message queue is created.
1061 * @msq contains the message queue to act upon.
1062 * @msqflg contains the operation control flags.
1063 * Return 0 if permission is granted.
1064 * @msg_queue_msgctl:
1065 * Check permission when a message control operation specified by @cmd
1066 * is to be performed on the message queue @msq.
1067 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
1068 * @msq contains the message queue to act upon. May be NULL.
1069 * @cmd contains the operation to be performed.
Eric Paris7b41b172008-04-23 14:10:25 -04001070 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071 * @msg_queue_msgsnd:
1072 * Check permission before a message, @msg, is enqueued on the message
1073 * queue, @msq.
1074 * @msq contains the message queue to send message to.
1075 * @msg contains the message to be enqueued.
1076 * @msqflg contains operational flags.
1077 * Return 0 if permission is granted.
1078 * @msg_queue_msgrcv:
1079 * Check permission before a message, @msg, is removed from the message
Eric Paris7b41b172008-04-23 14:10:25 -04001080 * queue, @msq. The @target task structure contains a pointer to the
1081 * process that will be receiving the message (not equal to the current
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082 * process when inline receives are being performed).
1083 * @msq contains the message queue to retrieve message from.
1084 * @msg contains the message destination.
1085 * @target contains the task structure for recipient process.
1086 * @type contains the type of message requested.
1087 * @mode contains the operational flags.
1088 * Return 0 if permission is granted.
1089 *
1090 * Security hooks for System V Shared Memory Segments
1091 *
1092 * @shm_alloc_security:
1093 * Allocate and attach a security structure to the shp->shm_perm.security
1094 * field. The security field is initialized to NULL when the structure is
1095 * first created.
1096 * @shp contains the shared memory structure to be modified.
1097 * Return 0 if operation was successful and permission is granted.
1098 * @shm_free_security:
1099 * Deallocate the security struct for this memory segment.
1100 * @shp contains the shared memory structure to be modified.
1101 * @shm_associate:
1102 * Check permission when a shared memory region is requested through the
1103 * shmget system call. This hook is only called when returning the shared
1104 * memory region identifier for an existing region, not when a new shared
1105 * memory region is created.
1106 * @shp contains the shared memory structure to be modified.
1107 * @shmflg contains the operation control flags.
1108 * Return 0 if permission is granted.
1109 * @shm_shmctl:
1110 * Check permission when a shared memory control operation specified by
1111 * @cmd is to be performed on the shared memory region @shp.
1112 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1113 * @shp contains shared memory structure to be modified.
1114 * @cmd contains the operation to be performed.
1115 * Return 0 if permission is granted.
1116 * @shm_shmat:
1117 * Check permissions prior to allowing the shmat system call to attach the
1118 * shared memory segment @shp to the data segment of the calling process.
1119 * The attaching address is specified by @shmaddr.
1120 * @shp contains the shared memory structure to be modified.
1121 * @shmaddr contains the address to attach memory region to.
1122 * @shmflg contains the operational flags.
1123 * Return 0 if permission is granted.
1124 *
1125 * Security hooks for System V Semaphores
1126 *
1127 * @sem_alloc_security:
1128 * Allocate and attach a security structure to the sma->sem_perm.security
1129 * field. The security field is initialized to NULL when the structure is
1130 * first created.
1131 * @sma contains the semaphore structure
1132 * Return 0 if operation was successful and permission is granted.
1133 * @sem_free_security:
1134 * deallocate security struct for this semaphore
1135 * @sma contains the semaphore structure.
1136 * @sem_associate:
1137 * Check permission when a semaphore is requested through the semget
1138 * system call. This hook is only called when returning the semaphore
1139 * identifier for an existing semaphore, not when a new one must be
1140 * created.
1141 * @sma contains the semaphore structure.
1142 * @semflg contains the operation control flags.
1143 * Return 0 if permission is granted.
1144 * @sem_semctl:
1145 * Check permission when a semaphore operation specified by @cmd is to be
Eric Paris7b41b172008-04-23 14:10:25 -04001146 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 * IPC_INFO or SEM_INFO.
1148 * @sma contains the semaphore structure. May be NULL.
1149 * @cmd contains the operation to be performed.
1150 * Return 0 if permission is granted.
1151 * @sem_semop
1152 * Check permissions before performing operations on members of the
Eric Paris7b41b172008-04-23 14:10:25 -04001153 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1154 * may be modified.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155 * @sma contains the semaphore structure.
1156 * @sops contains the operations to perform.
1157 * @nsops contains the number of operations to perform.
1158 * @alter contains the flag indicating whether changes are to be made.
1159 * Return 0 if permission is granted.
1160 *
David Howells5cd9c582008-08-14 11:37:28 +01001161 * @ptrace_may_access:
1162 * Check permission before allowing the current process to trace the
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 * @child process.
1164 * Security modules may also want to perform a process tracing check
1165 * during an execve in the set_security or apply_creds hooks of
David Howellsd84f4f92008-11-14 10:39:23 +11001166 * tracing check during an execve in the bprm_set_creds hook of
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167 * binprm_security_ops if the process is being traced and its security
1168 * attributes would be changed by the execve.
David Howells5cd9c582008-08-14 11:37:28 +01001169 * @child contains the task_struct structure for the target process.
Stephen Smalley006ebb42008-05-19 08:32:49 -04001170 * @mode contains the PTRACE_MODE flags indicating the form of access.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001171 * Return 0 if permission is granted.
David Howells5cd9c582008-08-14 11:37:28 +01001172 * @ptrace_traceme:
1173 * Check that the @parent process has sufficient permission to trace the
1174 * current process before allowing the current process to present itself
1175 * to the @parent process for tracing.
1176 * The parent process will still have to undergo the ptrace_may_access
1177 * checks before it is allowed to trace this one.
1178 * @parent contains the task_struct structure for debugger process.
1179 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 * @capget:
1181 * Get the @effective, @inheritable, and @permitted capability sets for
1182 * the @target process. The hook may also perform permission checking to
1183 * determine if the current process is allowed to see the capability sets
1184 * of the @target process.
1185 * @target contains the task_struct structure for target process.
1186 * @effective contains the effective capability set.
1187 * @inheritable contains the inheritable capability set.
1188 * @permitted contains the permitted capability set.
1189 * Return 0 if the capability sets were successfully obtained.
David Howellsd84f4f92008-11-14 10:39:23 +11001190 * @capset:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001191 * Set the @effective, @inheritable, and @permitted capability sets for
David Howells1cdcbec2008-11-14 10:39:14 +11001192 * the current process.
David Howellsd84f4f92008-11-14 10:39:23 +11001193 * @new contains the new credentials structure for target process.
1194 * @old contains the current credentials structure for target process.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195 * @effective contains the effective capability set.
1196 * @inheritable contains the inheritable capability set.
1197 * @permitted contains the permitted capability set.
David Howellsd84f4f92008-11-14 10:39:23 +11001198 * Return 0 and update @new if permission is granted.
Chris Wright12b59892006-03-25 03:07:41 -08001199 * @capable:
1200 * Check whether the @tsk process has the @cap capability.
1201 * @tsk contains the task_struct for the process.
1202 * @cap contains the capability <include/linux/capability.h>.
1203 * Return 0 if the capability is granted for @tsk.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001204 * @acct:
1205 * Check permission before enabling or disabling process accounting. If
1206 * accounting is being enabled, then @file refers to the open file used to
1207 * store accounting records. If accounting is being disabled, then @file
1208 * is NULL.
1209 * @file contains the file structure for the accounting file (may be NULL).
1210 * Return 0 if permission is granted.
1211 * @sysctl:
1212 * Check permission before accessing the @table sysctl variable in the
1213 * manner specified by @op.
1214 * @table contains the ctl_table structure for the sysctl variable.
1215 * @op contains the operation (001 = search, 002 = write, 004 = read).
1216 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001217 * @syslog:
1218 * Check permission before accessing the kernel message ring or changing
1219 * logging to the console.
Eric Paris7b41b172008-04-23 14:10:25 -04001220 * See the syslog(2) manual page for an explanation of the @type values.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221 * @type contains the type of action.
1222 * Return 0 if permission is granted.
1223 * @settime:
1224 * Check permission to change the system time.
1225 * struct timespec and timezone are defined in include/linux/time.h
1226 * @ts contains new time
1227 * @tz contains new timezone
1228 * Return 0 if permission is granted.
1229 * @vm_enough_memory:
1230 * Check permissions for allocating a new virtual mapping.
Alan Cox34b4e4a2007-08-22 14:01:28 -07001231 * @mm contains the mm struct it is being added to.
Eric Paris7b41b172008-04-23 14:10:25 -04001232 * @pages contains the number of pages.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001233 * Return 0 if permission is granted.
1234 *
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001235 * @secid_to_secctx:
1236 * Convert secid to security context.
1237 * @secid contains the security ID.
1238 * @secdata contains the pointer that stores the converted security context.
David Howells63cb3442008-01-15 23:47:35 +00001239 * @secctx_to_secid:
Eric Paris7b41b172008-04-23 14:10:25 -04001240 * Convert security context to secid.
1241 * @secid contains the pointer to the generated security ID.
1242 * @secdata contains the security context.
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001243 *
1244 * @release_secctx:
1245 * Release the security context.
1246 * @secdata contains the security context.
1247 * @seclen contains the length of the security context.
1248 *
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02001249 * Security hooks for Audit
1250 *
1251 * @audit_rule_init:
1252 * Allocate and initialize an LSM audit rule structure.
1253 * @field contains the required Audit action. Fields flags are defined in include/linux/audit.h
1254 * @op contains the operator the rule uses.
1255 * @rulestr contains the context where the rule will be applied to.
1256 * @lsmrule contains a pointer to receive the result.
1257 * Return 0 if @lsmrule has been successfully set,
1258 * -EINVAL in case of an invalid rule.
1259 *
1260 * @audit_rule_known:
1261 * Specifies whether given @rule contains any fields related to current LSM.
1262 * @rule contains the audit rule of interest.
1263 * Return 1 in case of relation found, 0 otherwise.
1264 *
1265 * @audit_rule_match:
1266 * Determine if given @secid matches a rule previously approved
1267 * by @audit_rule_known.
1268 * @secid contains the security id in question.
1269 * @field contains the field which relates to current LSM.
1270 * @op contains the operator that will be used for matching.
1271 * @rule points to the audit rule that will be checked against.
1272 * @actx points to the audit context associated with the check.
1273 * Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure.
1274 *
1275 * @audit_rule_free:
1276 * Deallocate the LSM audit rule structure previously allocated by
1277 * audit_rule_init.
1278 * @rule contains the allocated rule
1279 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 * This is the main security structure.
1281 */
1282struct security_operations {
Ahmed S. Darwish076c54c2008-03-06 18:09:10 +02001283 char name[SECURITY_NAME_MAX + 1];
1284
David Howells5cd9c582008-08-14 11:37:28 +01001285 int (*ptrace_may_access) (struct task_struct *child, unsigned int mode);
1286 int (*ptrace_traceme) (struct task_struct *parent);
Eric Paris7b41b172008-04-23 14:10:25 -04001287 int (*capget) (struct task_struct *target,
1288 kernel_cap_t *effective,
1289 kernel_cap_t *inheritable, kernel_cap_t *permitted);
David Howellsd84f4f92008-11-14 10:39:23 +11001290 int (*capset) (struct cred *new,
1291 const struct cred *old,
1292 const kernel_cap_t *effective,
1293 const kernel_cap_t *inheritable,
1294 const kernel_cap_t *permitted);
Eric Paris06112162008-11-11 22:02:50 +11001295 int (*capable) (struct task_struct *tsk, int cap, int audit);
Eric Paris7b41b172008-04-23 14:10:25 -04001296 int (*acct) (struct file *file);
1297 int (*sysctl) (struct ctl_table *table, int op);
1298 int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
1299 int (*quota_on) (struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300 int (*syslog) (int type);
1301 int (*settime) (struct timespec *ts, struct timezone *tz);
Alan Cox34b4e4a2007-08-22 14:01:28 -07001302 int (*vm_enough_memory) (struct mm_struct *mm, long pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303
Eric Paris7b41b172008-04-23 14:10:25 -04001304 int (*bprm_alloc_security) (struct linux_binprm *bprm);
1305 void (*bprm_free_security) (struct linux_binprm *bprm);
David Howellsd84f4f92008-11-14 10:39:23 +11001306 int (*bprm_apply_creds) (struct linux_binprm *bprm, int unsafe);
Eric Paris7b41b172008-04-23 14:10:25 -04001307 void (*bprm_post_apply_creds) (struct linux_binprm *bprm);
1308 int (*bprm_set_security) (struct linux_binprm *bprm);
1309 int (*bprm_check_security) (struct linux_binprm *bprm);
1310 int (*bprm_secureexec) (struct linux_binprm *bprm);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311
Eric Paris7b41b172008-04-23 14:10:25 -04001312 int (*sb_alloc_security) (struct super_block *sb);
1313 void (*sb_free_security) (struct super_block *sb);
1314 int (*sb_copy_data) (char *orig, char *copy);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315 int (*sb_kern_mount) (struct super_block *sb, void *data);
Eric Paris2069f452008-07-04 09:47:13 +10001316 int (*sb_show_options) (struct seq_file *m, struct super_block *sb);
David Howells726c3342006-06-23 02:02:58 -07001317 int (*sb_statfs) (struct dentry *dentry);
Al Virob5266eb2008-03-22 17:48:24 -04001318 int (*sb_mount) (char *dev_name, struct path *path,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001319 char *type, unsigned long flags, void *data);
Eric Paris7b41b172008-04-23 14:10:25 -04001320 int (*sb_check_sb) (struct vfsmount *mnt, struct path *path);
1321 int (*sb_umount) (struct vfsmount *mnt, int flags);
1322 void (*sb_umount_close) (struct vfsmount *mnt);
1323 void (*sb_umount_busy) (struct vfsmount *mnt);
1324 void (*sb_post_remount) (struct vfsmount *mnt,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 unsigned long flags, void *data);
Eric Paris7b41b172008-04-23 14:10:25 -04001326 void (*sb_post_addmount) (struct vfsmount *mnt,
Al Virob5266eb2008-03-22 17:48:24 -04001327 struct path *mountpoint);
1328 int (*sb_pivotroot) (struct path *old_path,
1329 struct path *new_path);
1330 void (*sb_post_pivotroot) (struct path *old_path,
1331 struct path *new_path);
Eric Parise0007522008-03-05 10:31:54 -05001332 int (*sb_set_mnt_opts) (struct super_block *sb,
1333 struct security_mnt_opts *opts);
Eric Parisc9180a52007-11-30 13:00:35 -05001334 void (*sb_clone_mnt_opts) (const struct super_block *oldsb,
1335 struct super_block *newsb);
Eric Parise0007522008-03-05 10:31:54 -05001336 int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337
Eric Paris7b41b172008-04-23 14:10:25 -04001338 int (*inode_alloc_security) (struct inode *inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 void (*inode_free_security) (struct inode *inode);
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001340 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1341 char **name, void **value, size_t *len);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342 int (*inode_create) (struct inode *dir,
Eric Paris7b41b172008-04-23 14:10:25 -04001343 struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001344 int (*inode_link) (struct dentry *old_dentry,
Eric Paris7b41b172008-04-23 14:10:25 -04001345 struct inode *dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1347 int (*inode_symlink) (struct inode *dir,
Eric Paris7b41b172008-04-23 14:10:25 -04001348 struct dentry *dentry, const char *old_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001349 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1351 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
Eric Paris7b41b172008-04-23 14:10:25 -04001352 int mode, dev_t dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
Eric Paris7b41b172008-04-23 14:10:25 -04001354 struct inode *new_dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 int (*inode_readlink) (struct dentry *dentry);
1356 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
Al Virob77b0642008-07-17 09:37:02 -04001357 int (*inode_permission) (struct inode *inode, int mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001358 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1359 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
Eric Paris7b41b172008-04-23 14:10:25 -04001360 void (*inode_delete) (struct inode *inode);
David Howells8f0cfa52008-04-29 00:59:41 -07001361 int (*inode_setxattr) (struct dentry *dentry, const char *name,
1362 const void *value, size_t size, int flags);
1363 void (*inode_post_setxattr) (struct dentry *dentry, const char *name,
1364 const void *value, size_t size, int flags);
1365 int (*inode_getxattr) (struct dentry *dentry, const char *name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001366 int (*inode_listxattr) (struct dentry *dentry);
David Howells8f0cfa52008-04-29 00:59:41 -07001367 int (*inode_removexattr) (struct dentry *dentry, const char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -07001368 int (*inode_need_killpriv) (struct dentry *dentry);
1369 int (*inode_killpriv) (struct dentry *dentry);
Eric Paris7b41b172008-04-23 14:10:25 -04001370 int (*inode_getsecurity) (const struct inode *inode, const char *name, void **buffer, bool alloc);
1371 int (*inode_setsecurity) (struct inode *inode, const char *name, const void *value, size_t size, int flags);
1372 int (*inode_listsecurity) (struct inode *inode, char *buffer, size_t buffer_size);
1373 void (*inode_getsecid) (const struct inode *inode, u32 *secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001374
Eric Paris7b41b172008-04-23 14:10:25 -04001375 int (*file_permission) (struct file *file, int mask);
1376 int (*file_alloc_security) (struct file *file);
1377 void (*file_free_security) (struct file *file);
1378 int (*file_ioctl) (struct file *file, unsigned int cmd,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379 unsigned long arg);
Eric Paris7b41b172008-04-23 14:10:25 -04001380 int (*file_mmap) (struct file *file,
Eric Parised032182007-06-28 15:55:21 -04001381 unsigned long reqprot, unsigned long prot,
1382 unsigned long flags, unsigned long addr,
1383 unsigned long addr_only);
Eric Paris7b41b172008-04-23 14:10:25 -04001384 int (*file_mprotect) (struct vm_area_struct *vma,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385 unsigned long reqprot,
1386 unsigned long prot);
Eric Paris7b41b172008-04-23 14:10:25 -04001387 int (*file_lock) (struct file *file, unsigned int cmd);
1388 int (*file_fcntl) (struct file *file, unsigned int cmd,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389 unsigned long arg);
Eric Paris7b41b172008-04-23 14:10:25 -04001390 int (*file_set_fowner) (struct file *file);
1391 int (*file_send_sigiotask) (struct task_struct *tsk,
1392 struct fown_struct *fown, int sig);
1393 int (*file_receive) (struct file *file);
David Howells745ca242008-11-14 10:39:22 +11001394 int (*dentry_open) (struct file *file, const struct cred *cred);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001395
1396 int (*task_create) (unsigned long clone_flags);
David Howellsf1752ee2008-11-14 10:39:17 +11001397 void (*cred_free) (struct cred *cred);
David Howellsd84f4f92008-11-14 10:39:23 +11001398 int (*cred_prepare)(struct cred *new, const struct cred *old,
1399 gfp_t gfp);
1400 void (*cred_commit)(struct cred *new, const struct cred *old);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
David Howellsd84f4f92008-11-14 10:39:23 +11001402 int (*task_fix_setuid) (struct cred *new, const struct cred *old,
1403 int flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001404 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
Eric Paris7b41b172008-04-23 14:10:25 -04001405 int (*task_setpgid) (struct task_struct *p, pid_t pgid);
1406 int (*task_getpgid) (struct task_struct *p);
1407 int (*task_getsid) (struct task_struct *p);
1408 void (*task_getsecid) (struct task_struct *p, u32 *secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409 int (*task_setgroups) (struct group_info *group_info);
Eric Paris7b41b172008-04-23 14:10:25 -04001410 int (*task_setnice) (struct task_struct *p, int nice);
1411 int (*task_setioprio) (struct task_struct *p, int ioprio);
1412 int (*task_getioprio) (struct task_struct *p);
1413 int (*task_setrlimit) (unsigned int resource, struct rlimit *new_rlim);
1414 int (*task_setscheduler) (struct task_struct *p, int policy,
1415 struct sched_param *lp);
1416 int (*task_getscheduler) (struct task_struct *p);
1417 int (*task_movememory) (struct task_struct *p);
1418 int (*task_kill) (struct task_struct *p,
1419 struct siginfo *info, int sig, u32 secid);
1420 int (*task_wait) (struct task_struct *p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001421 int (*task_prctl) (int option, unsigned long arg2,
1422 unsigned long arg3, unsigned long arg4,
David Howellsd84f4f92008-11-14 10:39:23 +11001423 unsigned long arg5);
Eric Paris7b41b172008-04-23 14:10:25 -04001424 void (*task_to_inode) (struct task_struct *p, struct inode *inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001425
Eric Paris7b41b172008-04-23 14:10:25 -04001426 int (*ipc_permission) (struct kern_ipc_perm *ipcp, short flag);
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02001427 void (*ipc_getsecid) (struct kern_ipc_perm *ipcp, u32 *secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001428
Eric Paris7b41b172008-04-23 14:10:25 -04001429 int (*msg_msg_alloc_security) (struct msg_msg *msg);
1430 void (*msg_msg_free_security) (struct msg_msg *msg);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431
Eric Paris7b41b172008-04-23 14:10:25 -04001432 int (*msg_queue_alloc_security) (struct msg_queue *msq);
1433 void (*msg_queue_free_security) (struct msg_queue *msq);
1434 int (*msg_queue_associate) (struct msg_queue *msq, int msqflg);
1435 int (*msg_queue_msgctl) (struct msg_queue *msq, int cmd);
1436 int (*msg_queue_msgsnd) (struct msg_queue *msq,
1437 struct msg_msg *msg, int msqflg);
1438 int (*msg_queue_msgrcv) (struct msg_queue *msq,
1439 struct msg_msg *msg,
1440 struct task_struct *target,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441 long type, int mode);
1442
Eric Paris7b41b172008-04-23 14:10:25 -04001443 int (*shm_alloc_security) (struct shmid_kernel *shp);
1444 void (*shm_free_security) (struct shmid_kernel *shp);
1445 int (*shm_associate) (struct shmid_kernel *shp, int shmflg);
1446 int (*shm_shmctl) (struct shmid_kernel *shp, int cmd);
1447 int (*shm_shmat) (struct shmid_kernel *shp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448 char __user *shmaddr, int shmflg);
1449
Eric Paris7b41b172008-04-23 14:10:25 -04001450 int (*sem_alloc_security) (struct sem_array *sma);
1451 void (*sem_free_security) (struct sem_array *sma);
1452 int (*sem_associate) (struct sem_array *sma, int semflg);
1453 int (*sem_semctl) (struct sem_array *sma, int cmd);
1454 int (*sem_semop) (struct sem_array *sma,
1455 struct sembuf *sops, unsigned nsops, int alter);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456
Eric Paris7b41b172008-04-23 14:10:25 -04001457 int (*netlink_send) (struct sock *sk, struct sk_buff *skb);
1458 int (*netlink_recv) (struct sk_buff *skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1461
Eric Paris7b41b172008-04-23 14:10:25 -04001462 int (*getprocattr) (struct task_struct *p, char *name, char **value);
1463 int (*setprocattr) (struct task_struct *p, char *name, void *value, size_t size);
1464 int (*secid_to_secctx) (u32 secid, char **secdata, u32 *seclen);
David Howells7bf570d2008-04-29 20:52:51 +01001465 int (*secctx_to_secid) (const char *secdata, u32 seclen, u32 *secid);
Eric Paris7b41b172008-04-23 14:10:25 -04001466 void (*release_secctx) (char *secdata, u32 seclen);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467
1468#ifdef CONFIG_SECURITY_NETWORK
Eric Paris7b41b172008-04-23 14:10:25 -04001469 int (*unix_stream_connect) (struct socket *sock,
1470 struct socket *other, struct sock *newsk);
1471 int (*unix_may_send) (struct socket *sock, struct socket *other);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472
1473 int (*socket_create) (int family, int type, int protocol, int kern);
Eric Paris7b41b172008-04-23 14:10:25 -04001474 int (*socket_post_create) (struct socket *sock, int family,
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07001475 int type, int protocol, int kern);
Eric Paris7b41b172008-04-23 14:10:25 -04001476 int (*socket_bind) (struct socket *sock,
1477 struct sockaddr *address, int addrlen);
1478 int (*socket_connect) (struct socket *sock,
1479 struct sockaddr *address, int addrlen);
1480 int (*socket_listen) (struct socket *sock, int backlog);
1481 int (*socket_accept) (struct socket *sock, struct socket *newsock);
1482 void (*socket_post_accept) (struct socket *sock,
1483 struct socket *newsock);
1484 int (*socket_sendmsg) (struct socket *sock,
1485 struct msghdr *msg, int size);
1486 int (*socket_recvmsg) (struct socket *sock,
1487 struct msghdr *msg, int size, int flags);
1488 int (*socket_getsockname) (struct socket *sock);
1489 int (*socket_getpeername) (struct socket *sock);
1490 int (*socket_getsockopt) (struct socket *sock, int level, int optname);
1491 int (*socket_setsockopt) (struct socket *sock, int level, int optname);
1492 int (*socket_shutdown) (struct socket *sock, int how);
1493 int (*socket_sock_rcv_skb) (struct sock *sk, struct sk_buff *skb);
Catherine Zhang2c7946a2006-03-20 22:41:23 -08001494 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001495 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
Al Viro7d877f32005-10-21 03:20:43 -04001496 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 void (*sk_free_security) (struct sock *sk);
Venkat Yekkirala892c1412006-08-04 23:08:56 -07001498 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001499 void (*sk_getsecid) (struct sock *sk, u32 *secid);
Eric Paris7b41b172008-04-23 14:10:25 -04001500 void (*sock_graft) (struct sock *sk, struct socket *parent);
1501 int (*inet_conn_request) (struct sock *sk, struct sk_buff *skb,
1502 struct request_sock *req);
1503 void (*inet_csk_clone) (struct sock *newsk, const struct request_sock *req);
1504 void (*inet_conn_established) (struct sock *sk, struct sk_buff *skb);
1505 void (*req_classify_flow) (const struct request_sock *req, struct flowi *fl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506#endif /* CONFIG_SECURITY_NETWORK */
David Howells29db9192005-10-30 15:02:44 -08001507
Trent Jaegerdf718372005-12-13 23:12:27 -08001508#ifdef CONFIG_SECURITY_NETWORK_XFRM
Paul Moore03e1ad72008-04-12 19:07:52 -07001509 int (*xfrm_policy_alloc_security) (struct xfrm_sec_ctx **ctxp,
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -06001510 struct xfrm_user_sec_ctx *sec_ctx);
Paul Moore03e1ad72008-04-12 19:07:52 -07001511 int (*xfrm_policy_clone_security) (struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctx);
1512 void (*xfrm_policy_free_security) (struct xfrm_sec_ctx *ctx);
1513 int (*xfrm_policy_delete_security) (struct xfrm_sec_ctx *ctx);
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001514 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
Venkat Yekkiralac1a856c2006-11-08 17:03:44 -06001515 struct xfrm_user_sec_ctx *sec_ctx,
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001516 u32 secid);
Trent Jaegerdf718372005-12-13 23:12:27 -08001517 void (*xfrm_state_free_security) (struct xfrm_state *x);
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001518 int (*xfrm_state_delete_security) (struct xfrm_state *x);
Eric Paris7b41b172008-04-23 14:10:25 -04001519 int (*xfrm_policy_lookup) (struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
1520 int (*xfrm_state_pol_flow_match) (struct xfrm_state *x,
1521 struct xfrm_policy *xp,
1522 struct flowi *fl);
1523 int (*xfrm_decode_session) (struct sk_buff *skb, u32 *secid, int ckall);
Trent Jaegerdf718372005-12-13 23:12:27 -08001524#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1525
David Howells29db9192005-10-30 15:02:44 -08001526 /* key management security hooks */
1527#ifdef CONFIG_KEYS
David Howellsd84f4f92008-11-14 10:39:23 +11001528 int (*key_alloc) (struct key *key, const struct cred *cred, unsigned long flags);
Eric Paris7b41b172008-04-23 14:10:25 -04001529 void (*key_free) (struct key *key);
1530 int (*key_permission) (key_ref_t key_ref,
David Howellsd84f4f92008-11-14 10:39:23 +11001531 const struct cred *cred,
Eric Paris7b41b172008-04-23 14:10:25 -04001532 key_perm_t perm);
David Howells70a5bb72008-04-29 01:01:26 -07001533 int (*key_getsecurity)(struct key *key, char **_buffer);
David Howells29db9192005-10-30 15:02:44 -08001534#endif /* CONFIG_KEYS */
1535
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02001536#ifdef CONFIG_AUDIT
Eric Paris7b41b172008-04-23 14:10:25 -04001537 int (*audit_rule_init) (u32 field, u32 op, char *rulestr, void **lsmrule);
1538 int (*audit_rule_known) (struct audit_krule *krule);
1539 int (*audit_rule_match) (u32 secid, u32 field, u32 op, void *lsmrule,
1540 struct audit_context *actx);
1541 void (*audit_rule_free) (void *lsmrule);
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02001542#endif /* CONFIG_AUDIT */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543};
1544
Linus Torvalds1da177e2005-04-16 15:20:36 -07001545/* prototypes */
Eric Paris7b41b172008-04-23 14:10:25 -04001546extern int security_init(void);
Ahmed S. Darwish076c54c2008-03-06 18:09:10 +02001547extern int security_module_enable(struct security_operations *ops);
Eric Paris7b41b172008-04-23 14:10:25 -04001548extern int register_security(struct security_operations *ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001549
James Morris20510f22007-10-16 23:31:32 -07001550/* Security operations */
David Howells5cd9c582008-08-14 11:37:28 +01001551int security_ptrace_may_access(struct task_struct *child, unsigned int mode);
1552int security_ptrace_traceme(struct task_struct *parent);
James Morris20510f22007-10-16 23:31:32 -07001553int security_capget(struct task_struct *target,
Eric Paris7b41b172008-04-23 14:10:25 -04001554 kernel_cap_t *effective,
1555 kernel_cap_t *inheritable,
1556 kernel_cap_t *permitted);
David Howellsd84f4f92008-11-14 10:39:23 +11001557int security_capset(struct cred *new, const struct cred *old,
1558 const kernel_cap_t *effective,
1559 const kernel_cap_t *inheritable,
1560 const kernel_cap_t *permitted);
James Morris20510f22007-10-16 23:31:32 -07001561int security_capable(struct task_struct *tsk, int cap);
Eric Paris06112162008-11-11 22:02:50 +11001562int security_capable_noaudit(struct task_struct *tsk, int cap);
James Morris20510f22007-10-16 23:31:32 -07001563int security_acct(struct file *file);
1564int security_sysctl(struct ctl_table *table, int op);
1565int security_quotactl(int cmds, int type, int id, struct super_block *sb);
1566int security_quota_on(struct dentry *dentry);
1567int security_syslog(int type);
1568int security_settime(struct timespec *ts, struct timezone *tz);
1569int security_vm_enough_memory(long pages);
1570int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
Alan Cox731572d2008-10-29 14:01:20 -07001571int security_vm_enough_memory_kern(long pages);
James Morris20510f22007-10-16 23:31:32 -07001572int security_bprm_alloc(struct linux_binprm *bprm);
1573void security_bprm_free(struct linux_binprm *bprm);
David Howellsd84f4f92008-11-14 10:39:23 +11001574int security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe);
James Morris20510f22007-10-16 23:31:32 -07001575void security_bprm_post_apply_creds(struct linux_binprm *bprm);
1576int security_bprm_set(struct linux_binprm *bprm);
1577int security_bprm_check(struct linux_binprm *bprm);
1578int security_bprm_secureexec(struct linux_binprm *bprm);
1579int security_sb_alloc(struct super_block *sb);
1580void security_sb_free(struct super_block *sb);
Eric Parise0007522008-03-05 10:31:54 -05001581int security_sb_copy_data(char *orig, char *copy);
James Morris20510f22007-10-16 23:31:32 -07001582int security_sb_kern_mount(struct super_block *sb, void *data);
Eric Paris2069f452008-07-04 09:47:13 +10001583int security_sb_show_options(struct seq_file *m, struct super_block *sb);
James Morris20510f22007-10-16 23:31:32 -07001584int security_sb_statfs(struct dentry *dentry);
Al Virob5266eb2008-03-22 17:48:24 -04001585int security_sb_mount(char *dev_name, struct path *path,
Eric Paris7b41b172008-04-23 14:10:25 -04001586 char *type, unsigned long flags, void *data);
Al Virob5266eb2008-03-22 17:48:24 -04001587int security_sb_check_sb(struct vfsmount *mnt, struct path *path);
James Morris20510f22007-10-16 23:31:32 -07001588int security_sb_umount(struct vfsmount *mnt, int flags);
1589void security_sb_umount_close(struct vfsmount *mnt);
1590void security_sb_umount_busy(struct vfsmount *mnt);
1591void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data);
Al Virob5266eb2008-03-22 17:48:24 -04001592void security_sb_post_addmount(struct vfsmount *mnt, struct path *mountpoint);
1593int security_sb_pivotroot(struct path *old_path, struct path *new_path);
1594void security_sb_post_pivotroot(struct path *old_path, struct path *new_path);
Eric Parise0007522008-03-05 10:31:54 -05001595int security_sb_set_mnt_opts(struct super_block *sb, struct security_mnt_opts *opts);
Eric Parisc9180a52007-11-30 13:00:35 -05001596void security_sb_clone_mnt_opts(const struct super_block *oldsb,
1597 struct super_block *newsb);
Eric Parise0007522008-03-05 10:31:54 -05001598int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts);
Eric Parisc9180a52007-11-30 13:00:35 -05001599
James Morris20510f22007-10-16 23:31:32 -07001600int security_inode_alloc(struct inode *inode);
1601void security_inode_free(struct inode *inode);
1602int security_inode_init_security(struct inode *inode, struct inode *dir,
1603 char **name, void **value, size_t *len);
1604int security_inode_create(struct inode *dir, struct dentry *dentry, int mode);
1605int security_inode_link(struct dentry *old_dentry, struct inode *dir,
1606 struct dentry *new_dentry);
1607int security_inode_unlink(struct inode *dir, struct dentry *dentry);
1608int security_inode_symlink(struct inode *dir, struct dentry *dentry,
Eric Paris7b41b172008-04-23 14:10:25 -04001609 const char *old_name);
James Morris20510f22007-10-16 23:31:32 -07001610int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode);
1611int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
1612int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
1613int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
Eric Paris7b41b172008-04-23 14:10:25 -04001614 struct inode *new_dir, struct dentry *new_dentry);
James Morris20510f22007-10-16 23:31:32 -07001615int security_inode_readlink(struct dentry *dentry);
1616int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
Al Virob77b0642008-07-17 09:37:02 -04001617int security_inode_permission(struct inode *inode, int mask);
James Morris20510f22007-10-16 23:31:32 -07001618int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1619int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1620void security_inode_delete(struct inode *inode);
David Howells8f0cfa52008-04-29 00:59:41 -07001621int security_inode_setxattr(struct dentry *dentry, const char *name,
1622 const void *value, size_t size, int flags);
1623void security_inode_post_setxattr(struct dentry *dentry, const char *name,
1624 const void *value, size_t size, int flags);
1625int security_inode_getxattr(struct dentry *dentry, const char *name);
James Morris20510f22007-10-16 23:31:32 -07001626int security_inode_listxattr(struct dentry *dentry);
David Howells8f0cfa52008-04-29 00:59:41 -07001627int security_inode_removexattr(struct dentry *dentry, const char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -07001628int security_inode_need_killpriv(struct dentry *dentry);
1629int security_inode_killpriv(struct dentry *dentry);
David P. Quigley42492592008-02-04 22:29:39 -08001630int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc);
James Morris20510f22007-10-16 23:31:32 -07001631int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1632int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02001633void security_inode_getsecid(const struct inode *inode, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -07001634int security_file_permission(struct file *file, int mask);
1635int security_file_alloc(struct file *file);
1636void security_file_free(struct file *file);
1637int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1638int security_file_mmap(struct file *file, unsigned long reqprot,
1639 unsigned long prot, unsigned long flags,
1640 unsigned long addr, unsigned long addr_only);
1641int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
Eric Paris7b41b172008-04-23 14:10:25 -04001642 unsigned long prot);
James Morris20510f22007-10-16 23:31:32 -07001643int security_file_lock(struct file *file, unsigned int cmd);
1644int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
1645int security_file_set_fowner(struct file *file);
1646int security_file_send_sigiotask(struct task_struct *tsk,
Eric Paris7b41b172008-04-23 14:10:25 -04001647 struct fown_struct *fown, int sig);
James Morris20510f22007-10-16 23:31:32 -07001648int security_file_receive(struct file *file);
David Howells745ca242008-11-14 10:39:22 +11001649int security_dentry_open(struct file *file, const struct cred *cred);
James Morris20510f22007-10-16 23:31:32 -07001650int security_task_create(unsigned long clone_flags);
David Howellsf1752ee2008-11-14 10:39:17 +11001651void security_cred_free(struct cred *cred);
David Howellsd84f4f92008-11-14 10:39:23 +11001652int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
1653void security_commit_creds(struct cred *new, const struct cred *old);
James Morris20510f22007-10-16 23:31:32 -07001654int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags);
David Howellsd84f4f92008-11-14 10:39:23 +11001655int security_task_fix_setuid(struct cred *new, const struct cred *old,
1656 int flags);
James Morris20510f22007-10-16 23:31:32 -07001657int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags);
1658int security_task_setpgid(struct task_struct *p, pid_t pgid);
1659int security_task_getpgid(struct task_struct *p);
1660int security_task_getsid(struct task_struct *p);
1661void security_task_getsecid(struct task_struct *p, u32 *secid);
1662int security_task_setgroups(struct group_info *group_info);
1663int security_task_setnice(struct task_struct *p, int nice);
1664int security_task_setioprio(struct task_struct *p, int ioprio);
1665int security_task_getioprio(struct task_struct *p);
1666int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim);
1667int security_task_setscheduler(struct task_struct *p,
1668 int policy, struct sched_param *lp);
1669int security_task_getscheduler(struct task_struct *p);
1670int security_task_movememory(struct task_struct *p);
1671int security_task_kill(struct task_struct *p, struct siginfo *info,
1672 int sig, u32 secid);
1673int security_task_wait(struct task_struct *p);
1674int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
David Howellsd84f4f92008-11-14 10:39:23 +11001675 unsigned long arg4, unsigned long arg5);
James Morris20510f22007-10-16 23:31:32 -07001676void security_task_to_inode(struct task_struct *p, struct inode *inode);
1677int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02001678void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -07001679int security_msg_msg_alloc(struct msg_msg *msg);
1680void security_msg_msg_free(struct msg_msg *msg);
1681int security_msg_queue_alloc(struct msg_queue *msq);
1682void security_msg_queue_free(struct msg_queue *msq);
1683int security_msg_queue_associate(struct msg_queue *msq, int msqflg);
1684int security_msg_queue_msgctl(struct msg_queue *msq, int cmd);
1685int security_msg_queue_msgsnd(struct msg_queue *msq,
Eric Paris7b41b172008-04-23 14:10:25 -04001686 struct msg_msg *msg, int msqflg);
James Morris20510f22007-10-16 23:31:32 -07001687int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
Eric Paris7b41b172008-04-23 14:10:25 -04001688 struct task_struct *target, long type, int mode);
James Morris20510f22007-10-16 23:31:32 -07001689int security_shm_alloc(struct shmid_kernel *shp);
1690void security_shm_free(struct shmid_kernel *shp);
1691int security_shm_associate(struct shmid_kernel *shp, int shmflg);
1692int security_shm_shmctl(struct shmid_kernel *shp, int cmd);
1693int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg);
1694int security_sem_alloc(struct sem_array *sma);
1695void security_sem_free(struct sem_array *sma);
1696int security_sem_associate(struct sem_array *sma, int semflg);
1697int security_sem_semctl(struct sem_array *sma, int cmd);
1698int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
1699 unsigned nsops, int alter);
Eric Paris7b41b172008-04-23 14:10:25 -04001700void security_d_instantiate(struct dentry *dentry, struct inode *inode);
James Morris20510f22007-10-16 23:31:32 -07001701int security_getprocattr(struct task_struct *p, char *name, char **value);
1702int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
1703int security_netlink_send(struct sock *sk, struct sk_buff *skb);
1704int security_netlink_recv(struct sk_buff *skb, int cap);
1705int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
David Howells7bf570d2008-04-29 20:52:51 +01001706int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -07001707void security_release_secctx(char *secdata, u32 seclen);
1708
Linus Torvalds1da177e2005-04-16 15:20:36 -07001709#else /* CONFIG_SECURITY */
Eric Parise0007522008-03-05 10:31:54 -05001710struct security_mnt_opts {
1711};
1712
1713static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
1714{
1715}
1716
1717static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1718{
1719}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001720
1721/*
1722 * This is the default capabilities functionality. Most of these functions
1723 * are just stubbed out, but a few must call the proper capable code.
1724 */
1725
1726static inline int security_init(void)
1727{
1728 return 0;
1729}
1730
David Howells5cd9c582008-08-14 11:37:28 +01001731static inline int security_ptrace_may_access(struct task_struct *child,
1732 unsigned int mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733{
David Howells5cd9c582008-08-14 11:37:28 +01001734 return cap_ptrace_may_access(child, mode);
1735}
1736
Alexander Beregalov5e186b52008-08-17 05:34:20 +04001737static inline int security_ptrace_traceme(struct task_struct *parent)
David Howells5cd9c582008-08-14 11:37:28 +01001738{
1739 return cap_ptrace_traceme(parent);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740}
1741
Eric Paris7b41b172008-04-23 14:10:25 -04001742static inline int security_capget(struct task_struct *target,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743 kernel_cap_t *effective,
1744 kernel_cap_t *inheritable,
1745 kernel_cap_t *permitted)
1746{
Eric Paris7b41b172008-04-23 14:10:25 -04001747 return cap_capget(target, effective, inheritable, permitted);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001748}
1749
David Howellsd84f4f92008-11-14 10:39:23 +11001750static inline int security_capset(struct cred *new,
1751 const struct cred *old,
1752 const kernel_cap_t *effective,
1753 const kernel_cap_t *inheritable,
1754 const kernel_cap_t *permitted)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001755{
David Howellsd84f4f92008-11-14 10:39:23 +11001756 return cap_capset(new, old, effective, inheritable, permitted);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757}
1758
Chris Wright12b59892006-03-25 03:07:41 -08001759static inline int security_capable(struct task_struct *tsk, int cap)
1760{
Eric Paris06112162008-11-11 22:02:50 +11001761 return cap_capable(tsk, cap, SECURITY_CAP_AUDIT);
1762}
1763
1764static inline int security_capable_noaudit(struct task_struct *tsk, int cap)
1765{
1766 return cap_capable(tsk, cap, SECURITY_CAP_NOAUDIT);
Chris Wright12b59892006-03-25 03:07:41 -08001767}
1768
Eric Paris7b41b172008-04-23 14:10:25 -04001769static inline int security_acct(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001770{
1771 return 0;
1772}
1773
1774static inline int security_sysctl(struct ctl_table *table, int op)
1775{
1776 return 0;
1777}
1778
Eric Paris7b41b172008-04-23 14:10:25 -04001779static inline int security_quotactl(int cmds, int type, int id,
1780 struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001781{
1782 return 0;
1783}
1784
Eric Paris7b41b172008-04-23 14:10:25 -04001785static inline int security_quota_on(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001786{
1787 return 0;
1788}
1789
1790static inline int security_syslog(int type)
1791{
1792 return cap_syslog(type);
1793}
1794
1795static inline int security_settime(struct timespec *ts, struct timezone *tz)
1796{
1797 return cap_settime(ts, tz);
1798}
1799
1800static inline int security_vm_enough_memory(long pages)
1801{
Alan Cox34b4e4a2007-08-22 14:01:28 -07001802 return cap_vm_enough_memory(current->mm, pages);
1803}
1804
Alan Cox731572d2008-10-29 14:01:20 -07001805static inline int security_vm_enough_memory_kern(long pages)
1806{
1807 return cap_vm_enough_memory(current->mm, pages);
1808}
1809
Alan Cox34b4e4a2007-08-22 14:01:28 -07001810static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
1811{
1812 return cap_vm_enough_memory(mm, pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001813}
1814
Eric Paris7b41b172008-04-23 14:10:25 -04001815static inline int security_bprm_alloc(struct linux_binprm *bprm)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001816{
1817 return 0;
1818}
1819
Eric Paris7b41b172008-04-23 14:10:25 -04001820static inline void security_bprm_free(struct linux_binprm *bprm)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001821{ }
1822
David Howellsd84f4f92008-11-14 10:39:23 +11001823static inline int security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe)
Eric Paris7b41b172008-04-23 14:10:25 -04001824{
David Howellsd84f4f92008-11-14 10:39:23 +11001825 return cap_bprm_apply_creds(bprm, unsafe);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001826}
1827
Eric Paris7b41b172008-04-23 14:10:25 -04001828static inline void security_bprm_post_apply_creds(struct linux_binprm *bprm)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001829{
1830 return;
1831}
1832
Eric Paris7b41b172008-04-23 14:10:25 -04001833static inline int security_bprm_set(struct linux_binprm *bprm)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834{
Eric Paris7b41b172008-04-23 14:10:25 -04001835 return cap_bprm_set_security(bprm);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001836}
1837
Eric Paris7b41b172008-04-23 14:10:25 -04001838static inline int security_bprm_check(struct linux_binprm *bprm)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001839{
1840 return 0;
1841}
1842
Eric Paris7b41b172008-04-23 14:10:25 -04001843static inline int security_bprm_secureexec(struct linux_binprm *bprm)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001844{
1845 return cap_bprm_secureexec(bprm);
1846}
1847
Eric Paris7b41b172008-04-23 14:10:25 -04001848static inline int security_sb_alloc(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001849{
1850 return 0;
1851}
1852
Eric Paris7b41b172008-04-23 14:10:25 -04001853static inline void security_sb_free(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001854{ }
1855
Eric Paris7b41b172008-04-23 14:10:25 -04001856static inline int security_sb_copy_data(char *orig, char *copy)
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_kern_mount(struct super_block *sb, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862{
1863 return 0;
1864}
1865
Eric Paris2069f452008-07-04 09:47:13 +10001866static inline int security_sb_show_options(struct seq_file *m,
1867 struct super_block *sb)
1868{
1869 return 0;
1870}
1871
Eric Paris7b41b172008-04-23 14:10:25 -04001872static inline int security_sb_statfs(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001873{
1874 return 0;
1875}
1876
Eric Paris7b41b172008-04-23 14:10:25 -04001877static inline int security_sb_mount(char *dev_name, struct path *path,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001878 char *type, unsigned long flags,
1879 void *data)
1880{
1881 return 0;
1882}
1883
Eric Paris7b41b172008-04-23 14:10:25 -04001884static inline int security_sb_check_sb(struct vfsmount *mnt,
1885 struct path *path)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001886{
1887 return 0;
1888}
1889
Eric Paris7b41b172008-04-23 14:10:25 -04001890static inline int security_sb_umount(struct vfsmount *mnt, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001891{
1892 return 0;
1893}
1894
Eric Paris7b41b172008-04-23 14:10:25 -04001895static inline void security_sb_umount_close(struct vfsmount *mnt)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001896{ }
1897
Eric Paris7b41b172008-04-23 14:10:25 -04001898static inline void security_sb_umount_busy(struct vfsmount *mnt)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899{ }
1900
Eric Paris7b41b172008-04-23 14:10:25 -04001901static inline void security_sb_post_remount(struct vfsmount *mnt,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001902 unsigned long flags, void *data)
1903{ }
1904
Eric Paris7b41b172008-04-23 14:10:25 -04001905static inline void security_sb_post_addmount(struct vfsmount *mnt,
1906 struct path *mountpoint)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001907{ }
1908
Eric Paris7b41b172008-04-23 14:10:25 -04001909static inline int security_sb_pivotroot(struct path *old_path,
1910 struct path *new_path)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001911{
1912 return 0;
1913}
1914
Eric Paris7b41b172008-04-23 14:10:25 -04001915static inline void security_sb_post_pivotroot(struct path *old_path,
1916 struct path *new_path)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001917{ }
Eric Parise0007522008-03-05 10:31:54 -05001918
1919static inline int security_sb_set_mnt_opts(struct super_block *sb,
1920 struct security_mnt_opts *opts)
1921{
1922 return 0;
1923}
1924
1925static inline void security_sb_clone_mnt_opts(const struct super_block *oldsb,
1926 struct super_block *newsb)
1927{ }
1928
1929static inline int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts)
1930{
1931 return 0;
1932}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001933
Eric Paris7b41b172008-04-23 14:10:25 -04001934static inline int security_inode_alloc(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001935{
1936 return 0;
1937}
1938
Eric Paris7b41b172008-04-23 14:10:25 -04001939static inline void security_inode_free(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001940{ }
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001941
Eric Paris7b41b172008-04-23 14:10:25 -04001942static inline int security_inode_init_security(struct inode *inode,
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001943 struct inode *dir,
1944 char **name,
1945 void **value,
1946 size_t *len)
1947{
1948 return -EOPNOTSUPP;
1949}
Eric Paris7b41b172008-04-23 14:10:25 -04001950
1951static inline int security_inode_create(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001952 struct dentry *dentry,
1953 int mode)
1954{
1955 return 0;
1956}
1957
Eric Paris7b41b172008-04-23 14:10:25 -04001958static inline int security_inode_link(struct dentry *old_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001959 struct inode *dir,
1960 struct dentry *new_dentry)
1961{
1962 return 0;
1963}
1964
Eric Paris7b41b172008-04-23 14:10:25 -04001965static inline int security_inode_unlink(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001966 struct dentry *dentry)
1967{
1968 return 0;
1969}
1970
Eric Paris7b41b172008-04-23 14:10:25 -04001971static inline int security_inode_symlink(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001972 struct dentry *dentry,
1973 const char *old_name)
1974{
1975 return 0;
1976}
1977
Eric Paris7b41b172008-04-23 14:10:25 -04001978static inline int security_inode_mkdir(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001979 struct dentry *dentry,
1980 int mode)
1981{
1982 return 0;
1983}
1984
Eric Paris7b41b172008-04-23 14:10:25 -04001985static inline int security_inode_rmdir(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001986 struct dentry *dentry)
1987{
1988 return 0;
1989}
1990
Eric Paris7b41b172008-04-23 14:10:25 -04001991static inline int security_inode_mknod(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001992 struct dentry *dentry,
1993 int mode, dev_t dev)
1994{
1995 return 0;
1996}
1997
Eric Paris7b41b172008-04-23 14:10:25 -04001998static inline int security_inode_rename(struct inode *old_dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001999 struct dentry *old_dentry,
2000 struct inode *new_dir,
2001 struct dentry *new_dentry)
2002{
2003 return 0;
2004}
2005
Eric Paris7b41b172008-04-23 14:10:25 -04002006static inline int security_inode_readlink(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002007{
2008 return 0;
2009}
2010
Eric Paris7b41b172008-04-23 14:10:25 -04002011static inline int security_inode_follow_link(struct dentry *dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002012 struct nameidata *nd)
2013{
2014 return 0;
2015}
2016
Al Virob77b0642008-07-17 09:37:02 -04002017static inline int security_inode_permission(struct inode *inode, int mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002018{
2019 return 0;
2020}
2021
Eric Paris7b41b172008-04-23 14:10:25 -04002022static inline int security_inode_setattr(struct dentry *dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002023 struct iattr *attr)
2024{
2025 return 0;
2026}
2027
Eric Paris7b41b172008-04-23 14:10:25 -04002028static inline int security_inode_getattr(struct vfsmount *mnt,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002029 struct dentry *dentry)
2030{
2031 return 0;
2032}
2033
Eric Paris7b41b172008-04-23 14:10:25 -04002034static inline void security_inode_delete(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002035{ }
2036
David Howells8f0cfa52008-04-29 00:59:41 -07002037static inline int security_inode_setxattr(struct dentry *dentry,
2038 const char *name, const void *value, size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039{
2040 return cap_inode_setxattr(dentry, name, value, size, flags);
2041}
2042
David Howells8f0cfa52008-04-29 00:59:41 -07002043static inline void security_inode_post_setxattr(struct dentry *dentry,
2044 const char *name, const void *value, size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002045{ }
2046
David Howells8f0cfa52008-04-29 00:59:41 -07002047static inline int security_inode_getxattr(struct dentry *dentry,
2048 const char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002049{
2050 return 0;
2051}
2052
Eric Paris7b41b172008-04-23 14:10:25 -04002053static inline int security_inode_listxattr(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002054{
2055 return 0;
2056}
2057
David Howells8f0cfa52008-04-29 00:59:41 -07002058static inline int security_inode_removexattr(struct dentry *dentry,
2059 const char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002060{
2061 return cap_inode_removexattr(dentry, name);
2062}
2063
Serge E. Hallynb5376772007-10-16 23:31:36 -07002064static inline int security_inode_need_killpriv(struct dentry *dentry)
2065{
2066 return cap_inode_need_killpriv(dentry);
2067}
2068
2069static inline int security_inode_killpriv(struct dentry *dentry)
2070{
2071 return cap_inode_killpriv(dentry);
2072}
2073
David P. Quigley42492592008-02-04 22:29:39 -08002074static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002075{
2076 return -EOPNOTSUPP;
2077}
2078
2079static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2080{
2081 return -EOPNOTSUPP;
2082}
2083
2084static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2085{
2086 return 0;
2087}
2088
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02002089static inline void security_inode_getsecid(const struct inode *inode, u32 *secid)
2090{
2091 *secid = 0;
2092}
2093
Eric Paris7b41b172008-04-23 14:10:25 -04002094static inline int security_file_permission(struct file *file, int mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002095{
2096 return 0;
2097}
2098
Eric Paris7b41b172008-04-23 14:10:25 -04002099static inline int security_file_alloc(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002100{
2101 return 0;
2102}
2103
Eric Paris7b41b172008-04-23 14:10:25 -04002104static inline void security_file_free(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002105{ }
2106
Eric Paris7b41b172008-04-23 14:10:25 -04002107static inline int security_file_ioctl(struct file *file, unsigned int cmd,
2108 unsigned long arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002109{
2110 return 0;
2111}
2112
Eric Paris7b41b172008-04-23 14:10:25 -04002113static inline int security_file_mmap(struct file *file, unsigned long reqprot,
2114 unsigned long prot,
2115 unsigned long flags,
2116 unsigned long addr,
2117 unsigned long addr_only)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002118{
2119 return 0;
2120}
2121
Eric Paris7b41b172008-04-23 14:10:25 -04002122static inline int security_file_mprotect(struct vm_area_struct *vma,
2123 unsigned long reqprot,
2124 unsigned long prot)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002125{
2126 return 0;
2127}
2128
Eric Paris7b41b172008-04-23 14:10:25 -04002129static inline int security_file_lock(struct file *file, unsigned int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002130{
2131 return 0;
2132}
2133
Eric Paris7b41b172008-04-23 14:10:25 -04002134static inline int security_file_fcntl(struct file *file, unsigned int cmd,
2135 unsigned long arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002136{
2137 return 0;
2138}
2139
Eric Paris7b41b172008-04-23 14:10:25 -04002140static inline int security_file_set_fowner(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002141{
2142 return 0;
2143}
2144
Eric Paris7b41b172008-04-23 14:10:25 -04002145static inline int security_file_send_sigiotask(struct task_struct *tsk,
2146 struct fown_struct *fown,
2147 int sig)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002148{
2149 return 0;
2150}
2151
Eric Paris7b41b172008-04-23 14:10:25 -04002152static inline int security_file_receive(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002153{
2154 return 0;
2155}
2156
David Howells745ca242008-11-14 10:39:22 +11002157static inline int security_dentry_open(struct file *file,
2158 const struct cred *cred)
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +09002159{
2160 return 0;
2161}
2162
Eric Paris7b41b172008-04-23 14:10:25 -04002163static inline int security_task_create(unsigned long clone_flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002164{
2165 return 0;
2166}
2167
David Howellsd84f4f92008-11-14 10:39:23 +11002168static inline void security_cred_free(struct cred *cred)
2169{ }
2170
2171static inline int security_prepare_creds(struct cred *new,
2172 const struct cred *old,
2173 gfp_t gfp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174{
2175 return 0;
2176}
2177
David Howellsd84f4f92008-11-14 10:39:23 +11002178static inline void security_commit_creds(struct cred *new,
2179 const struct cred *old)
2180{
2181}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182
Eric Paris7b41b172008-04-23 14:10:25 -04002183static inline int security_task_setuid(uid_t id0, uid_t id1, uid_t id2,
2184 int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002185{
2186 return 0;
2187}
2188
David Howellsd84f4f92008-11-14 10:39:23 +11002189static inline int security_task_fix_setuid(struct cred *new,
2190 const struct cred *old,
2191 int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002192{
David Howellsd84f4f92008-11-14 10:39:23 +11002193 return cap_task_fix_setuid(new, old, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194}
2195
Eric Paris7b41b172008-04-23 14:10:25 -04002196static inline int security_task_setgid(gid_t id0, gid_t id1, gid_t id2,
2197 int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002198{
2199 return 0;
2200}
2201
Eric Paris7b41b172008-04-23 14:10:25 -04002202static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002203{
2204 return 0;
2205}
2206
Eric Paris7b41b172008-04-23 14:10:25 -04002207static inline int security_task_getpgid(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002208{
2209 return 0;
2210}
2211
Eric Paris7b41b172008-04-23 14:10:25 -04002212static inline int security_task_getsid(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002213{
2214 return 0;
2215}
2216
Eric Paris7b41b172008-04-23 14:10:25 -04002217static inline void security_task_getsecid(struct task_struct *p, u32 *secid)
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02002218{
2219 *secid = 0;
2220}
David Quigleyf9008e42006-06-30 01:55:46 -07002221
Eric Paris7b41b172008-04-23 14:10:25 -04002222static inline int security_task_setgroups(struct group_info *group_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002223{
2224 return 0;
2225}
2226
Eric Paris7b41b172008-04-23 14:10:25 -04002227static inline int security_task_setnice(struct task_struct *p, int nice)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002228{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002229 return cap_task_setnice(p, nice);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002230}
2231
Eric Paris7b41b172008-04-23 14:10:25 -04002232static inline int security_task_setioprio(struct task_struct *p, int ioprio)
James Morris03e68062006-06-23 02:03:58 -07002233{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002234 return cap_task_setioprio(p, ioprio);
James Morris03e68062006-06-23 02:03:58 -07002235}
2236
Eric Paris7b41b172008-04-23 14:10:25 -04002237static inline int security_task_getioprio(struct task_struct *p)
David Quigleya1836a42006-06-30 01:55:49 -07002238{
2239 return 0;
2240}
2241
Eric Paris7b41b172008-04-23 14:10:25 -04002242static inline int security_task_setrlimit(unsigned int resource,
2243 struct rlimit *new_rlim)
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_setscheduler(struct task_struct *p,
2249 int policy,
2250 struct sched_param *lp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002251{
Serge E. Hallynb5376772007-10-16 23:31:36 -07002252 return cap_task_setscheduler(p, policy, lp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002253}
2254
Eric Paris7b41b172008-04-23 14:10:25 -04002255static inline int security_task_getscheduler(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002256{
2257 return 0;
2258}
2259
Eric Paris7b41b172008-04-23 14:10:25 -04002260static inline int security_task_movememory(struct task_struct *p)
David Quigley35601542006-06-23 02:04:01 -07002261{
2262 return 0;
2263}
2264
Eric Paris7b41b172008-04-23 14:10:25 -04002265static inline int security_task_kill(struct task_struct *p,
2266 struct siginfo *info, int sig,
2267 u32 secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002268{
Serge Hallynaedb60a2008-02-29 15:14:57 +00002269 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270}
2271
Eric Paris7b41b172008-04-23 14:10:25 -04002272static inline int security_task_wait(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002273{
2274 return 0;
2275}
2276
Eric Paris7b41b172008-04-23 14:10:25 -04002277static inline int security_task_prctl(int option, unsigned long arg2,
2278 unsigned long arg3,
2279 unsigned long arg4,
David Howellsd84f4f92008-11-14 10:39:23 +11002280 unsigned long arg5)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281{
David Howellsd84f4f92008-11-14 10:39:23 +11002282 return cap_task_prctl(option, arg2, arg3, arg3, arg5);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283}
2284
2285static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2286{ }
2287
Eric Paris7b41b172008-04-23 14:10:25 -04002288static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
2289 short flag)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290{
2291 return 0;
2292}
2293
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02002294static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
2295{
2296 *secid = 0;
2297}
2298
Eric Paris7b41b172008-04-23 14:10:25 -04002299static inline int security_msg_msg_alloc(struct msg_msg *msg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300{
2301 return 0;
2302}
2303
Eric Paris7b41b172008-04-23 14:10:25 -04002304static inline void security_msg_msg_free(struct msg_msg *msg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305{ }
2306
Eric Paris7b41b172008-04-23 14:10:25 -04002307static inline int security_msg_queue_alloc(struct msg_queue *msq)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002308{
2309 return 0;
2310}
2311
Eric Paris7b41b172008-04-23 14:10:25 -04002312static inline void security_msg_queue_free(struct msg_queue *msq)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313{ }
2314
Eric Paris7b41b172008-04-23 14:10:25 -04002315static inline int security_msg_queue_associate(struct msg_queue *msq,
2316 int msqflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002317{
2318 return 0;
2319}
2320
Eric Paris7b41b172008-04-23 14:10:25 -04002321static inline int security_msg_queue_msgctl(struct msg_queue *msq, int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002322{
2323 return 0;
2324}
2325
Eric Paris7b41b172008-04-23 14:10:25 -04002326static inline int security_msg_queue_msgsnd(struct msg_queue *msq,
2327 struct msg_msg *msg, int msqflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002328{
2329 return 0;
2330}
2331
Eric Paris7b41b172008-04-23 14:10:25 -04002332static inline int security_msg_queue_msgrcv(struct msg_queue *msq,
2333 struct msg_msg *msg,
2334 struct task_struct *target,
2335 long type, int mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002336{
2337 return 0;
2338}
2339
Eric Paris7b41b172008-04-23 14:10:25 -04002340static inline int security_shm_alloc(struct shmid_kernel *shp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341{
2342 return 0;
2343}
2344
Eric Paris7b41b172008-04-23 14:10:25 -04002345static inline void security_shm_free(struct shmid_kernel *shp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002346{ }
2347
Eric Paris7b41b172008-04-23 14:10:25 -04002348static inline int security_shm_associate(struct shmid_kernel *shp,
2349 int shmflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002350{
2351 return 0;
2352}
2353
Eric Paris7b41b172008-04-23 14:10:25 -04002354static inline int security_shm_shmctl(struct shmid_kernel *shp, int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002355{
2356 return 0;
2357}
2358
Eric Paris7b41b172008-04-23 14:10:25 -04002359static inline int security_shm_shmat(struct shmid_kernel *shp,
2360 char __user *shmaddr, int shmflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002361{
2362 return 0;
2363}
2364
Eric Paris7b41b172008-04-23 14:10:25 -04002365static inline int security_sem_alloc(struct sem_array *sma)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366{
2367 return 0;
2368}
2369
Eric Paris7b41b172008-04-23 14:10:25 -04002370static inline void security_sem_free(struct sem_array *sma)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002371{ }
2372
Eric Paris7b41b172008-04-23 14:10:25 -04002373static inline int security_sem_associate(struct sem_array *sma, int semflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002374{
2375 return 0;
2376}
2377
Eric Paris7b41b172008-04-23 14:10:25 -04002378static inline int security_sem_semctl(struct sem_array *sma, int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002379{
2380 return 0;
2381}
2382
Eric Paris7b41b172008-04-23 14:10:25 -04002383static inline int security_sem_semop(struct sem_array *sma,
2384 struct sembuf *sops, unsigned nsops,
2385 int alter)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386{
2387 return 0;
2388}
2389
Eric Paris7b41b172008-04-23 14:10:25 -04002390static inline void security_d_instantiate(struct dentry *dentry, struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391{ }
2392
Al Viro04ff9702007-03-12 16:17:58 +00002393static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394{
2395 return -EINVAL;
2396}
2397
2398static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2399{
2400 return -EINVAL;
2401}
2402
Eric Paris7b41b172008-04-23 14:10:25 -04002403static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404{
Eric Paris7b41b172008-04-23 14:10:25 -04002405 return cap_netlink_send(sk, skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002406}
2407
Eric Paris7b41b172008-04-23 14:10:25 -04002408static inline int security_netlink_recv(struct sk_buff *skb, int cap)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002409{
Eric Paris7b41b172008-04-23 14:10:25 -04002410 return cap_netlink_recv(skb, cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411}
2412
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002413static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2414{
2415 return -EOPNOTSUPP;
2416}
2417
David Howells7bf570d2008-04-29 20:52:51 +01002418static inline int security_secctx_to_secid(const char *secdata,
David Howells63cb3442008-01-15 23:47:35 +00002419 u32 seclen,
2420 u32 *secid)
2421{
2422 return -EOPNOTSUPP;
2423}
2424
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002425static inline void security_release_secctx(char *secdata, u32 seclen)
2426{
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002427}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002428#endif /* CONFIG_SECURITY */
2429
2430#ifdef CONFIG_SECURITY_NETWORK
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431
James Morris20510f22007-10-16 23:31:32 -07002432int security_unix_stream_connect(struct socket *sock, struct socket *other,
2433 struct sock *newsk);
2434int security_unix_may_send(struct socket *sock, struct socket *other);
2435int security_socket_create(int family, int type, int protocol, int kern);
2436int security_socket_post_create(struct socket *sock, int family,
2437 int type, int protocol, int kern);
2438int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
2439int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
2440int security_socket_listen(struct socket *sock, int backlog);
2441int security_socket_accept(struct socket *sock, struct socket *newsock);
2442void security_socket_post_accept(struct socket *sock, struct socket *newsock);
2443int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
2444int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
2445 int size, int flags);
2446int security_socket_getsockname(struct socket *sock);
2447int security_socket_getpeername(struct socket *sock);
2448int security_socket_getsockopt(struct socket *sock, int level, int optname);
2449int security_socket_setsockopt(struct socket *sock, int level, int optname);
2450int security_socket_shutdown(struct socket *sock, int how);
2451int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
2452int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2453 int __user *optlen, unsigned len);
2454int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
2455int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
2456void security_sk_free(struct sock *sk);
2457void security_sk_clone(const struct sock *sk, struct sock *newsk);
2458void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
2459void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
2460void security_sock_graft(struct sock*sk, struct socket *parent);
2461int security_inet_conn_request(struct sock *sk,
2462 struct sk_buff *skb, struct request_sock *req);
2463void security_inet_csk_clone(struct sock *newsk,
2464 const struct request_sock *req);
2465void security_inet_conn_established(struct sock *sk,
2466 struct sk_buff *skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002467
Linus Torvalds1da177e2005-04-16 15:20:36 -07002468#else /* CONFIG_SECURITY_NETWORK */
Eric Paris7b41b172008-04-23 14:10:25 -04002469static inline int security_unix_stream_connect(struct socket *sock,
2470 struct socket *other,
2471 struct sock *newsk)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002472{
2473 return 0;
2474}
2475
Eric Paris7b41b172008-04-23 14:10:25 -04002476static inline int security_unix_may_send(struct socket *sock,
2477 struct socket *other)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002478{
2479 return 0;
2480}
2481
Eric Paris7b41b172008-04-23 14:10:25 -04002482static inline int security_socket_create(int family, int type,
2483 int protocol, int kern)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002484{
2485 return 0;
2486}
2487
Eric Paris7b41b172008-04-23 14:10:25 -04002488static inline int security_socket_post_create(struct socket *sock,
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07002489 int family,
2490 int type,
2491 int protocol, int kern)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492{
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07002493 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494}
2495
Eric Paris7b41b172008-04-23 14:10:25 -04002496static inline int security_socket_bind(struct socket *sock,
2497 struct sockaddr *address,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002498 int addrlen)
2499{
2500 return 0;
2501}
2502
Eric Paris7b41b172008-04-23 14:10:25 -04002503static inline int security_socket_connect(struct socket *sock,
2504 struct sockaddr *address,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002505 int addrlen)
2506{
2507 return 0;
2508}
2509
Eric Paris7b41b172008-04-23 14:10:25 -04002510static inline int security_socket_listen(struct socket *sock, int backlog)
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_accept(struct socket *sock,
2516 struct socket *newsock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002517{
2518 return 0;
2519}
2520
Eric Paris7b41b172008-04-23 14:10:25 -04002521static inline void security_socket_post_accept(struct socket *sock,
2522 struct socket *newsock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002523{
2524}
2525
Eric Paris7b41b172008-04-23 14:10:25 -04002526static inline int security_socket_sendmsg(struct socket *sock,
2527 struct msghdr *msg, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002528{
2529 return 0;
2530}
2531
Eric Paris7b41b172008-04-23 14:10:25 -04002532static inline int security_socket_recvmsg(struct socket *sock,
2533 struct msghdr *msg, int size,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002534 int flags)
2535{
2536 return 0;
2537}
2538
Eric Paris7b41b172008-04-23 14:10:25 -04002539static inline int security_socket_getsockname(struct socket *sock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002540{
2541 return 0;
2542}
2543
Eric Paris7b41b172008-04-23 14:10:25 -04002544static inline int security_socket_getpeername(struct socket *sock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002545{
2546 return 0;
2547}
2548
Eric Paris7b41b172008-04-23 14:10:25 -04002549static inline int security_socket_getsockopt(struct socket *sock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550 int level, int optname)
2551{
2552 return 0;
2553}
2554
Eric Paris7b41b172008-04-23 14:10:25 -04002555static inline int security_socket_setsockopt(struct socket *sock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002556 int level, int optname)
2557{
2558 return 0;
2559}
2560
Eric Paris7b41b172008-04-23 14:10:25 -04002561static inline int security_socket_shutdown(struct socket *sock, int how)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002562{
2563 return 0;
2564}
Eric Paris7b41b172008-04-23 14:10:25 -04002565static inline int security_sock_rcv_skb(struct sock *sk,
2566 struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002567{
2568 return 0;
2569}
2570
Catherine Zhang2c7946a2006-03-20 22:41:23 -08002571static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2572 int __user *optlen, unsigned len)
2573{
2574 return -ENOPROTOOPT;
2575}
2576
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002577static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002578{
2579 return -ENOPROTOOPT;
2580}
2581
Al Virodd0fc662005-10-07 07:46:04 +01002582static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002583{
2584 return 0;
2585}
2586
2587static inline void security_sk_free(struct sock *sk)
2588{
2589}
Trent Jaegerdf718372005-12-13 23:12:27 -08002590
Venkat Yekkirala892c1412006-08-04 23:08:56 -07002591static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2592{
2593}
2594
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002595static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
Trent Jaegerdf718372005-12-13 23:12:27 -08002596{
Trent Jaegerdf718372005-12-13 23:12:27 -08002597}
Venkat Yekkirala4237c752006-07-24 23:32:50 -07002598
2599static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2600{
2601}
2602
Eric Paris7b41b172008-04-23 14:10:25 -04002603static inline void security_sock_graft(struct sock *sk, struct socket *parent)
Venkat Yekkirala4237c752006-07-24 23:32:50 -07002604{
2605}
2606
2607static inline int security_inet_conn_request(struct sock *sk,
2608 struct sk_buff *skb, struct request_sock *req)
2609{
2610 return 0;
2611}
2612
2613static inline void security_inet_csk_clone(struct sock *newsk,
2614 const struct request_sock *req)
2615{
2616}
Venkat Yekkirala6b877692006-11-08 17:04:09 -06002617
2618static inline void security_inet_conn_established(struct sock *sk,
2619 struct sk_buff *skb)
2620{
2621}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622#endif /* CONFIG_SECURITY_NETWORK */
2623
Trent Jaegerdf718372005-12-13 23:12:27 -08002624#ifdef CONFIG_SECURITY_NETWORK_XFRM
Venkat Yekkiralacb969f02006-07-24 23:32:20 -07002625
Paul Moore03e1ad72008-04-12 19:07:52 -07002626int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *sec_ctx);
2627int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
2628void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
2629int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
James Morris20510f22007-10-16 23:31:32 -07002630int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
2631int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2632 struct xfrm_sec_ctx *polsec, u32 secid);
2633int security_xfrm_state_delete(struct xfrm_state *x);
2634void security_xfrm_state_free(struct xfrm_state *x);
Paul Moore03e1ad72008-04-12 19:07:52 -07002635int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
James Morris20510f22007-10-16 23:31:32 -07002636int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2637 struct xfrm_policy *xp, struct flowi *fl);
2638int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
2639void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
Trent Jaegerdf718372005-12-13 23:12:27 -08002640
Trent Jaegerdf718372005-12-13 23:12:27 -08002641#else /* CONFIG_SECURITY_NETWORK_XFRM */
James Morris20510f22007-10-16 23:31:32 -07002642
Paul Moore03e1ad72008-04-12 19:07:52 -07002643static 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 -08002644{
2645 return 0;
2646}
2647
Paul Moore03e1ad72008-04-12 19:07:52 -07002648static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
Trent Jaegerdf718372005-12-13 23:12:27 -08002649{
2650 return 0;
2651}
2652
Paul Moore03e1ad72008-04-12 19:07:52 -07002653static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
Trent Jaegerdf718372005-12-13 23:12:27 -08002654{
2655}
2656
Paul Moore03e1ad72008-04-12 19:07:52 -07002657static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
Catherine Zhangc8c05a82006-06-08 23:39:49 -07002658{
2659 return 0;
2660}
2661
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002662static inline int security_xfrm_state_alloc(struct xfrm_state *x,
2663 struct xfrm_user_sec_ctx *sec_ctx)
2664{
2665 return 0;
2666}
2667
2668static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2669 struct xfrm_sec_ctx *polsec, u32 secid)
Trent Jaegerdf718372005-12-13 23:12:27 -08002670{
2671 return 0;
2672}
2673
2674static inline void security_xfrm_state_free(struct xfrm_state *x)
2675{
2676}
2677
David S. Miller6f68dc32006-06-08 23:58:52 -07002678static inline int security_xfrm_state_delete(struct xfrm_state *x)
Catherine Zhangc8c05a82006-06-08 23:39:49 -07002679{
2680 return 0;
2681}
2682
Paul Moore03e1ad72008-04-12 19:07:52 -07002683static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
Trent Jaegerdf718372005-12-13 23:12:27 -08002684{
2685 return 0;
2686}
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002687
2688static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2689 struct xfrm_policy *xp, struct flowi *fl)
2690{
2691 return 1;
2692}
2693
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002694static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07002695{
2696 return 0;
2697}
2698
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002699static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
2700{
2701}
2702
Trent Jaegerdf718372005-12-13 23:12:27 -08002703#endif /* CONFIG_SECURITY_NETWORK_XFRM */
2704
David Howells29db9192005-10-30 15:02:44 -08002705#ifdef CONFIG_KEYS
2706#ifdef CONFIG_SECURITY
David Howells29db9192005-10-30 15:02:44 -08002707
David Howellsd84f4f92008-11-14 10:39:23 +11002708int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
James Morris20510f22007-10-16 23:31:32 -07002709void security_key_free(struct key *key);
2710int security_key_permission(key_ref_t key_ref,
David Howellsd84f4f92008-11-14 10:39:23 +11002711 const struct cred *cred, key_perm_t perm);
David Howells70a5bb72008-04-29 01:01:26 -07002712int security_key_getsecurity(struct key *key, char **_buffer);
David Howells29db9192005-10-30 15:02:44 -08002713
2714#else
2715
Michael LeMayd7200242006-06-22 14:47:17 -07002716static inline int security_key_alloc(struct key *key,
David Howellsd84f4f92008-11-14 10:39:23 +11002717 const struct cred *cred,
David Howells7e047ef2006-06-26 00:24:50 -07002718 unsigned long flags)
David Howells29db9192005-10-30 15:02:44 -08002719{
2720 return 0;
2721}
2722
2723static inline void security_key_free(struct key *key)
2724{
2725}
2726
2727static inline int security_key_permission(key_ref_t key_ref,
David Howellsd84f4f92008-11-14 10:39:23 +11002728 const struct cred *cred,
David Howells29db9192005-10-30 15:02:44 -08002729 key_perm_t perm)
2730{
2731 return 0;
2732}
2733
David Howells70a5bb72008-04-29 01:01:26 -07002734static inline int security_key_getsecurity(struct key *key, char **_buffer)
2735{
2736 *_buffer = NULL;
2737 return 0;
2738}
2739
David Howells29db9192005-10-30 15:02:44 -08002740#endif
2741#endif /* CONFIG_KEYS */
2742
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02002743#ifdef CONFIG_AUDIT
2744#ifdef CONFIG_SECURITY
2745int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
2746int security_audit_rule_known(struct audit_krule *krule);
2747int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
2748 struct audit_context *actx);
2749void security_audit_rule_free(void *lsmrule);
2750
2751#else
2752
2753static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
2754 void **lsmrule)
2755{
2756 return 0;
2757}
2758
2759static inline int security_audit_rule_known(struct audit_krule *krule)
2760{
2761 return 0;
2762}
2763
2764static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
2765 void *lsmrule, struct audit_context *actx)
2766{
2767 return 0;
2768}
2769
2770static inline void security_audit_rule_free(void *lsmrule)
2771{ }
2772
2773#endif /* CONFIG_SECURITY */
2774#endif /* CONFIG_AUDIT */
2775
Eric Parisda318942008-08-22 11:35:57 -04002776#ifdef CONFIG_SECURITYFS
2777
2778extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
2779 struct dentry *parent, void *data,
2780 const struct file_operations *fops);
2781extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2782extern void securityfs_remove(struct dentry *dentry);
2783
2784#else /* CONFIG_SECURITYFS */
2785
2786static inline struct dentry *securityfs_create_dir(const char *name,
2787 struct dentry *parent)
2788{
2789 return ERR_PTR(-ENODEV);
2790}
2791
2792static inline struct dentry *securityfs_create_file(const char *name,
2793 mode_t mode,
2794 struct dentry *parent,
2795 void *data,
2796 const struct file_operations *fops)
2797{
2798 return ERR_PTR(-ENODEV);
2799}
2800
2801static inline void securityfs_remove(struct dentry *dentry)
2802{}
2803
2804#endif
2805
Linus Torvalds1da177e2005-04-16 15:20:36 -07002806#endif /* ! __LINUX_SECURITY_H */
2807