1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * evm.h 4 * 5 * Copyright (c) 2009 IBM Corporation 6 * Author: Mimi Zohar <zohar@us.ibm.com> 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#ifdef CONFIG_EVM 16extern int evm_set_key(void *key, size_t keylen); 17extern enum integrity_status evm_verifyxattr(struct dentry *dentry, 18 const char *xattr_name, 19 void *xattr_value, 20 size_t xattr_value_len); 21int evm_inode_init_security(struct inode *inode, struct inode *dir, 22 const struct qstr *qstr, struct xattr *xattrs, 23 int *xattr_count); 24extern bool evm_revalidate_status(const char *xattr_name); 25extern int evm_protected_xattr_if_enabled(const char *req_xattr_name); 26extern int evm_read_protected_xattrs(struct dentry *dentry, u8 *buffer, 27 int buffer_size, char type, 28 bool canonical_fmt); 29#ifdef CONFIG_FS_POSIX_ACL 30extern int posix_xattr_acl(const char *xattrname); 31#else 32static inline int posix_xattr_acl(const char *xattrname) 33{ 34 return 0; 35} 36#endif 37#else 38 39static inline int evm_set_key(void *key, size_t keylen) 40{ 41 return -EOPNOTSUPP; 42} 43 44#ifdef CONFIG_INTEGRITY 45static inline enum integrity_status evm_verifyxattr(struct dentry *dentry, 46 const char *xattr_name, 47 void *xattr_value, 48 size_t xattr_value_len) 49{ 50 return INTEGRITY_UNKNOWN; 51} 52#endif 53 54static inline int evm_inode_init_security(struct inode *inode, struct inode *dir, 55 const struct qstr *qstr, 56 struct xattr *xattrs, 57 int *xattr_count) 58{ 59 return 0; 60} 61 62static inline bool evm_revalidate_status(const char *xattr_name) 63{ 64 return false; 65} 66 67static inline int evm_protected_xattr_if_enabled(const char *req_xattr_name) 68{ 69 return false; 70} 71 72static inline int evm_read_protected_xattrs(struct dentry *dentry, u8 *buffer, 73 int buffer_size, char type, 74 bool canonical_fmt) 75{ 76 return -EOPNOTSUPP; 77} 78 79#endif /* CONFIG_EVM */ 80#endif /* LINUX_EVM_H */ 81