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 dentry *dentry, const char *name, 27 const void *value, size_t size); 28 extern void evm_inode_post_setxattr(struct dentry *dentry, 29 const char *xattr_name, 30 const void *xattr_value, 31 size_t xattr_value_len); 32 extern int evm_inode_removexattr(struct dentry *dentry, const char *xattr_name); 33 extern void evm_inode_post_removexattr(struct dentry *dentry, 34 const char *xattr_name); 35 extern int evm_inode_init_security(struct inode *inode, 36 const struct xattr *xattr_array, 37 struct xattr *evm); 38 extern bool evm_revalidate_status(const char *xattr_name); 39 #ifdef CONFIG_FS_POSIX_ACL 40 extern int posix_xattr_acl(const char *xattrname); 41 #else 42 static inline int posix_xattr_acl(const char *xattrname) 43 { 44 return 0; 45 } 46 #endif 47 #else 48 49 static inline int evm_set_key(void *key, size_t keylen) 50 { 51 return -EOPNOTSUPP; 52 } 53 54 #ifdef CONFIG_INTEGRITY 55 static inline enum integrity_status evm_verifyxattr(struct dentry *dentry, 56 const char *xattr_name, 57 void *xattr_value, 58 size_t xattr_value_len, 59 struct integrity_iint_cache *iint) 60 { 61 return INTEGRITY_UNKNOWN; 62 } 63 #endif 64 65 static inline int evm_inode_setattr(struct dentry *dentry, struct iattr *attr) 66 { 67 return 0; 68 } 69 70 static inline void evm_inode_post_setattr(struct dentry *dentry, int ia_valid) 71 { 72 return; 73 } 74 75 static inline int evm_inode_setxattr(struct dentry *dentry, const char *name, 76 const void *value, size_t size) 77 { 78 return 0; 79 } 80 81 static inline void evm_inode_post_setxattr(struct dentry *dentry, 82 const char *xattr_name, 83 const void *xattr_value, 84 size_t xattr_value_len) 85 { 86 return; 87 } 88 89 static inline int evm_inode_removexattr(struct dentry *dentry, 90 const char *xattr_name) 91 { 92 return 0; 93 } 94 95 static inline void evm_inode_post_removexattr(struct dentry *dentry, 96 const char *xattr_name) 97 { 98 return; 99 } 100 101 static inline int evm_inode_init_security(struct inode *inode, 102 const struct xattr *xattr_array, 103 struct xattr *evm) 104 { 105 return 0; 106 } 107 108 static inline bool evm_revalidate_status(const char *xattr_name) 109 { 110 return false; 111 } 112 113 #endif /* CONFIG_EVM */ 114 #endif /* LINUX_EVM_H */ 115