blob: 00036d2f57c30824aad747469f4d640dfd0d6857 [file] [log] [blame]
Thomas Gleixnerb886d83c2019-06-01 10:08:55 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Mimi Zohar6146f0d2009-02-04 09:06:57 -05002/*
3 * Copyright (C) 2008 IBM Corporation
4 * Author: Mimi Zohar <zohar@us.ibm.com>
Mimi Zohar6146f0d2009-02-04 09:06:57 -05005 */
6
Mimi Zohar6146f0d2009-02-04 09:06:57 -05007#ifndef _LINUX_IMA_H
8#define _LINUX_IMA_H
9
Mimi Zohared850a52009-02-10 23:01:19 -050010#include <linux/fs.h>
Mimi Zohar16c267a2018-07-13 14:05:58 -040011#include <linux/security.h>
Mimi Zohar7b8589c2016-12-19 16:22:48 -080012#include <linux/kexec.h>
Mimi Zohared850a52009-02-10 23:01:19 -050013struct linux_binprm;
14
Mimi Zohar3323eec2009-02-04 09:06:58 -050015#ifdef CONFIG_IMA
16extern int ima_bprm_check(struct linux_binprm *bprm);
Al Viro6035a272018-06-08 13:40:10 -040017extern int ima_file_check(struct file *file, int mask);
Mimi Zoharfdb24102019-01-22 14:06:49 -060018extern void ima_post_create_tmpfile(struct inode *inode);
Mimi Zohar3323eec2009-02-04 09:06:58 -050019extern void ima_file_free(struct file *file);
20extern int ima_file_mmap(struct file *file, unsigned long prot);
Mimi Zohar16c267a2018-07-13 14:05:58 -040021extern int ima_load_data(enum kernel_load_data_id id);
Mimi Zohar39eeb4f2016-01-30 22:23:26 -050022extern int ima_read_file(struct file *file, enum kernel_read_file_id id);
Mimi Zoharcf222212016-01-14 17:57:47 -050023extern int ima_post_read_file(struct file *file, void *buf, loff_t size,
24 enum kernel_read_file_id id);
Mimi Zohar05d1a712016-02-29 19:52:05 -050025extern void ima_post_path_mknod(struct dentry *dentry);
Mimi Zohar3323eec2009-02-04 09:06:58 -050026
Mimi Zohar7b8589c2016-12-19 16:22:48 -080027#ifdef CONFIG_IMA_KEXEC
28extern void ima_add_kexec_buffer(struct kimage *image);
29#endif
30
Philipp Rudo268a7842019-03-26 15:45:53 +010031#if (defined(CONFIG_X86) && defined(CONFIG_EFI)) || defined(CONFIG_S390)
Nayna Jain0914ade2018-10-09 23:00:33 +053032extern bool arch_ima_get_secureboot(void);
Eric Richterd9580832018-10-09 23:00:37 +053033extern const char * const *arch_get_ima_policy(void);
Nayna Jain0914ade2018-10-09 23:00:33 +053034#else
35static inline bool arch_ima_get_secureboot(void)
36{
37 return false;
38}
Nayna Jain0914ade2018-10-09 23:00:33 +053039
Nayna Jain61917062018-10-09 23:00:36 +053040static inline const char * const *arch_get_ima_policy(void)
41{
42 return NULL;
43}
Eric Richterd9580832018-10-09 23:00:37 +053044#endif
Nayna Jain61917062018-10-09 23:00:36 +053045
Mimi Zohar3323eec2009-02-04 09:06:58 -050046#else
Mimi Zohar6146f0d2009-02-04 09:06:57 -050047static inline int ima_bprm_check(struct linux_binprm *bprm)
48{
49 return 0;
50}
51
Al Viro6035a272018-06-08 13:40:10 -040052static inline int ima_file_check(struct file *file, int mask)
Mimi Zohar6146f0d2009-02-04 09:06:57 -050053{
54 return 0;
55}
56
Mimi Zoharfdb24102019-01-22 14:06:49 -060057static inline void ima_post_create_tmpfile(struct inode *inode)
58{
59}
60
Mimi Zohar6146f0d2009-02-04 09:06:57 -050061static inline void ima_file_free(struct file *file)
62{
63 return;
64}
65
66static inline int ima_file_mmap(struct file *file, unsigned long prot)
67{
68 return 0;
69}
Mimi Zohar9957a502011-03-09 22:57:53 -050070
Mimi Zohar16c267a2018-07-13 14:05:58 -040071static inline int ima_load_data(enum kernel_load_data_id id)
72{
73 return 0;
74}
75
Mimi Zohar39eeb4f2016-01-30 22:23:26 -050076static inline int ima_read_file(struct file *file, enum kernel_read_file_id id)
77{
78 return 0;
79}
80
Mimi Zoharcf222212016-01-14 17:57:47 -050081static inline int ima_post_read_file(struct file *file, void *buf, loff_t size,
82 enum kernel_read_file_id id)
83{
84 return 0;
85}
86
Mimi Zohar05d1a712016-02-29 19:52:05 -050087static inline void ima_post_path_mknod(struct dentry *dentry)
88{
89 return;
90}
91
Paul Bollee05a4f42013-03-25 21:12:27 +010092#endif /* CONFIG_IMA */
Mimi Zohar9957a502011-03-09 22:57:53 -050093
Mimi Zohar7b8589c2016-12-19 16:22:48 -080094#ifndef CONFIG_IMA_KEXEC
95struct kimage;
96
97static inline void ima_add_kexec_buffer(struct kimage *image)
98{}
99#endif
100
Mimi Zohar9957a502011-03-09 22:57:53 -0500101#ifdef CONFIG_IMA_APPRAISE
Mimi Zohar6f6723e2017-04-24 22:43:52 -0400102extern bool is_ima_appraise_enabled(void);
Mimi Zohar9957a502011-03-09 22:57:53 -0500103extern void ima_inode_post_setattr(struct dentry *dentry);
Mimi Zohar42c63332011-03-10 18:54:15 -0500104extern int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name,
105 const void *xattr_value, size_t xattr_value_len);
106extern int ima_inode_removexattr(struct dentry *dentry, const char *xattr_name);
Mimi Zohar9957a502011-03-09 22:57:53 -0500107#else
Mimi Zohar6f6723e2017-04-24 22:43:52 -0400108static inline bool is_ima_appraise_enabled(void)
109{
110 return 0;
111}
112
Mimi Zohar9957a502011-03-09 22:57:53 -0500113static inline void ima_inode_post_setattr(struct dentry *dentry)
114{
115 return;
116}
Mimi Zohar42c63332011-03-10 18:54:15 -0500117
118static inline int ima_inode_setxattr(struct dentry *dentry,
119 const char *xattr_name,
120 const void *xattr_value,
121 size_t xattr_value_len)
122{
123 return 0;
124}
125
126static inline int ima_inode_removexattr(struct dentry *dentry,
127 const char *xattr_name)
128{
129 return 0;
130}
Paul Bollee05a4f42013-03-25 21:12:27 +0100131#endif /* CONFIG_IMA_APPRAISE */
Mimi Zohar6146f0d2009-02-04 09:06:57 -0500132#endif /* _LINUX_IMA_H */