Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Search a tree of keyrings that point to other keyrings up to the maximum* depth.

Proto:static bool search_nested_keyrings(struct key *keyring, struct keyring_search_context *ctx)

Type:bool

Parameter:

TypeParameterName
struct key *keyring
struct keyring_search_context *ctx
670  struct{struct key * keyring;struct assoc_array_node * node;int slot;}stack[6]
680  sp = 0
682  kenter("{%d},{%s,%s}", key serial number , name, description)
688  BUG_ON((flags & Search a tree of keyrings that point to other keyrings up to the maximum* depth.) == 0 || (flags & Search a tree of keyrings that point to other keyrings up to the maximum* depth.) == Search a tree of keyrings that point to other keyrings up to the maximum* depth.)
691  If description Then Finalise an index key to include a part of the description actually in the* index key, to set the domain tag and to calculate the hash.
697  If Type of lookup for this search. == Iterative search. || keyring_compare_object(keyring, & index_key) Then
699  Internal stuff = 2
701  Case iterator(keyring_key_to_ptr(keyring), ctx) == 1
702  Go to found
703  Case iterator(keyring_key_to_ptr(keyring), ctx) == 2
704  Return false
705  Default
706  Break
710  Internal stuff = 0
713  descend_to_keyring :
714  kdebug("descend to %d", key serial number )
715  If status flags (change with bitops) & ( 1 << set if key has been invalidated | 1 << set if key had been revoked ) Then Go to not_this_keyring
722  If Search inside a keyring for a key. We can search by walking to it* directly based on its index-key or we can iterate over the entire* tree looking for it, based on the match function. Then Go to found
733  If Not (flags & Search child keyrings also ) Then Go to not_this_keyring
736  ptr = READ_ONCE(The node at the root of the tree )
737  If Not ptr Then Go to not_this_keyring
740  If assoc_array_ptr_is_shortcut(ptr) Then
745  shortcut = assoc_array_ptr_to_shortcut(ptr)
746  If (index_key[0] & ASSOC_ARRAY_FAN_MASK) != 0 Then Go to not_this_keyring
749  ptr = READ_ONCE(next_node)
750  node = assoc_array_ptr_to_node(ptr)
751  Go to begin_node
754  node = assoc_array_ptr_to_node(ptr)
755  ptr = slots[0]
756  If Not assoc_array_ptr_is_meta(ptr) Then Go to begin_node
759  descend_to_node :
763  kdebug("descend")
764  If assoc_array_ptr_is_shortcut(ptr) Then
765  shortcut = assoc_array_ptr_to_shortcut(ptr)
766  ptr = READ_ONCE(next_node)
767  BUG_ON(!assoc_array_ptr_is_node(ptr))
769  node = assoc_array_ptr_to_node(ptr)
771  begin_node :
772  kdebug("begin_node")
773  slot = 0
774  ascend_to_node :
776  When slot < Number of slots per node cycle
777  ptr = READ_ONCE(slots[slot])
779  If assoc_array_ptr_is_meta(ptr) && back_pointer Then Go to descend_to_node
782  If Not keyring_ptr_is_keyring(ptr) Then Continue
785  key = keyring_ptr_to_key(ptr)
789  result = ERR_PTR( - ELOOP)
790  Return false
792  Go to not_this_keyring
796  If Not (flags & Don't check permissions ) && key_task_permission(make_key_ref(key, possessed), cred, Require permission to search (keyring) or find (key) ) < 0 Then Continue
802  keyring = keyring
803  node = node
804  slot = slot
805  sp++
808  keyring = key
809  Go to descend_to_keyring
815  ptr = READ_ONCE(back_pointer)
816  slot = parent_slot
818  If ptr && assoc_array_ptr_is_shortcut(ptr) Then
819  shortcut = assoc_array_ptr_to_shortcut(ptr)
820  ptr = READ_ONCE(back_pointer)
821  slot = parent_slot
823  If Not ptr Then Go to not_this_keyring
825  node = assoc_array_ptr_to_node(ptr)
826  slot++
832  If back_pointer Then
833  kdebug("ascend %d", slot)
834  Go to ascend_to_node
840  not_this_keyring :
841  kdebug("not_this_keyring %d", sp)
842  If sp <= 0 Then
843  kleave(" = false")
844  Return false
848  sp--
849  keyring = keyring
850  node = node
851  slot = slot + 1
852  kdebug("ascend to %d [%d]", key serial number , slot)
853  Go to ascend_to_node
856  found :
857  key = key_ref_to_ptr(result)
858  key_check(key)
859  If Not (flags & Don't update times ) Then
860  last time used for LRU keyring discard = now
861  last time used for LRU keyring discard = now
862  When sp > 0 cycle
863  last time used for LRU keyring discard = now
865  kleave(" = true")
866  Return true
Caller
NameDescribe
keyring_search_rcukeyring_search_rcu - Search a keyring tree for a matching key under RCU*@keyring_ref: A pointer to the keyring with possession indicator
keyring_detect_cycleSee if a cycle will will be created by inserting acyclic tree B in acyclic* tree A at the topmost level (ie: as a direct child of A).* Since we are adding B to A at the top level, checking for cycles should just