18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * SELinux support for the Audit LSM hooks 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Author: James Morris <jmorris@redhat.com> 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (C) 2005 Red Hat, Inc., James Morris <jmorris@redhat.com> 88c2ecf20Sopenharmony_ci * Copyright (C) 2006 Trusted Computer Solutions, Inc. <dgoeddel@trustedcs.com> 98c2ecf20Sopenharmony_ci * Copyright (C) 2006 IBM Corporation, Timothy R. Chavez <tinytim@us.ibm.com> 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifndef _SELINUX_AUDIT_H 138c2ecf20Sopenharmony_ci#define _SELINUX_AUDIT_H 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/** 168c2ecf20Sopenharmony_ci * selinux_audit_rule_init - alloc/init an selinux audit rule structure. 178c2ecf20Sopenharmony_ci * @field: the field this rule refers to 188c2ecf20Sopenharmony_ci * @op: the operater the rule uses 198c2ecf20Sopenharmony_ci * @rulestr: the text "target" of the rule 208c2ecf20Sopenharmony_ci * @rule: pointer to the new rule structure returned via this 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci * Returns 0 if successful, -errno if not. On success, the rule structure 238c2ecf20Sopenharmony_ci * will be allocated internally. The caller must free this structure with 248c2ecf20Sopenharmony_ci * selinux_audit_rule_free() after use. 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_ciint selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **rule); 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/** 298c2ecf20Sopenharmony_ci * selinux_audit_rule_free - free an selinux audit rule structure. 308c2ecf20Sopenharmony_ci * @rule: pointer to the audit rule to be freed 318c2ecf20Sopenharmony_ci * 328c2ecf20Sopenharmony_ci * This will free all memory associated with the given rule. 338c2ecf20Sopenharmony_ci * If @rule is NULL, no operation is performed. 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_civoid selinux_audit_rule_free(void *rule); 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/** 388c2ecf20Sopenharmony_ci * selinux_audit_rule_match - determine if a context ID matches a rule. 398c2ecf20Sopenharmony_ci * @sid: the context ID to check 408c2ecf20Sopenharmony_ci * @field: the field this rule refers to 418c2ecf20Sopenharmony_ci * @op: the operater the rule uses 428c2ecf20Sopenharmony_ci * @rule: pointer to the audit rule to check against 438c2ecf20Sopenharmony_ci * 448c2ecf20Sopenharmony_ci * Returns 1 if the context id matches the rule, 0 if it does not, and 458c2ecf20Sopenharmony_ci * -errno on failure. 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_ciint selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *rule); 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci/** 508c2ecf20Sopenharmony_ci * selinux_audit_rule_known - check to see if rule contains selinux fields. 518c2ecf20Sopenharmony_ci * @rule: rule to be checked 528c2ecf20Sopenharmony_ci * Returns 1 if there are selinux fields specified in the rule, 0 otherwise. 538c2ecf20Sopenharmony_ci */ 548c2ecf20Sopenharmony_ciint selinux_audit_rule_known(struct audit_krule *krule); 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#endif /* _SELINUX_AUDIT_H */ 578c2ecf20Sopenharmony_ci 58