Skip to content

Commit ecc419a

Browse files
committed
lsm: move the key 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 742b994 commit ecc419a

2 files changed

Lines changed: 40 additions & 32 deletions

File tree

include/linux/lsm_hooks.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,38 +32,6 @@
3232
/**
3333
* union security_list_options - Linux Security Module hook function list
3434
*
35-
* Security hooks affecting all Key Management operations
36-
*
37-
* @key_alloc:
38-
* Permit allocation of a key and assign security data. Note that key does
39-
* not have a serial number assigned at this point.
40-
* @key points to the key.
41-
* @flags is the allocation flags.
42-
* Return 0 if permission is granted, -ve error otherwise.
43-
* @key_free:
44-
* Notification of destruction; free security data.
45-
* @key points to the key.
46-
* No return value.
47-
* @key_permission:
48-
* See whether a specific operational right is granted to a process on a
49-
* key.
50-
* @key_ref refers to the key (key pointer + possession attribute bit).
51-
* @cred points to the credentials to provide the context against which to
52-
* evaluate the security data on the key.
53-
* @perm describes the combination of permissions required of this key.
54-
* Return 0 if permission is granted, -ve error otherwise.
55-
* @key_getsecurity:
56-
* Get a textual representation of the security context attached to a key
57-
* for the purposes of honouring KEYCTL_GETSECURITY. This function
58-
* allocates the storage for the NUL-terminated string and the caller
59-
* should free it.
60-
* @key points to the key to be queried.
61-
* @_buffer points to a pointer that should be set to point to the
62-
* resulting string (if no label or an error occurs).
63-
* Return the length of the string (including terminating NUL) or -ve if
64-
* an error.
65-
* May also return 0 (and a NULL buffer pointer) if there is no label.
66-
*
6735
* Security hooks affecting all System V IPC operations.
6836
*
6937
* @ipc_permission:

security/security.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4468,23 +4468,63 @@ EXPORT_SYMBOL(security_skb_classify_flow);
44684468

44694469
#ifdef CONFIG_KEYS
44704470

4471+
/**
4472+
* security_key_alloc() - Allocate and initialize a kernel key LSM blob
4473+
* @key: key
4474+
* @cred: credentials
4475+
* @flags: allocation flags
4476+
*
4477+
* Permit allocation of a key and assign security data. Note that key does not
4478+
* have a serial number assigned at this point.
4479+
*
4480+
* Return: Return 0 if permission is granted, -ve error otherwise.
4481+
*/
44714482
int security_key_alloc(struct key *key, const struct cred *cred,
44724483
unsigned long flags)
44734484
{
44744485
return call_int_hook(key_alloc, 0, key, cred, flags);
44754486
}
44764487

4488+
/**
4489+
* security_key_free() - Free a kernel key LSM blob
4490+
* @key: key
4491+
*
4492+
* Notification of destruction; free security data.
4493+
*/
44774494
void security_key_free(struct key *key)
44784495
{
44794496
call_void_hook(key_free, key);
44804497
}
44814498

4499+
/**
4500+
* security_key_permission() - Check if a kernel key operation is allowed
4501+
* @key_ref: key reference
4502+
* @cred: credentials of actor requesting access
4503+
* @need_perm: requested permissions
4504+
*
4505+
* See whether a specific operational right is granted to a process on a key.
4506+
*
4507+
* Return: Return 0 if permission is granted, -ve error otherwise.
4508+
*/
44824509
int security_key_permission(key_ref_t key_ref, const struct cred *cred,
44834510
enum key_need_perm need_perm)
44844511
{
44854512
return call_int_hook(key_permission, 0, key_ref, cred, need_perm);
44864513
}
44874514

4515+
/**
4516+
* security_key_getsecurity() - Get the key's security label
4517+
* @key: key
4518+
* @buffer: security label buffer
4519+
*
4520+
* Get a textual representation of the security context attached to a key for
4521+
* the purposes of honouring KEYCTL_GETSECURITY. This function allocates the
4522+
* storage for the NUL-terminated string and the caller should free it.
4523+
*
4524+
* Return: Returns the length of @buffer (including terminating NUL) or -ve if
4525+
* an error occurs. May also return 0 (and a NULL buffer pointer) if
4526+
* there is no security label assigned to the key.
4527+
*/
44884528
int security_key_getsecurity(struct key *key, char **_buffer)
44894529
{
44904530
*_buffer = NULL;

0 commit comments

Comments
 (0)