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