Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\keys\request_key_auth.c Create Date:2022-07-28 18:24:22
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Create an authorisation token for /sbin/request-key or whoever to gain* access to the caller's security data.

Proto:struct key *request_key_auth_new(struct key *target, const char *op, const void *callout_info, size_t callout_len, struct key *dest_keyring)

Type:struct key

Parameter:

TypeParameterName
struct key *target
const char *op
const void *callout_info
size_tcallout_len
struct key *dest_keyring
167  cred = current_cred - Access the current task's subjective credentials* Access the subjective credentials of the current task. RCU-safe,* since nobody else can modify it.()
168  struct key * authkey = NULL
170  ret = -ENOMEM
172  kenter("%d,", key serial number )
175  rka = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
176  If Not rka Then Go to error
178  callout_info = kmemdup - duplicate region of memory*@src: memory region to duplicate*@len: memory region length*@gfp: GFP mask to use* Return: newly allocated copy of @src or %NULL in case of error
179  If Not callout_info Then Go to error_free_rka
181  callout_len = callout_len
182  Copy a NUL terminated string into a sized buffer
186  If assumed request_key authority Then
188  lock for reading
195  ret = -EKEYREVOKED
196  Go to error_free_rka
199  irka = data[0]
200  cred = get_cred - Get a reference on a set of credentials*@cred: The credentials to reference* Get a reference on the specified set of credentials. The caller must* release the reference. If %NULL is passed, it is returned with no action.
201  pid = pid
203  lease a read lock
205  Else
207  cred = get_cred - Get a reference on a set of credentials*@cred: The credentials to reference* Get a reference on the specified set of credentials. The caller must* release the reference. If %NULL is passed, it is returned with no action.
208  pid = pid
211  target_key = key_get(target)
212  dest_keyring = key_get(dest_keyring)
215  sprintf(desc, "%x", key serial number )
217  authkey = key_alloc - Allocate a key of the specified type.*@type: The type of key to allocate.*@desc: The key description to allow the key to be searched out.*@uid: The owner of the new key.*@gid: The group ID for the new key's group permissions.
221  If IS_ERR(authkey) Then
222  ret = PTR_ERR(authkey)
223  Go to error_free_rka
227  ret = key_instantiate_and_link - Instantiate a key and link it into the keyring.*@key: The key to instantiate.*@data: The data to use to instantiate the keyring.*@datalen: The length of @data.*@keyring: Keyring to create a link in on success (or NULL).
228  If ret < 0 Then Go to error_put_authkey
231  kleave(" = {%d,%d}", key serial number , _read - get a refcount's value*@r: the refcount* Return: the refcount's value)
232  Return authkey
234  error_put_authkey :
235  key_put - Discard a reference to a key.*@key: The key to discard a reference from.* Discard a reference to a key, and when all the references are gone, we* schedule the cleanup task to come and pull it out of the tree in process
236  error_free_rka :
237  free_request_key_auth(rka)
238  error :
239  kleave("= %d", ret)
240  Return ERR_PTR(ret)
Caller
NameDescribe
construct_keyCall out to userspace for key construction.* Program failure is ignored in favour of key status.