evm.h 2.61 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
 * evm.h
 *
 * Copyright (c) 2009 IBM Corporation
 * Author: Mimi Zohar <zohar@us.ibm.com>
 */

#ifndef _LINUX_EVM_H
#define _LINUX_EVM_H

#include <linux/integrity.h>
12
#include <linux/xattr.h>
13

14 15
struct integrity_iint_cache;

16
#ifdef CONFIG_EVM
17
extern int evm_set_key(void *key, size_t keylen);
18 19 20
extern enum integrity_status evm_verifyxattr(struct dentry *dentry,
					     const char *xattr_name,
					     void *xattr_value,
21 22
					     size_t xattr_value_len,
					     struct integrity_iint_cache *iint);
23
extern int evm_inode_setattr(struct dentry *dentry, struct iattr *attr);
24
extern void evm_inode_post_setattr(struct dentry *dentry, int ia_valid);
25 26 27 28 29 30 31
extern int evm_inode_setxattr(struct dentry *dentry, const char *name,
			      const void *value, size_t size);
extern void evm_inode_post_setxattr(struct dentry *dentry,
				    const char *xattr_name,
				    const void *xattr_value,
				    size_t xattr_value_len);
extern int evm_inode_removexattr(struct dentry *dentry, const char *xattr_name);
32 33
extern void evm_inode_post_removexattr(struct dentry *dentry,
				       const char *xattr_name);
34 35 36
extern int evm_inode_init_security(struct inode *inode,
				   const struct xattr *xattr_array,
				   struct xattr *evm);
37 38 39 40 41 42 43 44
#ifdef CONFIG_FS_POSIX_ACL
extern int posix_xattr_acl(const char *xattrname);
#else
static inline int posix_xattr_acl(const char *xattrname)
{
	return 0;
}
#endif
45
#else
46 47 48 49 50 51

static inline int evm_set_key(void *key, size_t keylen)
{
	return -EOPNOTSUPP;
}

52 53 54 55
#ifdef CONFIG_INTEGRITY
static inline enum integrity_status evm_verifyxattr(struct dentry *dentry,
						    const char *xattr_name,
						    void *xattr_value,
56 57
						    size_t xattr_value_len,
					struct integrity_iint_cache *iint)
58 59 60 61 62
{
	return INTEGRITY_UNKNOWN;
}
#endif

63
static inline int evm_inode_setattr(struct dentry *dentry, struct iattr *attr)
64 65 66 67
{
	return 0;
}

68 69 70 71 72
static inline void evm_inode_post_setattr(struct dentry *dentry, int ia_valid)
{
	return;
}

73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
static inline int evm_inode_setxattr(struct dentry *dentry, const char *name,
				     const void *value, size_t size)
{
	return 0;
}

static inline void evm_inode_post_setxattr(struct dentry *dentry,
					   const char *xattr_name,
					   const void *xattr_value,
					   size_t xattr_value_len)
{
	return;
}

static inline int evm_inode_removexattr(struct dentry *dentry,
					const char *xattr_name)
{
	return 0;
}
92 93 94 95 96 97 98

static inline void evm_inode_post_removexattr(struct dentry *dentry,
					      const char *xattr_name)
{
	return;
}

99 100 101 102
static inline int evm_inode_init_security(struct inode *inode,
					  const struct xattr *xattr_array,
					  struct xattr *evm)
{
103
	return 0;
104 105
}

106
#endif /* CONFIG_EVM */
107
#endif /* LINUX_EVM_H */