Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Allocate a serial number for a key. These are assigned randomly to avoid* security issues through covert channel problems.

Proto:static inline void key_alloc_serial(struct key *key)

Type:void

Parameter:

TypeParameterName
struct key *key
140  Do
141  get_random_bytes( & key serial number , size of key serial number )
143  key serial number >>= 1
144  When key serial number < 3 cycle
146  spin_lock( & key_serial_lock)
148  attempt_insertion :
149  parent = NULL
150  p = rb_node
152  When p cycle
153  parent = p
154  xkey = rb_entry(parent, structkey, serial_node)
156  If key serial number < key serial number Then p = rb_left
158  Else if key serial number > key serial number Then p = rb_right
160  Else Go to serial_exists
165  rb_link_node( & serial_node, parent, p)
166  rb_insert_color( & serial_node, & ree of keys indexed by serial )
168  spin_unlock( & key_serial_lock)
169  Return
173  serial_exists :
174  cycle
175  key serial number ++
176  If key serial number < 3 Then
178  Go to attempt_insertion
181  parent = rb_next(parent)
182  If Not parent Then Go to attempt_insertion
185  xkey = rb_entry(parent, structkey, serial_node)
186  If key serial number < key serial number Then Go to attempt_insertion
Caller
NameDescribe
key_allockey_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.