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