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