Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\keys\keyctl.c Create Date:2022-07-28 18:19:27
Last Modify:2020-03-18 07:59:52 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Search the process keyrings and keyring trees linked from those for a* matching key. Keyrings must have appropriate Search permission to be* searched.* If a key is found, it will be attached to the destination keyring if there's

Proto:SYSCALL_DEFINE4(request_key, const char __user *, _type, const char __user *, _description, const char __user *, _callout_info, key_serial_t, destringid)

Type:

Parameter:Nothing

181  ret = key_get_type_from_user(type, _type, size of type )
182  If ret < 0 Then Go to error
186  description = strndup_user - duplicate an existing string from user space*@s: The string to duplicate*@n: Maximum number of bytes to copy, including the trailing NUL.* Return: newly allocated copy of @s or an ERR_PTR() in case of error
187  If IS_ERR(description) Then
188  ret = PTR_ERR(description)
189  Go to error
193  callout_info = NULL
194  callout_len = 0
195  If _callout_info Then
196  callout_info = strndup_user - duplicate an existing string from user space*@s: The string to duplicate*@n: Maximum number of bytes to copy, including the trailing NUL.* Return: newly allocated copy of @s or an ERR_PTR() in case of error
197  If IS_ERR(callout_info) Then
199  Go to error2
201  callout_len = strlen - Find the length of a string*@s: The string to be sized
205  dest_ref = NULL
206  If destringid Then
207  dest_ref = Look up a key ID given us by userspace with a given permissions mask to get* the key it refers to.* Flags can be passed to request that special keyrings be created if referred* to directly, to permit partially constructed keys to be found and to skip
209  If IS_ERR(dest_ref) Then
210  ret = PTR_ERR(dest_ref)
211  Go to error3
216  ktype = Find and lock the specified key type against removal.* We return with the sem read-locked if successful. If the type wasn't* available -ENOKEY is returned instead.
217  If IS_ERR(ktype) Then
218  ret = PTR_ERR(ktype)
219  Go to error4
223  key = quest_key_and_link - Request a key and cache it in a keyring.*@type: The type of key we want.*@description: The searchable description of the key.*@domain_tag: The domain in which the key operates.
226  If IS_ERR(key) Then
227  ret = PTR_ERR(key)
228  Go to error5
232  ret = wait_for_key_construction(key, 1)
233  If ret < 0 Then Go to error6
236  ret = key serial number
238  error6 :
239  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
240  error5 :
241  Unlock a key type locked by key_type_lookup().
242  error4 :
243  key_ref_put(dest_ref)
244  error3 :
245  kfree(callout_info)
246  error2 :
247  kfree(description)
248  error :
249  Return ret