函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:key_create_or_update - Update or create and instantiate a key.*@keyring_ref: A pointer to the destination keyring with possession flag.*@type: The type of key.*@description: The searchable description for the key.

函数原型:key_ref_t key_create_or_update(key_ref_t keyring_ref, const char *type, const char *description, const void *payload, size_t plen, key_perm_t perm, unsigned long flags)

返回类型:key_ref_t

参数:

类型参数名称
key_ref_tkeyring_ref
const char *type
const char *description
const void *payload
size_tplen
key_perm_tperm
unsigned longflags
816  struct keyring_index_key index_key = {description = description, }
820  struct assoc_array_edit * edit = NULL
821  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.()
822  struct key * keyring, * key = NULL
825  struct key_restriction * restrict_link = NULL
829  type等于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.
830  如果是错误
831  key_ref等于错误号
832  转到:error
835  key_ref等于错误号
836  如果非instantiate或非description且非preparse则转到:error_put_type
840  keyring等于key_ref_to_ptr(keyring_ref)
842  key_check(keyring)
844  如果非flags按位与Override the check on restricted keyrings 的值则restrict_link等于 This is set on a keyring to restrict the addition of a link to a key * to it. If this structure isn't provided then it is assumed that the * keyring is open to any addition. It is ignored for non-keyring * keys. Only set this value using keyring_restrict(
847  key_ref等于错误号
848  如果 type of key 不等于key_type_keyring则转到:error_put_type
851  memset( & prep, 0, prep的长度)
852  Raw data 等于payload
853  Raw datalen 等于plen
854  Quota length for proposed payload 等于def_datalen
855  Expiry time of key 等于Located here for timespec[64]_valid_strict
856  如果preparse
857  ret等于preparse( & prep)
858  如果ret小于0则
859  key_ref等于错误号
860  转到:error_free_prep
862  如果非descriptiondescription等于Proposed key description (or NULL)
864  key_ref等于错误号
865  如果非description则转到:error_free_prep
868  desc_len等于strlen - Find the length of a string*@s: The string to be sized
869  key_set_index_key( & index_key)
871  ret等于__key_link_lock(keyring, & index_key)
872  如果ret小于0则
873  key_ref等于错误号
874  转到:error_free_prep
877  ret等于Preallocate memory so that a key can be linked into to a keyring.
878  如果ret小于0则
879  key_ref等于错误号
880  转到:error_link_end
883  如果restrict_linkcheck
884  ret等于check(keyring, type, & Proposed payload , key)
886  如果ret小于0则
887  key_ref等于错误号
888  转到:error_link_end
894  ret等于Check to see whether permission is granted to use a key in the desired way.
895  如果ret小于0则
896  key_ref等于错误号
897  转到:error_link_end
904  如果update
905  key_ref等于find_key_to_update(keyring_ref, & index_key)
906  如果key_ref则转到:found_matching_key
911  如果perm恒等于KEY_PERM_UNDEF
912  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
913  perm或等于user permissions...
915  如果readperm或等于possessor can read key payload / view keyring
918  如果type恒等于key_type_keyringupdateperm或等于possessor can update key payload / add link to keyring
924  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.
926  如果是错误
927  key_ref等于错误指示
928  转到:error_link_end
932  ret等于Instantiate a key and link it into the target keyring atomically. Must be* called with the target keyring's semaphore writelocked. The target key's* semaphore need not be locked as instantiation is serialised by* key_construction_mutex.
933  如果ret小于0则
934  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
935  key_ref等于错误号
936  转到:error_link_end
939  key_ref等于make_key_ref(key, is_key_possessed(keyring_ref))
941  error_link_end :
942  Finish linking a key into to a keyring.* Must be called with __key_link_begin() having being called.
943  error_free_prep :
944  如果preparsefree_preparse( & prep)
946  error_put_type :
947  Unlock a key type locked by key_type_lookup().
948  error :
949  返回:key_ref
951  found_matching_key :
955  Finish linking a key into to a keyring.* Must be called with __key_link_begin() having being called.
957  key等于key_ref_to_ptr(key_ref)
958  如果st_bit - Determine whether a bit is set*@nr: bit number to test*@addr: Address to start counting from
959  ret等于wait_for_key_construction(key, true)
960  如果ret小于0则
962  key_ref等于错误号
963  转到:error_free_prep
967  key_ref等于Attempt to update an existing key.* The key is given to us with an incremented refcount that we need to discard* if we get an error.
968  转到:error_free_prep
调用者
名称描述
SYSCALL_DEFINE5Extract the description of a new key from userspace and either add it as a* new key to the specified keyring or update a matching key in that keyring.* If the description is NULL or an empty string, the key type is asked to* generate one from the payload.
integrity_add_key