blob: e844834db698678365e6bc5c8fa81dbf05629126 [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
Scott Brandenb89999d02020-10-02 10:38:15 -070026#include <linux/kernel_read_file.h>
David Howells29db9192005-10-30 15:02:44 -080027#include <linux/key.h>
Al Viro40401532012-02-13 03:58:52 +000028#include <linux/capability.h>
Mimi Zoharcf222212016-01-14 17:57:47 -050029#include <linux/fs.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090030#include <linux/slab.h>
Al Viro40401532012-02-13 03:58:52 +000031#include <linux/err.h>
David Quigleyd47be3d2013-05-22 12:50:34 -040032#include <linux/string.h>
Casey Schauflerb1d9e6b2015-05-02 15:11:42 -070033#include <linux/mm.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;
David Howells344fa642020-02-12 13:58:35 +000060struct watch;
61struct watch_notification;
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Micah Mortonc1a85a02019-01-07 16:10:53 -080063/* Default (no) options for the capable function */
64#define CAP_OPT_NONE 0x0
Eric Paris06112162008-11-11 22:02:50 +110065/* If capable should audit the security request */
Micah Mortonc1a85a02019-01-07 16:10:53 -080066#define CAP_OPT_NOAUDIT BIT(1)
67/* If capable is being called by a setid function */
68#define CAP_OPT_INSETID BIT(2)
Eric Paris06112162008-11-11 22:02:50 +110069
David Howells846e5662018-11-01 23:07:24 +000070/* LSM Agnostic defines for fs_context::lsm_flags */
David Quigleyeb9ae682013-05-22 12:50:37 -040071#define SECURITY_LSM_NATIVE_LABELS 1
72
Linus Torvalds1da177e2005-04-16 15:20:36 -070073struct ctl_table;
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +020074struct audit_krule;
Serge E. Hallyn34867402011-03-23 16:43:17 -070075struct user_namespace;
Al Viro40401532012-02-13 03:58:52 +000076struct timezone;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Daniel Jurgens8f408ab2017-05-19 15:48:53 +030078enum lsm_event {
79 LSM_POLICY_CHANGE,
80};
81
Matthew Garrett9e47d312019-08-19 17:17:38 -070082/*
83 * These are reasons that can be passed to the security_locked_down()
84 * LSM hook. Lockdown reasons that protect kernel integrity (ie, the
85 * ability for userland to modify kernel code) are placed before
86 * LOCKDOWN_INTEGRITY_MAX. Lockdown reasons that protect kernel
87 * confidentiality (ie, the ability for userland to extract
88 * information from the running kernel that would otherwise be
89 * restricted) are placed before LOCKDOWN_CONFIDENTIALITY_MAX.
90 *
91 * LSM authors should note that the semantics of any given lockdown
92 * reason are not guaranteed to be stable - the same reason may block
93 * one set of features in one kernel release, and a slightly different
94 * set of features in a later kernel release. LSMs that seek to expose
95 * lockdown policy at any level of granularity other than "none",
96 * "integrity" or "confidentiality" are responsible for either
97 * ensuring that they expose a consistent level of functionality to
98 * userland, or ensuring that userland is aware that this is
99 * potentially a moving target. It is easy to misuse this information
100 * in a way that could break userspace. Please be careful not to do
101 * so.
Matthew Garrett000d3882019-08-19 17:17:39 -0700102 *
103 * If you add to this, remember to extend lockdown_reasons in
104 * security/lockdown/lockdown.c.
Matthew Garrett9e47d312019-08-19 17:17:38 -0700105 */
106enum lockdown_reason {
107 LOCKDOWN_NONE,
David Howells49fcf732019-08-19 17:17:40 -0700108 LOCKDOWN_MODULE_SIGNATURE,
Matthew Garrett9b9d8dd2019-08-19 17:17:41 -0700109 LOCKDOWN_DEV_MEM,
Javier Martinez Canillas359efcc2019-10-29 18:37:55 +0100110 LOCKDOWN_EFI_TEST,
Matthew Garrett7d31f462019-08-19 17:17:42 -0700111 LOCKDOWN_KEXEC,
Josh Boyer38bd94b2019-08-19 17:17:46 -0700112 LOCKDOWN_HIBERNATION,
Matthew Garretteb627e12019-08-19 17:17:47 -0700113 LOCKDOWN_PCI_ACCESS,
Matthew Garrett96c4f672019-08-19 17:17:48 -0700114 LOCKDOWN_IOPORT,
Matthew Garrett95f5e952019-08-19 17:17:49 -0700115 LOCKDOWN_MSR,
Matthew Garrettf474e142019-08-19 17:17:50 -0700116 LOCKDOWN_ACPI_TABLES,
David Howells3f19cad2019-08-19 17:17:53 -0700117 LOCKDOWN_PCMCIA_CIS,
David Howells794edf32019-08-19 17:17:54 -0700118 LOCKDOWN_TIOCSSERIAL,
David Howells20657f62019-08-19 17:17:55 -0700119 LOCKDOWN_MODULE_PARAMETERS,
David Howells906357f2019-08-19 17:17:56 -0700120 LOCKDOWN_MMIOTRACE,
David Howells54961972019-08-19 17:18:02 -0700121 LOCKDOWN_DEBUGFS,
Christopher M. Riedl69393cb2019-09-07 01:11:24 -0500122 LOCKDOWN_XMON_WR,
Daniel Borkmann51e1bb92021-08-09 12:43:17 +0200123 LOCKDOWN_BPF_WRITE_USER,
Daniel Thompson69c5d302022-05-23 19:11:02 +0100124 LOCKDOWN_DBG_WRITE_KERNEL,
Matthew Garrett9e47d312019-08-19 17:17:38 -0700125 LOCKDOWN_INTEGRITY_MAX,
David Howells02e935b2019-08-19 17:17:57 -0700126 LOCKDOWN_KCORE,
David Howellsa94549d2019-08-19 17:17:58 -0700127 LOCKDOWN_KPROBES,
Daniel Borkmann71330842021-08-09 21:45:32 +0200128 LOCKDOWN_BPF_READ_KERNEL,
Daniel Thompson69c5d302022-05-23 19:11:02 +0100129 LOCKDOWN_DBG_READ_KERNEL,
David Howellsb0c8fdc2019-08-19 17:18:00 -0700130 LOCKDOWN_PERF,
Matthew Garrettccbd54f2019-08-19 17:18:03 -0700131 LOCKDOWN_TRACEFS,
Christopher M. Riedl69393cb2019-09-07 01:11:24 -0500132 LOCKDOWN_XMON_RW,
Antony Antonyc7a58992020-11-17 17:47:23 +0100133 LOCKDOWN_XFRM_SECRET,
Matthew Garrett9e47d312019-08-19 17:17:38 -0700134 LOCKDOWN_CONFIDENTIALITY_MAX,
135};
136
Stephen Smalley59438b462019-11-27 12:04:36 -0500137extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
138
Casey Schauflerb1d9e6b2015-05-02 15:11:42 -0700139/* These functions are in security/commoncap.c */
Eric Paris6a9de492012-01-03 12:25:14 -0500140extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
Micah Mortonc1a85a02019-01-07 16:10:53 -0800141 int cap, unsigned int opts);
Baolin Wang457db292016-04-08 14:02:11 +0800142extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
Ingo Molnar9e488582009-05-07 19:26:19 +1000143extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
David Howells5cd9c582008-08-14 11:37:28 +0100144extern int cap_ptrace_traceme(struct task_struct *parent);
Eric Paris7b41b172008-04-23 14:10:25 -0400145extern 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 +1100146extern int cap_capset(struct cred *new, const struct cred *old,
147 const kernel_cap_t *effective,
148 const kernel_cap_t *inheritable,
149 const kernel_cap_t *permitted);
Eric W. Biederman56305aa2020-05-29 22:00:54 -0500150extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
Christian Brauner71bc3562021-01-21 14:19:29 +0100151int cap_inode_setxattr(struct dentry *dentry, const char *name,
152 const void *value, size_t size, int flags);
153int cap_inode_removexattr(struct user_namespace *mnt_userns,
154 struct dentry *dentry, const char *name);
155int cap_inode_need_killpriv(struct dentry *dentry);
156int cap_inode_killpriv(struct user_namespace *mnt_userns,
157 struct dentry *dentry);
158int cap_inode_getsecurity(struct user_namespace *mnt_userns,
159 struct inode *inode, const char *name, void **buffer,
160 bool alloc);
Al Virod0077942012-05-30 13:11:37 -0400161extern int cap_mmap_addr(unsigned long addr);
Al Viroe5467852012-05-30 13:30:51 -0400162extern int cap_mmap_file(struct file *file, unsigned long reqprot,
163 unsigned long prot, unsigned long flags);
David Howellsd84f4f92008-11-14 10:39:23 +1100164extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
Andrew G. Morgan3898b1b2008-04-28 02:13:40 -0700165extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
David Howellsd84f4f92008-11-14 10:39:23 +1100166 unsigned long arg4, unsigned long arg5);
KOSAKI Motohirob0ae1982010-10-15 04:21:18 +0900167extern int cap_task_setscheduler(struct task_struct *p);
Eric Paris7b41b172008-04-23 14:10:25 -0400168extern int cap_task_setioprio(struct task_struct *p, int ioprio);
169extern int cap_task_setnice(struct task_struct *p, int nice);
James Morris20510f22007-10-16 23:31:32 -0700170extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
172struct msghdr;
173struct sk_buff;
174struct sock;
175struct sockaddr;
176struct socket;
Paul Moore3df98d72020-09-27 22:38:26 -0400177struct flowi_common;
Trent Jaegerdf718372005-12-13 23:12:27 -0800178struct dst_entry;
179struct xfrm_selector;
180struct xfrm_policy;
181struct xfrm_state;
182struct xfrm_user_sec_ctx;
Eric Paris2069f452008-07-04 09:47:13 +1000183struct seq_file;
Richard Haines72e89f52018-02-13 20:53:21 +0000184struct sctp_endpoint;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
David Howells6e141542009-12-15 19:27:45 +0000186#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -0400187extern unsigned long mmap_min_addr;
Eric Parisa2551df72009-07-31 12:54:11 -0400188extern unsigned long dac_mmap_min_addr;
David Howells6e141542009-12-15 19:27:45 +0000189#else
Mark Salterbe8cfc42012-09-24 17:17:38 -0700190#define mmap_min_addr 0UL
David Howells6e141542009-12-15 19:27:45 +0000191#define dac_mmap_min_addr 0UL
192#endif
193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194/*
195 * Values used in the task_security_ops calls
196 */
197/* setuid or setgid, id0 == uid or gid */
198#define LSM_SETID_ID 1
199
200/* setreuid or setregid, id0 == real, id1 == eff */
201#define LSM_SETID_RE 2
202
203/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
204#define LSM_SETID_RES 4
205
206/* setfsuid or setfsgid, id0 == fsuid or fsgid */
207#define LSM_SETID_FS 8
208
Stephen Smalley791ec492017-02-17 07:57:00 -0500209/* Flags for security_task_prlimit(). */
210#define LSM_PRLIMIT_READ 1
211#define LSM_PRLIMIT_WRITE 2
212
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213/* forward declares to avoid warnings */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214struct sched_param;
Venkat Yekkirala4237c752006-07-24 23:32:50 -0700215struct request_sock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
David Howellsa6f76f22008-11-14 10:39:24 +1100217/* bprm->unsafe reasons */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218#define LSM_UNSAFE_SHARE 1
219#define LSM_UNSAFE_PTRACE 2
Eric W. Biederman9227dd22017-01-23 17:26:31 +1300220#define LSM_UNSAFE_NO_NEW_PRIVS 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
David Howells6e141542009-12-15 19:27:45 +0000222#ifdef CONFIG_MMU
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700223extern int mmap_min_addr_handler(struct ctl_table *table, int write,
Christoph Hellwig32927392020-04-24 08:43:38 +0200224 void *buffer, size_t *lenp, loff_t *ppos);
David Howells6e141542009-12-15 19:27:45 +0000225#endif
Eric Paris47d439e2009-08-07 14:53:57 -0400226
Mimi Zohar9d8f13b2011-06-06 15:29:25 -0400227/* security_inode_init_security callback function to write xattrs */
228typedef int (*initxattrs) (struct inode *inode,
229 const struct xattr *xattr_array, void *fs_data);
230
Mimi Zohar377179c2018-07-13 14:05:56 -0400231
232/* Keep the kernel_load_data_id enum in sync with kernel_read_file_id */
233#define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM,
234#define __data_id_stringify(dummy, str) #str,
235
236enum kernel_load_data_id {
237 __kernel_read_file_id(__data_id_enumify)
238};
239
240static const char * const kernel_load_data_str[] = {
241 __kernel_read_file_id(__data_id_stringify)
242};
243
244static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
245{
246 if ((unsigned)id >= LOADING_MAX_ID)
247 return kernel_load_data_str[LOADING_UNKNOWN];
248
249 return kernel_load_data_str[id];
250}
251
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252#ifdef CONFIG_SECURITY
253
Janne Karhunen42df7442019-06-14 15:20:14 +0300254int call_blocking_lsm_notifier(enum lsm_event event, void *data);
255int register_blocking_lsm_notifier(struct notifier_block *nb);
256int unregister_blocking_lsm_notifier(struct notifier_block *nb);
Daniel Jurgens8f408ab2017-05-19 15:48:53 +0300257
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258/* prototypes */
Eric Paris7b41b172008-04-23 14:10:25 -0400259extern int security_init(void);
Matthew Garrette6b1db92019-08-19 17:17:37 -0700260extern int early_security_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
James Morris20510f22007-10-16 23:31:32 -0700262/* Security operations */
Todd Kjos3f3c31d2021-10-12 09:56:13 -0700263int security_binder_set_context_mgr(const struct cred *mgr);
264int security_binder_transaction(const struct cred *from,
265 const struct cred *to);
266int security_binder_transfer_binder(const struct cred *from,
267 const struct cred *to);
268int security_binder_transfer_file(const struct cred *from,
269 const struct cred *to, struct file *file);
Ingo Molnar9e488582009-05-07 19:26:19 +1000270int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
David Howells5cd9c582008-08-14 11:37:28 +0100271int security_ptrace_traceme(struct task_struct *parent);
James Morris20510f22007-10-16 23:31:32 -0700272int security_capget(struct task_struct *target,
Eric Paris7b41b172008-04-23 14:10:25 -0400273 kernel_cap_t *effective,
274 kernel_cap_t *inheritable,
275 kernel_cap_t *permitted);
David Howellsd84f4f92008-11-14 10:39:23 +1100276int security_capset(struct cred *new, const struct cred *old,
277 const kernel_cap_t *effective,
278 const kernel_cap_t *inheritable,
279 const kernel_cap_t *permitted);
Micah Mortonc1a85a02019-01-07 16:10:53 -0800280int security_capable(const struct cred *cred,
281 struct user_namespace *ns,
282 int cap,
283 unsigned int opts);
James Morris20510f22007-10-16 23:31:32 -0700284int security_quotactl(int cmds, int type, int id, struct super_block *sb);
285int security_quota_on(struct dentry *dentry);
Eric Paris12b30522010-11-15 18:36:29 -0500286int security_syslog(int type);
Baolin Wang457db292016-04-08 14:02:11 +0800287int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
James Morris20510f22007-10-16 23:31:32 -0700288int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
Eric W. Biedermanb8bff592020-03-22 15:46:24 -0500289int security_bprm_creds_for_exec(struct linux_binprm *bprm);
Eric W. Biederman56305aa2020-05-29 22:00:54 -0500290int security_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
James Morris20510f22007-10-16 23:31:32 -0700291int security_bprm_check(struct linux_binprm *bprm);
David Howellsa6f76f22008-11-14 10:39:24 +1100292void security_bprm_committing_creds(struct linux_binprm *bprm);
293void security_bprm_committed_creds(struct linux_binprm *bprm);
Al Viro0b520752018-12-23 16:02:47 -0500294int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc);
David Howellsda2441f2018-11-01 23:07:24 +0000295int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
James Morris20510f22007-10-16 23:31:32 -0700296int security_sb_alloc(struct super_block *sb);
Mickaël Salaün83e804f2021-04-22 17:41:16 +0200297void security_sb_delete(struct super_block *sb);
James Morris20510f22007-10-16 23:31:32 -0700298void security_sb_free(struct super_block *sb);
Al Viro204cc0c2018-12-13 13:41:47 -0500299void security_free_mnt_opts(void **mnt_opts);
300int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
Olga Kornievskaia69c4a422021-02-26 22:37:55 -0500301int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
Al Viro204cc0c2018-12-13 13:41:47 -0500302int security_sb_remount(struct super_block *sb, void *mnt_opts);
Al Viroa10d7c22018-12-05 11:58:35 -0500303int security_sb_kern_mount(struct super_block *sb);
Eric Paris2069f452008-07-04 09:47:13 +1000304int security_sb_show_options(struct seq_file *m, struct super_block *sb);
James Morris20510f22007-10-16 23:31:32 -0700305int security_sb_statfs(struct dentry *dentry);
Al Viro8a04c432016-03-25 14:52:53 -0400306int security_sb_mount(const char *dev_name, const struct path *path,
Al Viro808d4e32012-10-11 11:42:01 -0400307 const char *type, unsigned long flags, void *data);
James Morris20510f22007-10-16 23:31:32 -0700308int security_sb_umount(struct vfsmount *mnt, int flags);
Al Viro3b73b682016-03-25 15:31:19 -0400309int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
David Quigley649f6e72013-05-22 12:50:36 -0400310int security_sb_set_mnt_opts(struct super_block *sb,
Al Viro204cc0c2018-12-13 13:41:47 -0500311 void *mnt_opts,
David Quigley649f6e72013-05-22 12:50:36 -0400312 unsigned long kern_flags,
313 unsigned long *set_kern_flags);
Jeff Layton094f7b62013-04-01 08:14:24 -0400314int security_sb_clone_mnt_opts(const struct super_block *oldsb,
Scott Mayhew0b4d3452017-06-05 11:45:04 -0400315 struct super_block *newsb,
316 unsigned long kern_flags,
317 unsigned long *set_kern_flags);
Al Viro757cbe52018-12-14 23:42:21 -0500318int security_add_mnt_opt(const char *option, const char *val,
319 int len, void **mnt_opts);
David Howells2db154b2018-11-05 17:40:30 +0000320int security_move_mount(const struct path *from_path, const struct path *to_path);
David Quigleyd47be3d2013-05-22 12:50:34 -0400321int security_dentry_init_security(struct dentry *dentry, int mode,
Al Viro4f3ccd72016-07-20 16:06:15 -0400322 const struct qstr *name, void **ctx,
David Quigleyd47be3d2013-05-22 12:50:34 -0400323 u32 *ctxlen);
Vivek Goyal26026252016-07-13 10:44:52 -0400324int security_dentry_create_files_as(struct dentry *dentry, int mode,
325 struct qstr *name,
326 const struct cred *old,
327 struct cred *new);
Aaron Goidelac5656d2019-08-12 11:20:00 -0400328int security_path_notify(const struct path *path, u64 mask,
329 unsigned int obj_type);
James Morris20510f22007-10-16 23:31:32 -0700330int security_inode_alloc(struct inode *inode);
331void security_inode_free(struct inode *inode);
332int security_inode_init_security(struct inode *inode, struct inode *dir,
Mimi Zohar9d8f13b2011-06-06 15:29:25 -0400333 const struct qstr *qstr,
334 initxattrs initxattrs, void *fs_data);
Lokesh Gidra215b674b2021-01-08 14:22:20 -0800335int security_inode_init_security_anon(struct inode *inode,
336 const struct qstr *name,
337 const struct inode *context_inode);
Mimi Zohar9d8f13b2011-06-06 15:29:25 -0400338int security_old_inode_init_security(struct inode *inode, struct inode *dir,
Tetsuo Handa95489062013-07-25 05:44:02 +0900339 const struct qstr *qstr, const char **name,
Mimi Zohar9d8f13b2011-06-06 15:29:25 -0400340 void **value, size_t *len);
Al Viro4acdaf22011-07-26 01:42:34 -0400341int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
James Morris20510f22007-10-16 23:31:32 -0700342int security_inode_link(struct dentry *old_dentry, struct inode *dir,
343 struct dentry *new_dentry);
344int security_inode_unlink(struct inode *dir, struct dentry *dentry);
345int security_inode_symlink(struct inode *dir, struct dentry *dentry,
Eric Paris7b41b172008-04-23 14:10:25 -0400346 const char *old_name);
Al Viro18bb1db2011-07-26 01:41:39 -0400347int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
James Morris20510f22007-10-16 23:31:32 -0700348int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
Al Viro1a67aaf2011-07-26 01:52:52 -0400349int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
James Morris20510f22007-10-16 23:31:32 -0700350int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
Miklos Szeredi0b3974e2014-04-01 17:08:43 +0200351 struct inode *new_dir, struct dentry *new_dentry,
352 unsigned int flags);
James Morris20510f22007-10-16 23:31:32 -0700353int security_inode_readlink(struct dentry *dentry);
NeilBrownbda0be72015-03-23 13:37:39 +1100354int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
355 bool rcu);
Al Virob77b0642008-07-17 09:37:02 -0400356int security_inode_permission(struct inode *inode, int mask);
James Morris20510f22007-10-16 23:31:32 -0700357int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
Al Viro3f7036a2015-03-08 19:28:30 -0400358int security_inode_getattr(const struct path *path);
Christian Brauner71bc3562021-01-21 14:19:29 +0100359int security_inode_setxattr(struct user_namespace *mnt_userns,
360 struct dentry *dentry, const char *name,
David Howells8f0cfa52008-04-29 00:59:41 -0700361 const void *value, size_t size, int flags);
362void security_inode_post_setxattr(struct dentry *dentry, const char *name,
363 const void *value, size_t size, int flags);
364int security_inode_getxattr(struct dentry *dentry, const char *name);
James Morris20510f22007-10-16 23:31:32 -0700365int security_inode_listxattr(struct dentry *dentry);
Christian Brauner71bc3562021-01-21 14:19:29 +0100366int security_inode_removexattr(struct user_namespace *mnt_userns,
367 struct dentry *dentry, const char *name);
Serge E. Hallynb5376772007-10-16 23:31:36 -0700368int security_inode_need_killpriv(struct dentry *dentry);
Christian Brauner71bc3562021-01-21 14:19:29 +0100369int security_inode_killpriv(struct user_namespace *mnt_userns,
370 struct dentry *dentry);
371int security_inode_getsecurity(struct user_namespace *mnt_userns,
372 struct inode *inode, const char *name,
373 void **buffer, bool alloc);
James Morris20510f22007-10-16 23:31:32 -0700374int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
375int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
Andreas Gruenbacherd6335d72015-12-24 11:09:39 -0500376void security_inode_getsecid(struct inode *inode, u32 *secid);
Vivek Goyald8ad8b42016-07-13 11:13:56 -0400377int security_inode_copy_up(struct dentry *src, struct cred **new);
Vivek Goyal121ab822016-07-13 10:44:49 -0400378int security_inode_copy_up_xattr(const char *name);
Ondrej Mosnacekb230d5a2019-02-22 15:57:16 +0100379int security_kernfs_init_security(struct kernfs_node *kn_dir,
380 struct kernfs_node *kn);
James Morris20510f22007-10-16 23:31:32 -0700381int security_file_permission(struct file *file, int mask);
382int security_file_alloc(struct file *file);
383void security_file_free(struct file *file);
384int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
Alfred Piccioni4590f202023-12-19 10:09:09 +0100385int security_file_ioctl_compat(struct file *file, unsigned int cmd,
386 unsigned long arg);
Al Viro8b3ec682012-05-30 17:11:23 -0400387int security_mmap_file(struct file *file, unsigned long prot,
388 unsigned long flags);
Al Viroe5467852012-05-30 13:30:51 -0400389int security_mmap_addr(unsigned long addr);
James Morris20510f22007-10-16 23:31:32 -0700390int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
Eric Paris7b41b172008-04-23 14:10:25 -0400391 unsigned long prot);
James Morris20510f22007-10-16 23:31:32 -0700392int security_file_lock(struct file *file, unsigned int cmd);
393int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
Jeff Laytone0b93ed2014-08-22 11:27:32 -0400394void security_file_set_fowner(struct file *file);
James Morris20510f22007-10-16 23:31:32 -0700395int security_file_send_sigiotask(struct task_struct *tsk,
Eric Paris7b41b172008-04-23 14:10:25 -0400396 struct fown_struct *fown, int sig);
James Morris20510f22007-10-16 23:31:32 -0700397int security_file_receive(struct file *file);
Al Viroe3f20ae2018-07-10 13:25:29 -0400398int security_file_open(struct file *file);
Tetsuo Handae4e55b42017-03-24 20:46:33 +0900399int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
Kees Cook1a2a4d02011-12-21 12:17:03 -0800400void security_task_free(struct task_struct *task);
David Howellsee18d642009-09-02 09:14:21 +0100401int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
David Howellsf1752ee2008-11-14 10:39:17 +1100402void security_cred_free(struct cred *cred);
David Howellsd84f4f92008-11-14 10:39:23 +1100403int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
David Howellsee18d642009-09-02 09:14:21 +0100404void security_transfer_creds(struct cred *new, const struct cred *old);
Matthew Garrett3ec30112018-01-08 13:36:19 -0800405void security_cred_getsecid(const struct cred *c, u32 *secid);
David Howells3a3b7ce2008-11-14 10:39:28 +1100406int security_kernel_act_as(struct cred *new, u32 secid);
407int security_kernel_create_files_as(struct cred *new, struct inode *inode);
Eric Parisdd8dbf22009-11-03 16:35:32 +1100408int security_kernel_module_request(char *kmod_name);
Kees Cookb64fcae2020-10-02 10:38:20 -0700409int security_kernel_load_data(enum kernel_load_data_id id, bool contents);
410int security_kernel_post_load_data(char *buf, loff_t size,
411 enum kernel_load_data_id id,
412 char *description);
Kees Cook2039bda2020-10-02 10:38:23 -0700413int security_kernel_read_file(struct file *file, enum kernel_read_file_id id,
414 bool contents);
Mimi Zoharbc8ca5b2016-01-24 10:07:32 -0500415int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
416 enum kernel_read_file_id id);
David Howellsd84f4f92008-11-14 10:39:23 +1100417int security_task_fix_setuid(struct cred *new, const struct cred *old,
418 int flags);
Thomas Cedeno39030e12020-06-09 10:22:13 -0700419int security_task_fix_setgid(struct cred *new, const struct cred *old,
420 int flags);
James Morris20510f22007-10-16 23:31:32 -0700421int security_task_setpgid(struct task_struct *p, pid_t pgid);
422int security_task_getpgid(struct task_struct *p);
423int security_task_getsid(struct task_struct *p);
Paul Moore4ebd7652021-02-19 14:26:21 -0500424void security_task_getsecid_subj(struct task_struct *p, u32 *secid);
425void security_task_getsecid_obj(struct task_struct *p, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -0700426int security_task_setnice(struct task_struct *p, int nice);
427int security_task_setioprio(struct task_struct *p, int ioprio);
428int security_task_getioprio(struct task_struct *p);
Stephen Smalley791ec492017-02-17 07:57:00 -0500429int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
430 unsigned int flags);
Jiri Slaby8fd00b42009-08-26 18:41:16 +0200431int security_task_setrlimit(struct task_struct *p, unsigned int resource,
432 struct rlimit *new_rlim);
KOSAKI Motohirob0ae1982010-10-15 04:21:18 +0900433int security_task_setscheduler(struct task_struct *p);
James Morris20510f22007-10-16 23:31:32 -0700434int security_task_getscheduler(struct task_struct *p);
435int security_task_movememory(struct task_struct *p);
Eric W. Biedermanae7795b2018-09-25 11:27:20 +0200436int security_task_kill(struct task_struct *p, struct kernel_siginfo *info,
Stephen Smalley6b4f3d02017-09-08 12:40:01 -0400437 int sig, const struct cred *cred);
James Morris20510f22007-10-16 23:31:32 -0700438int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
David Howellsd84f4f92008-11-14 10:39:23 +1100439 unsigned long arg4, unsigned long arg5);
James Morris20510f22007-10-16 23:31:32 -0700440void security_task_to_inode(struct task_struct *p, struct inode *inode);
441int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
Ahmed S. Darwish8a076192008-03-01 21:51:09 +0200442void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -0700443int security_msg_msg_alloc(struct msg_msg *msg);
444void security_msg_msg_free(struct msg_msg *msg);
Eric W. Biedermand8c6e852018-03-22 21:22:26 -0500445int security_msg_queue_alloc(struct kern_ipc_perm *msq);
446void security_msg_queue_free(struct kern_ipc_perm *msq);
447int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg);
448int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd);
449int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
Eric Paris7b41b172008-04-23 14:10:25 -0400450 struct msg_msg *msg, int msqflg);
Eric W. Biedermand8c6e852018-03-22 21:22:26 -0500451int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg,
Eric Paris7b41b172008-04-23 14:10:25 -0400452 struct task_struct *target, long type, int mode);
Eric W. Biederman7191adf2018-03-22 21:08:27 -0500453int security_shm_alloc(struct kern_ipc_perm *shp);
454void security_shm_free(struct kern_ipc_perm *shp);
455int security_shm_associate(struct kern_ipc_perm *shp, int shmflg);
456int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd);
457int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg);
Eric W. Biedermanaefad952018-03-22 20:52:43 -0500458int security_sem_alloc(struct kern_ipc_perm *sma);
459void security_sem_free(struct kern_ipc_perm *sma);
460int security_sem_associate(struct kern_ipc_perm *sma, int semflg);
461int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
462int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
James Morris20510f22007-10-16 23:31:32 -0700463 unsigned nsops, int alter);
Eric Paris7b41b172008-04-23 14:10:25 -0400464void security_d_instantiate(struct dentry *dentry, struct inode *inode);
Casey Schaufler6d9c9392018-09-21 17:16:59 -0700465int security_getprocattr(struct task_struct *p, const char *lsm, char *name,
466 char **value);
467int security_setprocattr(const char *lsm, const char *name, void *value,
468 size_t size);
James Morris20510f22007-10-16 23:31:32 -0700469int security_netlink_send(struct sock *sk, struct sk_buff *skb);
David Quigley746df9b2013-05-22 12:50:35 -0400470int security_ismaclabel(const char *name);
James Morris20510f22007-10-16 23:31:32 -0700471int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
David Howells7bf570d2008-04-29 20:52:51 +0100472int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
James Morris20510f22007-10-16 23:31:32 -0700473void security_release_secctx(char *secdata, u32 seclen);
Andreas Gruenbacher6f3be9f2015-12-24 11:09:40 -0500474void security_inode_invalidate_secctx(struct inode *inode);
David P. Quigley1ee65e32009-09-03 14:25:57 -0400475int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
476int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
477int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
Matthew Garrett9e47d312019-08-19 17:17:38 -0700478int security_locked_down(enum lockdown_reason what);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479#else /* CONFIG_SECURITY */
Eric Parise0007522008-03-05 10:31:54 -0500480
Janne Karhunen42df7442019-06-14 15:20:14 +0300481static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data)
Daniel Jurgens8f408ab2017-05-19 15:48:53 +0300482{
483 return 0;
484}
485
Janne Karhunen42df7442019-06-14 15:20:14 +0300486static inline int register_blocking_lsm_notifier(struct notifier_block *nb)
Daniel Jurgens8f408ab2017-05-19 15:48:53 +0300487{
488 return 0;
489}
490
Janne Karhunen42df7442019-06-14 15:20:14 +0300491static inline int unregister_blocking_lsm_notifier(struct notifier_block *nb)
Daniel Jurgens8f408ab2017-05-19 15:48:53 +0300492{
493 return 0;
494}
495
Al Viro204cc0c2018-12-13 13:41:47 -0500496static inline void security_free_mnt_opts(void **mnt_opts)
Eric Parise0007522008-03-05 10:31:54 -0500497{
498}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499
500/*
501 * This is the default capabilities functionality. Most of these functions
502 * are just stubbed out, but a few must call the proper capable code.
503 */
504
505static inline int security_init(void)
506{
507 return 0;
508}
509
Matthew Garrette6b1db92019-08-19 17:17:37 -0700510static inline int early_security_init(void)
511{
512 return 0;
513}
514
Todd Kjos3f3c31d2021-10-12 09:56:13 -0700515static inline int security_binder_set_context_mgr(const struct cred *mgr)
Stephen Smalley79af7302015-01-21 10:54:10 -0500516{
517 return 0;
518}
519
Todd Kjos3f3c31d2021-10-12 09:56:13 -0700520static inline int security_binder_transaction(const struct cred *from,
521 const struct cred *to)
Stephen Smalley79af7302015-01-21 10:54:10 -0500522{
523 return 0;
524}
525
Todd Kjos3f3c31d2021-10-12 09:56:13 -0700526static inline int security_binder_transfer_binder(const struct cred *from,
527 const struct cred *to)
Stephen Smalley79af7302015-01-21 10:54:10 -0500528{
529 return 0;
530}
531
Todd Kjos3f3c31d2021-10-12 09:56:13 -0700532static inline int security_binder_transfer_file(const struct cred *from,
533 const struct cred *to,
Stephen Smalley79af7302015-01-21 10:54:10 -0500534 struct file *file)
535{
536 return 0;
537}
538
Ingo Molnar9e488582009-05-07 19:26:19 +1000539static inline int security_ptrace_access_check(struct task_struct *child,
David Howells5cd9c582008-08-14 11:37:28 +0100540 unsigned int mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541{
Ingo Molnar9e488582009-05-07 19:26:19 +1000542 return cap_ptrace_access_check(child, mode);
David Howells5cd9c582008-08-14 11:37:28 +0100543}
544
Alexander Beregalov5e186b52008-08-17 05:34:20 +0400545static inline int security_ptrace_traceme(struct task_struct *parent)
David Howells5cd9c582008-08-14 11:37:28 +0100546{
547 return cap_ptrace_traceme(parent);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548}
549
Eric Paris7b41b172008-04-23 14:10:25 -0400550static inline int security_capget(struct task_struct *target,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 kernel_cap_t *effective,
552 kernel_cap_t *inheritable,
553 kernel_cap_t *permitted)
554{
Eric Paris7b41b172008-04-23 14:10:25 -0400555 return cap_capget(target, effective, inheritable, permitted);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556}
557
David Howellsd84f4f92008-11-14 10:39:23 +1100558static inline int security_capset(struct cred *new,
559 const struct cred *old,
560 const kernel_cap_t *effective,
561 const kernel_cap_t *inheritable,
562 const kernel_cap_t *permitted)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563{
David Howellsd84f4f92008-11-14 10:39:23 +1100564 return cap_capset(new, old, effective, inheritable, permitted);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565}
566
Eric Parisb7e724d2012-01-03 12:25:15 -0500567static inline int security_capable(const struct cred *cred,
Micah Mortonc1a85a02019-01-07 16:10:53 -0800568 struct user_namespace *ns,
569 int cap,
570 unsigned int opts)
Chris Wright12b59892006-03-25 03:07:41 -0800571{
Micah Mortonc1a85a02019-01-07 16:10:53 -0800572 return cap_capable(cred, ns, cap, opts);
Chris Wright12b59892006-03-25 03:07:41 -0800573}
574
Eric Paris7b41b172008-04-23 14:10:25 -0400575static inline int security_quotactl(int cmds, int type, int id,
576 struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577{
578 return 0;
579}
580
Eric Paris7b41b172008-04-23 14:10:25 -0400581static inline int security_quota_on(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582{
583 return 0;
584}
585
Eric Paris12b30522010-11-15 18:36:29 -0500586static inline int security_syslog(int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587{
Eric Paris12b30522010-11-15 18:36:29 -0500588 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589}
590
Baolin Wang457db292016-04-08 14:02:11 +0800591static inline int security_settime64(const struct timespec64 *ts,
592 const struct timezone *tz)
593{
594 return cap_settime(ts, tz);
595}
596
Alan Cox34b4e4a2007-08-22 14:01:28 -0700597static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
598{
Casey Schauflerb1d9e6b2015-05-02 15:11:42 -0700599 return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600}
601
Eric W. Biedermanb8bff592020-03-22 15:46:24 -0500602static inline int security_bprm_creds_for_exec(struct linux_binprm *bprm)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603{
Eric W. Biedermanb8bff592020-03-22 15:46:24 -0500604 return 0;
605}
606
Eric W. Biederman56305aa2020-05-29 22:00:54 -0500607static inline int security_bprm_creds_from_file(struct linux_binprm *bprm,
608 struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609{
Eric W. Biederman56305aa2020-05-29 22:00:54 -0500610 return cap_bprm_creds_from_file(bprm, file);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611}
612
Eric Paris7b41b172008-04-23 14:10:25 -0400613static inline int security_bprm_check(struct linux_binprm *bprm)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614{
615 return 0;
616}
617
David Howellsa6f76f22008-11-14 10:39:24 +1100618static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
619{
620}
621
622static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
623{
624}
625
Al Viro0b520752018-12-23 16:02:47 -0500626static inline int security_fs_context_dup(struct fs_context *fc,
627 struct fs_context *src_fc)
628{
629 return 0;
630}
David Howellsda2441f2018-11-01 23:07:24 +0000631static inline int security_fs_context_parse_param(struct fs_context *fc,
632 struct fs_parameter *param)
633{
634 return -ENOPARAM;
635}
636
Eric Paris7b41b172008-04-23 14:10:25 -0400637static inline int security_sb_alloc(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638{
639 return 0;
640}
641
Mickaël Salaün83e804f2021-04-22 17:41:16 +0200642static inline void security_sb_delete(struct super_block *sb)
643{ }
644
Eric Paris7b41b172008-04-23 14:10:25 -0400645static inline void security_sb_free(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646{ }
647
Al Virof5c0c262018-11-17 12:09:18 -0500648static inline int security_sb_eat_lsm_opts(char *options,
Al Viro204cc0c2018-12-13 13:41:47 -0500649 void **mnt_opts)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650{
651 return 0;
652}
653
Al Viroc039bc32018-12-01 23:06:57 -0500654static inline int security_sb_remount(struct super_block *sb,
Al Viro204cc0c2018-12-13 13:41:47 -0500655 void *mnt_opts)
Eric Parisff36fe22011-03-03 16:09:14 -0500656{
657 return 0;
658}
659
Olga Kornievskaia69c4a422021-02-26 22:37:55 -0500660static inline int security_sb_mnt_opts_compat(struct super_block *sb,
661 void *mnt_opts)
662{
663 return 0;
664}
665
666
Al Viroa10d7c22018-12-05 11:58:35 -0500667static inline int security_sb_kern_mount(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668{
669 return 0;
670}
671
Eric Paris2069f452008-07-04 09:47:13 +1000672static inline int security_sb_show_options(struct seq_file *m,
673 struct super_block *sb)
674{
675 return 0;
676}
677
Eric Paris7b41b172008-04-23 14:10:25 -0400678static inline int security_sb_statfs(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679{
680 return 0;
681}
682
Al Viro8a04c432016-03-25 14:52:53 -0400683static inline int security_sb_mount(const char *dev_name, const struct path *path,
Al Viro808d4e32012-10-11 11:42:01 -0400684 const char *type, unsigned long flags,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 void *data)
686{
687 return 0;
688}
689
Eric Paris7b41b172008-04-23 14:10:25 -0400690static inline int security_sb_umount(struct vfsmount *mnt, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691{
692 return 0;
693}
694
Al Viro3b73b682016-03-25 15:31:19 -0400695static inline int security_sb_pivotroot(const struct path *old_path,
696 const struct path *new_path)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697{
698 return 0;
699}
700
Eric Parise0007522008-03-05 10:31:54 -0500701static inline int security_sb_set_mnt_opts(struct super_block *sb,
Al Viro204cc0c2018-12-13 13:41:47 -0500702 void *mnt_opts,
David Quigley649f6e72013-05-22 12:50:36 -0400703 unsigned long kern_flags,
704 unsigned long *set_kern_flags)
Eric Parise0007522008-03-05 10:31:54 -0500705{
706 return 0;
707}
708
Jeff Layton094f7b62013-04-01 08:14:24 -0400709static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
Scott Mayhew0b4d3452017-06-05 11:45:04 -0400710 struct super_block *newsb,
711 unsigned long kern_flags,
712 unsigned long *set_kern_flags)
Jeff Layton094f7b62013-04-01 08:14:24 -0400713{
714 return 0;
715}
Eric Parise0007522008-03-05 10:31:54 -0500716
Al Viro757cbe52018-12-14 23:42:21 -0500717static inline int security_add_mnt_opt(const char *option, const char *val,
718 int len, void **mnt_opts)
Eric Parise0007522008-03-05 10:31:54 -0500719{
720 return 0;
721}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722
David Howells2db154b2018-11-05 17:40:30 +0000723static inline int security_move_mount(const struct path *from_path,
724 const struct path *to_path)
725{
726 return 0;
727}
728
Aaron Goidelac5656d2019-08-12 11:20:00 -0400729static inline int security_path_notify(const struct path *path, u64 mask,
730 unsigned int obj_type)
731{
732 return 0;
733}
734
Eric Paris7b41b172008-04-23 14:10:25 -0400735static inline int security_inode_alloc(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736{
737 return 0;
738}
739
Eric Paris7b41b172008-04-23 14:10:25 -0400740static inline void security_inode_free(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741{ }
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700742
David Quigleyd47be3d2013-05-22 12:50:34 -0400743static inline int security_dentry_init_security(struct dentry *dentry,
744 int mode,
Al Viro4f3ccd72016-07-20 16:06:15 -0400745 const struct qstr *name,
David Quigleyd47be3d2013-05-22 12:50:34 -0400746 void **ctx,
747 u32 *ctxlen)
748{
749 return -EOPNOTSUPP;
750}
751
Vivek Goyal26026252016-07-13 10:44:52 -0400752static inline int security_dentry_create_files_as(struct dentry *dentry,
753 int mode, struct qstr *name,
754 const struct cred *old,
755 struct cred *new)
756{
757 return 0;
758}
759
David Quigleyd47be3d2013-05-22 12:50:34 -0400760
Eric Paris7b41b172008-04-23 14:10:25 -0400761static inline int security_inode_init_security(struct inode *inode,
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700762 struct inode *dir,
Eric Paris2a7dba32011-02-01 11:05:39 -0500763 const struct qstr *qstr,
Mark Rustadfbff6612014-08-28 04:43:09 -0700764 const initxattrs xattrs,
Mimi Zohar9d8f13b2011-06-06 15:29:25 -0400765 void *fs_data)
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700766{
Mimi Zohar1e39f382011-08-15 09:09:16 -0400767 return 0;
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700768}
Eric Paris7b41b172008-04-23 14:10:25 -0400769
Lokesh Gidra215b674b2021-01-08 14:22:20 -0800770static inline int security_inode_init_security_anon(struct inode *inode,
771 const struct qstr *name,
772 const struct inode *context_inode)
773{
774 return 0;
775}
776
Mimi Zohar1e39f382011-08-15 09:09:16 -0400777static inline int security_old_inode_init_security(struct inode *inode,
778 struct inode *dir,
779 const struct qstr *qstr,
Tetsuo Handa95489062013-07-25 05:44:02 +0900780 const char **name,
781 void **value, size_t *len)
Mimi Zohare1c9b232011-08-11 00:22:51 -0400782{
Jan Kara30e05322012-01-03 13:14:29 +0100783 return -EOPNOTSUPP;
Mimi Zohare1c9b232011-08-11 00:22:51 -0400784}
785
Eric Paris7b41b172008-04-23 14:10:25 -0400786static inline int security_inode_create(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 struct dentry *dentry,
Al Viro4acdaf22011-07-26 01:42:34 -0400788 umode_t mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789{
790 return 0;
791}
792
Eric Paris7b41b172008-04-23 14:10:25 -0400793static inline int security_inode_link(struct dentry *old_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 struct inode *dir,
795 struct dentry *new_dentry)
796{
797 return 0;
798}
799
Eric Paris7b41b172008-04-23 14:10:25 -0400800static inline int security_inode_unlink(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 struct dentry *dentry)
802{
803 return 0;
804}
805
Eric Paris7b41b172008-04-23 14:10:25 -0400806static inline int security_inode_symlink(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 struct dentry *dentry,
808 const char *old_name)
809{
810 return 0;
811}
812
Eric Paris7b41b172008-04-23 14:10:25 -0400813static inline int security_inode_mkdir(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 struct dentry *dentry,
815 int mode)
816{
817 return 0;
818}
819
Eric Paris7b41b172008-04-23 14:10:25 -0400820static inline int security_inode_rmdir(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 struct dentry *dentry)
822{
823 return 0;
824}
825
Eric Paris7b41b172008-04-23 14:10:25 -0400826static inline int security_inode_mknod(struct inode *dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 struct dentry *dentry,
828 int mode, dev_t dev)
829{
830 return 0;
831}
832
Eric Paris7b41b172008-04-23 14:10:25 -0400833static inline int security_inode_rename(struct inode *old_dir,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 struct dentry *old_dentry,
835 struct inode *new_dir,
Miklos Szeredi0b3974e2014-04-01 17:08:43 +0200836 struct dentry *new_dentry,
837 unsigned int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838{
839 return 0;
840}
841
Eric Paris7b41b172008-04-23 14:10:25 -0400842static inline int security_inode_readlink(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843{
844 return 0;
845}
846
NeilBrownbda0be72015-03-23 13:37:39 +1100847static inline int security_inode_follow_link(struct dentry *dentry,
848 struct inode *inode,
849 bool rcu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850{
851 return 0;
852}
853
Al Virob77b0642008-07-17 09:37:02 -0400854static inline int security_inode_permission(struct inode *inode, int mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855{
856 return 0;
857}
858
Eric Paris7b41b172008-04-23 14:10:25 -0400859static inline int security_inode_setattr(struct dentry *dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860 struct iattr *attr)
861{
862 return 0;
863}
864
Al Viro3f7036a2015-03-08 19:28:30 -0400865static inline int security_inode_getattr(const struct path *path)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866{
867 return 0;
868}
869
Christian Brauner71bc3562021-01-21 14:19:29 +0100870static inline int security_inode_setxattr(struct user_namespace *mnt_userns,
871 struct dentry *dentry, const char *name, const void *value,
872 size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873{
874 return cap_inode_setxattr(dentry, name, value, size, flags);
875}
876
David Howells8f0cfa52008-04-29 00:59:41 -0700877static inline void security_inode_post_setxattr(struct dentry *dentry,
878 const char *name, const void *value, size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879{ }
880
David Howells8f0cfa52008-04-29 00:59:41 -0700881static inline int security_inode_getxattr(struct dentry *dentry,
882 const char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883{
884 return 0;
885}
886
Eric Paris7b41b172008-04-23 14:10:25 -0400887static inline int security_inode_listxattr(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888{
889 return 0;
890}
891
Christian Brauner71bc3562021-01-21 14:19:29 +0100892static inline int security_inode_removexattr(struct user_namespace *mnt_userns,
893 struct dentry *dentry,
894 const char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895{
Christian Brauner71bc3562021-01-21 14:19:29 +0100896 return cap_inode_removexattr(mnt_userns, dentry, name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897}
898
Serge E. Hallynb5376772007-10-16 23:31:36 -0700899static inline int security_inode_need_killpriv(struct dentry *dentry)
900{
901 return cap_inode_need_killpriv(dentry);
902}
903
Christian Brauner71bc3562021-01-21 14:19:29 +0100904static inline int security_inode_killpriv(struct user_namespace *mnt_userns,
905 struct dentry *dentry)
Serge E. Hallynb5376772007-10-16 23:31:36 -0700906{
Christian Brauner71bc3562021-01-21 14:19:29 +0100907 return cap_inode_killpriv(mnt_userns, dentry);
Serge E. Hallynb5376772007-10-16 23:31:36 -0700908}
909
Christian Brauner71bc3562021-01-21 14:19:29 +0100910static inline int security_inode_getsecurity(struct user_namespace *mnt_userns,
911 struct inode *inode,
912 const char *name, void **buffer,
913 bool alloc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914{
Christian Brauner71bc3562021-01-21 14:19:29 +0100915 return cap_inode_getsecurity(mnt_userns, inode, name, buffer, alloc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916}
917
918static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
919{
920 return -EOPNOTSUPP;
921}
922
923static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
924{
925 return 0;
926}
927
Andreas Gruenbacherd6335d72015-12-24 11:09:39 -0500928static inline void security_inode_getsecid(struct inode *inode, u32 *secid)
Ahmed S. Darwish8a076192008-03-01 21:51:09 +0200929{
930 *secid = 0;
931}
932
Vivek Goyald8ad8b42016-07-13 11:13:56 -0400933static inline int security_inode_copy_up(struct dentry *src, struct cred **new)
934{
935 return 0;
936}
937
Ondrej Mosnacekb230d5a2019-02-22 15:57:16 +0100938static inline int security_kernfs_init_security(struct kernfs_node *kn_dir,
939 struct kernfs_node *kn)
940{
941 return 0;
942}
943
Vivek Goyal121ab822016-07-13 10:44:49 -0400944static inline int security_inode_copy_up_xattr(const char *name)
945{
946 return -EOPNOTSUPP;
947}
948
Eric Paris7b41b172008-04-23 14:10:25 -0400949static inline int security_file_permission(struct file *file, int mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950{
951 return 0;
952}
953
Eric Paris7b41b172008-04-23 14:10:25 -0400954static inline int security_file_alloc(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955{
956 return 0;
957}
958
Eric Paris7b41b172008-04-23 14:10:25 -0400959static inline void security_file_free(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700960{ }
961
Eric Paris7b41b172008-04-23 14:10:25 -0400962static inline int security_file_ioctl(struct file *file, unsigned int cmd,
963 unsigned long arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964{
965 return 0;
966}
967
Alfred Piccioni4590f202023-12-19 10:09:09 +0100968static inline int security_file_ioctl_compat(struct file *file,
969 unsigned int cmd,
970 unsigned long arg)
971{
972 return 0;
973}
974
Al Viro8b3ec682012-05-30 17:11:23 -0400975static inline int security_mmap_file(struct file *file, unsigned long prot,
Al Viroe5467852012-05-30 13:30:51 -0400976 unsigned long flags)
977{
978 return 0;
979}
980
981static inline int security_mmap_addr(unsigned long addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700982{
Al Virod0077942012-05-30 13:11:37 -0400983 return cap_mmap_addr(addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984}
985
Eric Paris7b41b172008-04-23 14:10:25 -0400986static inline int security_file_mprotect(struct vm_area_struct *vma,
987 unsigned long reqprot,
988 unsigned long prot)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989{
990 return 0;
991}
992
Eric Paris7b41b172008-04-23 14:10:25 -0400993static inline int security_file_lock(struct file *file, unsigned int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994{
995 return 0;
996}
997
Eric Paris7b41b172008-04-23 14:10:25 -0400998static inline int security_file_fcntl(struct file *file, unsigned int cmd,
999 unsigned long arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000{
1001 return 0;
1002}
1003
Jeff Laytone0b93ed2014-08-22 11:27:32 -04001004static inline void security_file_set_fowner(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005{
Jeff Laytone0b93ed2014-08-22 11:27:32 -04001006 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007}
1008
Eric Paris7b41b172008-04-23 14:10:25 -04001009static inline int security_file_send_sigiotask(struct task_struct *tsk,
1010 struct fown_struct *fown,
1011 int sig)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012{
1013 return 0;
1014}
1015
Eric Paris7b41b172008-04-23 14:10:25 -04001016static inline int security_file_receive(struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017{
1018 return 0;
1019}
1020
Al Viroe3f20ae2018-07-10 13:25:29 -04001021static inline int security_file_open(struct file *file)
Yuichi Nakamura788e7dd2007-09-14 09:27:07 +09001022{
1023 return 0;
1024}
1025
Tetsuo Handae4e55b42017-03-24 20:46:33 +09001026static inline int security_task_alloc(struct task_struct *task,
1027 unsigned long clone_flags)
1028{
1029 return 0;
1030}
1031
Kees Cook1a2a4d02011-12-21 12:17:03 -08001032static inline void security_task_free(struct task_struct *task)
1033{ }
1034
David Howells945af7c2009-09-04 09:19:48 +01001035static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
1036{
1037 return 0;
1038}
David Howellsee18d642009-09-02 09:14:21 +01001039
David Howellsd84f4f92008-11-14 10:39:23 +11001040static inline void security_cred_free(struct cred *cred)
1041{ }
1042
1043static inline int security_prepare_creds(struct cred *new,
1044 const struct cred *old,
1045 gfp_t gfp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046{
1047 return 0;
1048}
1049
David Howellsee18d642009-09-02 09:14:21 +01001050static inline void security_transfer_creds(struct cred *new,
1051 const struct cred *old)
1052{
1053}
1054
Todd Kjos6e8813e2021-10-12 09:56:14 -07001055static inline void security_cred_getsecid(const struct cred *c, u32 *secid)
1056{
1057 *secid = 0;
1058}
1059
David Howells3a3b7ce2008-11-14 10:39:28 +11001060static inline int security_kernel_act_as(struct cred *cred, u32 secid)
1061{
1062 return 0;
1063}
1064
1065static inline int security_kernel_create_files_as(struct cred *cred,
1066 struct inode *inode)
1067{
1068 return 0;
1069}
1070
Eric Parisdd8dbf22009-11-03 16:35:32 +11001071static inline int security_kernel_module_request(char *kmod_name)
Eric Paris91884992009-08-13 09:44:57 -04001072{
1073 return 0;
1074}
1075
Kees Cookb64fcae2020-10-02 10:38:20 -07001076static inline int security_kernel_load_data(enum kernel_load_data_id id, bool contents)
1077{
1078 return 0;
1079}
1080
1081static inline int security_kernel_post_load_data(char *buf, loff_t size,
1082 enum kernel_load_data_id id,
1083 char *description)
Mimi Zohar377179c2018-07-13 14:05:56 -04001084{
1085 return 0;
1086}
1087
Mimi Zohar39eeb4f2016-01-30 22:23:26 -05001088static inline int security_kernel_read_file(struct file *file,
Kees Cook2039bda2020-10-02 10:38:23 -07001089 enum kernel_read_file_id id,
1090 bool contents)
Mimi Zohar39eeb4f2016-01-30 22:23:26 -05001091{
1092 return 0;
1093}
1094
Mimi Zoharb44a7df2015-12-28 16:02:29 -05001095static inline int security_kernel_post_read_file(struct file *file,
Mimi Zoharbc8ca5b2016-01-24 10:07:32 -05001096 char *buf, loff_t size,
1097 enum kernel_read_file_id id)
Mimi Zoharb44a7df2015-12-28 16:02:29 -05001098{
1099 return 0;
1100}
1101
David Howellsd84f4f92008-11-14 10:39:23 +11001102static inline int security_task_fix_setuid(struct cred *new,
1103 const struct cred *old,
1104 int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105{
David Howellsd84f4f92008-11-14 10:39:23 +11001106 return cap_task_fix_setuid(new, old, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107}
1108
Thomas Cedeno39030e12020-06-09 10:22:13 -07001109static inline int security_task_fix_setgid(struct cred *new,
1110 const struct cred *old,
1111 int flags)
1112{
1113 return 0;
1114}
1115
Eric Paris7b41b172008-04-23 14:10:25 -04001116static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117{
1118 return 0;
1119}
1120
Eric Paris7b41b172008-04-23 14:10:25 -04001121static inline int security_task_getpgid(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122{
1123 return 0;
1124}
1125
Eric Paris7b41b172008-04-23 14:10:25 -04001126static inline int security_task_getsid(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127{
1128 return 0;
1129}
1130
Paul Moore4ebd7652021-02-19 14:26:21 -05001131static inline void security_task_getsecid_subj(struct task_struct *p, u32 *secid)
1132{
1133 *secid = 0;
1134}
1135
1136static inline void security_task_getsecid_obj(struct task_struct *p, u32 *secid)
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02001137{
1138 *secid = 0;
1139}
David Quigleyf9008e4c2006-06-30 01:55:46 -07001140
Eric Paris7b41b172008-04-23 14:10:25 -04001141static inline int security_task_setnice(struct task_struct *p, int nice)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142{
Serge E. Hallynb5376772007-10-16 23:31:36 -07001143 return cap_task_setnice(p, nice);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144}
1145
Eric Paris7b41b172008-04-23 14:10:25 -04001146static inline int security_task_setioprio(struct task_struct *p, int ioprio)
James Morris03e68062006-06-23 02:03:58 -07001147{
Serge E. Hallynb5376772007-10-16 23:31:36 -07001148 return cap_task_setioprio(p, ioprio);
James Morris03e68062006-06-23 02:03:58 -07001149}
1150
Eric Paris7b41b172008-04-23 14:10:25 -04001151static inline int security_task_getioprio(struct task_struct *p)
David Quigleya1836a42006-06-30 01:55:49 -07001152{
1153 return 0;
1154}
1155
Stephen Smalley791ec492017-02-17 07:57:00 -05001156static inline int security_task_prlimit(const struct cred *cred,
1157 const struct cred *tcred,
1158 unsigned int flags)
1159{
1160 return 0;
1161}
1162
Jiri Slaby8fd00b42009-08-26 18:41:16 +02001163static inline int security_task_setrlimit(struct task_struct *p,
1164 unsigned int resource,
Eric Paris7b41b172008-04-23 14:10:25 -04001165 struct rlimit *new_rlim)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166{
1167 return 0;
1168}
1169
KOSAKI Motohirob0ae1982010-10-15 04:21:18 +09001170static inline int security_task_setscheduler(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001171{
KOSAKI Motohirob0ae1982010-10-15 04:21:18 +09001172 return cap_task_setscheduler(p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173}
1174
Eric Paris7b41b172008-04-23 14:10:25 -04001175static inline int security_task_getscheduler(struct task_struct *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176{
1177 return 0;
1178}
1179
Eric Paris7b41b172008-04-23 14:10:25 -04001180static inline int security_task_movememory(struct task_struct *p)
David Quigley35601542006-06-23 02:04:01 -07001181{
1182 return 0;
1183}
1184
Eric Paris7b41b172008-04-23 14:10:25 -04001185static inline int security_task_kill(struct task_struct *p,
Eric W. Biedermanae7795b2018-09-25 11:27:20 +02001186 struct kernel_siginfo *info, int sig,
Stephen Smalley6b4f3d02017-09-08 12:40:01 -04001187 const struct cred *cred)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188{
Serge Hallynaedb60a2008-02-29 15:14:57 +00001189 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190}
1191
Eric Paris7b41b172008-04-23 14:10:25 -04001192static inline int security_task_prctl(int option, unsigned long arg2,
1193 unsigned long arg3,
1194 unsigned long arg4,
David Howellsd84f4f92008-11-14 10:39:23 +11001195 unsigned long arg5)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196{
Jann Hornb7f76ea2015-09-18 23:41:23 +02001197 return cap_task_prctl(option, arg2, arg3, arg4, arg5);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198}
1199
1200static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1201{ }
1202
Eric Paris7b41b172008-04-23 14:10:25 -04001203static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
1204 short flag)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001205{
1206 return 0;
1207}
1208
Ahmed S. Darwish8a076192008-03-01 21:51:09 +02001209static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
1210{
1211 *secid = 0;
1212}
1213
Eric Paris7b41b172008-04-23 14:10:25 -04001214static inline int security_msg_msg_alloc(struct msg_msg *msg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001215{
1216 return 0;
1217}
1218
Eric Paris7b41b172008-04-23 14:10:25 -04001219static inline void security_msg_msg_free(struct msg_msg *msg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220{ }
1221
Eric W. Biedermand8c6e852018-03-22 21:22:26 -05001222static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001223{
1224 return 0;
1225}
1226
Eric W. Biedermand8c6e852018-03-22 21:22:26 -05001227static inline void security_msg_queue_free(struct kern_ipc_perm *msq)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001228{ }
1229
Eric W. Biedermand8c6e852018-03-22 21:22:26 -05001230static inline int security_msg_queue_associate(struct kern_ipc_perm *msq,
Eric Paris7b41b172008-04-23 14:10:25 -04001231 int msqflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232{
1233 return 0;
1234}
1235
Eric W. Biedermand8c6e852018-03-22 21:22:26 -05001236static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001237{
1238 return 0;
1239}
1240
Eric W. Biedermand8c6e852018-03-22 21:22:26 -05001241static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
Eric Paris7b41b172008-04-23 14:10:25 -04001242 struct msg_msg *msg, int msqflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243{
1244 return 0;
1245}
1246
Eric W. Biedermand8c6e852018-03-22 21:22:26 -05001247static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq,
Eric Paris7b41b172008-04-23 14:10:25 -04001248 struct msg_msg *msg,
1249 struct task_struct *target,
1250 long type, int mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001251{
1252 return 0;
1253}
1254
Eric W. Biederman7191adf2018-03-22 21:08:27 -05001255static inline int security_shm_alloc(struct kern_ipc_perm *shp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001256{
1257 return 0;
1258}
1259
Eric W. Biederman7191adf2018-03-22 21:08:27 -05001260static inline void security_shm_free(struct kern_ipc_perm *shp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001261{ }
1262
Eric W. Biederman7191adf2018-03-22 21:08:27 -05001263static inline int security_shm_associate(struct kern_ipc_perm *shp,
Eric Paris7b41b172008-04-23 14:10:25 -04001264 int shmflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001265{
1266 return 0;
1267}
1268
Eric W. Biederman7191adf2018-03-22 21:08:27 -05001269static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001270{
1271 return 0;
1272}
1273
Eric W. Biederman7191adf2018-03-22 21:08:27 -05001274static inline int security_shm_shmat(struct kern_ipc_perm *shp,
Eric Paris7b41b172008-04-23 14:10:25 -04001275 char __user *shmaddr, int shmflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276{
1277 return 0;
1278}
1279
Eric W. Biedermanaefad952018-03-22 20:52:43 -05001280static inline int security_sem_alloc(struct kern_ipc_perm *sma)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001281{
1282 return 0;
1283}
1284
Eric W. Biedermanaefad952018-03-22 20:52:43 -05001285static inline void security_sem_free(struct kern_ipc_perm *sma)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001286{ }
1287
Eric W. Biedermanaefad952018-03-22 20:52:43 -05001288static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001289{
1290 return 0;
1291}
1292
Eric W. Biedermanaefad952018-03-22 20:52:43 -05001293static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294{
1295 return 0;
1296}
1297
Eric W. Biedermanaefad952018-03-22 20:52:43 -05001298static inline int security_sem_semop(struct kern_ipc_perm *sma,
Eric Paris7b41b172008-04-23 14:10:25 -04001299 struct sembuf *sops, unsigned nsops,
1300 int alter)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001301{
1302 return 0;
1303}
1304
Casey Schaufler6d9c9392018-09-21 17:16:59 -07001305static inline void security_d_instantiate(struct dentry *dentry,
1306 struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001307{ }
1308
Casey Schaufler6d9c9392018-09-21 17:16:59 -07001309static inline int security_getprocattr(struct task_struct *p, const char *lsm,
1310 char *name, char **value)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311{
1312 return -EINVAL;
1313}
1314
Casey Schaufler6d9c9392018-09-21 17:16:59 -07001315static inline int security_setprocattr(const char *lsm, char *name,
1316 void *value, size_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317{
1318 return -EINVAL;
1319}
1320
Eric Paris7b41b172008-04-23 14:10:25 -04001321static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001322{
Casey Schauflerb1d9e6b2015-05-02 15:11:42 -07001323 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001324}
1325
David Quigley746df9b2013-05-22 12:50:35 -04001326static inline int security_ismaclabel(const char *name)
1327{
1328 return 0;
1329}
1330
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001331static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
1332{
1333 return -EOPNOTSUPP;
1334}
1335
David Howells7bf570d2008-04-29 20:52:51 +01001336static inline int security_secctx_to_secid(const char *secdata,
David Howells63cb3442008-01-15 23:47:35 +00001337 u32 seclen,
1338 u32 *secid)
1339{
1340 return -EOPNOTSUPP;
1341}
1342
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001343static inline void security_release_secctx(char *secdata, u32 seclen)
1344{
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001345}
David P. Quigley1ee65e32009-09-03 14:25:57 -04001346
Andreas Gruenbacher6f3be9f2015-12-24 11:09:40 -05001347static inline void security_inode_invalidate_secctx(struct inode *inode)
1348{
1349}
1350
David P. Quigley1ee65e32009-09-03 14:25:57 -04001351static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
1352{
1353 return -EOPNOTSUPP;
1354}
1355static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
1356{
1357 return -EOPNOTSUPP;
1358}
1359static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
1360{
1361 return -EOPNOTSUPP;
1362}
Matthew Garrett9e47d312019-08-19 17:17:38 -07001363static inline int security_locked_down(enum lockdown_reason what)
1364{
1365 return 0;
1366}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367#endif /* CONFIG_SECURITY */
1368
David Howells344fa642020-02-12 13:58:35 +00001369#if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
1370int security_post_notification(const struct cred *w_cred,
1371 const struct cred *cred,
1372 struct watch_notification *n);
1373#else
1374static inline int security_post_notification(const struct cred *w_cred,
1375 const struct cred *cred,
1376 struct watch_notification *n)
1377{
1378 return 0;
1379}
1380#endif
1381
David Howells998f5042020-02-12 13:58:35 +00001382#if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
1383int security_watch_key(struct key *key);
1384#else
1385static inline int security_watch_key(struct key *key)
1386{
1387 return 0;
1388}
1389#endif
1390
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391#ifdef CONFIG_SECURITY_NETWORK
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392
David S. Miller3610cda2011-01-05 15:38:53 -08001393int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
James Morris20510f22007-10-16 23:31:32 -07001394int security_unix_may_send(struct socket *sock, struct socket *other);
1395int security_socket_create(int family, int type, int protocol, int kern);
1396int security_socket_post_create(struct socket *sock, int family,
1397 int type, int protocol, int kern);
David Herrmannaae7cfc2018-05-04 16:28:19 +02001398int security_socket_socketpair(struct socket *socka, struct socket *sockb);
James Morris20510f22007-10-16 23:31:32 -07001399int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
1400int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
1401int security_socket_listen(struct socket *sock, int backlog);
1402int security_socket_accept(struct socket *sock, struct socket *newsock);
James Morris20510f22007-10-16 23:31:32 -07001403int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
1404int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
1405 int size, int flags);
1406int security_socket_getsockname(struct socket *sock);
1407int security_socket_getpeername(struct socket *sock);
1408int security_socket_getsockopt(struct socket *sock, int level, int optname);
1409int security_socket_setsockopt(struct socket *sock, int level, int optname);
1410int security_socket_shutdown(struct socket *sock, int how);
1411int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
1412int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
1413 int __user *optlen, unsigned len);
1414int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
1415int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
1416void security_sk_free(struct sock *sk);
1417void security_sk_clone(const struct sock *sk, struct sock *newsk);
Paul Moore3df98d72020-09-27 22:38:26 -04001418void security_sk_classify_flow(struct sock *sk, struct flowi_common *flic);
1419void security_req_classify_flow(const struct request_sock *req,
1420 struct flowi_common *flic);
James Morris20510f22007-10-16 23:31:32 -07001421void security_sock_graft(struct sock*sk, struct socket *parent);
Florian Westphal41dd9592020-11-30 16:36:29 +01001422int security_inet_conn_request(const struct sock *sk,
James Morris20510f22007-10-16 23:31:32 -07001423 struct sk_buff *skb, struct request_sock *req);
1424void security_inet_csk_clone(struct sock *newsk,
1425 const struct request_sock *req);
1426void security_inet_conn_established(struct sock *sk,
1427 struct sk_buff *skb);
Eric Paris2606fd12010-10-13 16:24:41 -04001428int security_secmark_relabel_packet(u32 secid);
1429void security_secmark_refcount_inc(void);
1430void security_secmark_refcount_dec(void);
Paul Moore5dbbaf22013-01-14 07:12:19 +00001431int security_tun_dev_alloc_security(void **security);
1432void security_tun_dev_free_security(void *security);
Paul Moore2b980db2009-08-28 18:12:43 -04001433int security_tun_dev_create(void);
Paul Moore5dbbaf22013-01-14 07:12:19 +00001434int security_tun_dev_attach_queue(void *security);
1435int security_tun_dev_attach(struct sock *sk, void *security);
1436int security_tun_dev_open(void *security);
Richard Haines72e89f52018-02-13 20:53:21 +00001437int security_sctp_assoc_request(struct sctp_endpoint *ep, struct sk_buff *skb);
1438int security_sctp_bind_connect(struct sock *sk, int optname,
1439 struct sockaddr *address, int addrlen);
1440void security_sctp_sk_clone(struct sctp_endpoint *ep, struct sock *sk,
1441 struct sock *newsk);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001442
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443#else /* CONFIG_SECURITY_NETWORK */
David S. Miller3610cda2011-01-05 15:38:53 -08001444static inline int security_unix_stream_connect(struct sock *sock,
1445 struct sock *other,
Eric Paris7b41b172008-04-23 14:10:25 -04001446 struct sock *newsk)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447{
1448 return 0;
1449}
1450
Eric Paris7b41b172008-04-23 14:10:25 -04001451static inline int security_unix_may_send(struct socket *sock,
1452 struct socket *other)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453{
1454 return 0;
1455}
1456
Eric Paris7b41b172008-04-23 14:10:25 -04001457static inline int security_socket_create(int family, int type,
1458 int protocol, int kern)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459{
1460 return 0;
1461}
1462
Eric Paris7b41b172008-04-23 14:10:25 -04001463static inline int security_socket_post_create(struct socket *sock,
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07001464 int family,
1465 int type,
1466 int protocol, int kern)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467{
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07001468 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469}
1470
David Herrmannaae7cfc2018-05-04 16:28:19 +02001471static inline int security_socket_socketpair(struct socket *socka,
1472 struct socket *sockb)
1473{
1474 return 0;
1475}
1476
Eric Paris7b41b172008-04-23 14:10:25 -04001477static inline int security_socket_bind(struct socket *sock,
1478 struct sockaddr *address,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479 int addrlen)
1480{
1481 return 0;
1482}
1483
Eric Paris7b41b172008-04-23 14:10:25 -04001484static inline int security_socket_connect(struct socket *sock,
1485 struct sockaddr *address,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486 int addrlen)
1487{
1488 return 0;
1489}
1490
Eric Paris7b41b172008-04-23 14:10:25 -04001491static inline int security_socket_listen(struct socket *sock, int backlog)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492{
1493 return 0;
1494}
1495
Eric Paris7b41b172008-04-23 14:10:25 -04001496static inline int security_socket_accept(struct socket *sock,
1497 struct socket *newsock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498{
1499 return 0;
1500}
1501
Eric Paris7b41b172008-04-23 14:10:25 -04001502static inline int security_socket_sendmsg(struct socket *sock,
1503 struct msghdr *msg, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504{
1505 return 0;
1506}
1507
Eric Paris7b41b172008-04-23 14:10:25 -04001508static inline int security_socket_recvmsg(struct socket *sock,
1509 struct msghdr *msg, int size,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001510 int flags)
1511{
1512 return 0;
1513}
1514
Eric Paris7b41b172008-04-23 14:10:25 -04001515static inline int security_socket_getsockname(struct socket *sock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516{
1517 return 0;
1518}
1519
Eric Paris7b41b172008-04-23 14:10:25 -04001520static inline int security_socket_getpeername(struct socket *sock)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001521{
1522 return 0;
1523}
1524
Eric Paris7b41b172008-04-23 14:10:25 -04001525static inline int security_socket_getsockopt(struct socket *sock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526 int level, int optname)
1527{
1528 return 0;
1529}
1530
Eric Paris7b41b172008-04-23 14:10:25 -04001531static inline int security_socket_setsockopt(struct socket *sock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532 int level, int optname)
1533{
1534 return 0;
1535}
1536
Eric Paris7b41b172008-04-23 14:10:25 -04001537static inline int security_socket_shutdown(struct socket *sock, int how)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538{
1539 return 0;
1540}
Eric Paris7b41b172008-04-23 14:10:25 -04001541static inline int security_sock_rcv_skb(struct sock *sk,
1542 struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543{
1544 return 0;
1545}
1546
Catherine Zhang2c7946a2006-03-20 22:41:23 -08001547static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
1548 int __user *optlen, unsigned len)
1549{
1550 return -ENOPROTOOPT;
1551}
1552
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001553static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554{
1555 return -ENOPROTOOPT;
1556}
1557
Al Virodd0fc662005-10-07 07:46:04 +01001558static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559{
1560 return 0;
1561}
1562
1563static inline void security_sk_free(struct sock *sk)
1564{
1565}
Trent Jaegerdf718372005-12-13 23:12:27 -08001566
Venkat Yekkirala892c1412006-08-04 23:08:56 -07001567static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
1568{
1569}
1570
Paul Moore3df98d72020-09-27 22:38:26 -04001571static inline void security_sk_classify_flow(struct sock *sk,
1572 struct flowi_common *flic)
Trent Jaegerdf718372005-12-13 23:12:27 -08001573{
Trent Jaegerdf718372005-12-13 23:12:27 -08001574}
Venkat Yekkirala4237c752006-07-24 23:32:50 -07001575
Paul Moore3df98d72020-09-27 22:38:26 -04001576static inline void security_req_classify_flow(const struct request_sock *req,
1577 struct flowi_common *flic)
Venkat Yekkirala4237c752006-07-24 23:32:50 -07001578{
1579}
1580
Eric Paris7b41b172008-04-23 14:10:25 -04001581static inline void security_sock_graft(struct sock *sk, struct socket *parent)
Venkat Yekkirala4237c752006-07-24 23:32:50 -07001582{
1583}
1584
Florian Westphal41dd9592020-11-30 16:36:29 +01001585static inline int security_inet_conn_request(const struct sock *sk,
Venkat Yekkirala4237c752006-07-24 23:32:50 -07001586 struct sk_buff *skb, struct request_sock *req)
1587{
1588 return 0;
1589}
1590
1591static inline void security_inet_csk_clone(struct sock *newsk,
1592 const struct request_sock *req)
1593{
1594}
Venkat Yekkirala6b877692006-11-08 17:04:09 -06001595
1596static inline void security_inet_conn_established(struct sock *sk,
1597 struct sk_buff *skb)
1598{
1599}
Paul Moore2b980db2009-08-28 18:12:43 -04001600
Eric Paris2606fd12010-10-13 16:24:41 -04001601static inline int security_secmark_relabel_packet(u32 secid)
1602{
1603 return 0;
1604}
1605
1606static inline void security_secmark_refcount_inc(void)
1607{
1608}
1609
1610static inline void security_secmark_refcount_dec(void)
1611{
1612}
1613
Paul Moore5dbbaf22013-01-14 07:12:19 +00001614static inline int security_tun_dev_alloc_security(void **security)
1615{
1616 return 0;
1617}
1618
1619static inline void security_tun_dev_free_security(void *security)
1620{
1621}
1622
Paul Moore2b980db2009-08-28 18:12:43 -04001623static inline int security_tun_dev_create(void)
1624{
1625 return 0;
1626}
1627
Paul Moore5dbbaf22013-01-14 07:12:19 +00001628static inline int security_tun_dev_attach_queue(void *security)
Paul Moore2b980db2009-08-28 18:12:43 -04001629{
Paul Moore5dbbaf22013-01-14 07:12:19 +00001630 return 0;
Paul Moore2b980db2009-08-28 18:12:43 -04001631}
1632
Paul Moore5dbbaf22013-01-14 07:12:19 +00001633static inline int security_tun_dev_attach(struct sock *sk, void *security)
1634{
1635 return 0;
1636}
1637
1638static inline int security_tun_dev_open(void *security)
Paul Moore2b980db2009-08-28 18:12:43 -04001639{
1640 return 0;
1641}
Richard Haines72e89f52018-02-13 20:53:21 +00001642
1643static inline int security_sctp_assoc_request(struct sctp_endpoint *ep,
1644 struct sk_buff *skb)
1645{
1646 return 0;
1647}
1648
1649static inline int security_sctp_bind_connect(struct sock *sk, int optname,
1650 struct sockaddr *address,
1651 int addrlen)
1652{
1653 return 0;
1654}
1655
1656static inline void security_sctp_sk_clone(struct sctp_endpoint *ep,
1657 struct sock *sk,
1658 struct sock *newsk)
1659{
1660}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001661#endif /* CONFIG_SECURITY_NETWORK */
1662
Daniel Jurgensd291f1a2017-05-19 15:48:52 +03001663#ifdef CONFIG_SECURITY_INFINIBAND
1664int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey);
Daniel Jurgens47a2b332017-05-19 15:48:54 +03001665int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num);
Daniel Jurgensd291f1a2017-05-19 15:48:52 +03001666int security_ib_alloc_security(void **sec);
1667void security_ib_free_security(void *sec);
1668#else /* CONFIG_SECURITY_INFINIBAND */
1669static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey)
1670{
1671 return 0;
1672}
1673
Daniel Jurgens47a2b332017-05-19 15:48:54 +03001674static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num)
1675{
1676 return 0;
1677}
1678
Daniel Jurgensd291f1a2017-05-19 15:48:52 +03001679static inline int security_ib_alloc_security(void **sec)
1680{
1681 return 0;
1682}
1683
1684static inline void security_ib_free_security(void *sec)
1685{
1686}
1687#endif /* CONFIG_SECURITY_INFINIBAND */
1688
Trent Jaegerdf718372005-12-13 23:12:27 -08001689#ifdef CONFIG_SECURITY_NETWORK_XFRM
Venkat Yekkiralacb969f02006-07-24 23:32:20 -07001690
Nikolay Aleksandrov52a4c642014-03-07 12:44:19 +01001691int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1692 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
Paul Moore03e1ad72008-04-12 19:07:52 -07001693int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
1694void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
1695int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
James Morris20510f22007-10-16 23:31:32 -07001696int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1697int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1698 struct xfrm_sec_ctx *polsec, u32 secid);
1699int security_xfrm_state_delete(struct xfrm_state *x);
1700void security_xfrm_state_free(struct xfrm_state *x);
Zhongjun Tan8a922802021-04-09 13:48:41 +08001701int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid);
James Morris20510f22007-10-16 23:31:32 -07001702int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
David S. Millere33f7702011-02-22 18:13:15 -08001703 struct xfrm_policy *xp,
Paul Moore3df98d72020-09-27 22:38:26 -04001704 const struct flowi_common *flic);
James Morris20510f22007-10-16 23:31:32 -07001705int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
Paul Moore3df98d72020-09-27 22:38:26 -04001706void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic);
Trent Jaegerdf718372005-12-13 23:12:27 -08001707
Trent Jaegerdf718372005-12-13 23:12:27 -08001708#else /* CONFIG_SECURITY_NETWORK_XFRM */
James Morris20510f22007-10-16 23:31:32 -07001709
Nikolay Aleksandrov52a4c642014-03-07 12:44:19 +01001710static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
1711 struct xfrm_user_sec_ctx *sec_ctx,
1712 gfp_t gfp)
Trent Jaegerdf718372005-12-13 23:12:27 -08001713{
1714 return 0;
1715}
1716
Paul Moore03e1ad72008-04-12 19:07:52 -07001717static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
Trent Jaegerdf718372005-12-13 23:12:27 -08001718{
1719 return 0;
1720}
1721
Paul Moore03e1ad72008-04-12 19:07:52 -07001722static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
Trent Jaegerdf718372005-12-13 23:12:27 -08001723{
1724}
1725
Paul Moore03e1ad72008-04-12 19:07:52 -07001726static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001727{
1728 return 0;
1729}
1730
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001731static inline int security_xfrm_state_alloc(struct xfrm_state *x,
1732 struct xfrm_user_sec_ctx *sec_ctx)
1733{
1734 return 0;
1735}
1736
1737static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
1738 struct xfrm_sec_ctx *polsec, u32 secid)
Trent Jaegerdf718372005-12-13 23:12:27 -08001739{
1740 return 0;
1741}
1742
1743static inline void security_xfrm_state_free(struct xfrm_state *x)
1744{
1745}
1746
David S. Miller6f68dc32006-06-08 23:58:52 -07001747static inline int security_xfrm_state_delete(struct xfrm_state *x)
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001748{
1749 return 0;
1750}
1751
Zhongjun Tan8a922802021-04-09 13:48:41 +08001752static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
Trent Jaegerdf718372005-12-13 23:12:27 -08001753{
1754 return 0;
1755}
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001756
1757static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
Paul Moore3df98d72020-09-27 22:38:26 -04001758 struct xfrm_policy *xp,
1759 const struct flowi_common *flic)
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001760{
1761 return 1;
1762}
1763
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001764static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001765{
1766 return 0;
1767}
1768
Paul Moore3df98d72020-09-27 22:38:26 -04001769static inline void security_skb_classify_flow(struct sk_buff *skb,
1770 struct flowi_common *flic)
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001771{
1772}
1773
Trent Jaegerdf718372005-12-13 23:12:27 -08001774#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1775
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001776#ifdef CONFIG_SECURITY_PATH
Al Viro989f74e2016-03-25 15:13:39 -04001777int security_path_unlink(const struct path *dir, struct dentry *dentry);
Al Virod3607752016-03-25 15:21:09 -04001778int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
Al Viro989f74e2016-03-25 15:13:39 -04001779int security_path_rmdir(const struct path *dir, struct dentry *dentry);
Al Virod3607752016-03-25 15:21:09 -04001780int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001781 unsigned int dev);
Al Viro81f4c502016-03-25 14:22:01 -04001782int security_path_truncate(const struct path *path);
Al Virod3607752016-03-25 15:21:09 -04001783int security_path_symlink(const struct path *dir, struct dentry *dentry,
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001784 const char *old_name);
Al Viro3ccee462016-03-25 15:27:45 -04001785int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001786 struct dentry *new_dentry);
Al Viro3ccee462016-03-25 15:27:45 -04001787int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
1788 const struct path *new_dir, struct dentry *new_dentry,
Miklos Szeredi0b3974e2014-04-01 17:08:43 +02001789 unsigned int flags);
Al Virobe01f9f2016-03-25 14:56:23 -04001790int security_path_chmod(const struct path *path, umode_t mode);
Al Viro7fd25da2016-03-25 14:44:41 -04001791int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
Al Viro77b286c2016-03-25 15:28:43 -04001792int security_path_chroot(const struct path *path);
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001793#else /* CONFIG_SECURITY_PATH */
Al Viro989f74e2016-03-25 15:13:39 -04001794static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001795{
1796 return 0;
1797}
1798
Al Virod3607752016-03-25 15:21:09 -04001799static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
Al Viro4572bef2011-11-21 14:56:21 -05001800 umode_t mode)
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001801{
1802 return 0;
1803}
1804
Al Viro989f74e2016-03-25 15:13:39 -04001805static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001806{
1807 return 0;
1808}
1809
Al Virod3607752016-03-25 15:21:09 -04001810static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
Al Viro04fc66e2011-11-21 14:58:38 -05001811 umode_t mode, unsigned int dev)
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001812{
1813 return 0;
1814}
1815
Al Viro81f4c502016-03-25 14:22:01 -04001816static inline int security_path_truncate(const struct path *path)
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001817{
1818 return 0;
1819}
1820
Al Virod3607752016-03-25 15:21:09 -04001821static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001822 const char *old_name)
1823{
1824 return 0;
1825}
1826
1827static inline int security_path_link(struct dentry *old_dentry,
Al Viro3ccee462016-03-25 15:27:45 -04001828 const struct path *new_dir,
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001829 struct dentry *new_dentry)
1830{
1831 return 0;
1832}
1833
Al Viro3ccee462016-03-25 15:27:45 -04001834static inline int security_path_rename(const struct path *old_dir,
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001835 struct dentry *old_dentry,
Al Viro3ccee462016-03-25 15:27:45 -04001836 const struct path *new_dir,
Miklos Szeredi0b3974e2014-04-01 17:08:43 +02001837 struct dentry *new_dentry,
1838 unsigned int flags)
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001839{
1840 return 0;
1841}
Tetsuo Handa89eda062009-10-04 21:49:47 +09001842
Al Virobe01f9f2016-03-25 14:56:23 -04001843static inline int security_path_chmod(const struct path *path, umode_t mode)
Tetsuo Handa89eda062009-10-04 21:49:47 +09001844{
1845 return 0;
1846}
1847
Al Viro7fd25da2016-03-25 14:44:41 -04001848static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
Tetsuo Handa89eda062009-10-04 21:49:47 +09001849{
1850 return 0;
1851}
Tetsuo Handa8b8efb42009-10-04 21:49:48 +09001852
Al Viro77b286c2016-03-25 15:28:43 -04001853static inline int security_path_chroot(const struct path *path)
Tetsuo Handa8b8efb42009-10-04 21:49:48 +09001854{
1855 return 0;
1856}
Kentaro Takedabe6d3e52008-12-17 13:24:15 +09001857#endif /* CONFIG_SECURITY_PATH */
1858
David Howells29db9192005-10-30 15:02:44 -08001859#ifdef CONFIG_KEYS
1860#ifdef CONFIG_SECURITY
David Howells29db9192005-10-30 15:02:44 -08001861
David Howellsd84f4f92008-11-14 10:39:23 +11001862int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
James Morris20510f22007-10-16 23:31:32 -07001863void security_key_free(struct key *key);
David Howells8c0637e2020-05-12 15:16:29 +01001864int security_key_permission(key_ref_t key_ref, const struct cred *cred,
1865 enum key_need_perm need_perm);
David Howells70a5bb72008-04-29 01:01:26 -07001866int security_key_getsecurity(struct key *key, char **_buffer);
David Howells29db9192005-10-30 15:02:44 -08001867
1868#else
1869
Michael LeMayd7200242006-06-22 14:47:17 -07001870static inline int security_key_alloc(struct key *key,
David Howellsd84f4f92008-11-14 10:39:23 +11001871 const struct cred *cred,
David Howells7e047ef2006-06-26 00:24:50 -07001872 unsigned long flags)
David Howells29db9192005-10-30 15:02:44 -08001873{
1874 return 0;
1875}
1876
1877static inline void security_key_free(struct key *key)
1878{
1879}
1880
1881static inline int security_key_permission(key_ref_t key_ref,
David Howellsd84f4f92008-11-14 10:39:23 +11001882 const struct cred *cred,
David Howells8c0637e2020-05-12 15:16:29 +01001883 enum key_need_perm need_perm)
David Howells29db9192005-10-30 15:02:44 -08001884{
1885 return 0;
1886}
1887
David Howells70a5bb72008-04-29 01:01:26 -07001888static inline int security_key_getsecurity(struct key *key, char **_buffer)
1889{
1890 *_buffer = NULL;
1891 return 0;
1892}
1893
David Howells29db9192005-10-30 15:02:44 -08001894#endif
1895#endif /* CONFIG_KEYS */
1896
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02001897#ifdef CONFIG_AUDIT
1898#ifdef CONFIG_SECURITY
1899int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
1900int security_audit_rule_known(struct audit_krule *krule);
Richard Guy Briggs90462a52019-01-31 11:52:11 -05001901int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule);
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02001902void security_audit_rule_free(void *lsmrule);
1903
1904#else
1905
1906static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
1907 void **lsmrule)
1908{
1909 return 0;
1910}
1911
1912static inline int security_audit_rule_known(struct audit_krule *krule)
1913{
1914 return 0;
1915}
1916
1917static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
Richard Guy Briggs90462a52019-01-31 11:52:11 -05001918 void *lsmrule)
Ahmed S. Darwish03d37d22008-03-01 22:00:05 +02001919{
1920 return 0;
1921}
1922
1923static inline void security_audit_rule_free(void *lsmrule)
1924{ }
1925
1926#endif /* CONFIG_SECURITY */
1927#endif /* CONFIG_AUDIT */
1928
Eric Parisda318942008-08-22 11:35:57 -04001929#ifdef CONFIG_SECURITYFS
1930
Al Viro52ef0c02011-07-26 04:30:04 -04001931extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
Eric Parisda318942008-08-22 11:35:57 -04001932 struct dentry *parent, void *data,
1933 const struct file_operations *fops);
1934extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
John Johansen6623ec72017-05-07 05:53:37 -07001935struct dentry *securityfs_create_symlink(const char *name,
1936 struct dentry *parent,
1937 const char *target,
1938 const struct inode_operations *iops);
Eric Parisda318942008-08-22 11:35:57 -04001939extern void securityfs_remove(struct dentry *dentry);
1940
1941#else /* CONFIG_SECURITYFS */
1942
1943static inline struct dentry *securityfs_create_dir(const char *name,
1944 struct dentry *parent)
1945{
1946 return ERR_PTR(-ENODEV);
1947}
1948
1949static inline struct dentry *securityfs_create_file(const char *name,
Al Viro52ef0c02011-07-26 04:30:04 -04001950 umode_t mode,
Eric Parisda318942008-08-22 11:35:57 -04001951 struct dentry *parent,
1952 void *data,
1953 const struct file_operations *fops)
1954{
1955 return ERR_PTR(-ENODEV);
1956}
1957
John Johansen6623ec72017-05-07 05:53:37 -07001958static inline struct dentry *securityfs_create_symlink(const char *name,
1959 struct dentry *parent,
1960 const char *target,
1961 const struct inode_operations *iops)
1962{
1963 return ERR_PTR(-ENODEV);
1964}
1965
Eric Parisda318942008-08-22 11:35:57 -04001966static inline void securityfs_remove(struct dentry *dentry)
1967{}
1968
1969#endif
1970
Chenbo Fengafdb09c2017-10-18 13:00:24 -07001971#ifdef CONFIG_BPF_SYSCALL
Jakub Kicinski1495dc92017-11-01 11:48:00 -07001972union bpf_attr;
1973struct bpf_map;
1974struct bpf_prog;
1975struct bpf_prog_aux;
Chenbo Fengafdb09c2017-10-18 13:00:24 -07001976#ifdef CONFIG_SECURITY
1977extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size);
1978extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
1979extern int security_bpf_prog(struct bpf_prog *prog);
1980extern int security_bpf_map_alloc(struct bpf_map *map);
1981extern void security_bpf_map_free(struct bpf_map *map);
1982extern int security_bpf_prog_alloc(struct bpf_prog_aux *aux);
1983extern void security_bpf_prog_free(struct bpf_prog_aux *aux);
1984#else
1985static inline int security_bpf(int cmd, union bpf_attr *attr,
1986 unsigned int size)
1987{
1988 return 0;
1989}
1990
1991static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode)
1992{
1993 return 0;
1994}
1995
1996static inline int security_bpf_prog(struct bpf_prog *prog)
1997{
1998 return 0;
1999}
2000
2001static inline int security_bpf_map_alloc(struct bpf_map *map)
2002{
2003 return 0;
2004}
2005
2006static inline void security_bpf_map_free(struct bpf_map *map)
2007{ }
2008
2009static inline int security_bpf_prog_alloc(struct bpf_prog_aux *aux)
2010{
2011 return 0;
2012}
2013
2014static inline void security_bpf_prog_free(struct bpf_prog_aux *aux)
2015{ }
2016#endif /* CONFIG_SECURITY */
2017#endif /* CONFIG_BPF_SYSCALL */
2018
Joel Fernandes (Google)da97e182019-10-14 13:03:08 -04002019#ifdef CONFIG_PERF_EVENTS
2020struct perf_event_attr;
Ingo Molnarae79d552019-10-19 09:15:27 +02002021struct perf_event;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002022
Joel Fernandes (Google)da97e182019-10-14 13:03:08 -04002023#ifdef CONFIG_SECURITY
2024extern int security_perf_event_open(struct perf_event_attr *attr, int type);
2025extern int security_perf_event_alloc(struct perf_event *event);
2026extern void security_perf_event_free(struct perf_event *event);
2027extern int security_perf_event_read(struct perf_event *event);
2028extern int security_perf_event_write(struct perf_event *event);
2029#else
2030static inline int security_perf_event_open(struct perf_event_attr *attr,
2031 int type)
2032{
2033 return 0;
2034}
2035
2036static inline int security_perf_event_alloc(struct perf_event *event)
2037{
2038 return 0;
2039}
2040
2041static inline void security_perf_event_free(struct perf_event *event)
2042{
2043}
2044
2045static inline int security_perf_event_read(struct perf_event *event)
2046{
2047 return 0;
2048}
2049
2050static inline int security_perf_event_write(struct perf_event *event)
2051{
2052 return 0;
2053}
2054#endif /* CONFIG_SECURITY */
2055#endif /* CONFIG_PERF_EVENTS */
2056
2057#endif /* ! __LINUX_SECURITY_H */