ima.h 2.2 KB

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