Mimi Zohar | 3e1be52 | 2011-03-09 14:38:26 -0500 | [diff] [blame] | 1 | /* |
| 2 | * evm.h |
| 3 | * |
| 4 | * Copyright (c) 2009 IBM Corporation |
| 5 | * Author: Mimi Zohar <zohar@us.ibm.com> |
| 6 | */ |
| 7 | |
| 8 | #ifndef _LINUX_EVM_H |
| 9 | #define _LINUX_EVM_H |
| 10 | |
| 11 | #include <linux/integrity.h> |
Mimi Zohar | cb72318 | 2011-03-09 14:40:44 -0500 | [diff] [blame] | 12 | #include <linux/xattr.h> |
Mimi Zohar | 3e1be52 | 2011-03-09 14:38:26 -0500 | [diff] [blame] | 13 | |
Dmitry Kasatkin | 2960e6c | 2011-05-06 11:34:13 +0300 | [diff] [blame] | 14 | struct integrity_iint_cache; |
| 15 | |
Mimi Zohar | 3e1be52 | 2011-03-09 14:38:26 -0500 | [diff] [blame] | 16 | #ifdef CONFIG_EVM |
Dmitry Kasatkin | 7626676 | 2015-10-22 21:26:32 +0300 | [diff] [blame] | 17 | extern int evm_set_key(void *key, size_t keylen); |
Mimi Zohar | 3e1be52 | 2011-03-09 14:38:26 -0500 | [diff] [blame] | 18 | extern enum integrity_status evm_verifyxattr(struct dentry *dentry, |
| 19 | const char *xattr_name, |
| 20 | void *xattr_value, |
Dmitry Kasatkin | 2960e6c | 2011-05-06 11:34:13 +0300 | [diff] [blame] | 21 | size_t xattr_value_len, |
| 22 | struct integrity_iint_cache *iint); |
Mimi Zohar | 817b54a | 2011-05-13 12:53:38 -0400 | [diff] [blame] | 23 | extern int evm_inode_setattr(struct dentry *dentry, struct iattr *attr); |
Mimi Zohar | 975d294 | 2011-03-09 14:39:57 -0500 | [diff] [blame] | 24 | extern void evm_inode_post_setattr(struct dentry *dentry, int ia_valid); |
Mimi Zohar | 3e1be52 | 2011-03-09 14:38:26 -0500 | [diff] [blame] | 25 | extern int evm_inode_setxattr(struct dentry *dentry, const char *name, |
| 26 | const void *value, size_t size); |
| 27 | extern void evm_inode_post_setxattr(struct dentry *dentry, |
| 28 | const char *xattr_name, |
| 29 | const void *xattr_value, |
| 30 | size_t xattr_value_len); |
| 31 | extern int evm_inode_removexattr(struct dentry *dentry, const char *xattr_name); |
Mimi Zohar | c7b87de | 2011-03-09 14:39:18 -0500 | [diff] [blame] | 32 | extern void evm_inode_post_removexattr(struct dentry *dentry, |
| 33 | const char *xattr_name); |
Mimi Zohar | cb72318 | 2011-03-09 14:40:44 -0500 | [diff] [blame] | 34 | extern int evm_inode_init_security(struct inode *inode, |
| 35 | const struct xattr *xattr_array, |
| 36 | struct xattr *evm); |
Mimi Zohar | bf6d0f5 | 2011-08-18 18:07:44 -0400 | [diff] [blame] | 37 | #ifdef CONFIG_FS_POSIX_ACL |
| 38 | extern int posix_xattr_acl(const char *xattrname); |
| 39 | #else |
| 40 | static inline int posix_xattr_acl(const char *xattrname) |
| 41 | { |
| 42 | return 0; |
| 43 | } |
| 44 | #endif |
Mimi Zohar | 3e1be52 | 2011-03-09 14:38:26 -0500 | [diff] [blame] | 45 | #else |
Dmitry Kasatkin | 7626676 | 2015-10-22 21:26:32 +0300 | [diff] [blame] | 46 | |
| 47 | static inline int evm_set_key(void *key, size_t keylen) |
| 48 | { |
| 49 | return -EOPNOTSUPP; |
| 50 | } |
| 51 | |
Mimi Zohar | 3e1be52 | 2011-03-09 14:38:26 -0500 | [diff] [blame] | 52 | #ifdef CONFIG_INTEGRITY |
| 53 | static inline enum integrity_status evm_verifyxattr(struct dentry *dentry, |
| 54 | const char *xattr_name, |
| 55 | void *xattr_value, |
Dmitry Kasatkin | 2960e6c | 2011-05-06 11:34:13 +0300 | [diff] [blame] | 56 | size_t xattr_value_len, |
| 57 | struct integrity_iint_cache *iint) |
Mimi Zohar | 3e1be52 | 2011-03-09 14:38:26 -0500 | [diff] [blame] | 58 | { |
| 59 | return INTEGRITY_UNKNOWN; |
| 60 | } |
| 61 | #endif |
| 62 | |
Mimi Zohar | e1c9b23 | 2011-08-11 00:22:51 -0400 | [diff] [blame] | 63 | static inline int evm_inode_setattr(struct dentry *dentry, struct iattr *attr) |
Mimi Zohar | 817b54a | 2011-05-13 12:53:38 -0400 | [diff] [blame] | 64 | { |
| 65 | return 0; |
| 66 | } |
| 67 | |
Mimi Zohar | 975d294 | 2011-03-09 14:39:57 -0500 | [diff] [blame] | 68 | static inline void evm_inode_post_setattr(struct dentry *dentry, int ia_valid) |
| 69 | { |
| 70 | return; |
| 71 | } |
| 72 | |
Mimi Zohar | 3e1be52 | 2011-03-09 14:38:26 -0500 | [diff] [blame] | 73 | static inline int evm_inode_setxattr(struct dentry *dentry, const char *name, |
| 74 | const void *value, size_t size) |
| 75 | { |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | static inline void evm_inode_post_setxattr(struct dentry *dentry, |
| 80 | const char *xattr_name, |
| 81 | const void *xattr_value, |
| 82 | size_t xattr_value_len) |
| 83 | { |
| 84 | return; |
| 85 | } |
| 86 | |
| 87 | static inline int evm_inode_removexattr(struct dentry *dentry, |
| 88 | const char *xattr_name) |
| 89 | { |
| 90 | return 0; |
| 91 | } |
Mimi Zohar | c7b87de | 2011-03-09 14:39:18 -0500 | [diff] [blame] | 92 | |
| 93 | static inline void evm_inode_post_removexattr(struct dentry *dentry, |
| 94 | const char *xattr_name) |
| 95 | { |
| 96 | return; |
| 97 | } |
| 98 | |
Mimi Zohar | cb72318 | 2011-03-09 14:40:44 -0500 | [diff] [blame] | 99 | static inline int evm_inode_init_security(struct inode *inode, |
| 100 | const struct xattr *xattr_array, |
| 101 | struct xattr *evm) |
| 102 | { |
Mimi Zohar | 5a4730b | 2011-08-11 00:22:52 -0400 | [diff] [blame] | 103 | return 0; |
Mimi Zohar | cb72318 | 2011-03-09 14:40:44 -0500 | [diff] [blame] | 104 | } |
| 105 | |
Paul Bolle | e05a4f4 | 2013-03-25 21:12:27 +0100 | [diff] [blame] | 106 | #endif /* CONFIG_EVM */ |
Mimi Zohar | 3e1be52 | 2011-03-09 14:38:26 -0500 | [diff] [blame] | 107 | #endif /* LINUX_EVM_H */ |