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