dm-audit.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Creating audit records for mapped devices.
  4. *
  5. * Copyright (C) 2021 Fraunhofer AISEC. All rights reserved.
  6. *
  7. * Authors: Michael Weiß <[email protected]>
  8. */
  9. #ifndef DM_AUDIT_H
  10. #define DM_AUDIT_H
  11. #include <linux/device-mapper.h>
  12. #include <linux/audit.h>
  13. #ifdef CONFIG_DM_AUDIT
  14. void dm_audit_log_bio(const char *dm_msg_prefix, const char *op,
  15. struct bio *bio, sector_t sector, int result);
  16. /*
  17. * dm_audit_log_ti() is not intended to be used directly in dm modules,
  18. * the wrapper functions below should be called by dm modules instead.
  19. */
  20. void dm_audit_log_ti(int audit_type, const char *dm_msg_prefix, const char *op,
  21. struct dm_target *ti, int result);
  22. static inline void dm_audit_log_ctr(const char *dm_msg_prefix,
  23. struct dm_target *ti, int result)
  24. {
  25. dm_audit_log_ti(AUDIT_DM_CTRL, dm_msg_prefix, "ctr", ti, result);
  26. }
  27. static inline void dm_audit_log_dtr(const char *dm_msg_prefix,
  28. struct dm_target *ti, int result)
  29. {
  30. dm_audit_log_ti(AUDIT_DM_CTRL, dm_msg_prefix, "dtr", ti, result);
  31. }
  32. static inline void dm_audit_log_target(const char *dm_msg_prefix, const char *op,
  33. struct dm_target *ti, int result)
  34. {
  35. dm_audit_log_ti(AUDIT_DM_EVENT, dm_msg_prefix, op, ti, result);
  36. }
  37. #else
  38. static inline void dm_audit_log_bio(const char *dm_msg_prefix, const char *op,
  39. struct bio *bio, sector_t sector,
  40. int result)
  41. {
  42. }
  43. static inline void dm_audit_log_target(const char *dm_msg_prefix,
  44. const char *op, struct dm_target *ti,
  45. int result)
  46. {
  47. }
  48. static inline void dm_audit_log_ctr(const char *dm_msg_prefix,
  49. struct dm_target *ti, int result)
  50. {
  51. }
  52. static inline void dm_audit_log_dtr(const char *dm_msg_prefix,
  53. struct dm_target *ti, int result)
  54. {
  55. }
  56. #endif
  57. #endif