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