Skip to content

Commit b14faf9

Browse files
committed
lsm: move the audit hook comments to security/security.c
This patch relocates the LSM hook function comments to the function definitions, in keeping with the current kernel conventions. This should make the hook descriptions more easily discoverable and easier to maintain. While formatting changes have been done to better fit the kernel-doc style, content changes have been kept to a minimum and limited to text which was obviously incorrect and/or outdated. It is expected the future patches will improve the quality of the function header comments. Acked-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 1427ddb commit b14faf9

2 files changed

Lines changed: 41 additions & 32 deletions

File tree

include/linux/lsm_hooks.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -135,38 +135,6 @@
135135
* @secdata contains the security context.
136136
* @seclen contains the length of the security context.
137137
*
138-
* Security hooks for Audit
139-
*
140-
* @audit_rule_init:
141-
* Allocate and initialize an LSM audit rule structure.
142-
* @field contains the required Audit action.
143-
* Fields flags are defined in <include/linux/audit.h>
144-
* @op contains the operator the rule uses.
145-
* @rulestr contains the context where the rule will be applied to.
146-
* @lsmrule contains a pointer to receive the result.
147-
* Return 0 if @lsmrule has been successfully set,
148-
* -EINVAL in case of an invalid rule.
149-
*
150-
* @audit_rule_known:
151-
* Specifies whether given @krule contains any fields related to
152-
* current LSM.
153-
* @krule contains the audit rule of interest.
154-
* Return 1 in case of relation found, 0 otherwise.
155-
*
156-
* @audit_rule_match:
157-
* Determine if given @secid matches a rule previously approved
158-
* by @audit_rule_known.
159-
* @secid contains the security id in question.
160-
* @field contains the field which relates to current LSM.
161-
* @op contains the operator that will be used for matching.
162-
* @lrule points to the audit rule that will be checked against.
163-
* Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure.
164-
*
165-
* @audit_rule_free:
166-
* Deallocate the LSM audit rule structure previously allocated by
167-
* audit_rule_init.
168-
* @lsmrule contains the allocated rule.
169-
*
170138
* @inode_invalidate_secctx:
171139
* Notify the security module that it must revalidate the security context
172140
* of an inode.

security/security.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4762,21 +4762,62 @@ int security_key_getsecurity(struct key *key, char **_buffer)
47624762

47634763
#ifdef CONFIG_AUDIT
47644764

4765+
/**
4766+
* security_audit_rule_init() - Allocate and init an LSM audit rule struct
4767+
* @field: audit action
4768+
* @op: rule operator
4769+
* @rulestr: rule context
4770+
* @lsmrule: receive buffer for audit rule struct
4771+
*
4772+
* Allocate and initialize an LSM audit rule structure.
4773+
*
4774+
* Return: Return 0 if @lsmrule has been successfully set, -EINVAL in case of
4775+
* an invalid rule.
4776+
*/
47654777
int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule)
47664778
{
47674779
return call_int_hook(audit_rule_init, 0, field, op, rulestr, lsmrule);
47684780
}
47694781

4782+
/**
4783+
* security_audit_rule_known() - Check if an audit rule contains LSM fields
4784+
* @krule: audit rule
4785+
*
4786+
* Specifies whether given @krule contains any fields related to the current
4787+
* LSM.
4788+
*
4789+
* Return: Returns 1 in case of relation found, 0 otherwise.
4790+
*/
47704791
int security_audit_rule_known(struct audit_krule *krule)
47714792
{
47724793
return call_int_hook(audit_rule_known, 0, krule);
47734794
}
47744795

4796+
/**
4797+
* security_audit_rule_free() - Free an LSM audit rule struct
4798+
* @lsmrule: audit rule struct
4799+
*
4800+
* Deallocate the LSM audit rule structure previously allocated by
4801+
* audit_rule_init().
4802+
*/
47754803
void security_audit_rule_free(void *lsmrule)
47764804
{
47774805
call_void_hook(audit_rule_free, lsmrule);
47784806
}
47794807

4808+
/**
4809+
* security_audit_rule_match() - Check if a label matches an audit rule
4810+
* @secid: security label
4811+
* @field: LSM audit field
4812+
* @op: matching operator
4813+
* @lsmrule: audit rule
4814+
*
4815+
* Determine if given @secid matches a rule previously approved by
4816+
* security_audit_rule_known().
4817+
*
4818+
* Return: Returns 1 if secid matches the rule, 0 if it does not, -ERRNO on
4819+
* failure.
4820+
*/
47804821
int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule)
47814822
{
47824823
return call_int_hook(audit_rule_match, 0, secid, field, op, lsmrule);

0 commit comments

Comments
 (0)