xref: /linux-6.15/include/linux/evm.h (revision 7e135dc7)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * evm.h
4  *
5  * Copyright (c) 2009 IBM Corporation
6  * Author: Mimi Zohar <[email protected]>
7  */
8 
9 #ifndef _LINUX_EVM_H
10 #define _LINUX_EVM_H
11 
12 #include <linux/integrity.h>
13 #include <linux/xattr.h>
14 
15 struct integrity_iint_cache;
16 
17 #ifdef CONFIG_EVM
18 extern int evm_set_key(void *key, size_t keylen);
19 extern enum integrity_status evm_verifyxattr(struct dentry *dentry,
20 					     const char *xattr_name,
21 					     void *xattr_value,
22 					     size_t xattr_value_len,
23 					     struct integrity_iint_cache *iint);
24 extern int evm_inode_setattr(struct dentry *dentry, struct iattr *attr);
25 extern void evm_inode_post_setattr(struct dentry *dentry, int ia_valid);
26 extern int evm_inode_setxattr(struct user_namespace *mnt_userns,
27 			      struct dentry *dentry, const char *name,
28 			      const void *value, size_t size);
29 extern void evm_inode_post_setxattr(struct dentry *dentry,
30 				    const char *xattr_name,
31 				    const void *xattr_value,
32 				    size_t xattr_value_len);
33 extern int evm_inode_removexattr(struct user_namespace *mnt_userns,
34 				 struct dentry *dentry, const char *xattr_name);
35 extern void evm_inode_post_removexattr(struct dentry *dentry,
36 				       const char *xattr_name);
37 extern int evm_inode_init_security(struct inode *inode,
38 				   const struct xattr *xattr_array,
39 				   struct xattr *evm);
40 extern bool evm_revalidate_status(const char *xattr_name);
41 #ifdef CONFIG_FS_POSIX_ACL
42 extern int posix_xattr_acl(const char *xattrname);
43 #else
44 static inline int posix_xattr_acl(const char *xattrname)
45 {
46 	return 0;
47 }
48 #endif
49 #else
50 
51 static inline int evm_set_key(void *key, size_t keylen)
52 {
53 	return -EOPNOTSUPP;
54 }
55 
56 #ifdef CONFIG_INTEGRITY
57 static inline enum integrity_status evm_verifyxattr(struct dentry *dentry,
58 						    const char *xattr_name,
59 						    void *xattr_value,
60 						    size_t xattr_value_len,
61 					struct integrity_iint_cache *iint)
62 {
63 	return INTEGRITY_UNKNOWN;
64 }
65 #endif
66 
67 static inline int evm_inode_setattr(struct dentry *dentry, struct iattr *attr)
68 {
69 	return 0;
70 }
71 
72 static inline void evm_inode_post_setattr(struct dentry *dentry, int ia_valid)
73 {
74 	return;
75 }
76 
77 static inline int evm_inode_setxattr(struct user_namespace *mnt_userns,
78 				     struct dentry *dentry, const char *name,
79 				     const void *value, size_t size)
80 {
81 	return 0;
82 }
83 
84 static inline void evm_inode_post_setxattr(struct dentry *dentry,
85 					   const char *xattr_name,
86 					   const void *xattr_value,
87 					   size_t xattr_value_len)
88 {
89 	return;
90 }
91 
92 static inline int evm_inode_removexattr(struct user_namespace *mnt_userns,
93 					struct dentry *dentry,
94 					const char *xattr_name)
95 {
96 	return 0;
97 }
98 
99 static inline void evm_inode_post_removexattr(struct dentry *dentry,
100 					      const char *xattr_name)
101 {
102 	return;
103 }
104 
105 static inline int evm_inode_init_security(struct inode *inode,
106 					  const struct xattr *xattr_array,
107 					  struct xattr *evm)
108 {
109 	return 0;
110 }
111 
112 static inline bool evm_revalidate_status(const char *xattr_name)
113 {
114 	return false;
115 }
116 
117 #endif /* CONFIG_EVM */
118 #endif /* LINUX_EVM_H */
119