2 * SELinux services exported to the rest of the kernel.
4 * Author: James Morris <jmorris@redhat.com>
6 * Copyright (C) 2005 Red Hat, Inc., James Morris <jmorris@redhat.com>
7 * Copyright (C) 2006 Trusted Computer Solutions, Inc. <dgoeddel@trustedcs.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2,
11 * as published by the Free Software Foundation.
13 #ifndef _LINUX_SELINUX_H
14 #define _LINUX_SELINUX_H
16 struct selinux_audit_rule;
19 #ifdef CONFIG_SECURITY_SELINUX
22 * selinux_audit_rule_init - alloc/init an selinux audit rule structure.
23 * @field: the field this rule refers to
24 * @op: the operater the rule uses
25 * @rulestr: the text "target" of the rule
26 * @rule: pointer to the new rule structure returned via this
28 * Returns 0 if successful, -errno if not. On success, the rule structure
29 * will be allocated internally. The caller must free this structure with
30 * selinux_audit_rule_free() after use.
32 int selinux_audit_rule_init(u32 field, u32 op, char *rulestr,
33 struct selinux_audit_rule **rule);
36 * selinux_audit_rule_free - free an selinux audit rule structure.
37 * @rule: pointer to the audit rule to be freed
39 * This will free all memory associated with the given rule.
40 * If @rule is NULL, no operation is performed.
42 void selinux_audit_rule_free(struct selinux_audit_rule *rule);
45 * selinux_audit_rule_match - determine if a context ID matches a rule.
46 * @ctxid: the context ID to check
47 * @field: the field this rule refers to
48 * @op: the operater the rule uses
49 * @rule: pointer to the audit rule to check against
50 * @actx: the audit context (can be NULL) associated with the check
52 * Returns 1 if the context id matches the rule, 0 if it does not, and
55 int selinux_audit_rule_match(u32 ctxid, u32 field, u32 op,
56 struct selinux_audit_rule *rule,
57 struct audit_context *actx);
60 * selinux_audit_set_callback - set the callback for policy reloads.
61 * @callback: the function to call when the policy is reloaded
63 * This sets the function callback function that will update the rules
64 * upon policy reloads. This callback should rebuild all existing rules
65 * using selinux_audit_rule_init().
67 void selinux_audit_set_callback(int (*callback)(void));
70 * selinux_task_ctxid - determine a context ID for a process.
71 * @tsk: the task object
72 * @ctxid: ID value returned via this
74 * On return, ctxid will contain an ID for the context. This value
75 * should only be used opaquely.
77 void selinux_task_ctxid(struct task_struct *tsk, u32 *ctxid);
81 static inline int selinux_audit_rule_init(u32 field, u32 op,
83 struct selinux_audit_rule **rule)
88 static inline void selinux_audit_rule_free(struct selinux_audit_rule *rule)
93 static inline int selinux_audit_rule_match(u32 ctxid, u32 field, u32 op,
94 struct selinux_audit_rule *rule,
95 struct audit_context *actx)
100 static inline void selinux_audit_set_callback(int (*callback)(void))
105 static inline void selinux_task_ctxid(struct task_struct *tsk, u32 *ctxid)
110 #endif /* CONFIG_SECURITY_SELINUX */
112 #endif /* _LINUX_SELINUX_H */