aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAhmed S. Darwish <darwish.07@gmail.com>2008-03-01 15:00:05 -0500
committerJames Morris <jmorris@namei.org>2008-04-18 19:52:36 -0400
commit03d37d25e0f91b28c4b6d002be6221f1af4b19d8 (patch)
treede56538f7b6e7623d7cee2b0fcdc8f9764957252 /include
parent6b89a74be0fbbc6cc639d5cf7dcf8e6ee0f120a7 (diff)
LSM/Audit: Introduce generic Audit LSM hooks
Introduce a generic Audit interface for security modules by adding the following new LSM hooks: audit_rule_init(field, op, rulestr, lsmrule) audit_rule_known(krule) audit_rule_match(secid, field, op, rule, actx) audit_rule_free(rule) Those hooks are only available if CONFIG_AUDIT is enabled. Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com> Acked-by: James Morris <jmorris@namei.org> Reviewed-by: Paul Moore <paul.moore@hp.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/security.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/include/linux/security.h b/include/linux/security.h
index 45717d9d9656..697f228daf19 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -37,6 +37,7 @@
37extern unsigned securebits; 37extern unsigned securebits;
38 38
39struct ctl_table; 39struct ctl_table;
40struct audit_krule;
40 41
41/* 42/*
42 * These functions are in security/capability.c and are used 43 * These functions are in security/capability.c and are used
@@ -1235,6 +1236,37 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1235 * @secdata contains the security context. 1236 * @secdata contains the security context.
1236 * @seclen contains the length of the security context. 1237 * @seclen contains the length of the security context.
1237 * 1238 *
1239 * Security hooks for Audit
1240 *
1241 * @audit_rule_init:
1242 * Allocate and initialize an LSM audit rule structure.
1243 * @field contains the required Audit action. Fields flags are defined in include/linux/audit.h
1244 * @op contains the operator the rule uses.
1245 * @rulestr contains the context where the rule will be applied to.
1246 * @lsmrule contains a pointer to receive the result.
1247 * Return 0 if @lsmrule has been successfully set,
1248 * -EINVAL in case of an invalid rule.
1249 *
1250 * @audit_rule_known:
1251 * Specifies whether given @rule contains any fields related to current LSM.
1252 * @rule contains the audit rule of interest.
1253 * Return 1 in case of relation found, 0 otherwise.
1254 *
1255 * @audit_rule_match:
1256 * Determine if given @secid matches a rule previously approved
1257 * by @audit_rule_known.
1258 * @secid contains the security id in question.
1259 * @field contains the field which relates to current LSM.
1260 * @op contains the operator that will be used for matching.
1261 * @rule points to the audit rule that will be checked against.
1262 * @actx points to the audit context associated with the check.
1263 * Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure.
1264 *
1265 * @audit_rule_free:
1266 * Deallocate the LSM audit rule structure previously allocated by
1267 * audit_rule_init.
1268 * @rule contains the allocated rule
1269 *
1238 * This is the main security structure. 1270 * This is the main security structure.
1239 */ 1271 */
1240struct security_operations { 1272struct security_operations {
@@ -1494,6 +1526,13 @@ struct security_operations {
1494 1526
1495#endif /* CONFIG_KEYS */ 1527#endif /* CONFIG_KEYS */
1496 1528
1529#ifdef CONFIG_AUDIT
1530 int (*audit_rule_init)(u32 field, u32 op, char *rulestr, void **lsmrule);
1531 int (*audit_rule_known)(struct audit_krule *krule);
1532 int (*audit_rule_match)(u32 secid, u32 field, u32 op, void *lsmrule,
1533 struct audit_context *actx);
1534 void (*audit_rule_free)(void *lsmrule);
1535#endif /* CONFIG_AUDIT */
1497}; 1536};
1498 1537
1499/* prototypes */ 1538/* prototypes */
@@ -2700,5 +2739,38 @@ static inline int security_key_permission(key_ref_t key_ref,
2700#endif 2739#endif
2701#endif /* CONFIG_KEYS */ 2740#endif /* CONFIG_KEYS */
2702 2741
2742#ifdef CONFIG_AUDIT
2743#ifdef CONFIG_SECURITY
2744int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
2745int security_audit_rule_known(struct audit_krule *krule);
2746int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
2747 struct audit_context *actx);
2748void security_audit_rule_free(void *lsmrule);
2749
2750#else
2751
2752static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
2753 void **lsmrule)
2754{
2755 return 0;
2756}
2757
2758static inline int security_audit_rule_known(struct audit_krule *krule)
2759{
2760 return 0;
2761}
2762
2763static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
2764 void *lsmrule, struct audit_context *actx)
2765{
2766 return 0;
2767}
2768
2769static inline void security_audit_rule_free(void *lsmrule)
2770{ }
2771
2772#endif /* CONFIG_SECURITY */
2773#endif /* CONFIG_AUDIT */
2774
2703#endif /* ! __LINUX_SECURITY_H */ 2775#endif /* ! __LINUX_SECURITY_H */
2704 2776