blob: 35ed9a8a403a8557aba07222503daf6fa29bac7a [file] [log] [blame]
Mimi Zohar3e1be522011-03-09 14:38:26 -05001/*
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 Zoharcb7231802011-03-09 14:40:44 -050012#include <linux/xattr.h>
Mimi Zohar3e1be522011-03-09 14:38:26 -050013
Dmitry Kasatkin2960e6c2011-05-06 11:34:13 +030014struct integrity_iint_cache;
15
Mimi Zohar3e1be522011-03-09 14:38:26 -050016#ifdef CONFIG_EVM
Dmitry Kasatkin76266762015-10-22 21:26:32 +030017extern int evm_set_key(void *key, size_t keylen);
Mimi Zohar3e1be522011-03-09 14:38:26 -050018extern enum integrity_status evm_verifyxattr(struct dentry *dentry,
19 const char *xattr_name,
20 void *xattr_value,
Dmitry Kasatkin2960e6c2011-05-06 11:34:13 +030021 size_t xattr_value_len,
22 struct integrity_iint_cache *iint);
Mimi Zohar817b54a2011-05-13 12:53:38 -040023extern int evm_inode_setattr(struct dentry *dentry, struct iattr *attr);
Mimi Zohar975d2942011-03-09 14:39:57 -050024extern void evm_inode_post_setattr(struct dentry *dentry, int ia_valid);
Mimi Zohar3e1be522011-03-09 14:38:26 -050025extern int evm_inode_setxattr(struct dentry *dentry, const char *name,
26 const void *value, size_t size);
27extern void evm_inode_post_setxattr(struct dentry *dentry,
28 const char *xattr_name,
29 const void *xattr_value,
30 size_t xattr_value_len);
31extern int evm_inode_removexattr(struct dentry *dentry, const char *xattr_name);
Mimi Zoharc7b87de2011-03-09 14:39:18 -050032extern void evm_inode_post_removexattr(struct dentry *dentry,
33 const char *xattr_name);
Mimi Zoharcb7231802011-03-09 14:40:44 -050034extern int evm_inode_init_security(struct inode *inode,
35 const struct xattr *xattr_array,
36 struct xattr *evm);
Mimi Zoharbf6d0f52011-08-18 18:07:44 -040037#ifdef CONFIG_FS_POSIX_ACL
38extern int posix_xattr_acl(const char *xattrname);
39#else
40static inline int posix_xattr_acl(const char *xattrname)
41{
42 return 0;
43}
44#endif
Mimi Zohar3e1be522011-03-09 14:38:26 -050045#else
Dmitry Kasatkin76266762015-10-22 21:26:32 +030046
47static inline int evm_set_key(void *key, size_t keylen)
48{
49 return -EOPNOTSUPP;
50}
51
Mimi Zohar3e1be522011-03-09 14:38:26 -050052#ifdef CONFIG_INTEGRITY
53static inline enum integrity_status evm_verifyxattr(struct dentry *dentry,
54 const char *xattr_name,
55 void *xattr_value,
Dmitry Kasatkin2960e6c2011-05-06 11:34:13 +030056 size_t xattr_value_len,
57 struct integrity_iint_cache *iint)
Mimi Zohar3e1be522011-03-09 14:38:26 -050058{
59 return INTEGRITY_UNKNOWN;
60}
61#endif
62
Mimi Zohare1c9b232011-08-11 00:22:51 -040063static inline int evm_inode_setattr(struct dentry *dentry, struct iattr *attr)
Mimi Zohar817b54a2011-05-13 12:53:38 -040064{
65 return 0;
66}
67
Mimi Zohar975d2942011-03-09 14:39:57 -050068static inline void evm_inode_post_setattr(struct dentry *dentry, int ia_valid)
69{
70 return;
71}
72
Mimi Zohar3e1be522011-03-09 14:38:26 -050073static inline int evm_inode_setxattr(struct dentry *dentry, const char *name,
74 const void *value, size_t size)
75{
76 return 0;
77}
78
79static 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
87static inline int evm_inode_removexattr(struct dentry *dentry,
88 const char *xattr_name)
89{
90 return 0;
91}
Mimi Zoharc7b87de2011-03-09 14:39:18 -050092
93static inline void evm_inode_post_removexattr(struct dentry *dentry,
94 const char *xattr_name)
95{
96 return;
97}
98
Mimi Zoharcb7231802011-03-09 14:40:44 -050099static inline int evm_inode_init_security(struct inode *inode,
100 const struct xattr *xattr_array,
101 struct xattr *evm)
102{
Mimi Zohar5a4730b2011-08-11 00:22:52 -0400103 return 0;
Mimi Zoharcb7231802011-03-09 14:40:44 -0500104}
105
Paul Bollee05a4f42013-03-25 21:12:27 +0100106#endif /* CONFIG_EVM */
Mimi Zohar3e1be522011-03-09 14:38:26 -0500107#endif /* LINUX_EVM_H */