ima.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (C) 2008 IBM Corporation
  3. * Author: Mimi Zohar <zohar@us.ibm.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, version 2 of the License.
  8. */
  9. #ifndef _LINUX_IMA_H
  10. #define _LINUX_IMA_H
  11. #include <linux/fs.h>
  12. #include <linux/security.h>
  13. #include <linux/kexec.h>
  14. struct linux_binprm;
  15. #ifdef CONFIG_IMA
  16. extern int ima_bprm_check(struct linux_binprm *bprm);
  17. extern int ima_file_check(struct file *file, int mask);
  18. extern void ima_file_free(struct file *file);
  19. extern int ima_file_mmap(struct file *file, unsigned long prot);
  20. extern int ima_load_data(enum kernel_load_data_id id);
  21. extern int ima_read_file(struct file *file, enum kernel_read_file_id id);
  22. extern int ima_post_read_file(struct file *file, void *buf, loff_t size,
  23. enum kernel_read_file_id id);
  24. extern void ima_post_path_mknod(struct dentry *dentry);
  25. #ifdef CONFIG_IMA_KEXEC
  26. extern void ima_add_kexec_buffer(struct kimage *image);
  27. #endif
  28. #else
  29. static inline int ima_bprm_check(struct linux_binprm *bprm)
  30. {
  31. return 0;
  32. }
  33. static inline int ima_file_check(struct file *file, int mask)
  34. {
  35. return 0;
  36. }
  37. static inline void ima_file_free(struct file *file)
  38. {
  39. return;
  40. }
  41. static inline int ima_file_mmap(struct file *file, unsigned long prot)
  42. {
  43. return 0;
  44. }
  45. static inline int ima_load_data(enum kernel_load_data_id id)
  46. {
  47. return 0;
  48. }
  49. static inline int ima_read_file(struct file *file, enum kernel_read_file_id id)
  50. {
  51. return 0;
  52. }
  53. static inline int ima_post_read_file(struct file *file, void *buf, loff_t size,
  54. enum kernel_read_file_id id)
  55. {
  56. return 0;
  57. }
  58. static inline void ima_post_path_mknod(struct dentry *dentry)
  59. {
  60. return;
  61. }
  62. #endif /* CONFIG_IMA */
  63. #ifndef CONFIG_IMA_KEXEC
  64. struct kimage;
  65. static inline void ima_add_kexec_buffer(struct kimage *image)
  66. {}
  67. #endif
  68. #ifdef CONFIG_IMA_APPRAISE
  69. extern bool is_ima_appraise_enabled(void);
  70. extern void ima_inode_post_setattr(struct dentry *dentry);
  71. extern int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name,
  72. const void *xattr_value, size_t xattr_value_len);
  73. extern int ima_inode_removexattr(struct dentry *dentry, const char *xattr_name);
  74. #else
  75. static inline bool is_ima_appraise_enabled(void)
  76. {
  77. return 0;
  78. }
  79. static inline void ima_inode_post_setattr(struct dentry *dentry)
  80. {
  81. return;
  82. }
  83. static inline int ima_inode_setxattr(struct dentry *dentry,
  84. const char *xattr_name,
  85. const void *xattr_value,
  86. size_t xattr_value_len)
  87. {
  88. return 0;
  89. }
  90. static inline int ima_inode_removexattr(struct dentry *dentry,
  91. const char *xattr_name)
  92. {
  93. return 0;
  94. }
  95. #endif /* CONFIG_IMA_APPRAISE */
  96. #endif /* _LINUX_IMA_H */