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