1 /* SPDX-License-Identifier: GPL-2.0 */
5 * Copyright (c) 2009 IBM Corporation
12 #include <linux/integrity.h>
13 #include <linux/xattr.h>
15 struct integrity_iint_cache;
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,
22 size_t xattr_value_len,
23 struct integrity_iint_cache *iint);
24 extern int evm_inode_setattr(struct mnt_idmap *idmap,
25 struct dentry *dentry, struct iattr *attr);
26 extern void evm_inode_post_setattr(struct dentry *dentry, int ia_valid);
27 extern int evm_inode_setxattr(struct mnt_idmap *idmap,
28 struct dentry *dentry, const char *name,
29 const void *value, size_t size);
30 extern void evm_inode_post_setxattr(struct dentry *dentry,
31 const char *xattr_name,
32 const void *xattr_value,
33 size_t xattr_value_len);
34 extern int evm_inode_removexattr(struct mnt_idmap *idmap,
35 struct dentry *dentry, const char *xattr_name);
36 extern void evm_inode_post_removexattr(struct dentry *dentry,
37 const char *xattr_name);
38 static inline void evm_inode_post_remove_acl(struct mnt_idmap *idmap,
39 struct dentry *dentry,
42 evm_inode_post_removexattr(dentry, acl_name);
44 extern int evm_inode_set_acl(struct mnt_idmap *idmap,
45 struct dentry *dentry, const char *acl_name,
46 struct posix_acl *kacl);
47 static inline int evm_inode_remove_acl(struct mnt_idmap *idmap,
48 struct dentry *dentry,
51 return evm_inode_set_acl(idmap, dentry, acl_name, NULL);
53 static inline void evm_inode_post_set_acl(struct dentry *dentry,
55 struct posix_acl *kacl)
57 return evm_inode_post_setxattr(dentry, acl_name, NULL, 0);
60 int evm_inode_init_security(struct inode *inode, struct inode *dir,
61 const struct qstr *qstr, struct xattr *xattrs,
63 extern bool evm_revalidate_status(const char *xattr_name);
64 extern int evm_protected_xattr_if_enabled(const char *req_xattr_name);
65 extern int evm_read_protected_xattrs(struct dentry *dentry, u8 *buffer,
66 int buffer_size, char type,
68 #ifdef CONFIG_FS_POSIX_ACL
69 extern int posix_xattr_acl(const char *xattrname);
71 static inline int posix_xattr_acl(const char *xattrname)
78 static inline int evm_set_key(void *key, size_t keylen)
83 #ifdef CONFIG_INTEGRITY
84 static inline enum integrity_status evm_verifyxattr(struct dentry *dentry,
85 const char *xattr_name,
87 size_t xattr_value_len,
88 struct integrity_iint_cache *iint)
90 return INTEGRITY_UNKNOWN;
94 static inline int evm_inode_setattr(struct mnt_idmap *idmap,
95 struct dentry *dentry, struct iattr *attr)
100 static inline void evm_inode_post_setattr(struct dentry *dentry, int ia_valid)
105 static inline int evm_inode_setxattr(struct mnt_idmap *idmap,
106 struct dentry *dentry, const char *name,
107 const void *value, size_t size)
112 static inline void evm_inode_post_setxattr(struct dentry *dentry,
113 const char *xattr_name,
114 const void *xattr_value,
115 size_t xattr_value_len)
120 static inline int evm_inode_removexattr(struct mnt_idmap *idmap,
121 struct dentry *dentry,
122 const char *xattr_name)
127 static inline void evm_inode_post_removexattr(struct dentry *dentry,
128 const char *xattr_name)
133 static inline void evm_inode_post_remove_acl(struct mnt_idmap *idmap,
134 struct dentry *dentry,
135 const char *acl_name)
140 static inline int evm_inode_set_acl(struct mnt_idmap *idmap,
141 struct dentry *dentry, const char *acl_name,
142 struct posix_acl *kacl)
147 static inline int evm_inode_remove_acl(struct mnt_idmap *idmap,
148 struct dentry *dentry,
149 const char *acl_name)
154 static inline void evm_inode_post_set_acl(struct dentry *dentry,
155 const char *acl_name,
156 struct posix_acl *kacl)
161 static inline int evm_inode_init_security(struct inode *inode, struct inode *dir,
162 const struct qstr *qstr,
163 struct xattr *xattrs,
169 static inline bool evm_revalidate_status(const char *xattr_name)
174 static inline int evm_protected_xattr_if_enabled(const char *req_xattr_name)
179 static inline int evm_read_protected_xattrs(struct dentry *dentry, u8 *buffer,
180 int buffer_size, char type,
186 #endif /* CONFIG_EVM */
187 #endif /* LINUX_EVM_H */