]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/linux/security.h
nfs: don't atempt blocking locks on nfs reexports
[mirror_ubuntu-jammy-kernel.git] / include / linux / security.h
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 * Copyright (C) 2016 Mellanox Techonologies
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * Due to this file being licensed under the GPL there is controversy over
17 * whether this permits you to write a module that #includes this file
18 * without placing your module under the GPL. Please consult a lawyer for
19 * advice before doing this.
20 *
21 */
22
23 #ifndef __LINUX_SECURITY_H
24 #define __LINUX_SECURITY_H
25
26 #include <linux/kernel_read_file.h>
27 #include <linux/key.h>
28 #include <linux/capability.h>
29 #include <linux/fs.h>
30 #include <linux/slab.h>
31 #include <linux/err.h>
32 #include <linux/string.h>
33 #include <linux/mm.h>
34
35 struct linux_binprm;
36 struct cred;
37 struct rlimit;
38 struct kernel_siginfo;
39 struct sembuf;
40 struct kern_ipc_perm;
41 struct audit_context;
42 struct super_block;
43 struct inode;
44 struct dentry;
45 struct file;
46 struct vfsmount;
47 struct path;
48 struct qstr;
49 struct iattr;
50 struct fown_struct;
51 struct file_operations;
52 struct msg_msg;
53 struct xattr;
54 struct kernfs_node;
55 struct xfrm_sec_ctx;
56 struct mm_struct;
57 struct fs_context;
58 struct fs_parameter;
59 enum fs_value_type;
60 struct watch;
61 struct watch_notification;
62
63 /* Default (no) options for the capable function */
64 #define CAP_OPT_NONE 0x0
65 /* If capable should audit the security request */
66 #define CAP_OPT_NOAUDIT BIT(1)
67 /* If capable is being called by a setid function */
68 #define CAP_OPT_INSETID BIT(2)
69
70 /* LSM Agnostic defines for fs_context::lsm_flags */
71 #define SECURITY_LSM_NATIVE_LABELS 1
72
73 struct ctl_table;
74 struct audit_krule;
75 struct user_namespace;
76 struct timezone;
77
78 enum lsm_event {
79 LSM_POLICY_CHANGE,
80 };
81
82 /*
83 * These are reasons that can be passed to the security_locked_down()
84 * LSM hook. Lockdown reasons that protect kernel integrity (ie, the
85 * ability for userland to modify kernel code) are placed before
86 * LOCKDOWN_INTEGRITY_MAX. Lockdown reasons that protect kernel
87 * confidentiality (ie, the ability for userland to extract
88 * information from the running kernel that would otherwise be
89 * restricted) are placed before LOCKDOWN_CONFIDENTIALITY_MAX.
90 *
91 * LSM authors should note that the semantics of any given lockdown
92 * reason are not guaranteed to be stable - the same reason may block
93 * one set of features in one kernel release, and a slightly different
94 * set of features in a later kernel release. LSMs that seek to expose
95 * lockdown policy at any level of granularity other than "none",
96 * "integrity" or "confidentiality" are responsible for either
97 * ensuring that they expose a consistent level of functionality to
98 * userland, or ensuring that userland is aware that this is
99 * potentially a moving target. It is easy to misuse this information
100 * in a way that could break userspace. Please be careful not to do
101 * so.
102 *
103 * If you add to this, remember to extend lockdown_reasons in
104 * security/lockdown/lockdown.c.
105 */
106 enum lockdown_reason {
107 LOCKDOWN_NONE,
108 LOCKDOWN_MODULE_SIGNATURE,
109 LOCKDOWN_DEV_MEM,
110 LOCKDOWN_EFI_TEST,
111 LOCKDOWN_KEXEC,
112 LOCKDOWN_HIBERNATION,
113 LOCKDOWN_PCI_ACCESS,
114 LOCKDOWN_IOPORT,
115 LOCKDOWN_MSR,
116 LOCKDOWN_ACPI_TABLES,
117 LOCKDOWN_PCMCIA_CIS,
118 LOCKDOWN_TIOCSSERIAL,
119 LOCKDOWN_MODULE_PARAMETERS,
120 LOCKDOWN_MMIOTRACE,
121 LOCKDOWN_DEBUGFS,
122 LOCKDOWN_XMON_WR,
123 LOCKDOWN_BPF_WRITE_USER,
124 LOCKDOWN_INTEGRITY_MAX,
125 LOCKDOWN_KCORE,
126 LOCKDOWN_KPROBES,
127 LOCKDOWN_BPF_READ_KERNEL,
128 LOCKDOWN_PERF,
129 LOCKDOWN_TRACEFS,
130 LOCKDOWN_XMON_RW,
131 LOCKDOWN_XFRM_SECRET,
132 LOCKDOWN_CONFIDENTIALITY_MAX,
133 };
134
135 extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
136
137 /* These functions are in security/commoncap.c */
138 extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
139 int cap, unsigned int opts);
140 extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
141 extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
142 extern int cap_ptrace_traceme(struct task_struct *parent);
143 extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
144 extern int cap_capset(struct cred *new, const struct cred *old,
145 const kernel_cap_t *effective,
146 const kernel_cap_t *inheritable,
147 const kernel_cap_t *permitted);
148 extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
149 int cap_inode_setxattr(struct dentry *dentry, const char *name,
150 const void *value, size_t size, int flags);
151 int cap_inode_removexattr(struct user_namespace *mnt_userns,
152 struct dentry *dentry, const char *name);
153 int cap_inode_need_killpriv(struct dentry *dentry);
154 int cap_inode_killpriv(struct user_namespace *mnt_userns,
155 struct dentry *dentry);
156 int cap_inode_getsecurity(struct user_namespace *mnt_userns,
157 struct inode *inode, const char *name, void **buffer,
158 bool alloc);
159 extern int cap_mmap_addr(unsigned long addr);
160 extern int cap_mmap_file(struct file *file, unsigned long reqprot,
161 unsigned long prot, unsigned long flags);
162 extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
163 extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
164 unsigned long arg4, unsigned long arg5);
165 extern int cap_task_setscheduler(struct task_struct *p);
166 extern int cap_task_setioprio(struct task_struct *p, int ioprio);
167 extern int cap_task_setnice(struct task_struct *p, int nice);
168 extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
169
170 struct msghdr;
171 struct sk_buff;
172 struct sock;
173 struct sockaddr;
174 struct socket;
175 struct flowi_common;
176 struct dst_entry;
177 struct xfrm_selector;
178 struct xfrm_policy;
179 struct xfrm_state;
180 struct xfrm_user_sec_ctx;
181 struct seq_file;
182 struct sctp_endpoint;
183
184 #ifdef CONFIG_MMU
185 extern unsigned long mmap_min_addr;
186 extern unsigned long dac_mmap_min_addr;
187 #else
188 #define mmap_min_addr 0UL
189 #define dac_mmap_min_addr 0UL
190 #endif
191
192 /*
193 * Values used in the task_security_ops calls
194 */
195 /* setuid or setgid, id0 == uid or gid */
196 #define LSM_SETID_ID 1
197
198 /* setreuid or setregid, id0 == real, id1 == eff */
199 #define LSM_SETID_RE 2
200
201 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
202 #define LSM_SETID_RES 4
203
204 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
205 #define LSM_SETID_FS 8
206
207 /* Flags for security_task_prlimit(). */
208 #define LSM_PRLIMIT_READ 1
209 #define LSM_PRLIMIT_WRITE 2
210
211 /* forward declares to avoid warnings */
212 struct sched_param;
213 struct request_sock;
214
215 /* bprm->unsafe reasons */
216 #define LSM_UNSAFE_SHARE 1
217 #define LSM_UNSAFE_PTRACE 2
218 #define LSM_UNSAFE_NO_NEW_PRIVS 4
219
220 #ifdef CONFIG_MMU
221 extern int mmap_min_addr_handler(struct ctl_table *table, int write,
222 void *buffer, size_t *lenp, loff_t *ppos);
223 #endif
224
225 /* security_inode_init_security callback function to write xattrs */
226 typedef int (*initxattrs) (struct inode *inode,
227 const struct xattr *xattr_array, void *fs_data);
228
229
230 /* Keep the kernel_load_data_id enum in sync with kernel_read_file_id */
231 #define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM,
232 #define __data_id_stringify(dummy, str) #str,
233
234 enum kernel_load_data_id {
235 __kernel_read_file_id(__data_id_enumify)
236 };
237
238 static const char * const kernel_load_data_str[] = {
239 __kernel_read_file_id(__data_id_stringify)
240 };
241
242 static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
243 {
244 if ((unsigned)id >= LOADING_MAX_ID)
245 return kernel_load_data_str[LOADING_UNKNOWN];
246
247 return kernel_load_data_str[id];
248 }
249
250 #ifdef CONFIG_SECURITY
251
252 int call_blocking_lsm_notifier(enum lsm_event event, void *data);
253 int register_blocking_lsm_notifier(struct notifier_block *nb);
254 int unregister_blocking_lsm_notifier(struct notifier_block *nb);
255
256 /* prototypes */
257 extern int security_init(void);
258 extern int early_security_init(void);
259
260 /* Security operations */
261 int security_binder_set_context_mgr(struct task_struct *mgr);
262 int security_binder_transaction(struct task_struct *from,
263 struct task_struct *to);
264 int security_binder_transfer_binder(struct task_struct *from,
265 struct task_struct *to);
266 int security_binder_transfer_file(struct task_struct *from,
267 struct task_struct *to, struct file *file);
268 int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
269 int security_ptrace_traceme(struct task_struct *parent);
270 int security_capget(struct task_struct *target,
271 kernel_cap_t *effective,
272 kernel_cap_t *inheritable,
273 kernel_cap_t *permitted);
274 int security_capset(struct cred *new, const struct cred *old,
275 const kernel_cap_t *effective,
276 const kernel_cap_t *inheritable,
277 const kernel_cap_t *permitted);
278 int security_capable(const struct cred *cred,
279 struct user_namespace *ns,
280 int cap,
281 unsigned int opts);
282 int security_quotactl(int cmds, int type, int id, struct super_block *sb);
283 int security_quota_on(struct dentry *dentry);
284 int security_syslog(int type);
285 int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
286 int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
287 int security_bprm_creds_for_exec(struct linux_binprm *bprm);
288 int security_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
289 int security_bprm_check(struct linux_binprm *bprm);
290 void security_bprm_committing_creds(struct linux_binprm *bprm);
291 void security_bprm_committed_creds(struct linux_binprm *bprm);
292 int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc);
293 int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
294 int security_sb_alloc(struct super_block *sb);
295 void security_sb_delete(struct super_block *sb);
296 void security_sb_free(struct super_block *sb);
297 void security_free_mnt_opts(void **mnt_opts);
298 int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
299 int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
300 int security_sb_remount(struct super_block *sb, void *mnt_opts);
301 int security_sb_kern_mount(struct super_block *sb);
302 int security_sb_show_options(struct seq_file *m, struct super_block *sb);
303 int security_sb_statfs(struct dentry *dentry);
304 int security_sb_mount(const char *dev_name, const struct path *path,
305 const char *type, unsigned long flags, void *data);
306 int security_sb_umount(struct vfsmount *mnt, int flags);
307 int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
308 int security_sb_set_mnt_opts(struct super_block *sb,
309 void *mnt_opts,
310 unsigned long kern_flags,
311 unsigned long *set_kern_flags);
312 int security_sb_clone_mnt_opts(const struct super_block *oldsb,
313 struct super_block *newsb,
314 unsigned long kern_flags,
315 unsigned long *set_kern_flags);
316 int security_add_mnt_opt(const char *option, const char *val,
317 int len, void **mnt_opts);
318 int security_move_mount(const struct path *from_path, const struct path *to_path);
319 int security_dentry_init_security(struct dentry *dentry, int mode,
320 const struct qstr *name, void **ctx,
321 u32 *ctxlen);
322 int security_dentry_create_files_as(struct dentry *dentry, int mode,
323 struct qstr *name,
324 const struct cred *old,
325 struct cred *new);
326 int security_path_notify(const struct path *path, u64 mask,
327 unsigned int obj_type);
328 int security_inode_alloc(struct inode *inode);
329 void security_inode_free(struct inode *inode);
330 int security_inode_init_security(struct inode *inode, struct inode *dir,
331 const struct qstr *qstr,
332 initxattrs initxattrs, void *fs_data);
333 int security_inode_init_security_anon(struct inode *inode,
334 const struct qstr *name,
335 const struct inode *context_inode);
336 int security_old_inode_init_security(struct inode *inode, struct inode *dir,
337 const struct qstr *qstr, const char **name,
338 void **value, size_t *len);
339 int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
340 int security_inode_link(struct dentry *old_dentry, struct inode *dir,
341 struct dentry *new_dentry);
342 int security_inode_unlink(struct inode *dir, struct dentry *dentry);
343 int security_inode_symlink(struct inode *dir, struct dentry *dentry,
344 const char *old_name);
345 int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
346 int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
347 int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
348 int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
349 struct inode *new_dir, struct dentry *new_dentry,
350 unsigned int flags);
351 int security_inode_readlink(struct dentry *dentry);
352 int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
353 bool rcu);
354 int security_inode_permission(struct inode *inode, int mask);
355 int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
356 int security_inode_getattr(const struct path *path);
357 int security_inode_setxattr(struct user_namespace *mnt_userns,
358 struct dentry *dentry, const char *name,
359 const void *value, size_t size, int flags);
360 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
361 const void *value, size_t size, int flags);
362 int security_inode_getxattr(struct dentry *dentry, const char *name);
363 int security_inode_listxattr(struct dentry *dentry);
364 int security_inode_removexattr(struct user_namespace *mnt_userns,
365 struct dentry *dentry, const char *name);
366 int security_inode_need_killpriv(struct dentry *dentry);
367 int security_inode_killpriv(struct user_namespace *mnt_userns,
368 struct dentry *dentry);
369 int security_inode_getsecurity(struct user_namespace *mnt_userns,
370 struct inode *inode, const char *name,
371 void **buffer, bool alloc);
372 int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
373 int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
374 void security_inode_getsecid(struct inode *inode, u32 *secid);
375 int security_inode_copy_up(struct dentry *src, struct cred **new);
376 int security_inode_copy_up_xattr(const char *name);
377 int security_kernfs_init_security(struct kernfs_node *kn_dir,
378 struct kernfs_node *kn);
379 int security_file_permission(struct file *file, int mask);
380 int security_file_alloc(struct file *file);
381 void security_file_free(struct file *file);
382 int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
383 int security_mmap_file(struct file *file, unsigned long prot,
384 unsigned long flags);
385 int security_mmap_addr(unsigned long addr);
386 int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
387 unsigned long prot);
388 int security_file_lock(struct file *file, unsigned int cmd);
389 int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
390 void security_file_set_fowner(struct file *file);
391 int security_file_send_sigiotask(struct task_struct *tsk,
392 struct fown_struct *fown, int sig);
393 int security_file_receive(struct file *file);
394 int security_file_open(struct file *file);
395 int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
396 void security_task_free(struct task_struct *task);
397 int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
398 void security_cred_free(struct cred *cred);
399 int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
400 void security_transfer_creds(struct cred *new, const struct cred *old);
401 void security_cred_getsecid(const struct cred *c, u32 *secid);
402 int security_kernel_act_as(struct cred *new, u32 secid);
403 int security_kernel_create_files_as(struct cred *new, struct inode *inode);
404 int security_kernel_module_request(char *kmod_name);
405 int security_kernel_load_data(enum kernel_load_data_id id, bool contents);
406 int security_kernel_post_load_data(char *buf, loff_t size,
407 enum kernel_load_data_id id,
408 char *description);
409 int security_kernel_read_file(struct file *file, enum kernel_read_file_id id,
410 bool contents);
411 int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
412 enum kernel_read_file_id id);
413 int security_task_fix_setuid(struct cred *new, const struct cred *old,
414 int flags);
415 int security_task_fix_setgid(struct cred *new, const struct cred *old,
416 int flags);
417 int security_task_setpgid(struct task_struct *p, pid_t pgid);
418 int security_task_getpgid(struct task_struct *p);
419 int security_task_getsid(struct task_struct *p);
420 void security_task_getsecid_subj(struct task_struct *p, u32 *secid);
421 void security_task_getsecid_obj(struct task_struct *p, u32 *secid);
422 int security_task_setnice(struct task_struct *p, int nice);
423 int security_task_setioprio(struct task_struct *p, int ioprio);
424 int security_task_getioprio(struct task_struct *p);
425 int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
426 unsigned int flags);
427 int security_task_setrlimit(struct task_struct *p, unsigned int resource,
428 struct rlimit *new_rlim);
429 int security_task_setscheduler(struct task_struct *p);
430 int security_task_getscheduler(struct task_struct *p);
431 int security_task_movememory(struct task_struct *p);
432 int security_task_kill(struct task_struct *p, struct kernel_siginfo *info,
433 int sig, const struct cred *cred);
434 int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
435 unsigned long arg4, unsigned long arg5);
436 void security_task_to_inode(struct task_struct *p, struct inode *inode);
437 int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
438 void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
439 int security_msg_msg_alloc(struct msg_msg *msg);
440 void security_msg_msg_free(struct msg_msg *msg);
441 int security_msg_queue_alloc(struct kern_ipc_perm *msq);
442 void security_msg_queue_free(struct kern_ipc_perm *msq);
443 int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg);
444 int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd);
445 int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
446 struct msg_msg *msg, int msqflg);
447 int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg,
448 struct task_struct *target, long type, int mode);
449 int security_shm_alloc(struct kern_ipc_perm *shp);
450 void security_shm_free(struct kern_ipc_perm *shp);
451 int security_shm_associate(struct kern_ipc_perm *shp, int shmflg);
452 int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd);
453 int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg);
454 int security_sem_alloc(struct kern_ipc_perm *sma);
455 void security_sem_free(struct kern_ipc_perm *sma);
456 int security_sem_associate(struct kern_ipc_perm *sma, int semflg);
457 int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
458 int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
459 unsigned nsops, int alter);
460 void security_d_instantiate(struct dentry *dentry, struct inode *inode);
461 int security_getprocattr(struct task_struct *p, const char *lsm, char *name,
462 char **value);
463 int security_setprocattr(const char *lsm, const char *name, void *value,
464 size_t size);
465 int security_netlink_send(struct sock *sk, struct sk_buff *skb);
466 int security_ismaclabel(const char *name);
467 int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
468 int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
469 void security_release_secctx(char *secdata, u32 seclen);
470 void security_inode_invalidate_secctx(struct inode *inode);
471 int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
472 int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
473 int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
474 int security_locked_down(enum lockdown_reason what);
475 #else /* CONFIG_SECURITY */
476
477 static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data)
478 {
479 return 0;
480 }
481
482 static inline int register_blocking_lsm_notifier(struct notifier_block *nb)
483 {
484 return 0;
485 }
486
487 static inline int unregister_blocking_lsm_notifier(struct notifier_block *nb)
488 {
489 return 0;
490 }
491
492 static inline void security_free_mnt_opts(void **mnt_opts)
493 {
494 }
495
496 /*
497 * This is the default capabilities functionality. Most of these functions
498 * are just stubbed out, but a few must call the proper capable code.
499 */
500
501 static inline int security_init(void)
502 {
503 return 0;
504 }
505
506 static inline int early_security_init(void)
507 {
508 return 0;
509 }
510
511 static inline int security_binder_set_context_mgr(struct task_struct *mgr)
512 {
513 return 0;
514 }
515
516 static inline int security_binder_transaction(struct task_struct *from,
517 struct task_struct *to)
518 {
519 return 0;
520 }
521
522 static inline int security_binder_transfer_binder(struct task_struct *from,
523 struct task_struct *to)
524 {
525 return 0;
526 }
527
528 static inline int security_binder_transfer_file(struct task_struct *from,
529 struct task_struct *to,
530 struct file *file)
531 {
532 return 0;
533 }
534
535 static inline int security_ptrace_access_check(struct task_struct *child,
536 unsigned int mode)
537 {
538 return cap_ptrace_access_check(child, mode);
539 }
540
541 static inline int security_ptrace_traceme(struct task_struct *parent)
542 {
543 return cap_ptrace_traceme(parent);
544 }
545
546 static inline int security_capget(struct task_struct *target,
547 kernel_cap_t *effective,
548 kernel_cap_t *inheritable,
549 kernel_cap_t *permitted)
550 {
551 return cap_capget(target, effective, inheritable, permitted);
552 }
553
554 static inline int security_capset(struct cred *new,
555 const struct cred *old,
556 const kernel_cap_t *effective,
557 const kernel_cap_t *inheritable,
558 const kernel_cap_t *permitted)
559 {
560 return cap_capset(new, old, effective, inheritable, permitted);
561 }
562
563 static inline int security_capable(const struct cred *cred,
564 struct user_namespace *ns,
565 int cap,
566 unsigned int opts)
567 {
568 return cap_capable(cred, ns, cap, opts);
569 }
570
571 static inline int security_quotactl(int cmds, int type, int id,
572 struct super_block *sb)
573 {
574 return 0;
575 }
576
577 static inline int security_quota_on(struct dentry *dentry)
578 {
579 return 0;
580 }
581
582 static inline int security_syslog(int type)
583 {
584 return 0;
585 }
586
587 static inline int security_settime64(const struct timespec64 *ts,
588 const struct timezone *tz)
589 {
590 return cap_settime(ts, tz);
591 }
592
593 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
594 {
595 return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages));
596 }
597
598 static inline int security_bprm_creds_for_exec(struct linux_binprm *bprm)
599 {
600 return 0;
601 }
602
603 static inline int security_bprm_creds_from_file(struct linux_binprm *bprm,
604 struct file *file)
605 {
606 return cap_bprm_creds_from_file(bprm, file);
607 }
608
609 static inline int security_bprm_check(struct linux_binprm *bprm)
610 {
611 return 0;
612 }
613
614 static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
615 {
616 }
617
618 static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
619 {
620 }
621
622 static inline int security_fs_context_dup(struct fs_context *fc,
623 struct fs_context *src_fc)
624 {
625 return 0;
626 }
627 static inline int security_fs_context_parse_param(struct fs_context *fc,
628 struct fs_parameter *param)
629 {
630 return -ENOPARAM;
631 }
632
633 static inline int security_sb_alloc(struct super_block *sb)
634 {
635 return 0;
636 }
637
638 static inline void security_sb_delete(struct super_block *sb)
639 { }
640
641 static inline void security_sb_free(struct super_block *sb)
642 { }
643
644 static inline int security_sb_eat_lsm_opts(char *options,
645 void **mnt_opts)
646 {
647 return 0;
648 }
649
650 static inline int security_sb_remount(struct super_block *sb,
651 void *mnt_opts)
652 {
653 return 0;
654 }
655
656 static inline int security_sb_mnt_opts_compat(struct super_block *sb,
657 void *mnt_opts)
658 {
659 return 0;
660 }
661
662
663 static inline int security_sb_kern_mount(struct super_block *sb)
664 {
665 return 0;
666 }
667
668 static inline int security_sb_show_options(struct seq_file *m,
669 struct super_block *sb)
670 {
671 return 0;
672 }
673
674 static inline int security_sb_statfs(struct dentry *dentry)
675 {
676 return 0;
677 }
678
679 static inline int security_sb_mount(const char *dev_name, const struct path *path,
680 const char *type, unsigned long flags,
681 void *data)
682 {
683 return 0;
684 }
685
686 static inline int security_sb_umount(struct vfsmount *mnt, int flags)
687 {
688 return 0;
689 }
690
691 static inline int security_sb_pivotroot(const struct path *old_path,
692 const struct path *new_path)
693 {
694 return 0;
695 }
696
697 static inline int security_sb_set_mnt_opts(struct super_block *sb,
698 void *mnt_opts,
699 unsigned long kern_flags,
700 unsigned long *set_kern_flags)
701 {
702 return 0;
703 }
704
705 static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
706 struct super_block *newsb,
707 unsigned long kern_flags,
708 unsigned long *set_kern_flags)
709 {
710 return 0;
711 }
712
713 static inline int security_add_mnt_opt(const char *option, const char *val,
714 int len, void **mnt_opts)
715 {
716 return 0;
717 }
718
719 static inline int security_move_mount(const struct path *from_path,
720 const struct path *to_path)
721 {
722 return 0;
723 }
724
725 static inline int security_path_notify(const struct path *path, u64 mask,
726 unsigned int obj_type)
727 {
728 return 0;
729 }
730
731 static inline int security_inode_alloc(struct inode *inode)
732 {
733 return 0;
734 }
735
736 static inline void security_inode_free(struct inode *inode)
737 { }
738
739 static inline int security_dentry_init_security(struct dentry *dentry,
740 int mode,
741 const struct qstr *name,
742 void **ctx,
743 u32 *ctxlen)
744 {
745 return -EOPNOTSUPP;
746 }
747
748 static inline int security_dentry_create_files_as(struct dentry *dentry,
749 int mode, struct qstr *name,
750 const struct cred *old,
751 struct cred *new)
752 {
753 return 0;
754 }
755
756
757 static inline int security_inode_init_security(struct inode *inode,
758 struct inode *dir,
759 const struct qstr *qstr,
760 const initxattrs xattrs,
761 void *fs_data)
762 {
763 return 0;
764 }
765
766 static inline int security_inode_init_security_anon(struct inode *inode,
767 const struct qstr *name,
768 const struct inode *context_inode)
769 {
770 return 0;
771 }
772
773 static inline int security_old_inode_init_security(struct inode *inode,
774 struct inode *dir,
775 const struct qstr *qstr,
776 const char **name,
777 void **value, size_t *len)
778 {
779 return -EOPNOTSUPP;
780 }
781
782 static inline int security_inode_create(struct inode *dir,
783 struct dentry *dentry,
784 umode_t mode)
785 {
786 return 0;
787 }
788
789 static inline int security_inode_link(struct dentry *old_dentry,
790 struct inode *dir,
791 struct dentry *new_dentry)
792 {
793 return 0;
794 }
795
796 static inline int security_inode_unlink(struct inode *dir,
797 struct dentry *dentry)
798 {
799 return 0;
800 }
801
802 static inline int security_inode_symlink(struct inode *dir,
803 struct dentry *dentry,
804 const char *old_name)
805 {
806 return 0;
807 }
808
809 static inline int security_inode_mkdir(struct inode *dir,
810 struct dentry *dentry,
811 int mode)
812 {
813 return 0;
814 }
815
816 static inline int security_inode_rmdir(struct inode *dir,
817 struct dentry *dentry)
818 {
819 return 0;
820 }
821
822 static inline int security_inode_mknod(struct inode *dir,
823 struct dentry *dentry,
824 int mode, dev_t dev)
825 {
826 return 0;
827 }
828
829 static inline int security_inode_rename(struct inode *old_dir,
830 struct dentry *old_dentry,
831 struct inode *new_dir,
832 struct dentry *new_dentry,
833 unsigned int flags)
834 {
835 return 0;
836 }
837
838 static inline int security_inode_readlink(struct dentry *dentry)
839 {
840 return 0;
841 }
842
843 static inline int security_inode_follow_link(struct dentry *dentry,
844 struct inode *inode,
845 bool rcu)
846 {
847 return 0;
848 }
849
850 static inline int security_inode_permission(struct inode *inode, int mask)
851 {
852 return 0;
853 }
854
855 static inline int security_inode_setattr(struct dentry *dentry,
856 struct iattr *attr)
857 {
858 return 0;
859 }
860
861 static inline int security_inode_getattr(const struct path *path)
862 {
863 return 0;
864 }
865
866 static inline int security_inode_setxattr(struct user_namespace *mnt_userns,
867 struct dentry *dentry, const char *name, const void *value,
868 size_t size, int flags)
869 {
870 return cap_inode_setxattr(dentry, name, value, size, flags);
871 }
872
873 static inline void security_inode_post_setxattr(struct dentry *dentry,
874 const char *name, const void *value, size_t size, int flags)
875 { }
876
877 static inline int security_inode_getxattr(struct dentry *dentry,
878 const char *name)
879 {
880 return 0;
881 }
882
883 static inline int security_inode_listxattr(struct dentry *dentry)
884 {
885 return 0;
886 }
887
888 static inline int security_inode_removexattr(struct user_namespace *mnt_userns,
889 struct dentry *dentry,
890 const char *name)
891 {
892 return cap_inode_removexattr(mnt_userns, dentry, name);
893 }
894
895 static inline int security_inode_need_killpriv(struct dentry *dentry)
896 {
897 return cap_inode_need_killpriv(dentry);
898 }
899
900 static inline int security_inode_killpriv(struct user_namespace *mnt_userns,
901 struct dentry *dentry)
902 {
903 return cap_inode_killpriv(mnt_userns, dentry);
904 }
905
906 static inline int security_inode_getsecurity(struct user_namespace *mnt_userns,
907 struct inode *inode,
908 const char *name, void **buffer,
909 bool alloc)
910 {
911 return cap_inode_getsecurity(mnt_userns, inode, name, buffer, alloc);
912 }
913
914 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
915 {
916 return -EOPNOTSUPP;
917 }
918
919 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
920 {
921 return 0;
922 }
923
924 static inline void security_inode_getsecid(struct inode *inode, u32 *secid)
925 {
926 *secid = 0;
927 }
928
929 static inline int security_inode_copy_up(struct dentry *src, struct cred **new)
930 {
931 return 0;
932 }
933
934 static inline int security_kernfs_init_security(struct kernfs_node *kn_dir,
935 struct kernfs_node *kn)
936 {
937 return 0;
938 }
939
940 static inline int security_inode_copy_up_xattr(const char *name)
941 {
942 return -EOPNOTSUPP;
943 }
944
945 static inline int security_file_permission(struct file *file, int mask)
946 {
947 return 0;
948 }
949
950 static inline int security_file_alloc(struct file *file)
951 {
952 return 0;
953 }
954
955 static inline void security_file_free(struct file *file)
956 { }
957
958 static inline int security_file_ioctl(struct file *file, unsigned int cmd,
959 unsigned long arg)
960 {
961 return 0;
962 }
963
964 static inline int security_mmap_file(struct file *file, unsigned long prot,
965 unsigned long flags)
966 {
967 return 0;
968 }
969
970 static inline int security_mmap_addr(unsigned long addr)
971 {
972 return cap_mmap_addr(addr);
973 }
974
975 static inline int security_file_mprotect(struct vm_area_struct *vma,
976 unsigned long reqprot,
977 unsigned long prot)
978 {
979 return 0;
980 }
981
982 static inline int security_file_lock(struct file *file, unsigned int cmd)
983 {
984 return 0;
985 }
986
987 static inline int security_file_fcntl(struct file *file, unsigned int cmd,
988 unsigned long arg)
989 {
990 return 0;
991 }
992
993 static inline void security_file_set_fowner(struct file *file)
994 {
995 return;
996 }
997
998 static inline int security_file_send_sigiotask(struct task_struct *tsk,
999 struct fown_struct *fown,
1000 int sig)
1001 {
1002 return 0;
1003 }
1004
1005 static inline int security_file_receive(struct file *file)
1006 {
1007 return 0;
1008 }
1009
1010 static inline int security_file_open(struct file *file)
1011 {
1012 return 0;
1013 }
1014
1015 static inline int security_task_alloc(struct task_struct *task,
1016 unsigned long clone_flags)
1017 {
1018 return 0;
1019 }
1020
1021 static inline void security_task_free(struct task_struct *task)
1022 { }
1023
1024 static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
1025 {
1026 return 0;
1027 }
1028
1029 static inline void security_cred_free(struct cred *cred)
1030 { }
1031
1032 static inline int security_prepare_creds(struct cred *new,
1033 const struct cred *old,
1034 gfp_t gfp)
1035 {
1036 return 0;
1037 }
1038
1039 static inline void security_transfer_creds(struct cred *new,
1040 const struct cred *old)
1041 {
1042 }
1043
1044 static inline int security_kernel_act_as(struct cred *cred, u32 secid)
1045 {
1046 return 0;
1047 }
1048
1049 static inline int security_kernel_create_files_as(struct cred *cred,
1050 struct inode *inode)
1051 {
1052 return 0;
1053 }
1054
1055 static inline int security_kernel_module_request(char *kmod_name)
1056 {
1057 return 0;
1058 }
1059
1060 static inline int security_kernel_load_data(enum kernel_load_data_id id, bool contents)
1061 {
1062 return 0;
1063 }
1064
1065 static inline int security_kernel_post_load_data(char *buf, loff_t size,
1066 enum kernel_load_data_id id,
1067 char *description)
1068 {
1069 return 0;
1070 }
1071
1072 static inline int security_kernel_read_file(struct file *file,
1073 enum kernel_read_file_id id,
1074 bool contents)
1075 {
1076 return 0;
1077 }
1078
1079 static inline int security_kernel_post_read_file(struct file *file,
1080 char *buf, loff_t size,
1081 enum kernel_read_file_id id)
1082 {
1083 return 0;
1084 }
1085
1086 static inline int security_task_fix_setuid(struct cred *new,
1087 const struct cred *old,
1088 int flags)
1089 {
1090 return cap_task_fix_setuid(new, old, flags);
1091 }
1092
1093 static inline int security_task_fix_setgid(struct cred *new,
1094 const struct cred *old,
1095 int flags)
1096 {
1097 return 0;
1098 }
1099
1100 static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
1101 {
1102 return 0;
1103 }
1104
1105 static inline int security_task_getpgid(struct task_struct *p)
1106 {
1107 return 0;
1108 }
1109
1110 static inline int security_task_getsid(struct task_struct *p)
1111 {
1112 return 0;
1113 }
1114
1115 static inline void security_task_getsecid_subj(struct task_struct *p, u32 *secid)
1116 {
1117 *secid = 0;
1118 }
1119
1120 static inline void security_task_getsecid_obj(struct task_struct *p, u32 *secid)
1121 {
1122 *secid = 0;
1123 }
1124
1125 static inline int security_task_setnice(struct task_struct *p, int nice)
1126 {
1127 return cap_task_setnice(p, nice);
1128 }
1129
1130 static inline int security_task_setioprio(struct task_struct *p, int ioprio)
1131 {
1132 return cap_task_setioprio(p, ioprio);
1133 }
1134
1135 static inline int security_task_getioprio(struct task_struct *p)
1136 {
1137 return 0;
1138 }
1139
1140 static inline int security_task_prlimit(const struct cred *cred,
1141 const struct cred *tcred,
1142 unsigned int flags)
1143 {
1144 return 0;
1145 }
1146
1147 static inline int security_task_setrlimit(struct task_struct *p,
1148 unsigned int resource,
1149 struct rlimit *new_rlim)
1150 {
1151 return 0;
1152 }
1153
1154 static inline int security_task_setscheduler(struct task_struct *p)
1155 {
1156 return cap_task_setscheduler(p);
1157 }
1158
1159 static inline int security_task_getscheduler(struct task_struct *p)
1160 {
1161 return 0;
1162 }
1163
1164 static inline int security_task_movememory(struct task_struct *p)
1165 {
1166 return 0;
1167 }
1168
1169 static inline int security_task_kill(struct task_struct *p,
1170 struct kernel_siginfo *info, int sig,
1171 const struct cred *cred)
1172 {
1173 return 0;
1174 }
1175
1176 static inline int security_task_prctl(int option, unsigned long arg2,
1177 unsigned long arg3,
1178 unsigned long arg4,
1179 unsigned long arg5)
1180 {
1181 return cap_task_prctl(option, arg2, arg3, arg4, arg5);
1182 }
1183
1184 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1185 { }
1186
1187 static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
1188 short flag)
1189 {
1190 return 0;
1191 }
1192
1193 static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
1194 {
1195 *secid = 0;
1196 }
1197
1198 static inline int security_msg_msg_alloc(struct msg_msg *msg)
1199 {
1200 return 0;
1201 }
1202
1203 static inline void security_msg_msg_free(struct msg_msg *msg)
1204 { }
1205
1206 static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq)
1207 {
1208 return 0;
1209 }
1210
1211 static inline void security_msg_queue_free(struct kern_ipc_perm *msq)
1212 { }
1213
1214 static inline int security_msg_queue_associate(struct kern_ipc_perm *msq,
1215 int msqflg)
1216 {
1217 return 0;
1218 }
1219
1220 static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd)
1221 {
1222 return 0;
1223 }
1224
1225 static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
1226 struct msg_msg *msg, int msqflg)
1227 {
1228 return 0;
1229 }
1230
1231 static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq,
1232 struct msg_msg *msg,
1233 struct task_struct *target,
1234 long type, int mode)
1235 {
1236 return 0;
1237 }
1238
1239 static inline int security_shm_alloc(struct kern_ipc_perm *shp)
1240 {
1241 return 0;
1242 }
1243
1244 static inline void security_shm_free(struct kern_ipc_perm *shp)
1245 { }
1246
1247 static inline int security_shm_associate(struct kern_ipc_perm *shp,
1248 int shmflg)
1249 {
1250 return 0;
1251 }
1252
1253 static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd)
1254 {
1255 return 0;
1256 }
1257
1258 static inline int security_shm_shmat(struct kern_ipc_perm *shp,
1259 char __user *shmaddr, int shmflg)
1260 {
1261 return 0;
1262 }
1263
1264 static inline int security_sem_alloc(struct kern_ipc_perm *sma)
1265 {
1266 return 0;
1267 }
1268
1269 static inline void security_sem_free(struct kern_ipc_perm *sma)
1270 { }
1271
1272 static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg)
1273 {
1274 return 0;
1275 }
1276
1277 static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd)
1278 {
1279 return 0;
1280 }
1281
1282 static inline int security_sem_semop(struct kern_ipc_perm *sma,
1283 struct sembuf *sops, unsigned nsops,
1284 int alter)
1285 {
1286 return 0;
1287 }
1288
1289 static inline void security_d_instantiate(struct dentry *dentry,
1290 struct inode *inode)
1291 { }
1292
1293 static inline int security_getprocattr(struct task_struct *p, const char *lsm,
1294 char *name, char **value)
1295 {
1296 return -EINVAL;
1297 }
1298
1299 static inline int security_setprocattr(const char *lsm, char *name,
1300 void *value, size_t size)
1301 {
1302 return -EINVAL;
1303 }
1304
1305 static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
1306 {
1307 return 0;
1308 }
1309
1310 static inline int security_ismaclabel(const char *name)
1311 {
1312 return 0;
1313 }
1314
1315 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
1316 {
1317 return -EOPNOTSUPP;
1318 }
1319
1320 static inline int security_secctx_to_secid(const char *secdata,
1321 u32 seclen,
1322 u32 *secid)
1323 {
1324 return -EOPNOTSUPP;
1325 }
1326
1327 static inline void security_release_secctx(char *secdata, u32 seclen)
1328 {
1329 }
1330
1331 static inline void security_inode_invalidate_secctx(struct inode *inode)
1332 {
1333 }
1334
1335 static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
1336 {
1337 return -EOPNOTSUPP;
1338 }
1339 static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
1340 {
1341 return -EOPNOTSUPP;
1342 }
1343 static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
1344 {
1345 return -EOPNOTSUPP;
1346 }
1347 static inline int security_locked_down(enum lockdown_reason what)
1348 {
1349 return 0;
1350 }
1351 #endif /* CONFIG_SECURITY */
1352
1353 #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
1354 int security_post_notification(const struct cred *w_cred,
1355 const struct cred *cred,
1356 struct watch_notification *n);
1357 #else
1358 static inline int security_post_notification(const struct cred *w_cred,
1359 const struct cred *cred,
1360 struct watch_notification *n)
1361 {
1362 return 0;
1363 }
1364 #endif
1365
1366 #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
1367 int security_watch_key(struct key *key);
1368 #else
1369 static inline int security_watch_key(struct key *key)
1370 {
1371 return 0;
1372 }
1373 #endif
1374
1375 #ifdef CONFIG_SECURITY_NETWORK
1376
1377 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
1378 int security_unix_may_send(struct socket *sock, struct socket *other);
1379 int security_socket_create(int family, int type, int protocol, int kern);
1380 int security_socket_post_create(struct socket *sock, int family,
1381 int type, int protocol, int kern);
1382 int security_socket_socketpair(struct socket *socka, struct socket *sockb);
1383 int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
1384 int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
1385 int security_socket_listen(struct socket *sock, int backlog);
1386 int security_socket_accept(struct socket *sock, struct socket *newsock);
1387 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
1388 int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
1389 int size, int flags);
1390 int security_socket_getsockname(struct socket *sock);
1391 int security_socket_getpeername(struct socket *sock);
1392 int security_socket_getsockopt(struct socket *sock, int level, int optname);
1393 int security_socket_setsockopt(struct socket *sock, int level, int optname);
1394 int security_socket_shutdown(struct socket *sock, int how);
1395 int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
1396 int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
1397 int __user *optlen, unsigned len);
1398 int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
1399 int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
1400 void security_sk_free(struct sock *sk);
1401 void security_sk_clone(const struct sock *sk, struct sock *newsk);
1402 void security_sk_classify_flow(struct sock *sk, struct flowi_common *flic);
1403 void security_req_classify_flow(const struct request_sock *req,
1404 struct flowi_common *flic);
1405 void security_sock_graft(struct sock*sk, struct socket *parent);
1406 int security_inet_conn_request(const struct sock *sk,
1407 struct sk_buff *skb, struct request_sock *req);
1408 void security_inet_csk_clone(struct sock *newsk,
1409 const struct request_sock *req);
1410 void security_inet_conn_established(struct sock *sk,
1411 struct sk_buff *skb);
1412 int security_secmark_relabel_packet(u32 secid);
1413 void security_secmark_refcount_inc(void);
1414 void security_secmark_refcount_dec(void);
1415 int security_tun_dev_alloc_security(void **security);
1416 void security_tun_dev_free_security(void *security);
1417 int security_tun_dev_create(void);
1418 int security_tun_dev_attach_queue(void *security);
1419 int security_tun_dev_attach(struct sock *sk, void *security);
1420 int security_tun_dev_open(void *security);
1421 int security_sctp_assoc_request(struct sctp_endpoint *ep, struct sk_buff *skb);
1422 int security_sctp_bind_connect(struct sock *sk, int optname,
1423 struct sockaddr *address, int addrlen);
1424 void security_sctp_sk_clone(struct sctp_endpoint *ep, struct sock *sk,
1425 struct sock *newsk);
1426
1427 #else /* CONFIG_SECURITY_NETWORK */
1428 static inline int security_unix_stream_connect(struct sock *sock,
1429 struct sock *other,
1430 struct sock *newsk)
1431 {
1432 return 0;
1433 }
1434
1435 static inline int security_unix_may_send(struct socket *sock,
1436 struct socket *other)
1437 {
1438 return 0;
1439 }
1440
1441 static inline int security_socket_create(int family, int type,
1442 int protocol, int kern)
1443 {
1444 return 0;
1445 }
1446
1447 static inline int security_socket_post_create(struct socket *sock,
1448 int family,
1449 int type,
1450 int protocol, int kern)
1451 {
1452 return 0;
1453 }
1454
1455 static inline int security_socket_socketpair(struct socket *socka,
1456 struct socket *sockb)
1457 {
1458 return 0;
1459 }
1460
1461 static inline int security_socket_bind(struct socket *sock,
1462 struct sockaddr *address,
1463 int addrlen)
1464 {
1465 return 0;
1466 }
1467
1468 static inline int security_socket_connect(struct socket *sock,
1469 struct sockaddr *address,
1470 int addrlen)
1471 {
1472 return 0;
1473 }
1474
1475 static inline int security_socket_listen(struct socket *sock, int backlog)
1476 {
1477 return 0;
1478 }
1479
1480 static inline int security_socket_accept(struct socket *sock,
1481 struct socket *newsock)
1482 {
1483 return 0;
1484 }
1485
1486 static inline int security_socket_sendmsg(struct socket *sock,
1487 struct msghdr *msg, int size)
1488 {
1489 return 0;
1490 }
1491
1492 static inline int security_socket_recvmsg(struct socket *sock,
1493 struct msghdr *msg, int size,
1494 int flags)
1495 {
1496 return 0;
1497 }
1498
1499 static inline int security_socket_getsockname(struct socket *sock)
1500 {
1501 return 0;
1502 }
1503
1504 static inline int security_socket_getpeername(struct socket *sock)
1505 {
1506 return 0;
1507 }
1508
1509 static inline int security_socket_getsockopt(struct socket *sock,
1510 int level, int optname)
1511 {
1512 return 0;
1513 }
1514
1515 static inline int security_socket_setsockopt(struct socket *sock,
1516 int level, int optname)
1517 {
1518 return 0;
1519 }
1520
1521 static inline int security_socket_shutdown(struct socket *sock, int how)
1522 {
1523 return 0;
1524 }
1525 static inline int security_sock_rcv_skb(struct sock *sk,
1526 struct sk_buff *skb)
1527 {
1528 return 0;
1529 }
1530
1531 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
1532 int __user *optlen, unsigned len)
1533 {
1534 return -ENOPROTOOPT;
1535 }
1536
1537 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
1538 {
1539 return -ENOPROTOOPT;
1540 }
1541
1542 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
1543 {
1544 return 0;
1545 }
1546
1547 static inline void security_sk_free(struct sock *sk)
1548 {
1549 }
1550
1551 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
1552 {
1553 }
1554
1555 static inline void security_sk_classify_flow(struct sock *sk,
1556 struct flowi_common *flic)
1557 {
1558 }
1559
1560 static inline void security_req_classify_flow(const struct request_sock *req,
1561 struct flowi_common *flic)
1562 {
1563 }
1564
1565 static inline void security_sock_graft(struct sock *sk, struct socket *parent)
1566 {
1567 }
1568
1569 static inline int security_inet_conn_request(const struct sock *sk,
1570 struct sk_buff *skb, struct request_sock *req)
1571 {
1572 return 0;
1573 }
1574
1575 static inline void security_inet_csk_clone(struct sock *newsk,
1576 const struct request_sock *req)
1577 {
1578 }
1579
1580 static inline void security_inet_conn_established(struct sock *sk,
1581 struct sk_buff *skb)
1582 {
1583 }
1584
1585 static inline int security_secmark_relabel_packet(u32 secid)
1586 {
1587 return 0;
1588 }
1589
1590 static inline void security_secmark_refcount_inc(void)
1591 {
1592 }
1593
1594 static inline void security_secmark_refcount_dec(void)
1595 {
1596 }
1597
1598 static inline int security_tun_dev_alloc_security(void **security)
1599 {
1600 return 0;
1601 }
1602
1603 static inline void security_tun_dev_free_security(void *security)
1604 {
1605 }
1606
1607 static inline int security_tun_dev_create(void)
1608 {
1609 return 0;
1610 }
1611
1612 static inline int security_tun_dev_attach_queue(void *security)
1613 {
1614 return 0;
1615 }
1616
1617 static inline int security_tun_dev_attach(struct sock *sk, void *security)
1618 {
1619 return 0;
1620 }
1621
1622 static inline int security_tun_dev_open(void *security)
1623 {
1624 return 0;
1625 }
1626
1627 static inline int security_sctp_assoc_request(struct sctp_endpoint *ep,
1628 struct sk_buff *skb)
1629 {
1630 return 0;
1631 }
1632
1633 static inline int security_sctp_bind_connect(struct sock *sk, int optname,
1634 struct sockaddr *address,
1635 int addrlen)
1636 {
1637 return 0;
1638 }
1639
1640 static inline void security_sctp_sk_clone(struct sctp_endpoint *ep,
1641 struct sock *sk,
1642 struct sock *newsk)
1643 {
1644 }
1645 #endif /* CONFIG_SECURITY_NETWORK */
1646
1647 #ifdef CONFIG_SECURITY_INFINIBAND
1648 int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey);
1649 int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num);
1650 int security_ib_alloc_security(void **sec);
1651 void security_ib_free_security(void *sec);
1652 #else /* CONFIG_SECURITY_INFINIBAND */
1653 static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey)
1654 {
1655 return 0;
1656 }
1657
1658 static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num)
1659 {
1660 return 0;
1661 }
1662
1663 static inline int security_ib_alloc_security(void **sec)
1664 {
1665 return 0;
1666 }
1667
1668 static inline void security_ib_free_security(void *sec)
1669 {
1670 }
1671 #endif /* CONFIG_SECURITY_INFINIBAND */
1672
1673 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1674
1675 int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1676 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
1677 int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
1678 void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
1679 int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
1680 int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1681 int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1682 struct xfrm_sec_ctx *polsec, u32 secid);
1683 int security_xfrm_state_delete(struct xfrm_state *x);
1684 void security_xfrm_state_free(struct xfrm_state *x);
1685 int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid);
1686 int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1687 struct xfrm_policy *xp,
1688 const struct flowi_common *flic);
1689 int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
1690 void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic);
1691
1692 #else /* CONFIG_SECURITY_NETWORK_XFRM */
1693
1694 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1695 struct xfrm_user_sec_ctx *sec_ctx,
1696 gfp_t gfp)
1697 {
1698 return 0;
1699 }
1700
1701 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
1702 {
1703 return 0;
1704 }
1705
1706 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
1707 {
1708 }
1709
1710 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
1711 {
1712 return 0;
1713 }
1714
1715 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
1716 struct xfrm_user_sec_ctx *sec_ctx)
1717 {
1718 return 0;
1719 }
1720
1721 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1722 struct xfrm_sec_ctx *polsec, u32 secid)
1723 {
1724 return 0;
1725 }
1726
1727 static inline void security_xfrm_state_free(struct xfrm_state *x)
1728 {
1729 }
1730
1731 static inline int security_xfrm_state_delete(struct xfrm_state *x)
1732 {
1733 return 0;
1734 }
1735
1736 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
1737 {
1738 return 0;
1739 }
1740
1741 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
1742 struct xfrm_policy *xp,
1743 const struct flowi_common *flic)
1744 {
1745 return 1;
1746 }
1747
1748 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
1749 {
1750 return 0;
1751 }
1752
1753 static inline void security_skb_classify_flow(struct sk_buff *skb,
1754 struct flowi_common *flic)
1755 {
1756 }
1757
1758 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1759
1760 #ifdef CONFIG_SECURITY_PATH
1761 int security_path_unlink(const struct path *dir, struct dentry *dentry);
1762 int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
1763 int security_path_rmdir(const struct path *dir, struct dentry *dentry);
1764 int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
1765 unsigned int dev);
1766 int security_path_truncate(const struct path *path);
1767 int security_path_symlink(const struct path *dir, struct dentry *dentry,
1768 const char *old_name);
1769 int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
1770 struct dentry *new_dentry);
1771 int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
1772 const struct path *new_dir, struct dentry *new_dentry,
1773 unsigned int flags);
1774 int security_path_chmod(const struct path *path, umode_t mode);
1775 int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
1776 int security_path_chroot(const struct path *path);
1777 #else /* CONFIG_SECURITY_PATH */
1778 static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
1779 {
1780 return 0;
1781 }
1782
1783 static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
1784 umode_t mode)
1785 {
1786 return 0;
1787 }
1788
1789 static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
1790 {
1791 return 0;
1792 }
1793
1794 static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
1795 umode_t mode, unsigned int dev)
1796 {
1797 return 0;
1798 }
1799
1800 static inline int security_path_truncate(const struct path *path)
1801 {
1802 return 0;
1803 }
1804
1805 static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
1806 const char *old_name)
1807 {
1808 return 0;
1809 }
1810
1811 static inline int security_path_link(struct dentry *old_dentry,
1812 const struct path *new_dir,
1813 struct dentry *new_dentry)
1814 {
1815 return 0;
1816 }
1817
1818 static inline int security_path_rename(const struct path *old_dir,
1819 struct dentry *old_dentry,
1820 const struct path *new_dir,
1821 struct dentry *new_dentry,
1822 unsigned int flags)
1823 {
1824 return 0;
1825 }
1826
1827 static inline int security_path_chmod(const struct path *path, umode_t mode)
1828 {
1829 return 0;
1830 }
1831
1832 static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
1833 {
1834 return 0;
1835 }
1836
1837 static inline int security_path_chroot(const struct path *path)
1838 {
1839 return 0;
1840 }
1841 #endif /* CONFIG_SECURITY_PATH */
1842
1843 #ifdef CONFIG_KEYS
1844 #ifdef CONFIG_SECURITY
1845
1846 int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
1847 void security_key_free(struct key *key);
1848 int security_key_permission(key_ref_t key_ref, const struct cred *cred,
1849 enum key_need_perm need_perm);
1850 int security_key_getsecurity(struct key *key, char **_buffer);
1851
1852 #else
1853
1854 static inline int security_key_alloc(struct key *key,
1855 const struct cred *cred,
1856 unsigned long flags)
1857 {
1858 return 0;
1859 }
1860
1861 static inline void security_key_free(struct key *key)
1862 {
1863 }
1864
1865 static inline int security_key_permission(key_ref_t key_ref,
1866 const struct cred *cred,
1867 enum key_need_perm need_perm)
1868 {
1869 return 0;
1870 }
1871
1872 static inline int security_key_getsecurity(struct key *key, char **_buffer)
1873 {
1874 *_buffer = NULL;
1875 return 0;
1876 }
1877
1878 #endif
1879 #endif /* CONFIG_KEYS */
1880
1881 #ifdef CONFIG_AUDIT
1882 #ifdef CONFIG_SECURITY
1883 int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
1884 int security_audit_rule_known(struct audit_krule *krule);
1885 int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule);
1886 void security_audit_rule_free(void *lsmrule);
1887
1888 #else
1889
1890 static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
1891 void **lsmrule)
1892 {
1893 return 0;
1894 }
1895
1896 static inline int security_audit_rule_known(struct audit_krule *krule)
1897 {
1898 return 0;
1899 }
1900
1901 static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
1902 void *lsmrule)
1903 {
1904 return 0;
1905 }
1906
1907 static inline void security_audit_rule_free(void *lsmrule)
1908 { }
1909
1910 #endif /* CONFIG_SECURITY */
1911 #endif /* CONFIG_AUDIT */
1912
1913 #ifdef CONFIG_SECURITYFS
1914
1915 extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
1916 struct dentry *parent, void *data,
1917 const struct file_operations *fops);
1918 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1919 struct dentry *securityfs_create_symlink(const char *name,
1920 struct dentry *parent,
1921 const char *target,
1922 const struct inode_operations *iops);
1923 extern void securityfs_remove(struct dentry *dentry);
1924
1925 #else /* CONFIG_SECURITYFS */
1926
1927 static inline struct dentry *securityfs_create_dir(const char *name,
1928 struct dentry *parent)
1929 {
1930 return ERR_PTR(-ENODEV);
1931 }
1932
1933 static inline struct dentry *securityfs_create_file(const char *name,
1934 umode_t mode,
1935 struct dentry *parent,
1936 void *data,
1937 const struct file_operations *fops)
1938 {
1939 return ERR_PTR(-ENODEV);
1940 }
1941
1942 static inline struct dentry *securityfs_create_symlink(const char *name,
1943 struct dentry *parent,
1944 const char *target,
1945 const struct inode_operations *iops)
1946 {
1947 return ERR_PTR(-ENODEV);
1948 }
1949
1950 static inline void securityfs_remove(struct dentry *dentry)
1951 {}
1952
1953 #endif
1954
1955 #ifdef CONFIG_BPF_SYSCALL
1956 union bpf_attr;
1957 struct bpf_map;
1958 struct bpf_prog;
1959 struct bpf_prog_aux;
1960 #ifdef CONFIG_SECURITY
1961 extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size);
1962 extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
1963 extern int security_bpf_prog(struct bpf_prog *prog);
1964 extern int security_bpf_map_alloc(struct bpf_map *map);
1965 extern void security_bpf_map_free(struct bpf_map *map);
1966 extern int security_bpf_prog_alloc(struct bpf_prog_aux *aux);
1967 extern void security_bpf_prog_free(struct bpf_prog_aux *aux);
1968 #else
1969 static inline int security_bpf(int cmd, union bpf_attr *attr,
1970 unsigned int size)
1971 {
1972 return 0;
1973 }
1974
1975 static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode)
1976 {
1977 return 0;
1978 }
1979
1980 static inline int security_bpf_prog(struct bpf_prog *prog)
1981 {
1982 return 0;
1983 }
1984
1985 static inline int security_bpf_map_alloc(struct bpf_map *map)
1986 {
1987 return 0;
1988 }
1989
1990 static inline void security_bpf_map_free(struct bpf_map *map)
1991 { }
1992
1993 static inline int security_bpf_prog_alloc(struct bpf_prog_aux *aux)
1994 {
1995 return 0;
1996 }
1997
1998 static inline void security_bpf_prog_free(struct bpf_prog_aux *aux)
1999 { }
2000 #endif /* CONFIG_SECURITY */
2001 #endif /* CONFIG_BPF_SYSCALL */
2002
2003 #ifdef CONFIG_PERF_EVENTS
2004 struct perf_event_attr;
2005 struct perf_event;
2006
2007 #ifdef CONFIG_SECURITY
2008 extern int security_perf_event_open(struct perf_event_attr *attr, int type);
2009 extern int security_perf_event_alloc(struct perf_event *event);
2010 extern void security_perf_event_free(struct perf_event *event);
2011 extern int security_perf_event_read(struct perf_event *event);
2012 extern int security_perf_event_write(struct perf_event *event);
2013 #else
2014 static inline int security_perf_event_open(struct perf_event_attr *attr,
2015 int type)
2016 {
2017 return 0;
2018 }
2019
2020 static inline int security_perf_event_alloc(struct perf_event *event)
2021 {
2022 return 0;
2023 }
2024
2025 static inline void security_perf_event_free(struct perf_event *event)
2026 {
2027 }
2028
2029 static inline int security_perf_event_read(struct perf_event *event)
2030 {
2031 return 0;
2032 }
2033
2034 static inline int security_perf_event_write(struct perf_event *event)
2035 {
2036 return 0;
2037 }
2038 #endif /* CONFIG_SECURITY */
2039 #endif /* CONFIG_PERF_EVENTS */
2040
2041 #endif /* ! __LINUX_SECURITY_H */