Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * SELinux support for the Audit LSM hooks
0004  *
0005  * Author: James Morris <jmorris@redhat.com>
0006  *
0007  * Copyright (C) 2005 Red Hat, Inc., James Morris <jmorris@redhat.com>
0008  * Copyright (C) 2006 Trusted Computer Solutions, Inc. <dgoeddel@trustedcs.com>
0009  * Copyright (C) 2006 IBM Corporation, Timothy R. Chavez <tinytim@us.ibm.com>
0010  */
0011 
0012 #ifndef _SELINUX_AUDIT_H
0013 #define _SELINUX_AUDIT_H
0014 
0015 #include <linux/audit.h>
0016 #include <linux/types.h>
0017 
0018 /**
0019  *  selinux_audit_rule_init - alloc/init an selinux audit rule structure.
0020  *  @field: the field this rule refers to
0021  *  @op: the operator the rule uses
0022  *  @rulestr: the text "target" of the rule
0023  *  @rule: pointer to the new rule structure returned via this
0024  *
0025  *  Returns 0 if successful, -errno if not.  On success, the rule structure
0026  *  will be allocated internally.  The caller must free this structure with
0027  *  selinux_audit_rule_free() after use.
0028  */
0029 int selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **rule);
0030 
0031 /**
0032  *  selinux_audit_rule_free - free an selinux audit rule structure.
0033  *  @rule: pointer to the audit rule to be freed
0034  *
0035  *  This will free all memory associated with the given rule.
0036  *  If @rule is NULL, no operation is performed.
0037  */
0038 void selinux_audit_rule_free(void *rule);
0039 
0040 /**
0041  *  selinux_audit_rule_match - determine if a context ID matches a rule.
0042  *  @sid: the context ID to check
0043  *  @field: the field this rule refers to
0044  *  @op: the operater the rule uses
0045  *  @rule: pointer to the audit rule to check against
0046  *
0047  *  Returns 1 if the context id matches the rule, 0 if it does not, and
0048  *  -errno on failure.
0049  */
0050 int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *rule);
0051 
0052 /**
0053  *  selinux_audit_rule_known - check to see if rule contains selinux fields.
0054  *  @rule: rule to be checked
0055  *  Returns 1 if there are selinux fields specified in the rule, 0 otherwise.
0056  */
0057 int selinux_audit_rule_known(struct audit_krule *rule);
0058 
0059 #endif /* _SELINUX_AUDIT_H */
0060