ima.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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/kexec.h>
  13. struct linux_binprm;
  14. #ifdef CONFIG_IMA
  15. extern int ima_bprm_check(struct linux_binprm *bprm);
  16. extern int ima_file_check(struct file *file, int mask, int opened);
  17. extern void ima_file_free(struct file *file);
  18. extern int ima_file_mmap(struct file *file, unsigned long prot);
  19. extern int ima_read_file(struct file *file, enum kernel_read_file_id id);
  20. extern int ima_post_read_file(struct file *file, void *buf, loff_t size,
  21. enum kernel_read_file_id id);
  22. extern void ima_post_path_mknod(struct dentry *dentry);
  23. #ifdef CONFIG_IMA_KEXEC
  24. extern void ima_add_kexec_buffer(struct kimage *image);
  25. #endif
  26. #else
  27. static inline int ima_bprm_check(struct linux_binprm *bprm)
  28. {
  29. return 0;
  30. }
  31. static inline int ima_file_check(struct file *file, int mask, int opened)
  32. {
  33. return 0;
  34. }
  35. static inline void ima_file_free(struct file *file)
  36. {
  37. return;
  38. }
  39. static inline int ima_file_mmap(struct file *file, unsigned long prot)
  40. {
  41. return 0;
  42. }
  43. static inline int ima_read_file(struct file *file, enum kernel_read_file_id id)
  44. {
  45. return 0;
  46. }
  47. static inline int ima_post_read_file(struct file *file, void *buf, loff_t size,
  48. enum kernel_read_file_id id)
  49. {
  50. return 0;
  51. }
  52. static inline void ima_post_path_mknod(struct dentry *dentry)
  53. {
  54. return;
  55. }
  56. #endif /* CONFIG_IMA */
  57. #ifndef CONFIG_IMA_KEXEC
  58. struct kimage;
  59. static inline void ima_add_kexec_buffer(struct kimage *image)
  60. {}
  61. #endif
  62. #ifdef CONFIG_IMA_APPRAISE
  63. extern void ima_inode_post_setattr(struct dentry *dentry);
  64. extern int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name,
  65. const void *xattr_value, size_t xattr_value_len);
  66. extern int ima_inode_removexattr(struct dentry *dentry, const char *xattr_name);
  67. #else
  68. static inline void ima_inode_post_setattr(struct dentry *dentry)
  69. {
  70. return;
  71. }
  72. static inline int ima_inode_setxattr(struct dentry *dentry,
  73. const char *xattr_name,
  74. const void *xattr_value,
  75. size_t xattr_value_len)
  76. {
  77. return 0;
  78. }
  79. static inline int ima_inode_removexattr(struct dentry *dentry,
  80. const char *xattr_name)
  81. {
  82. return 0;
  83. }
  84. #endif /* CONFIG_IMA_APPRAISE */
  85. #endif /* _LINUX_IMA_H */