evm.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #ifndef _LINUX_EVM_H
  9. #define _LINUX_EVM_H
  10. #include <linux/integrity.h>
  11. #include <linux/xattr.h>
  12. struct integrity_iint_cache;
  13. #ifdef CONFIG_EVM
  14. extern int evm_set_key(void *key, size_t keylen);
  15. extern enum integrity_status evm_verifyxattr(struct dentry *dentry,
  16. const char *xattr_name,
  17. void *xattr_value,
  18. size_t xattr_value_len,
  19. struct integrity_iint_cache *iint);
  20. extern int evm_inode_setattr(struct dentry *dentry, struct iattr *attr);
  21. extern void evm_inode_post_setattr(struct dentry *dentry, int ia_valid);
  22. extern int evm_inode_setxattr(struct dentry *dentry, const char *name,
  23. const void *value, size_t size);
  24. extern void evm_inode_post_setxattr(struct dentry *dentry,
  25. const char *xattr_name,
  26. const void *xattr_value,
  27. size_t xattr_value_len);
  28. extern int evm_inode_removexattr(struct dentry *dentry, const char *xattr_name);
  29. extern void evm_inode_post_removexattr(struct dentry *dentry,
  30. const char *xattr_name);
  31. extern int evm_inode_init_security(struct inode *inode,
  32. const struct xattr *xattr_array,
  33. struct xattr *evm);
  34. #ifdef CONFIG_FS_POSIX_ACL
  35. extern int posix_xattr_acl(const char *xattrname);
  36. #else
  37. static inline int posix_xattr_acl(const char *xattrname)
  38. {
  39. return 0;
  40. }
  41. #endif
  42. #else
  43. static inline int evm_set_key(void *key, size_t keylen)
  44. {
  45. return -EOPNOTSUPP;
  46. }
  47. #ifdef CONFIG_INTEGRITY
  48. static inline enum integrity_status evm_verifyxattr(struct dentry *dentry,
  49. const char *xattr_name,
  50. void *xattr_value,
  51. size_t xattr_value_len,
  52. struct integrity_iint_cache *iint)
  53. {
  54. return INTEGRITY_UNKNOWN;
  55. }
  56. #endif
  57. static inline int evm_inode_setattr(struct dentry *dentry, struct iattr *attr)
  58. {
  59. return 0;
  60. }
  61. static inline void evm_inode_post_setattr(struct dentry *dentry, int ia_valid)
  62. {
  63. return;
  64. }
  65. static inline int evm_inode_setxattr(struct dentry *dentry, const char *name,
  66. const void *value, size_t size)
  67. {
  68. return 0;
  69. }
  70. static inline void evm_inode_post_setxattr(struct dentry *dentry,
  71. const char *xattr_name,
  72. const void *xattr_value,
  73. size_t xattr_value_len)
  74. {
  75. return;
  76. }
  77. static inline int evm_inode_removexattr(struct dentry *dentry,
  78. const char *xattr_name)
  79. {
  80. return 0;
  81. }
  82. static inline void evm_inode_post_removexattr(struct dentry *dentry,
  83. const char *xattr_name)
  84. {
  85. return;
  86. }
  87. static inline int evm_inode_init_security(struct inode *inode,
  88. const struct xattr *xattr_array,
  89. struct xattr *evm)
  90. {
  91. return 0;
  92. }
  93. #endif /* CONFIG_EVM */
  94. #endif /* LINUX_EVM_H */