audit.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * SELinux support for the Audit LSM hooks
  4. *
  5. * Author: James Morris <[email protected]>
  6. *
  7. * Copyright (C) 2005 Red Hat, Inc., James Morris <[email protected]>
  8. * Copyright (C) 2006 Trusted Computer Solutions, Inc. <[email protected]>
  9. * Copyright (C) 2006 IBM Corporation, Timothy R. Chavez <[email protected]>
  10. */
  11. #ifndef _SELINUX_AUDIT_H
  12. #define _SELINUX_AUDIT_H
  13. #include <linux/audit.h>
  14. #include <linux/types.h>
  15. /**
  16. * selinux_audit_rule_init - alloc/init an selinux audit rule structure.
  17. * @field: the field this rule refers to
  18. * @op: the operator the rule uses
  19. * @rulestr: the text "target" of the rule
  20. * @rule: pointer to the new rule structure returned via this
  21. *
  22. * Returns 0 if successful, -errno if not. On success, the rule structure
  23. * will be allocated internally. The caller must free this structure with
  24. * selinux_audit_rule_free() after use.
  25. */
  26. int selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **rule);
  27. /**
  28. * selinux_audit_rule_free - free an selinux audit rule structure.
  29. * @rule: pointer to the audit rule to be freed
  30. *
  31. * This will free all memory associated with the given rule.
  32. * If @rule is NULL, no operation is performed.
  33. */
  34. void selinux_audit_rule_free(void *rule);
  35. /**
  36. * selinux_audit_rule_match - determine if a context ID matches a rule.
  37. * @sid: the context ID to check
  38. * @field: the field this rule refers to
  39. * @op: the operater the rule uses
  40. * @rule: pointer to the audit rule to check against
  41. *
  42. * Returns 1 if the context id matches the rule, 0 if it does not, and
  43. * -errno on failure.
  44. */
  45. int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *rule);
  46. /**
  47. * selinux_audit_rule_known - check to see if rule contains selinux fields.
  48. * @rule: rule to be checked
  49. * Returns 1 if there are selinux fields specified in the rule, 0 otherwise.
  50. */
  51. int selinux_audit_rule_known(struct audit_krule *rule);
  52. #endif /* _SELINUX_AUDIT_H */