evm.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * evm.h
  4. *
  5. * Copyright (c) 2009 IBM Corporation
  6. * Author: Mimi Zohar <[email protected]>
  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 user_namespace *mnt_userns,
  21. struct dentry *dentry, struct iattr *attr);
  22. extern void evm_inode_post_setattr(struct dentry *dentry, int ia_valid);
  23. extern int evm_inode_setxattr(struct user_namespace *mnt_userns,
  24. struct dentry *dentry, const char *name,
  25. const void *value, size_t size);
  26. extern void evm_inode_post_setxattr(struct dentry *dentry,
  27. const char *xattr_name,
  28. const void *xattr_value,
  29. size_t xattr_value_len);
  30. extern int evm_inode_removexattr(struct user_namespace *mnt_userns,
  31. struct dentry *dentry, const char *xattr_name);
  32. extern void evm_inode_post_removexattr(struct dentry *dentry,
  33. const char *xattr_name);
  34. extern int evm_inode_init_security(struct inode *inode,
  35. const struct xattr *xattr_array,
  36. struct xattr *evm);
  37. extern bool evm_revalidate_status(const char *xattr_name);
  38. extern int evm_protected_xattr_if_enabled(const char *req_xattr_name);
  39. extern int evm_read_protected_xattrs(struct dentry *dentry, u8 *buffer,
  40. int buffer_size, char type,
  41. bool canonical_fmt);
  42. #ifdef CONFIG_FS_POSIX_ACL
  43. extern int posix_xattr_acl(const char *xattrname);
  44. #else
  45. static inline int posix_xattr_acl(const char *xattrname)
  46. {
  47. return 0;
  48. }
  49. #endif
  50. #else
  51. static inline int evm_set_key(void *key, size_t keylen)
  52. {
  53. return -EOPNOTSUPP;
  54. }
  55. #ifdef CONFIG_INTEGRITY
  56. static inline enum integrity_status evm_verifyxattr(struct dentry *dentry,
  57. const char *xattr_name,
  58. void *xattr_value,
  59. size_t xattr_value_len,
  60. struct integrity_iint_cache *iint)
  61. {
  62. return INTEGRITY_UNKNOWN;
  63. }
  64. #endif
  65. static inline int evm_inode_setattr(struct user_namespace *mnt_userns,
  66. struct dentry *dentry, struct iattr *attr)
  67. {
  68. return 0;
  69. }
  70. static inline void evm_inode_post_setattr(struct dentry *dentry, int ia_valid)
  71. {
  72. return;
  73. }
  74. static inline int evm_inode_setxattr(struct user_namespace *mnt_userns,
  75. struct dentry *dentry, const char *name,
  76. const void *value, size_t size)
  77. {
  78. return 0;
  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. static inline int evm_inode_removexattr(struct user_namespace *mnt_userns,
  88. struct dentry *dentry,
  89. const char *xattr_name)
  90. {
  91. return 0;
  92. }
  93. static inline void evm_inode_post_removexattr(struct dentry *dentry,
  94. const char *xattr_name)
  95. {
  96. return;
  97. }
  98. static inline int evm_inode_init_security(struct inode *inode,
  99. const struct xattr *xattr_array,
  100. struct xattr *evm)
  101. {
  102. return 0;
  103. }
  104. static inline bool evm_revalidate_status(const char *xattr_name)
  105. {
  106. return false;
  107. }
  108. static inline int evm_protected_xattr_if_enabled(const char *req_xattr_name)
  109. {
  110. return false;
  111. }
  112. static inline int evm_read_protected_xattrs(struct dentry *dentry, u8 *buffer,
  113. int buffer_size, char type,
  114. bool canonical_fmt)
  115. {
  116. return -EOPNOTSUPP;
  117. }
  118. #endif /* CONFIG_EVM */
  119. #endif /* LINUX_EVM_H */