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