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