函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\keys\request_key.c Create Date:2022-07-27 19:58:05
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:Allocate a new key in under-construction state and attempt to link it in to* the requested keyring.* May return a key that's already under construction instead if there was a* race between two thread calling request_key().

函数原型:static int construct_alloc_key(struct keyring_search_context *ctx, struct key *dest_keyring, unsigned long flags, struct key_user *user, struct key **_key)

返回类型:int

参数:

类型参数名称
struct keyring_search_context *ctx
struct key *dest_keyring
unsigned longflags
struct key_user *user
struct key **_key
372  struct assoc_array_edit * edit = NULL
378  kenter("%s,%s,,,", name, description)
381  * _key = NULL
382  mutex_lock( & construction initiation lock )
384  perm等于possessor can view a key's attributes 按位或possessor can find a key in search / search a keyring 按位或possessor can create a link to a key/keyring 按位或possessor can set key attributes
385  perm或等于user permissions...
386  如果readperm或等于possessor can read key payload / view keyring
388  如果type恒等于key_type_keyringupdateperm或等于possessor can update key payload / add link to keyring
392  key等于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.
395  如果是错误则转到:alloc_failed
398  设置内存位
400  如果dest_keyring
401  ret等于Lock keyring for link.
402  如果ret小于0则转到:link_lock_failed
404  ret等于Preallocate memory so that a key can be linked into to a keyring.
405  如果ret小于0则转到:link_prealloc_failed
412  mutex_lock( & We serialise key instantiation and link )
414  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
415  key_ref等于Search the process keyrings attached to the supplied cred for the first* matching key in the manner of search_my_process_keyrings(), but also search* the keys attached to the assumed authorisation key using its credentials if* one is available.
416  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
417  如果非是错误则转到:key_already_present
420  如果dest_keyringLink a key into to a keyring.* Must be called with __key_link_begin() having being called. Discards any* already extant link to matching key if there is one, so that each keyring* holds at most one link to any given key of a particular type+description
423  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
424  如果dest_keyringFinish linking a key into to a keyring.* Must be called with __key_link_begin() having being called.
426  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
427  _key等于key
428  kleave(" = 0 [%d]", key_serial(key))
429  返回:0
433  key_already_present :
434  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
435  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
436  key等于key_ref_to_ptr(key_ref)
437  如果dest_keyring
438  ret等于Check already instantiated keys aren't going to be a problem.* The caller must have called __key_link_begin(). Don't need to call this for* keys that were created since __key_link_begin() was called.
439  如果ret恒等于0则Link a key into to a keyring.* Must be called with __key_link_begin() having being called. Discards any* already extant link to matching key if there is one, so that each keyring* holds at most one link to any given key of a particular type+description
441  Finish linking a key into to a keyring.* Must be called with __key_link_begin() having being called.
442  如果ret小于0则转到:link_check_failed
445  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
446  _key等于key
447  kleave(" = -EINPROGRESS [%d]", key_serial(key))
448  返回:负EINPROGRESS
450  link_check_failed :
451  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
452  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
453  kleave(" = %d [linkcheck]", ret)
454  返回:ret
456  link_prealloc_failed :
457  Finish linking a key into to a keyring.* Must be called with __key_link_begin() having being called.
458  link_lock_failed :
459  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
460  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
461  kleave(" = %d [prelink]", ret)
462  返回:ret
464  alloc_failed :
465  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
466  kleave(" = %ld", 错误)
467  返回:错误
调用者
名称描述
construct_key_and_linkCommence key construction.