blob: cd93fa5d3c6d34f6aac5f0b7dde849e1ad4a1865 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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)
Daniel Jurgensd291f1a2017-05-19 15:48:52 +03009 * Copyright (C) 2016 Mellanox Techonologies
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
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
David Howells29db9192005-10-30 15:02:44 -080026#include <linux/key.h>
Al Viro40401532012-02-13 03:58:52 +000027#include <linux/capability.h>
Mimi Zoharcf222212016-01-14 17:57:47 -050028#include <linux/fs.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090029#include <linux/slab.h>
Al Viro40401532012-02-13 03:58:52 +000030#include <linux/err.h>
David Quigleyd47be3d2013-05-22 12:50:34 -040031#include <linux/string.h>
Casey Schauflerb1d9e6b2015-05-02 15:11:42 -070032#include <linux/mm.h>
Mimi Zoharbc8ca5b2016-01-24 10:07:32 -050033#include <linux/fs.h>
Al Viro40401532012-02-13 03:58:52 +000034
35struct linux_binprm;
36struct cred;
37struct rlimit;
Eric W. Biedermanae7795b2018-09-25 11:27:20 +020038struct kernel_siginfo;
Al Viro40401532012-02-13 03:58:52 +000039struct sembuf;
40struct kern_ipc_perm;
41struct audit_context;
42struct super_block;
43struct inode;
44struct dentry;
45struct file;
46struct vfsmount;
47struct path;
48struct qstr;
Al Viro40401532012-02-13 03:58:52 +000049struct iattr;
50struct fown_struct;
51struct file_operations;
Al Viro40401532012-02-13 03:58:52 +000052struct msg_msg;
Al Viro40401532012-02-13 03:58:52 +000053struct xattr;
Ondrej Mosnacekb230d5a2019-02-22 15:57:16 +010054struct kernfs_node;
Al Viro40401532012-02-13 03:58:52 +000055struct xfrm_sec_ctx;
56struct mm_struct;
David Howellsda2441f2018-11-01 23:07:24 +000057struct fs_context;
58struct fs_parameter;
59enum fs_value_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Micah Mortonc1a85a02019-01-07 16:10:53 -080061/* Default (no) options for the capable function */
62#define CAP_OPT_NONE 0x0
Eric Paris06112162008-11-11 22:02:50 +110063/* If capable should audit the security request */
Micah Mortonc1a85a02019-01-07 16:10:53 -080064#define CAP_OPT_NOAUDIT BIT(1)
65/* If capable is being called by a setid function */
66#define CAP_OPT_INSETID BIT(2)
Eric Paris06112162008-11-11 22:02:50 +110067
David Howells846e5662018-11-01 23:07:24 +000068/* LSM Agnostic defines for fs_context::lsm_flags */
David Quigleyeb9ae682013-05-22 12:50:37 -040069#define SECURITY_LSM_NATIVE_LABELS 1
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071struct ctl_table;
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +020072struct audit_krule;
Serge E. Hallyn34867402011-03-23 16:43:17 -070073struct user_namespace;
Al Viro40401532012-02-13 03:58:52 +000074struct timezone;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Daniel Jurgens8f408ab2017-05-19 15:48:53 +030076enum lsm_event {
77 LSM_POLICY_CHANGE,
78};
79
Matthew Garrett9e47d312019-08-19 17:17:38 -070080/*
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.
Matthew Garrett000d3882019-08-19 17:17:39 -0700100 *
101 * If you add to this, remember to extend lockdown_reasons in
102 * security/lockdown/lockdown.c.
Matthew Garrett9e47d312019-08-19 17:17:38 -0700103 */
104enum lockdown_reason {
105 LOCKDOWN_NONE,
David Howells49fcf732019-08-19 17:17:40 -0700106 LOCKDOWN_MODULE_SIGNATURE,
Matthew Garrett9b9d8dd2019-08-19 17:17:41 -0700107 LOCKDOWN_DEV_MEM,
Matthew Garrett7d31f462019-08-19 17:17:42 -0700108 LOCKDOWN_KEXEC,
Josh Boyer38bd94b2019-08-19 17:17:46 -0700109 LOCKDOWN_HIBERNATION,
Matthew Garretteb627e12019-08-19 17:17:47 -0700110 LOCKDOWN_PCI_ACCESS,
Matthew Garrett96c4f672019-08-19 17:17:48 -0700111 LOCKDOWN_IOPORT,
Matthew Garrett9e47d312019-08-19 17:17:38 -0700112 LOCKDOWN_INTEGRITY_MAX,
113 LOCKDOWN_CONFIDENTIALITY_MAX,
114};
115
Casey Schauflerb1d9e6b2015-05-02 15:11:42 -0700116/* These functions are in security/commoncap.c */
Eric Paris6a9de492012-01-03 12:25:14 -0500117extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
Micah Mortonc1a85a02019-01-07 16:10:53 -0800118 int cap, unsigned int opts);
Baolin Wang457db292016-04-08 14:02:11 +0800119extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
Ingo Molnar9e488582009-05-07 19:26:19 +1000120extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
David Howells5cd9c582008-08-14 11:37:28 +0100121extern int cap_ptrace_traceme(struct task_struct *parent);
Eric Paris7b41b172008-04-23 14:10:25 -0400122extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
David Howellsd84f4f92008-11-14 10:39:23 +1100123extern int cap_capset(struct cred *new, const struct cred *old,
124 const kernel_cap_t *effective,
125 const kernel_cap_t *inheritable,
126 const kernel_cap_t *permitted);
David Howellsa6f76f22008-11-14 10:39:24 +1100127extern int cap_bprm_set_creds(struct linux_binprm *bprm);
David Howells8f0cfa52008-04-29 00:59:41 -0700128extern int cap_inode_setxattr(struct dentry *dentry, const char *name,
129 const void *value, size_t size, int flags);
130extern int cap_inode_removexattr(struct dentry *dentry, const char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -0700131extern int cap_inode_need_killpriv(struct dentry *dentry);
132extern int cap_inode_killpriv(struct dentry *dentry);
Serge E. Hallyn8db6c342017-05-08 13:11:56 -0500133extern int cap_inode_getsecurity(struct inode *inode, const char *name,
134 void **buffer, bool alloc);
Al Virod0077942012-05-30 13:11:37 -0400135extern int cap_mmap_addr(unsigned long addr);
Al Viroe5467852012-05-30 13:30:51 -0400136extern int cap_mmap_file(struct file *file, unsigned long reqprot,
137 unsigned long prot, unsigned long flags);
David Howellsd84f4f92008-11-14 10:39:23 +1100138extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
Andrew G. Morgan3898b1b2008-04-28 02:13:40 -0700139extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
David Howellsd84f4f92008-11-14 10:39:23 +1100140 unsigned long arg4, unsigned long arg5);
KOSAKI Motohirob0ae1982010-10-15 04:21:18 +0900141extern int cap_task_setscheduler(struct task_struct *p);
Eric Paris7b41b172008-04-23 14:10:25 -0400142extern int cap_task_setioprio(struct task_struct *p, int ioprio);
143extern int cap_task_setnice(struct task_struct *p, int nice);
James Morris20510f22007-10-16 23:31:32 -0700144extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
146struct msghdr;
147struct sk_buff;
148struct sock;
149struct sockaddr;
150struct socket;
Trent Jaegerdf718372005-12-13 23:12:27 -0800151struct flowi;
152struct dst_entry;
153struct xfrm_selector;
154struct xfrm_policy;
155struct xfrm_state;
156struct xfrm_user_sec_ctx;
Eric Paris2069f452008-07-04 09:47:13 +1000157struct seq_file;
Richard Haines72e89f52018-02-13 20:53:21 +0000158struct sctp_endpoint;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
David Howells6e141542009-12-15 19:27:45 +0000160#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -0400161extern unsigned long mmap_min_addr;
Eric Parisa2551df72009-07-31 12:54:11 -0400162extern unsigned long dac_mmap_min_addr;
David Howells6e141542009-12-15 19:27:45 +0000163#else
Mark Salterbe8cfc42012-09-24 17:17:38 -0700164#define mmap_min_addr 0UL
David Howells6e141542009-12-15 19:27:45 +0000165#define dac_mmap_min_addr 0UL
166#endif
167
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168/*
169 * Values used in the task_security_ops calls
170 */
171/* setuid or setgid, id0 == uid or gid */
172#define LSM_SETID_ID 1
173
174/* setreuid or setregid, id0 == real, id1 == eff */
175#define LSM_SETID_RE 2
176
177/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
178#define LSM_SETID_RES 4
179
180/* setfsuid or setfsgid, id0 == fsuid or fsgid */
181#define LSM_SETID_FS 8
182
Stephen Smalley791ec492017-02-17 07:57:00 -0500183/* Flags for security_task_prlimit(). */
184#define LSM_PRLIMIT_READ 1
185#define LSM_PRLIMIT_WRITE 2
186
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187/* forward declares to avoid warnings */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188struct sched_param;
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700189struct request_sock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
David Howellsa6f76f22008-11-14 10:39:24 +1100191/* bprm->unsafe reasons */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192#define LSM_UNSAFE_SHARE 1
193#define LSM_UNSAFE_PTRACE 2
Eric W. Biederman9227dd22017-01-23 17:26:31 +1300194#define LSM_UNSAFE_NO_NEW_PRIVS 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
David Howells6e141542009-12-15 19:27:45 +0000196#ifdef CONFIG_MMU
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700197extern int mmap_min_addr_handler(struct ctl_table *table, int write,
Eric Paris47d439e2009-08-07 14:53:57 -0400198 void __user *buffer, size_t *lenp, loff_t *ppos);
David Howells6e141542009-12-15 19:27:45 +0000199#endif
Eric Paris47d439e2009-08-07 14:53:57 -0400200
Mimi Zohar9d8f13b2011-06-06 15:29:25 -0400201/* security_inode_init_security callback function to write xattrs */
202typedef int (*initxattrs) (struct inode *inode,
203 const struct xattr *xattr_array, void *fs_data);
204
Mimi Zohar377179c2018-07-13 14:05:56 -0400205
206/* Keep the kernel_load_data_id enum in sync with kernel_read_file_id */
207#define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM,
208#define __data_id_stringify(dummy, str) #str,
209
210enum kernel_load_data_id {
211 __kernel_read_file_id(__data_id_enumify)
212};
213
214static const char * const kernel_load_data_str[] = {
215 __kernel_read_file_id(__data_id_stringify)
216};
217
218static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
219{
220 if ((unsigned)id >= LOADING_MAX_ID)
221 return kernel_load_data_str[LOADING_UNKNOWN];
222
223 return kernel_load_data_str[id];
224}
225
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226#ifdef CONFIG_SECURITY
227
Daniel Jurgens8f408ab2017-05-19 15:48:53 +0300228int call_lsm_notifier(enum lsm_event event, void *data);
229int register_lsm_notifier(struct notifier_block *nb);
230int unregister_lsm_notifier(struct notifier_block *nb);
231
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232/* prototypes */
Eric Paris7b41b172008-04-23 14:10:25 -0400233extern int security_init(void);
Matthew Garrette6b1db92019-08-19 17:17:37 -0700234extern int early_security_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
James Morris20510f22007-10-16 23:31:32 -0700236/* Security operations */
Stephen Smalley79af7302015-01-21 10:54:10 -0500237int security_binder_set_context_mgr(struct task_struct *mgr);
238int security_binder_transaction(struct task_struct *from,
239 struct task_struct *to);
240int security_binder_transfer_binder(struct task_struct *from,
241 struct task_struct *to);
242int security_binder_transfer_file(struct task_struct *from,
243 struct task_struct *to, struct file *file);
Ingo Molnar9e488582009-05-07 19:26:19 +1000244int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
David Howells5cd9c582008-08-14 11:37:28 +0100245int security_ptrace_traceme(struct task_struct *parent);
James Morris20510f22007-10-16 23:31:32 -0700246int security_capget(struct task_struct *target,
Eric Paris7b41b172008-04-23 14:10:25 -0400247 kernel_cap_t *effective,
248 kernel_cap_t *inheritable,
249 kernel_cap_t *permitted);
David Howellsd84f4f92008-11-14 10:39:23 +1100250int security_capset(struct cred *new, const struct cred *old,
251 const kernel_cap_t *effective,
252 const kernel_cap_t *inheritable,
253 const kernel_cap_t *permitted);
Micah Mortonc1a85a02019-01-07 16:10:53 -0800254int security_capable(const struct cred *cred,
255 struct user_namespace *ns,
256 int cap,
257 unsigned int opts);
James Morris20510f22007-10-16 23:31:32 -0700258int security_quotactl(int cmds, int type, int id, struct super_block *sb);
259int security_quota_on(struct dentry *dentry);
Eric Paris12b30522010-11-15 18:36:29 -0500260int security_syslog(int type);
Baolin Wang457db292016-04-08 14:02:11 +0800261int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
James Morris20510f22007-10-16 23:31:32 -0700262int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
David Howellsa6f76f22008-11-14 10:39:24 +1100263int security_bprm_set_creds(struct linux_binprm *bprm);
James Morris20510f22007-10-16 23:31:32 -0700264int security_bprm_check(struct linux_binprm *bprm);
David Howellsa6f76f22008-11-14 10:39:24 +1100265void security_bprm_committing_creds(struct linux_binprm *bprm);
266void security_bprm_committed_creds(struct linux_binprm *bprm);
Al Viro0b520752018-12-23 16:02:47 -0500267int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc);
David Howellsda2441f2018-11-01 23:07:24 +0000268int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
James Morris20510f22007-10-16 23:31:32 -0700269int security_sb_alloc(struct super_block *sb);
270void security_sb_free(struct super_block *sb);
Al Viro204cc0c2018-12-13 13:41:47 -0500271void security_free_mnt_opts(void **mnt_opts);
272int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
273int security_sb_remount(struct super_block *sb, void *mnt_opts);
Al Viroa10d7c22018-12-05 11:58:35 -0500274int security_sb_kern_mount(struct super_block *sb);
Eric Paris2069f452008-07-04 09:47:13 +1000275int security_sb_show_options(struct seq_file *m, struct super_block *sb);
James Morris20510f22007-10-16 23:31:32 -0700276int security_sb_statfs(struct dentry *dentry);
Al Viro8a04c432016-03-25 14:52:53 -0400277int security_sb_mount(const char *dev_name, const struct path *path,
Al Viro808d4e32012-10-11 11:42:01 -0400278 const char *type, unsigned long flags, void *data);
James Morris20510f22007-10-16 23:31:32 -0700279int security_sb_umount(struct vfsmount *mnt, int flags);
Al Viro3b73b682016-03-25 15:31:19 -0400280int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
David Quigley649f6e72013-05-22 12:50:36 -0400281int security_sb_set_mnt_opts(struct super_block *sb,
Al Viro204cc0c2018-12-13 13:41:47 -0500282 void *mnt_opts,
David Quigley649f6e72013-05-22 12:50:36 -0400283 unsigned long kern_flags,
284 unsigned long *set_kern_flags);
Jeff Layton094f7b62013-04-01 08:14:24 -0400285int security_sb_clone_mnt_opts(const struct super_block *oldsb,
Scott Mayhew0b4d3452017-06-05 11:45:04 -0400286 struct super_block *newsb,
287 unsigned long kern_flags,
288 unsigned long *set_kern_flags);
Al Viro757cbe52018-12-14 23:42:21 -0500289int security_add_mnt_opt(const char *option, const char *val,
290 int len, void **mnt_opts);
David Howells2db154b2018-11-05 17:40:30 +0000291int security_move_mount(const struct path *from_path, const struct path *to_path);
David Quigleyd47be3d2013-05-22 12:50:34 -0400292int security_dentry_init_security(struct dentry *dentry, int mode,
Al Viro4f3ccd72016-07-20 16:06:15 -0400293 const struct qstr *name, void **ctx,
David Quigleyd47be3d2013-05-22 12:50:34 -0400294 u32 *ctxlen);
Vivek Goyal26026252016-07-13 10:44:52 -0400295int security_dentry_create_files_as(struct dentry *dentry, int mode,
296 struct qstr *name,
297 const struct cred *old,
298 struct cred *new);
Eric Parisc9180a52007-11-30 13:00:35 -0500299
James Morris20510f22007-10-16 23:31:32 -0700300int security_inode_alloc(struct inode *inode);
301void security_inode_free(struct inode *inode);
302int security_inode_init_security(struct inode *inode, struct inode *dir,
Mimi Zohar9d8f13b2011-06-06 15:29:25 -0400303 const struct qstr *qstr,
304 initxattrs initxattrs, void *fs_data);
305int security_old_inode_init_security(struct inode *inode, struct inode *dir,
Tetsuo Handa95489062013-07-25 05:44:02 +0900306 const struct qstr *qstr, const char **name,
Mimi Zohar9d8f13b2011-06-06 15:29:25 -0400307 void **value, size_t *len);
Al Viro4acdaf22011-07-26 01:42:34 -0400308int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
James Morris20510f22007-10-16 23:31:32 -0700309int security_inode_link(struct dentry *old_dentry, struct inode *dir,
310 struct dentry *new_dentry);
311int security_inode_unlink(struct inode *dir, struct dentry *dentry);
312int security_inode_symlink(struct inode *dir, struct dentry *dentry,
Eric Paris7b41b172008-04-23 14:10:25 -0400313 const char *old_name);
Al Viro18bb1db2011-07-26 01:41:39 -0400314int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
James Morris20510f22007-10-16 23:31:32 -0700315int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
Al Viro1a67aaf2011-07-26 01:52:52 -0400316int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
James Morris20510f22007-10-16 23:31:32 -0700317int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
Miklos Szeredi0b3974e2014-04-01 17:08:43 +0200318 struct inode *new_dir, struct dentry *new_dentry,
319 unsigned int flags);
James Morris20510f22007-10-16 23:31:32 -0700320int security_inode_readlink(struct dentry *dentry);
NeilBrownbda0be72015-03-23 13:37:39 +1100321int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
322 bool rcu);
Al Virob77b0642008-07-17 09:37:02 -0400323int security_inode_permission(struct inode *inode, int mask);
James Morris20510f22007-10-16 23:31:32 -0700324int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
Al Viro3f7036a2015-03-08 19:28:30 -0400325int security_inode_getattr(const struct path *path);
David Howells8f0cfa52008-04-29 00:59:41 -0700326int security_inode_setxattr(struct dentry *dentry, const char *name,
327 const void *value, size_t size, int flags);
328void security_inode_post_setxattr(struct dentry *dentry, const char *name,
329 const void *value, size_t size, int flags);
330int security_inode_getxattr(struct dentry *dentry, const char *name);
James Morris20510f22007-10-16 23:31:32 -0700331int security_inode_listxattr(struct dentry *dentry);
David Howells8f0cfa52008-04-29 00:59:41 -0700332int security_inode_removexattr(struct dentry *dentry, const char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -0700333int security_inode_need_killpriv(struct dentry *dentry);
334int security_inode_killpriv(struct dentry *dentry);
Andreas Gruenbacherea861df2015-12-24 11:09:39 -0500335int security_inode_getsecurity(struct inode *inode, const char *name, void **buffer, bool alloc);
James Morris20510f22007-10-16 23:31:32 -0700336int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
337int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
Andreas Gruenbacherd6335d72015-12-24 11:09:39 -0500338void security_inode_getsecid(struct inode *inode, u32 *secid);
Vivek Goyald8ad8b42016-07-13 11:13:56 -0400339int security_inode_copy_up(struct dentry *src, struct cred **new);
Vivek Goyal121ab822016-07-13 10:44:49 -0400340int security_inode_copy_up_xattr(const char *name);
Ondrej Mosnacekb230d5a2019-02-22 15:57:16 +0100341int security_kernfs_init_security(struct kernfs_node *kn_dir,
342 struct kernfs_node *kn);
James Morris20510f22007-10-16 23:31:32 -0700343int security_file_permission(struct file *file, int mask);
344int security_file_alloc(struct file *file);
345void security_file_free(struct file *file);
346int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
Al Viro8b3ec682012-05-30 17:11:23 -0400347int security_mmap_file(struct file *file, unsigned long prot,
348 unsigned long flags);
Al Viroe5467852012-05-30 13:30:51 -0400349int security_mmap_addr(unsigned long addr);
James Morris20510f22007-10-16 23:31:32 -0700350int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
Eric Paris7b41b172008-04-23 14:10:25 -0400351 unsigned long prot);
James Morris20510f22007-10-16 23:31:32 -0700352int security_file_lock(struct file *file, unsigned int cmd);
353int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
Jeff Laytone0b93ed2014-08-22 11:27:32 -0400354void security_file_set_fowner(struct file *file);
James Morris20510f22007-10-16 23:31:32 -0700355int security_file_send_sigiotask(struct task_struct *tsk,
Eric Paris7b41b172008-04-23 14:10:25 -0400356 struct fown_struct *fown, int sig);
James Morris20510f22007-10-16 23:31:32 -0700357int security_file_receive(struct file *file);
Al Viroe3f20ae2018-07-10 13:25:29 -0400358int security_file_open(struct file *file);
Tetsuo Handae4e55b42017-03-24 20:46:33 +0900359int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
Kees Cook1a2a4d02011-12-21 12:17:03 -0800360void security_task_free(struct task_struct *task);
David Howellsee18d642009-09-02 09:14:21 +0100361int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
David Howellsf1752ee2008-11-14 10:39:17 +1100362void security_cred_free(struct cred *cred);
David Howellsd84f4f92008-11-14 10:39:23 +1100363int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
David Howellsee18d642009-09-02 09:14:21 +0100364void security_transfer_creds(struct cred *new, const struct cred *old);
Matthew Garrett3ec30112018-01-08 13:36:19 -0800365void security_cred_getsecid(const struct cred *c, u32 *secid);
David Howells3a3b7ce2008-11-14 10:39:28 +1100366int security_kernel_act_as(struct cred *new, u32 secid);
367int security_kernel_create_files_as(struct cred *new, struct inode *inode);
Eric Parisdd8dbf22009-11-03 16:35:32 +1100368int security_kernel_module_request(char *kmod_name);
Mimi Zohar377179c2018-07-13 14:05:56 -0400369int security_kernel_load_data(enum kernel_load_data_id id);
Mimi Zohar39eeb4f2016-01-30 22:23:26 -0500370int security_kernel_read_file(struct file *file, enum kernel_read_file_id id);
Mimi Zoharbc8ca5b2016-01-24 10:07:32 -0500371int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
372 enum kernel_read_file_id id);
David Howellsd84f4f92008-11-14 10:39:23 +1100373int security_task_fix_setuid(struct cred *new, const struct cred *old,
374 int flags);
James Morris20510f22007-10-16 23:31:32 -0700375int security_task_setpgid(struct task_struct *p, pid_t pgid);
376int security_task_getpgid(struct task_struct *p);
377int security_task_getsid(struct task_struct *p);
378void security_task_getsecid(struct task_struct *p, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -0700379int security_task_setnice(struct task_struct *p, int nice);
380int security_task_setioprio(struct task_struct *p, int ioprio);
381int security_task_getioprio(struct task_struct *p);
Stephen Smalley791ec492017-02-17 07:57:00 -0500382int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
383 unsigned int flags);
Jiri Slaby8fd00b42009-08-26 18:41:16 +0200384int security_task_setrlimit(struct task_struct *p, unsigned int resource,
385 struct rlimit *new_rlim);
KOSAKI Motohirob0ae1982010-10-15 04:21:18 +0900386int security_task_setscheduler(struct task_struct *p);
James Morris20510f22007-10-16 23:31:32 -0700387int security_task_getscheduler(struct task_struct *p);
388int security_task_movememory(struct task_struct *p);
Eric W. Biedermanae7795b2018-09-25 11:27:20 +0200389int security_task_kill(struct task_struct *p, struct kernel_siginfo *info,
Stephen Smalley6b4f3d02017-09-08 12:40:01 -0400390 int sig, const struct cred *cred);
James Morris20510f22007-10-16 23:31:32 -0700391int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
David Howellsd84f4f92008-11-14 10:39:23 +1100392 unsigned long arg4, unsigned long arg5);
James Morris20510f22007-10-16 23:31:32 -0700393void security_task_to_inode(struct task_struct *p, struct inode *inode);
394int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
Ahmed S. Darwish8a076192008-03-01 21:51:09 +0200395void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -0700396int security_msg_msg_alloc(struct msg_msg *msg);
397void security_msg_msg_free(struct msg_msg *msg);
Eric W. Biedermand8c6e852018-03-22 21:22:26 -0500398int security_msg_queue_alloc(struct kern_ipc_perm *msq);
399void security_msg_queue_free(struct kern_ipc_perm *msq);
400int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg);
401int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd);
402int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
Eric Paris7b41b172008-04-23 14:10:25 -0400403 struct msg_msg *msg, int msqflg);
Eric W. Biedermand8c6e852018-03-22 21:22:26 -0500404int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg,
Eric Paris7b41b172008-04-23 14:10:25 -0400405 struct task_struct *target, long type, int mode);
Eric W. Biederman7191adf2018-03-22 21:08:27 -0500406int security_shm_alloc(struct kern_ipc_perm *shp);
407void security_shm_free(struct kern_ipc_perm *shp);
408int security_shm_associate(struct kern_ipc_perm *shp, int shmflg);
409int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd);
410int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg);
Eric W. Biedermanaefad952018-03-22 20:52:43 -0500411int security_sem_alloc(struct kern_ipc_perm *sma);
412void security_sem_free(struct kern_ipc_perm *sma);
413int security_sem_associate(struct kern_ipc_perm *sma, int semflg);
414int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
415int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
James Morris20510f22007-10-16 23:31:32 -0700416 unsigned nsops, int alter);
Eric Paris7b41b172008-04-23 14:10:25 -0400417void security_d_instantiate(struct dentry *dentry, struct inode *inode);
Casey Schaufler6d9c9392018-09-21 17:16:59 -0700418int security_getprocattr(struct task_struct *p, const char *lsm, char *name,
419 char **value);
420int security_setprocattr(const char *lsm, const char *name, void *value,
421 size_t size);
James Morris20510f22007-10-16 23:31:32 -0700422int security_netlink_send(struct sock *sk, struct sk_buff *skb);
David Quigley746df9b2013-05-22 12:50:35 -0400423int security_ismaclabel(const char *name);
James Morris20510f22007-10-16 23:31:32 -0700424int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
David Howells7bf570d2008-04-29 20:52:51 +0100425int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -0700426void security_release_secctx(char *secdata, u32 seclen);
427
Andreas Gruenbacher6f3be9f2015-12-24 11:09:40 -0500428void security_inode_invalidate_secctx(struct inode *inode);
David P. Quigley1ee65e32009-09-03 14:25:57 -0400429int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
430int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
431int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
Matthew Garrett9e47d312019-08-19 17:17:38 -0700432int security_locked_down(enum lockdown_reason what);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433#else /* CONFIG_SECURITY */
Eric Parise0007522008-03-05 10:31:54 -0500434
Daniel Jurgens8f408ab2017-05-19 15:48:53 +0300435static inline int call_lsm_notifier(enum lsm_event event, void *data)
436{
437 return 0;
438}
439
440static inline int register_lsm_notifier(struct notifier_block *nb)
441{
442 return 0;
443}
444
445static inline int unregister_lsm_notifier(struct notifier_block *nb)
446{
447 return 0;
448}
449
Al Viro204cc0c2018-12-13 13:41:47 -0500450static inline void security_free_mnt_opts(void **mnt_opts)
Eric Parise0007522008-03-05 10:31:54 -0500451{
452}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453
454/*
455 * This is the default capabilities functionality. Most of these functions
456 * are just stubbed out, but a few must call the proper capable code.
457 */
458
459static inline int security_init(void)
460{
461 return 0;
462}
463
Matthew Garrette6b1db92019-08-19 17:17:37 -0700464static inline int early_security_init(void)
465{
466 return 0;
467}
468
Stephen Smalley79af7302015-01-21 10:54:10 -0500469static inline int security_binder_set_context_mgr(struct task_struct *mgr)
470{
471 return 0;
472}
473
474static inline int security_binder_transaction(struct task_struct *from,
475 struct task_struct *to)
476{
477 return 0;
478}
479
480static inline int security_binder_transfer_binder(struct task_struct *from,
481 struct task_struct *to)
482{
483 return 0;
484}
485
486static inline int security_binder_transfer_file(struct task_struct *from,
487 struct task_struct *to,
488 struct file *file)
489{
490 return 0;
491}
492
Ingo Molnar9e488582009-05-07 19:26:19 +1000493static inline int security_ptrace_access_check(struct task_struct *child,
David Howells5cd9c582008-08-14 11:37:28 +0100494 unsigned int mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495{
Ingo Molnar9e488582009-05-07 19:26:19 +1000496 return cap_ptrace_access_check(child, mode);
David Howells5cd9c582008-08-14 11:37:28 +0100497}
498
Alexander Beregalov5e186b52008-08-17 05:34:20 +0400499static inline int security_ptrace_traceme(struct task_struct *parent)
David Howells5cd9c582008-08-14 11:37:28 +0100500{
501 return cap_ptrace_traceme(parent);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502}
503
Eric Paris7b41b172008-04-23 14:10:25 -0400504static inline int security_capget(struct task_struct *target,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 kernel_cap_t *effective,
506 kernel_cap_t *inheritable,
507 kernel_cap_t *permitted)
508{
Eric Paris7b41b172008-04-23 14:10:25 -0400509 return cap_capget(target, effective, inheritable, permitted);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510}
511
David Howellsd84f4f92008-11-14 10:39:23 +1100512static inline int security_capset(struct cred *new,
513 const struct cred *old,
514 const kernel_cap_t *effective,
515 const kernel_cap_t *inheritable,
516 const kernel_cap_t *permitted)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517{
David Howellsd84f4f92008-11-14 10:39:23 +1100518 return cap_capset(new, old, effective, inheritable, permitted);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519}
520
Eric Parisb7e724d2012-01-03 12:25:15 -0500521static inline int security_capable(const struct cred *cred,
Micah Mortonc1a85a02019-01-07 16:10:53 -0800522 struct user_namespace *ns,
523 int cap,
524 unsigned int opts)
Chris Wright12b59892006-03-25 03:07:41 -0800525{
Micah Mortonc1a85a02019-01-07 16:10:53 -0800526 return cap_capable(cred, ns, cap, opts);
Chris Wright12b59892006-03-25 03:07:41 -0800527}
528
Eric Paris7b41b172008-04-23 14:10:25 -0400529static inline int security_quotactl(int cmds, int type, int id,
530 struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531{
532 return 0;
533}
534
Eric Paris7b41b172008-04-23 14:10:25 -0400535static inline int security_quota_on(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536{
537 return 0;
538}
539
Eric Paris12b30522010-11-15 18:36:29 -0500540static inline int security_syslog(int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541{
Eric Paris12b30522010-11-15 18:36:29 -0500542 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543}
544
Baolin Wang457db292016-04-08 14:02:11 +0800545static inline int security_settime64(const struct timespec64 *ts,
546 const struct timezone *tz)
547{
548 return cap_settime(ts, tz);
549}
550
Alan Cox34b4e4a2007-08-22 14:01:28 -0700551static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
552{
Casey Schauflerb1d9e6b2015-05-02 15:11:42 -0700553 return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554}
555
David Howellsa6f76f22008-11-14 10:39:24 +1100556static inline int security_bprm_set_creds(struct linux_binprm *bprm)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557{
David Howellsa6f76f22008-11-14 10:39:24 +1100558 return cap_bprm_set_creds(bprm);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559}
560
Eric Paris7b41b172008-04-23 14:10:25 -0400561static inline int security_bprm_check(struct linux_binprm *bprm)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562{
563 return 0;
564}
565
David Howellsa6f76f22008-11-14 10:39:24 +1100566static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
567{
568}
569
570static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
571{
572}
573
Al Viro0b520752018-12-23 16:02:47 -0500574static inline int security_fs_context_dup(struct fs_context *fc,
575 struct fs_context *src_fc)
576{
577 return 0;
578}
David Howellsda2441f2018-11-01 23:07:24 +0000579static inline int security_fs_context_parse_param(struct fs_context *fc,
580 struct fs_parameter *param)
581{
582 return -ENOPARAM;
583}
584
Eric Paris7b41b172008-04-23 14:10:25 -0400585static inline int security_sb_alloc(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586{
587 return 0;
588}
589
Eric Paris7b41b172008-04-23 14:10:25 -0400590static inline void security_sb_free(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591{ }
592
Al Virof5c0c262018-11-17 12:09:18 -0500593static inline int security_sb_eat_lsm_opts(char *options,
Al Viro204cc0c2018-12-13 13:41:47 -0500594 void **mnt_opts)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595{
596 return 0;
597}
598
Al Viroc039bc32018-12-01 23:06:57 -0500599static inline int security_sb_remount(struct super_block *sb,
Al Viro204cc0c2018-12-13 13:41:47 -0500600 void *mnt_opts)
Eric Parisff36fe22011-03-03 16:09:14 -0500601{
602 return 0;
603}
604
Al Viroa10d7c22018-12-05 11:58:35 -0500605static inline int security_sb_kern_mount(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606{
607 return 0;
608}
609
Eric Paris2069f452008-07-04 09:47:13 +1000610static inline int security_sb_show_options(struct seq_file *m,
611 struct super_block *sb)
612{
613 return 0;
614}
615
Eric Paris7b41b172008-04-23 14:10:25 -0400616static inline int security_sb_statfs(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617{
618 return 0;
619}
620
Al Viro8a04c432016-03-25 14:52:53 -0400621static inline int security_sb_mount(const char *dev_name, const struct path *path,
Al Viro808d4e32012-10-11 11:42:01 -0400622 const char *type, unsigned long flags,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 void *data)
624{
625 return 0;
626}
627
Eric Paris7b41b172008-04-23 14:10:25 -0400628static inline int security_sb_umount(struct vfsmount *mnt, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629{
630 return 0;
631}
632
Al Viro3b73b682016-03-25 15:31:19 -0400633static inline int security_sb_pivotroot(const struct path *old_path,
634 const struct path *new_path)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635{
636 return 0;
637}
638
Eric Parise0007522008-03-05 10:31:54 -0500639static inline int security_sb_set_mnt_opts(struct super_block *sb,
Al Viro204cc0c2018-12-13 13:41:47 -0500640 void *mnt_opts,
David Quigley649f6e72013-05-22 12:50:36 -0400641 unsigned long kern_flags,
642 unsigned long *set_kern_flags)
Eric Parise0007522008-03-05 10:31:54 -0500643{
644 return 0;
645}
646
Jeff Layton094f7b62013-04-01 08:14:24 -0400647static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
Scott Mayhew0b4d3452017-06-05 11:45:04 -0400648 struct super_block *newsb,
649 unsigned long kern_flags,
650 unsigned long *set_kern_flags)
Jeff Layton094f7b62013-04-01 08:14:24 -0400651{
652 return 0;
653}
Eric Parise0007522008-03-05 10:31:54 -0500654
Al Viro757cbe52018-12-14 23:42:21 -0500655static inline int security_add_mnt_opt(const char *option, const char *val,
656 int len, void **mnt_opts)
Eric Parise0007522008-03-05 10:31:54 -0500657{
658 return 0;
659}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660
David Howells2db154b2018-11-05 17:40:30 +0000661static inline int security_move_mount(const struct path *from_path,
662 const struct path *to_path)
663{
664 return 0;
665}
666
Eric Paris7b41b172008-04-23 14:10:25 -0400667static inline int security_inode_alloc(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668{
669 return 0;
670}
671
Eric Paris7b41b172008-04-23 14:10:25 -0400672static inline void security_inode_free(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673{ }
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700674
David Quigleyd47be3d2013-05-22 12:50:34 -0400675static inline int security_dentry_init_security(struct dentry *dentry,
676 int mode,
Al Viro4f3ccd72016-07-20 16:06:15 -0400677 const struct qstr *name,
David Quigleyd47be3d2013-05-22 12:50:34 -0400678 void **ctx,
679 u32 *ctxlen)
680{
681 return -EOPNOTSUPP;
682}
683
Vivek Goyal26026252016-07-13 10:44:52 -0400684static inline int security_dentry_create_files_as(struct dentry *dentry,
685 int mode, struct qstr *name,
686 const struct cred *old,
687 struct cred *new)
688{
689 return 0;
690}
691
David Quigleyd47be3d2013-05-22 12:50:34 -0400692
Eric Paris7b41b172008-04-23 14:10:25 -0400693static inline int security_inode_init_security(struct inode *inode,
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700694 struct inode *dir,
Eric Paris2a7dba32011-02-01 11:05:39 -0500695 const struct qstr *qstr,
Mark Rustadfbff6612014-08-28 04:43:09 -0700696 const initxattrs xattrs,
Mimi Zohar9d8f13b2011-06-06 15:29:25 -0400697 void *fs_data)
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700698{
Mimi Zohar1e39f382011-08-15 09:09:16 -0400699 return 0;
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700700}
Eric Paris7b41b172008-04-23 14:10:25 -0400701
Mimi Zohar1e39f382011-08-15 09:09:16 -0400702static inline int security_old_inode_init_security(struct inode *inode,
703 struct inode *dir,
704 const struct qstr *qstr,
Tetsuo Handa95489062013-07-25 05:44:02 +0900705 const char **name,
706 void **value, size_t *len)
Mimi Zohare1c9b232011-08-11 00:22:51 -0400707{
Jan Kara30e05322012-01-03 13:14:29 +0100708 return -EOPNOTSUPP;
Mimi Zohare1c9b232011-08-11 00:22:51 -0400709}
710
Eric Paris7b41b172008-04-23 14:10:25 -0400711static inline int security_inode_create(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 struct dentry *dentry,
Al Viro4acdaf22011-07-26 01:42:34 -0400713 umode_t mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714{
715 return 0;
716}
717
Eric Paris7b41b172008-04-23 14:10:25 -0400718static inline int security_inode_link(struct dentry *old_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 struct inode *dir,
720 struct dentry *new_dentry)
721{
722 return 0;
723}
724
Eric Paris7b41b172008-04-23 14:10:25 -0400725static inline int security_inode_unlink(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 struct dentry *dentry)
727{
728 return 0;
729}
730
Eric Paris7b41b172008-04-23 14:10:25 -0400731static inline int security_inode_symlink(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 struct dentry *dentry,
733 const char *old_name)
734{
735 return 0;
736}
737
Eric Paris7b41b172008-04-23 14:10:25 -0400738static inline int security_inode_mkdir(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 struct dentry *dentry,
740 int mode)
741{
742 return 0;
743}
744
Eric Paris7b41b172008-04-23 14:10:25 -0400745static inline int security_inode_rmdir(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 struct dentry *dentry)
747{
748 return 0;
749}
750
Eric Paris7b41b172008-04-23 14:10:25 -0400751static inline int security_inode_mknod(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 struct dentry *dentry,
753 int mode, dev_t dev)
754{
755 return 0;
756}
757
Eric Paris7b41b172008-04-23 14:10:25 -0400758static inline int security_inode_rename(struct inode *old_dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 struct dentry *old_dentry,
760 struct inode *new_dir,
Miklos Szeredi0b3974e2014-04-01 17:08:43 +0200761 struct dentry *new_dentry,
762 unsigned int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763{
764 return 0;
765}
766
Eric Paris7b41b172008-04-23 14:10:25 -0400767static inline int security_inode_readlink(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768{
769 return 0;
770}
771
NeilBrownbda0be72015-03-23 13:37:39 +1100772static inline int security_inode_follow_link(struct dentry *dentry,
773 struct inode *inode,
774 bool rcu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775{
776 return 0;
777}
778
Al Virob77b0642008-07-17 09:37:02 -0400779static inline int security_inode_permission(struct inode *inode, int mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780{
781 return 0;
782}
783
Eric Paris7b41b172008-04-23 14:10:25 -0400784static inline int security_inode_setattr(struct dentry *dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 struct iattr *attr)
786{
787 return 0;
788}
789
Al Viro3f7036a2015-03-08 19:28:30 -0400790static inline int security_inode_getattr(const struct path *path)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791{
792 return 0;
793}
794
David Howells8f0cfa52008-04-29 00:59:41 -0700795static inline int security_inode_setxattr(struct dentry *dentry,
796 const char *name, const void *value, size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797{
798 return cap_inode_setxattr(dentry, name, value, size, flags);
799}
800
David Howells8f0cfa52008-04-29 00:59:41 -0700801static inline void security_inode_post_setxattr(struct dentry *dentry,
802 const char *name, const void *value, size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803{ }
804
David Howells8f0cfa52008-04-29 00:59:41 -0700805static inline int security_inode_getxattr(struct dentry *dentry,
806 const char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807{
808 return 0;
809}
810
Eric Paris7b41b172008-04-23 14:10:25 -0400811static inline int security_inode_listxattr(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812{
813 return 0;
814}
815
David Howells8f0cfa52008-04-29 00:59:41 -0700816static inline int security_inode_removexattr(struct dentry *dentry,
817 const char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818{
819 return cap_inode_removexattr(dentry, name);
820}
821
Serge E. Hallynb5376772007-10-16 23:31:36 -0700822static inline int security_inode_need_killpriv(struct dentry *dentry)
823{
824 return cap_inode_need_killpriv(dentry);
825}
826
827static inline int security_inode_killpriv(struct dentry *dentry)
828{
829 return cap_inode_killpriv(dentry);
830}
831
Andreas Gruenbacherea861df2015-12-24 11:09:39 -0500832static inline int security_inode_getsecurity(struct inode *inode, const char *name, void **buffer, bool alloc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833{
834 return -EOPNOTSUPP;
835}
836
837static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
838{
839 return -EOPNOTSUPP;
840}
841
842static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
843{
844 return 0;
845}
846
Andreas Gruenbacherd6335d72015-12-24 11:09:39 -0500847static inline void security_inode_getsecid(struct inode *inode, u32 *secid)
Ahmed S. Darwish8a076192008-03-01 21:51:09 +0200848{
849 *secid = 0;
850}
851
Vivek Goyald8ad8b42016-07-13 11:13:56 -0400852static inline int security_inode_copy_up(struct dentry *src, struct cred **new)
853{
854 return 0;
855}
856
Ondrej Mosnacekb230d5a2019-02-22 15:57:16 +0100857static inline int security_kernfs_init_security(struct kernfs_node *kn_dir,
858 struct kernfs_node *kn)
859{
860 return 0;
861}
862
Vivek Goyal121ab822016-07-13 10:44:49 -0400863static inline int security_inode_copy_up_xattr(const char *name)
864{
865 return -EOPNOTSUPP;
866}
867
Eric Paris7b41b172008-04-23 14:10:25 -0400868static inline int security_file_permission(struct file *file, int mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869{
870 return 0;
871}
872
Eric Paris7b41b172008-04-23 14:10:25 -0400873static inline int security_file_alloc(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874{
875 return 0;
876}
877
Eric Paris7b41b172008-04-23 14:10:25 -0400878static inline void security_file_free(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879{ }
880
Eric Paris7b41b172008-04-23 14:10:25 -0400881static inline int security_file_ioctl(struct file *file, unsigned int cmd,
882 unsigned long arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883{
884 return 0;
885}
886
Al Viro8b3ec682012-05-30 17:11:23 -0400887static inline int security_mmap_file(struct file *file, unsigned long prot,
Al Viroe5467852012-05-30 13:30:51 -0400888 unsigned long flags)
889{
890 return 0;
891}
892
893static inline int security_mmap_addr(unsigned long addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894{
Al Virod0077942012-05-30 13:11:37 -0400895 return cap_mmap_addr(addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896}
897
Eric Paris7b41b172008-04-23 14:10:25 -0400898static inline int security_file_mprotect(struct vm_area_struct *vma,
899 unsigned long reqprot,
900 unsigned long prot)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901{
902 return 0;
903}
904
Eric Paris7b41b172008-04-23 14:10:25 -0400905static inline int security_file_lock(struct file *file, unsigned int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906{
907 return 0;
908}
909
Eric Paris7b41b172008-04-23 14:10:25 -0400910static inline int security_file_fcntl(struct file *file, unsigned int cmd,
911 unsigned long arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912{
913 return 0;
914}
915
Jeff Laytone0b93ed2014-08-22 11:27:32 -0400916static inline void security_file_set_fowner(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917{
Jeff Laytone0b93ed2014-08-22 11:27:32 -0400918 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919}
920
Eric Paris7b41b172008-04-23 14:10:25 -0400921static inline int security_file_send_sigiotask(struct task_struct *tsk,
922 struct fown_struct *fown,
923 int sig)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924{
925 return 0;
926}
927
Eric Paris7b41b172008-04-23 14:10:25 -0400928static inline int security_file_receive(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929{
930 return 0;
931}
932
Al Viroe3f20ae2018-07-10 13:25:29 -0400933static inline int security_file_open(struct file *file)
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +0900934{
935 return 0;
936}
937
Tetsuo Handae4e55b42017-03-24 20:46:33 +0900938static inline int security_task_alloc(struct task_struct *task,
939 unsigned long clone_flags)
940{
941 return 0;
942}
943
Kees Cook1a2a4d02011-12-21 12:17:03 -0800944static inline void security_task_free(struct task_struct *task)
945{ }
946
David Howells945af7c2009-09-04 09:19:48 +0100947static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
948{
949 return 0;
950}
David Howellsee18d642009-09-02 09:14:21 +0100951
David Howellsd84f4f92008-11-14 10:39:23 +1100952static inline void security_cred_free(struct cred *cred)
953{ }
954
955static inline int security_prepare_creds(struct cred *new,
956 const struct cred *old,
957 gfp_t gfp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958{
959 return 0;
960}
961
David Howellsee18d642009-09-02 09:14:21 +0100962static inline void security_transfer_creds(struct cred *new,
963 const struct cred *old)
964{
965}
966
David Howells3a3b7ce2008-11-14 10:39:28 +1100967static inline int security_kernel_act_as(struct cred *cred, u32 secid)
968{
969 return 0;
970}
971
972static inline int security_kernel_create_files_as(struct cred *cred,
973 struct inode *inode)
974{
975 return 0;
976}
977
Eric Parisdd8dbf22009-11-03 16:35:32 +1100978static inline int security_kernel_module_request(char *kmod_name)
Eric Paris91884992009-08-13 09:44:57 -0400979{
980 return 0;
981}
982
Mimi Zohar377179c2018-07-13 14:05:56 -0400983static inline int security_kernel_load_data(enum kernel_load_data_id id)
984{
985 return 0;
986}
987
Mimi Zohar39eeb4f2016-01-30 22:23:26 -0500988static inline int security_kernel_read_file(struct file *file,
989 enum kernel_read_file_id id)
990{
991 return 0;
992}
993
Mimi Zoharb44a7df2015-12-28 16:02:29 -0500994static inline int security_kernel_post_read_file(struct file *file,
Mimi Zoharbc8ca5b2016-01-24 10:07:32 -0500995 char *buf, loff_t size,
996 enum kernel_read_file_id id)
Mimi Zoharb44a7df2015-12-28 16:02:29 -0500997{
998 return 0;
999}
1000
David Howellsd84f4f92008-11-14 10:39:23 +11001001static inline int security_task_fix_setuid(struct cred *new,
1002 const struct cred *old,
1003 int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001004{
David Howellsd84f4f92008-11-14 10:39:23 +11001005 return cap_task_fix_setuid(new, old, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006}
1007
Eric Paris7b41b172008-04-23 14:10:25 -04001008static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009{
1010 return 0;
1011}
1012
Eric Paris7b41b172008-04-23 14:10:25 -04001013static inline int security_task_getpgid(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014{
1015 return 0;
1016}
1017
Eric Paris7b41b172008-04-23 14:10:25 -04001018static inline int security_task_getsid(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001019{
1020 return 0;
1021}
1022
Eric Paris7b41b172008-04-23 14:10:25 -04001023static inline void security_task_getsecid(struct task_struct *p, u32 *secid)
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02001024{
1025 *secid = 0;
1026}
David Quigleyf9008e4c2006-06-30 01:55:46 -07001027
Eric Paris7b41b172008-04-23 14:10:25 -04001028static inline int security_task_setnice(struct task_struct *p, int nice)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001029{
Serge E. Hallynb5376772007-10-16 23:31:36 -07001030 return cap_task_setnice(p, nice);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001031}
1032
Eric Paris7b41b172008-04-23 14:10:25 -04001033static inline int security_task_setioprio(struct task_struct *p, int ioprio)
James Morris03e68062006-06-23 02:03:58 -07001034{
Serge E. Hallynb5376772007-10-16 23:31:36 -07001035 return cap_task_setioprio(p, ioprio);
James Morris03e68062006-06-23 02:03:58 -07001036}
1037
Eric Paris7b41b172008-04-23 14:10:25 -04001038static inline int security_task_getioprio(struct task_struct *p)
David Quigleya1836a42006-06-30 01:55:49 -07001039{
1040 return 0;
1041}
1042
Stephen Smalley791ec492017-02-17 07:57:00 -05001043static inline int security_task_prlimit(const struct cred *cred,
1044 const struct cred *tcred,
1045 unsigned int flags)
1046{
1047 return 0;
1048}
1049
Jiri Slaby8fd00b42009-08-26 18:41:16 +02001050static inline int security_task_setrlimit(struct task_struct *p,
1051 unsigned int resource,
Eric Paris7b41b172008-04-23 14:10:25 -04001052 struct rlimit *new_rlim)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053{
1054 return 0;
1055}
1056
KOSAKI Motohirob0ae1982010-10-15 04:21:18 +09001057static inline int security_task_setscheduler(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058{
KOSAKI Motohirob0ae1982010-10-15 04:21:18 +09001059 return cap_task_setscheduler(p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060}
1061
Eric Paris7b41b172008-04-23 14:10:25 -04001062static inline int security_task_getscheduler(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063{
1064 return 0;
1065}
1066
Eric Paris7b41b172008-04-23 14:10:25 -04001067static inline int security_task_movememory(struct task_struct *p)
David Quigley35601542006-06-23 02:04:01 -07001068{
1069 return 0;
1070}
1071
Eric Paris7b41b172008-04-23 14:10:25 -04001072static inline int security_task_kill(struct task_struct *p,
Eric W. Biedermanae7795b2018-09-25 11:27:20 +02001073 struct kernel_siginfo *info, int sig,
Stephen Smalley6b4f3d02017-09-08 12:40:01 -04001074 const struct cred *cred)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001075{
Serge Hallynaedb60a2008-02-29 15:14:57 +00001076 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077}
1078
Eric Paris7b41b172008-04-23 14:10:25 -04001079static inline int security_task_prctl(int option, unsigned long arg2,
1080 unsigned long arg3,
1081 unsigned long arg4,
David Howellsd84f4f92008-11-14 10:39:23 +11001082 unsigned long arg5)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001083{
Jann Hornb7f76ea2015-09-18 23:41:23 +02001084 return cap_task_prctl(option, arg2, arg3, arg4, arg5);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001085}
1086
1087static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1088{ }
1089
Eric Paris7b41b172008-04-23 14:10:25 -04001090static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
1091 short flag)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092{
1093 return 0;
1094}
1095
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02001096static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
1097{
1098 *secid = 0;
1099}
1100
Eric Paris7b41b172008-04-23 14:10:25 -04001101static inline int security_msg_msg_alloc(struct msg_msg *msg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102{
1103 return 0;
1104}
1105
Eric Paris7b41b172008-04-23 14:10:25 -04001106static inline void security_msg_msg_free(struct msg_msg *msg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107{ }
1108
Eric W. Biedermand8c6e852018-03-22 21:22:26 -05001109static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110{
1111 return 0;
1112}
1113
Eric W. Biedermand8c6e852018-03-22 21:22:26 -05001114static inline void security_msg_queue_free(struct kern_ipc_perm *msq)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115{ }
1116
Eric W. Biedermand8c6e852018-03-22 21:22:26 -05001117static inline int security_msg_queue_associate(struct kern_ipc_perm *msq,
Eric Paris7b41b172008-04-23 14:10:25 -04001118 int msqflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119{
1120 return 0;
1121}
1122
Eric W. Biedermand8c6e852018-03-22 21:22:26 -05001123static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124{
1125 return 0;
1126}
1127
Eric W. Biedermand8c6e852018-03-22 21:22:26 -05001128static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
Eric Paris7b41b172008-04-23 14:10:25 -04001129 struct msg_msg *msg, int msqflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130{
1131 return 0;
1132}
1133
Eric W. Biedermand8c6e852018-03-22 21:22:26 -05001134static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq,
Eric Paris7b41b172008-04-23 14:10:25 -04001135 struct msg_msg *msg,
1136 struct task_struct *target,
1137 long type, int mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138{
1139 return 0;
1140}
1141
Eric W. Biederman7191adf2018-03-22 21:08:27 -05001142static inline int security_shm_alloc(struct kern_ipc_perm *shp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143{
1144 return 0;
1145}
1146
Eric W. Biederman7191adf2018-03-22 21:08:27 -05001147static inline void security_shm_free(struct kern_ipc_perm *shp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148{ }
1149
Eric W. Biederman7191adf2018-03-22 21:08:27 -05001150static inline int security_shm_associate(struct kern_ipc_perm *shp,
Eric Paris7b41b172008-04-23 14:10:25 -04001151 int shmflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152{
1153 return 0;
1154}
1155
Eric W. Biederman7191adf2018-03-22 21:08:27 -05001156static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157{
1158 return 0;
1159}
1160
Eric W. Biederman7191adf2018-03-22 21:08:27 -05001161static inline int security_shm_shmat(struct kern_ipc_perm *shp,
Eric Paris7b41b172008-04-23 14:10:25 -04001162 char __user *shmaddr, int shmflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163{
1164 return 0;
1165}
1166
Eric W. Biedermanaefad952018-03-22 20:52:43 -05001167static inline int security_sem_alloc(struct kern_ipc_perm *sma)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168{
1169 return 0;
1170}
1171
Eric W. Biedermanaefad952018-03-22 20:52:43 -05001172static inline void security_sem_free(struct kern_ipc_perm *sma)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173{ }
1174
Eric W. Biedermanaefad952018-03-22 20:52:43 -05001175static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176{
1177 return 0;
1178}
1179
Eric W. Biedermanaefad952018-03-22 20:52:43 -05001180static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181{
1182 return 0;
1183}
1184
Eric W. Biedermanaefad952018-03-22 20:52:43 -05001185static inline int security_sem_semop(struct kern_ipc_perm *sma,
Eric Paris7b41b172008-04-23 14:10:25 -04001186 struct sembuf *sops, unsigned nsops,
1187 int alter)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188{
1189 return 0;
1190}
1191
Casey Schaufler6d9c9392018-09-21 17:16:59 -07001192static inline void security_d_instantiate(struct dentry *dentry,
1193 struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001194{ }
1195
Casey Schaufler6d9c9392018-09-21 17:16:59 -07001196static inline int security_getprocattr(struct task_struct *p, const char *lsm,
1197 char *name, char **value)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198{
1199 return -EINVAL;
1200}
1201
Casey Schaufler6d9c9392018-09-21 17:16:59 -07001202static inline int security_setprocattr(const char *lsm, char *name,
1203 void *value, size_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001204{
1205 return -EINVAL;
1206}
1207
Eric Paris7b41b172008-04-23 14:10:25 -04001208static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209{
Casey Schauflerb1d9e6b2015-05-02 15:11:42 -07001210 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211}
1212
David Quigley746df9b2013-05-22 12:50:35 -04001213static inline int security_ismaclabel(const char *name)
1214{
1215 return 0;
1216}
1217
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001218static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
1219{
1220 return -EOPNOTSUPP;
1221}
1222
David Howells7bf570d2008-04-29 20:52:51 +01001223static inline int security_secctx_to_secid(const char *secdata,
David Howells63cb3442008-01-15 23:47:35 +00001224 u32 seclen,
1225 u32 *secid)
1226{
1227 return -EOPNOTSUPP;
1228}
1229
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001230static inline void security_release_secctx(char *secdata, u32 seclen)
1231{
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001232}
David P. Quigley1ee65e32009-09-03 14:25:57 -04001233
Andreas Gruenbacher6f3be9f2015-12-24 11:09:40 -05001234static inline void security_inode_invalidate_secctx(struct inode *inode)
1235{
1236}
1237
David P. Quigley1ee65e32009-09-03 14:25:57 -04001238static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
1239{
1240 return -EOPNOTSUPP;
1241}
1242static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
1243{
1244 return -EOPNOTSUPP;
1245}
1246static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
1247{
1248 return -EOPNOTSUPP;
1249}
Matthew Garrett9e47d312019-08-19 17:17:38 -07001250static inline int security_locked_down(enum lockdown_reason what)
1251{
1252 return 0;
1253}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254#endif /* CONFIG_SECURITY */
1255
1256#ifdef CONFIG_SECURITY_NETWORK
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257
David S. Miller3610cda2011-01-05 15:38:53 -08001258int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
James Morris20510f22007-10-16 23:31:32 -07001259int security_unix_may_send(struct socket *sock, struct socket *other);
1260int security_socket_create(int family, int type, int protocol, int kern);
1261int security_socket_post_create(struct socket *sock, int family,
1262 int type, int protocol, int kern);
David Herrmannaae7cfc2018-05-04 16:28:19 +02001263int security_socket_socketpair(struct socket *socka, struct socket *sockb);
James Morris20510f22007-10-16 23:31:32 -07001264int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
1265int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
1266int security_socket_listen(struct socket *sock, int backlog);
1267int security_socket_accept(struct socket *sock, struct socket *newsock);
James Morris20510f22007-10-16 23:31:32 -07001268int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
1269int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
1270 int size, int flags);
1271int security_socket_getsockname(struct socket *sock);
1272int security_socket_getpeername(struct socket *sock);
1273int security_socket_getsockopt(struct socket *sock, int level, int optname);
1274int security_socket_setsockopt(struct socket *sock, int level, int optname);
1275int security_socket_shutdown(struct socket *sock, int how);
1276int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
1277int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
1278 int __user *optlen, unsigned len);
1279int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
1280int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
1281void security_sk_free(struct sock *sk);
1282void security_sk_clone(const struct sock *sk, struct sock *newsk);
1283void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
1284void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
1285void security_sock_graft(struct sock*sk, struct socket *parent);
1286int security_inet_conn_request(struct sock *sk,
1287 struct sk_buff *skb, struct request_sock *req);
1288void security_inet_csk_clone(struct sock *newsk,
1289 const struct request_sock *req);
1290void security_inet_conn_established(struct sock *sk,
1291 struct sk_buff *skb);
Eric Paris2606fd12010-10-13 16:24:41 -04001292int security_secmark_relabel_packet(u32 secid);
1293void security_secmark_refcount_inc(void);
1294void security_secmark_refcount_dec(void);
Paul Moore5dbbaf22013-01-14 07:12:19 +00001295int security_tun_dev_alloc_security(void **security);
1296void security_tun_dev_free_security(void *security);
Paul Moore2b980db2009-08-28 18:12:43 -04001297int security_tun_dev_create(void);
Paul Moore5dbbaf22013-01-14 07:12:19 +00001298int security_tun_dev_attach_queue(void *security);
1299int security_tun_dev_attach(struct sock *sk, void *security);
1300int security_tun_dev_open(void *security);
Richard Haines72e89f52018-02-13 20:53:21 +00001301int security_sctp_assoc_request(struct sctp_endpoint *ep, struct sk_buff *skb);
1302int security_sctp_bind_connect(struct sock *sk, int optname,
1303 struct sockaddr *address, int addrlen);
1304void security_sctp_sk_clone(struct sctp_endpoint *ep, struct sock *sk,
1305 struct sock *newsk);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001306
Linus Torvalds1da177e2005-04-16 15:20:36 -07001307#else /* CONFIG_SECURITY_NETWORK */
David S. Miller3610cda2011-01-05 15:38:53 -08001308static inline int security_unix_stream_connect(struct sock *sock,
1309 struct sock *other,
Eric Paris7b41b172008-04-23 14:10:25 -04001310 struct sock *newsk)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311{
1312 return 0;
1313}
1314
Eric Paris7b41b172008-04-23 14:10:25 -04001315static inline int security_unix_may_send(struct socket *sock,
1316 struct socket *other)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317{
1318 return 0;
1319}
1320
Eric Paris7b41b172008-04-23 14:10:25 -04001321static inline int security_socket_create(int family, int type,
1322 int protocol, int kern)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323{
1324 return 0;
1325}
1326
Eric Paris7b41b172008-04-23 14:10:25 -04001327static inline int security_socket_post_create(struct socket *sock,
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07001328 int family,
1329 int type,
1330 int protocol, int kern)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331{
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07001332 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001333}
1334
David Herrmannaae7cfc2018-05-04 16:28:19 +02001335static inline int security_socket_socketpair(struct socket *socka,
1336 struct socket *sockb)
1337{
1338 return 0;
1339}
1340
Eric Paris7b41b172008-04-23 14:10:25 -04001341static inline int security_socket_bind(struct socket *sock,
1342 struct sockaddr *address,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001343 int addrlen)
1344{
1345 return 0;
1346}
1347
Eric Paris7b41b172008-04-23 14:10:25 -04001348static inline int security_socket_connect(struct socket *sock,
1349 struct sockaddr *address,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350 int addrlen)
1351{
1352 return 0;
1353}
1354
Eric Paris7b41b172008-04-23 14:10:25 -04001355static inline int security_socket_listen(struct socket *sock, int backlog)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356{
1357 return 0;
1358}
1359
Eric Paris7b41b172008-04-23 14:10:25 -04001360static inline int security_socket_accept(struct socket *sock,
1361 struct socket *newsock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362{
1363 return 0;
1364}
1365
Eric Paris7b41b172008-04-23 14:10:25 -04001366static inline int security_socket_sendmsg(struct socket *sock,
1367 struct msghdr *msg, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001368{
1369 return 0;
1370}
1371
Eric Paris7b41b172008-04-23 14:10:25 -04001372static inline int security_socket_recvmsg(struct socket *sock,
1373 struct msghdr *msg, int size,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001374 int flags)
1375{
1376 return 0;
1377}
1378
Eric Paris7b41b172008-04-23 14:10:25 -04001379static inline int security_socket_getsockname(struct socket *sock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380{
1381 return 0;
1382}
1383
Eric Paris7b41b172008-04-23 14:10:25 -04001384static inline int security_socket_getpeername(struct socket *sock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385{
1386 return 0;
1387}
1388
Eric Paris7b41b172008-04-23 14:10:25 -04001389static inline int security_socket_getsockopt(struct socket *sock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390 int level, int optname)
1391{
1392 return 0;
1393}
1394
Eric Paris7b41b172008-04-23 14:10:25 -04001395static inline int security_socket_setsockopt(struct socket *sock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396 int level, int optname)
1397{
1398 return 0;
1399}
1400
Eric Paris7b41b172008-04-23 14:10:25 -04001401static inline int security_socket_shutdown(struct socket *sock, int how)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001402{
1403 return 0;
1404}
Eric Paris7b41b172008-04-23 14:10:25 -04001405static inline int security_sock_rcv_skb(struct sock *sk,
1406 struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407{
1408 return 0;
1409}
1410
Catherine Zhang2c7946a2006-03-20 22:41:23 -08001411static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
1412 int __user *optlen, unsigned len)
1413{
1414 return -ENOPROTOOPT;
1415}
1416
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001417static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001418{
1419 return -ENOPROTOOPT;
1420}
1421
Al Virodd0fc662005-10-07 07:46:04 +01001422static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001423{
1424 return 0;
1425}
1426
1427static inline void security_sk_free(struct sock *sk)
1428{
1429}
Trent Jaegerdf718372005-12-13 23:12:27 -08001430
Venkat Yekkirala892c1412006-08-04 23:08:56 -07001431static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
1432{
1433}
1434
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001435static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
Trent Jaegerdf718372005-12-13 23:12:27 -08001436{
Trent Jaegerdf718372005-12-13 23:12:27 -08001437}
Venkat Yekkirala4237c752006-07-24 23:32:50 -07001438
1439static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
1440{
1441}
1442
Eric Paris7b41b172008-04-23 14:10:25 -04001443static inline void security_sock_graft(struct sock *sk, struct socket *parent)
Venkat Yekkirala4237c752006-07-24 23:32:50 -07001444{
1445}
1446
1447static inline int security_inet_conn_request(struct sock *sk,
1448 struct sk_buff *skb, struct request_sock *req)
1449{
1450 return 0;
1451}
1452
1453static inline void security_inet_csk_clone(struct sock *newsk,
1454 const struct request_sock *req)
1455{
1456}
Venkat Yekkirala6b877692006-11-08 17:04:09 -06001457
1458static inline void security_inet_conn_established(struct sock *sk,
1459 struct sk_buff *skb)
1460{
1461}
Paul Moore2b980db2009-08-28 18:12:43 -04001462
Eric Paris2606fd12010-10-13 16:24:41 -04001463static inline int security_secmark_relabel_packet(u32 secid)
1464{
1465 return 0;
1466}
1467
1468static inline void security_secmark_refcount_inc(void)
1469{
1470}
1471
1472static inline void security_secmark_refcount_dec(void)
1473{
1474}
1475
Paul Moore5dbbaf22013-01-14 07:12:19 +00001476static inline int security_tun_dev_alloc_security(void **security)
1477{
1478 return 0;
1479}
1480
1481static inline void security_tun_dev_free_security(void *security)
1482{
1483}
1484
Paul Moore2b980db2009-08-28 18:12:43 -04001485static inline int security_tun_dev_create(void)
1486{
1487 return 0;
1488}
1489
Paul Moore5dbbaf22013-01-14 07:12:19 +00001490static inline int security_tun_dev_attach_queue(void *security)
Paul Moore2b980db2009-08-28 18:12:43 -04001491{
Paul Moore5dbbaf22013-01-14 07:12:19 +00001492 return 0;
Paul Moore2b980db2009-08-28 18:12:43 -04001493}
1494
Paul Moore5dbbaf22013-01-14 07:12:19 +00001495static inline int security_tun_dev_attach(struct sock *sk, void *security)
1496{
1497 return 0;
1498}
1499
1500static inline int security_tun_dev_open(void *security)
Paul Moore2b980db2009-08-28 18:12:43 -04001501{
1502 return 0;
1503}
Richard Haines72e89f52018-02-13 20:53:21 +00001504
1505static inline int security_sctp_assoc_request(struct sctp_endpoint *ep,
1506 struct sk_buff *skb)
1507{
1508 return 0;
1509}
1510
1511static inline int security_sctp_bind_connect(struct sock *sk, int optname,
1512 struct sockaddr *address,
1513 int addrlen)
1514{
1515 return 0;
1516}
1517
1518static inline void security_sctp_sk_clone(struct sctp_endpoint *ep,
1519 struct sock *sk,
1520 struct sock *newsk)
1521{
1522}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523#endif /* CONFIG_SECURITY_NETWORK */
1524
Daniel Jurgensd291f1a2017-05-19 15:48:52 +03001525#ifdef CONFIG_SECURITY_INFINIBAND
1526int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey);
Daniel Jurgens47a2b332017-05-19 15:48:54 +03001527int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num);
Daniel Jurgensd291f1a2017-05-19 15:48:52 +03001528int security_ib_alloc_security(void **sec);
1529void security_ib_free_security(void *sec);
1530#else /* CONFIG_SECURITY_INFINIBAND */
1531static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey)
1532{
1533 return 0;
1534}
1535
Daniel Jurgens47a2b332017-05-19 15:48:54 +03001536static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num)
1537{
1538 return 0;
1539}
1540
Daniel Jurgensd291f1a2017-05-19 15:48:52 +03001541static inline int security_ib_alloc_security(void **sec)
1542{
1543 return 0;
1544}
1545
1546static inline void security_ib_free_security(void *sec)
1547{
1548}
1549#endif /* CONFIG_SECURITY_INFINIBAND */
1550
Trent Jaegerdf718372005-12-13 23:12:27 -08001551#ifdef CONFIG_SECURITY_NETWORK_XFRM
Venkat Yekkiralacb969f02006-07-24 23:32:20 -07001552
Nikolay Aleksandrov52a4c642014-03-07 12:44:19 +01001553int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1554 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
Paul Moore03e1ad72008-04-12 19:07:52 -07001555int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
1556void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
1557int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
James Morris20510f22007-10-16 23:31:32 -07001558int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1559int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1560 struct xfrm_sec_ctx *polsec, u32 secid);
1561int security_xfrm_state_delete(struct xfrm_state *x);
1562void security_xfrm_state_free(struct xfrm_state *x);
Paul Moore03e1ad72008-04-12 19:07:52 -07001563int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
James Morris20510f22007-10-16 23:31:32 -07001564int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
David S. Millere33f7702011-02-22 18:13:15 -08001565 struct xfrm_policy *xp,
1566 const struct flowi *fl);
James Morris20510f22007-10-16 23:31:32 -07001567int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
1568void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
Trent Jaegerdf718372005-12-13 23:12:27 -08001569
Trent Jaegerdf718372005-12-13 23:12:27 -08001570#else /* CONFIG_SECURITY_NETWORK_XFRM */
James Morris20510f22007-10-16 23:31:32 -07001571
Nikolay Aleksandrov52a4c642014-03-07 12:44:19 +01001572static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1573 struct xfrm_user_sec_ctx *sec_ctx,
1574 gfp_t gfp)
Trent Jaegerdf718372005-12-13 23:12:27 -08001575{
1576 return 0;
1577}
1578
Paul Moore03e1ad72008-04-12 19:07:52 -07001579static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
Trent Jaegerdf718372005-12-13 23:12:27 -08001580{
1581 return 0;
1582}
1583
Paul Moore03e1ad72008-04-12 19:07:52 -07001584static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
Trent Jaegerdf718372005-12-13 23:12:27 -08001585{
1586}
1587
Paul Moore03e1ad72008-04-12 19:07:52 -07001588static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001589{
1590 return 0;
1591}
1592
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001593static inline int security_xfrm_state_alloc(struct xfrm_state *x,
1594 struct xfrm_user_sec_ctx *sec_ctx)
1595{
1596 return 0;
1597}
1598
1599static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1600 struct xfrm_sec_ctx *polsec, u32 secid)
Trent Jaegerdf718372005-12-13 23:12:27 -08001601{
1602 return 0;
1603}
1604
1605static inline void security_xfrm_state_free(struct xfrm_state *x)
1606{
1607}
1608
David S. Miller6f68dc32006-06-08 23:58:52 -07001609static inline int security_xfrm_state_delete(struct xfrm_state *x)
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001610{
1611 return 0;
1612}
1613
Paul Moore03e1ad72008-04-12 19:07:52 -07001614static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
Trent Jaegerdf718372005-12-13 23:12:27 -08001615{
1616 return 0;
1617}
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001618
1619static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
David S. Millere33f7702011-02-22 18:13:15 -08001620 struct xfrm_policy *xp, const struct flowi *fl)
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001621{
1622 return 1;
1623}
1624
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001625static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001626{
1627 return 0;
1628}
1629
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001630static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
1631{
1632}
1633
Trent Jaegerdf718372005-12-13 23:12:27 -08001634#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1635
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001636#ifdef CONFIG_SECURITY_PATH
Al Viro989f74e2016-03-25 15:13:39 -04001637int security_path_unlink(const struct path *dir, struct dentry *dentry);
Al Virod3607752016-03-25 15:21:09 -04001638int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
Al Viro989f74e2016-03-25 15:13:39 -04001639int security_path_rmdir(const struct path *dir, struct dentry *dentry);
Al Virod3607752016-03-25 15:21:09 -04001640int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001641 unsigned int dev);
Al Viro81f4c502016-03-25 14:22:01 -04001642int security_path_truncate(const struct path *path);
Al Virod3607752016-03-25 15:21:09 -04001643int security_path_symlink(const struct path *dir, struct dentry *dentry,
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001644 const char *old_name);
Al Viro3ccee462016-03-25 15:27:45 -04001645int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001646 struct dentry *new_dentry);
Al Viro3ccee462016-03-25 15:27:45 -04001647int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
1648 const struct path *new_dir, struct dentry *new_dentry,
Miklos Szeredi0b3974e2014-04-01 17:08:43 +02001649 unsigned int flags);
Al Virobe01f9f2016-03-25 14:56:23 -04001650int security_path_chmod(const struct path *path, umode_t mode);
Al Viro7fd25da2016-03-25 14:44:41 -04001651int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
Al Viro77b286c2016-03-25 15:28:43 -04001652int security_path_chroot(const struct path *path);
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001653#else /* CONFIG_SECURITY_PATH */
Al Viro989f74e2016-03-25 15:13:39 -04001654static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001655{
1656 return 0;
1657}
1658
Al Virod3607752016-03-25 15:21:09 -04001659static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
Al Viro4572bef2011-11-21 14:56:21 -05001660 umode_t mode)
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001661{
1662 return 0;
1663}
1664
Al Viro989f74e2016-03-25 15:13:39 -04001665static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001666{
1667 return 0;
1668}
1669
Al Virod3607752016-03-25 15:21:09 -04001670static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
Al Viro04fc66e2011-11-21 14:58:38 -05001671 umode_t mode, unsigned int dev)
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001672{
1673 return 0;
1674}
1675
Al Viro81f4c502016-03-25 14:22:01 -04001676static inline int security_path_truncate(const struct path *path)
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001677{
1678 return 0;
1679}
1680
Al Virod3607752016-03-25 15:21:09 -04001681static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001682 const char *old_name)
1683{
1684 return 0;
1685}
1686
1687static inline int security_path_link(struct dentry *old_dentry,
Al Viro3ccee462016-03-25 15:27:45 -04001688 const struct path *new_dir,
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001689 struct dentry *new_dentry)
1690{
1691 return 0;
1692}
1693
Al Viro3ccee462016-03-25 15:27:45 -04001694static inline int security_path_rename(const struct path *old_dir,
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001695 struct dentry *old_dentry,
Al Viro3ccee462016-03-25 15:27:45 -04001696 const struct path *new_dir,
Miklos Szeredi0b3974e2014-04-01 17:08:43 +02001697 struct dentry *new_dentry,
1698 unsigned int flags)
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001699{
1700 return 0;
1701}
Tetsuo Handa89eda062009-10-04 21:49:47 +09001702
Al Virobe01f9f2016-03-25 14:56:23 -04001703static inline int security_path_chmod(const struct path *path, umode_t mode)
Tetsuo Handa89eda062009-10-04 21:49:47 +09001704{
1705 return 0;
1706}
1707
Al Viro7fd25da2016-03-25 14:44:41 -04001708static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
Tetsuo Handa89eda062009-10-04 21:49:47 +09001709{
1710 return 0;
1711}
Tetsuo Handa8b8efb42009-10-04 21:49:48 +09001712
Al Viro77b286c2016-03-25 15:28:43 -04001713static inline int security_path_chroot(const struct path *path)
Tetsuo Handa8b8efb42009-10-04 21:49:48 +09001714{
1715 return 0;
1716}
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001717#endif /* CONFIG_SECURITY_PATH */
1718
David Howells29db9192005-10-30 15:02:44 -08001719#ifdef CONFIG_KEYS
1720#ifdef CONFIG_SECURITY
David Howells29db9192005-10-30 15:02:44 -08001721
David Howellsd84f4f92008-11-14 10:39:23 +11001722int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
James Morris20510f22007-10-16 23:31:32 -07001723void security_key_free(struct key *key);
1724int security_key_permission(key_ref_t key_ref,
David Howellsf5895942014-03-14 17:44:49 +00001725 const struct cred *cred, unsigned perm);
David Howells70a5bb72008-04-29 01:01:26 -07001726int security_key_getsecurity(struct key *key, char **_buffer);
David Howells29db9192005-10-30 15:02:44 -08001727
1728#else
1729
Michael LeMayd7200242006-06-22 14:47:17 -07001730static inline int security_key_alloc(struct key *key,
David Howellsd84f4f92008-11-14 10:39:23 +11001731 const struct cred *cred,
David Howells7e047ef2006-06-26 00:24:50 -07001732 unsigned long flags)
David Howells29db9192005-10-30 15:02:44 -08001733{
1734 return 0;
1735}
1736
1737static inline void security_key_free(struct key *key)
1738{
1739}
1740
1741static inline int security_key_permission(key_ref_t key_ref,
David Howellsd84f4f92008-11-14 10:39:23 +11001742 const struct cred *cred,
David Howellsf5895942014-03-14 17:44:49 +00001743 unsigned perm)
David Howells29db9192005-10-30 15:02:44 -08001744{
1745 return 0;
1746}
1747
David Howells70a5bb72008-04-29 01:01:26 -07001748static inline int security_key_getsecurity(struct key *key, char **_buffer)
1749{
1750 *_buffer = NULL;
1751 return 0;
1752}
1753
David Howells29db9192005-10-30 15:02:44 -08001754#endif
1755#endif /* CONFIG_KEYS */
1756
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02001757#ifdef CONFIG_AUDIT
1758#ifdef CONFIG_SECURITY
1759int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
1760int security_audit_rule_known(struct audit_krule *krule);
Richard Guy Briggs90462a52019-01-31 11:52:11 -05001761int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule);
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02001762void security_audit_rule_free(void *lsmrule);
1763
1764#else
1765
1766static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
1767 void **lsmrule)
1768{
1769 return 0;
1770}
1771
1772static inline int security_audit_rule_known(struct audit_krule *krule)
1773{
1774 return 0;
1775}
1776
1777static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
Richard Guy Briggs90462a52019-01-31 11:52:11 -05001778 void *lsmrule)
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02001779{
1780 return 0;
1781}
1782
1783static inline void security_audit_rule_free(void *lsmrule)
1784{ }
1785
1786#endif /* CONFIG_SECURITY */
1787#endif /* CONFIG_AUDIT */
1788
Eric Parisda318942008-08-22 11:35:57 -04001789#ifdef CONFIG_SECURITYFS
1790
Al Viro52ef0c02011-07-26 04:30:04 -04001791extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
Eric Parisda318942008-08-22 11:35:57 -04001792 struct dentry *parent, void *data,
1793 const struct file_operations *fops);
1794extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
John Johansen6623ec72017-05-07 05:53:37 -07001795struct dentry *securityfs_create_symlink(const char *name,
1796 struct dentry *parent,
1797 const char *target,
1798 const struct inode_operations *iops);
Eric Parisda318942008-08-22 11:35:57 -04001799extern void securityfs_remove(struct dentry *dentry);
1800
1801#else /* CONFIG_SECURITYFS */
1802
1803static inline struct dentry *securityfs_create_dir(const char *name,
1804 struct dentry *parent)
1805{
1806 return ERR_PTR(-ENODEV);
1807}
1808
1809static inline struct dentry *securityfs_create_file(const char *name,
Al Viro52ef0c02011-07-26 04:30:04 -04001810 umode_t mode,
Eric Parisda318942008-08-22 11:35:57 -04001811 struct dentry *parent,
1812 void *data,
1813 const struct file_operations *fops)
1814{
1815 return ERR_PTR(-ENODEV);
1816}
1817
John Johansen6623ec72017-05-07 05:53:37 -07001818static inline struct dentry *securityfs_create_symlink(const char *name,
1819 struct dentry *parent,
1820 const char *target,
1821 const struct inode_operations *iops)
1822{
1823 return ERR_PTR(-ENODEV);
1824}
1825
Eric Parisda318942008-08-22 11:35:57 -04001826static inline void securityfs_remove(struct dentry *dentry)
1827{}
1828
1829#endif
1830
Chenbo Fengafdb09c2017-10-18 13:00:24 -07001831#ifdef CONFIG_BPF_SYSCALL
Jakub Kicinski1495dc92017-11-01 11:48:00 -07001832union bpf_attr;
1833struct bpf_map;
1834struct bpf_prog;
1835struct bpf_prog_aux;
Chenbo Fengafdb09c2017-10-18 13:00:24 -07001836#ifdef CONFIG_SECURITY
1837extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size);
1838extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
1839extern int security_bpf_prog(struct bpf_prog *prog);
1840extern int security_bpf_map_alloc(struct bpf_map *map);
1841extern void security_bpf_map_free(struct bpf_map *map);
1842extern int security_bpf_prog_alloc(struct bpf_prog_aux *aux);
1843extern void security_bpf_prog_free(struct bpf_prog_aux *aux);
1844#else
1845static inline int security_bpf(int cmd, union bpf_attr *attr,
1846 unsigned int size)
1847{
1848 return 0;
1849}
1850
1851static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode)
1852{
1853 return 0;
1854}
1855
1856static inline int security_bpf_prog(struct bpf_prog *prog)
1857{
1858 return 0;
1859}
1860
1861static inline int security_bpf_map_alloc(struct bpf_map *map)
1862{
1863 return 0;
1864}
1865
1866static inline void security_bpf_map_free(struct bpf_map *map)
1867{ }
1868
1869static inline int security_bpf_prog_alloc(struct bpf_prog_aux *aux)
1870{
1871 return 0;
1872}
1873
1874static inline void security_bpf_prog_free(struct bpf_prog_aux *aux)
1875{ }
1876#endif /* CONFIG_SECURITY */
1877#endif /* CONFIG_BPF_SYSCALL */
1878
Linus Torvalds1da177e2005-04-16 15:20:36 -07001879#endif /* ! __LINUX_SECURITY_H */
1880