Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Reaper for unused keys.

Proto:static void key_garbage_collector(struct work_struct *work)

Type:void

Parameter:

TypeParameterName
struct work_struct *work
170  LIST_HEAD(graveyard)
184  kenter("[%lx,%x]", key_gc_flags, gc_state)
186  limit = ktime_get_real_seconds - Get the seconds portion of CLOCK_REALTIME* Returns the wall clock seconds since 1970. This replaces the* get_seconds() interface which is not y2038 safe on 32bit systems.
187  If limit > Delay between key revocation/expiry in seconds Then limit -= Delay between key revocation/expiry in seconds
189  Else limit = Delay between key revocation/expiry in seconds
193  gc_state &= - We need to mark dead keys | - We need to reap dead key links
194  gc_state <<= 1
195  If st_and_clear_bit - Clear a bit and return its old value*@nr: Bit to clear*@addr: Address to count from* This is an atomic fully-ordered operation (implied full memory barrier). Then gc_state |= - We need to reap links | - We need to restart the timer
198  If st_and_clear_bit - Clear a bit and return its old value*@nr: Bit to clear*@addr: Address to count from* This is an atomic fully-ordered operation (implied full memory barrier). Then gc_state |= - We need to mark dead keys
200  kdebug("new pass %x", gc_state)
202  new_timer = Located here for timespec[64]_valid_strict
208  spin_lock( & key_serial_lock)
209  cursor = This function returns the first node (in sort order) of the tree.
211  continue_scanning :
212  When cursor cycle
213  key = rb_entry(cursor, structkey, serial_node)
214  cursor = rb_next(cursor)
216  If _read - get a refcount's value*@r: the refcount* Return: the refcount's value == 0 Then Go to found_unreferenced_key
239  If Value for the false possibility is greater at compile time(gc_state & - We need to reap dead key links ) Then If type of key == key_gc_dead_keytype Then
241  gc_state |= - We found at least one dead key
249  If Value for the false possibility is greater at compile time(gc_state & - We need to reap dead keys ) Then If type of key == key_gc_dead_keytype Then
251  Go to destroy_dead_key
253  skip_dead_key :
254  If spin_is_contended( & key_serial_lock) || need_resched() Then Go to contended
258  contended :
259  spin_unlock( & key_serial_lock)
261  maybe_resched :
262  If cursor Then
263  cond_resched()
264  spin_lock( & key_serial_lock)
265  Go to continue_scanning
272  kdebug("pass complete")
274  If gc_state & - We need to restart the timer && new_timer != Located here for timespec[64]_valid_strict Then
275  new_timer += Delay between key revocation/expiry in seconds
276  Schedule a garbage collection run.* - time precision isn't particularly important
279  If Value for the false possibility is greater at compile time(gc_state & - We need to reap dead key links ) || Not list_empty - tests whether a list is empty*@head: the list to test. Then
286  kdebug("gc sync")
287  synchronize_rcu - wait until a grace period has elapsed
290  If Not list_empty - tests whether a list is empty*@head: the list to test. Then
291  kdebug("gc keys")
292  Garbage collect a list of unreferenced, detached keys
295  If Value for the false possibility is greater at compile time(gc_state & (- We need to mark dead keys | - We need to reap dead key links )) Then
301  kdebug("dead short")
304  Else
309  If Value for the false possibility is greater at compile time(gc_state & - We need to reap dead keys ) Then
310  kdebug("dead wake")
311  smp_mb()
312  lear_bit - Clears a bit in memory*@nr: Bit to clear*@addr: Address to start counting from* This is a relaxed atomic operation (no implied memory barriers).
313  wake_up_bit - wake up a waiter on a bit*@word: the word being waited on, a kernel virtual address*@bit: the bit of the word being waited on* There is a standard hashed waitqueue table for generic use
316  If gc_state & Internal persistent state Then schedule_work - put work task in global workqueue*@work: job to be done* Returns %false if @work was already on the kernel-global workqueue and* %true otherwise
318  kleave(" [end %x]", gc_state)
319  Return
324  found_unreferenced_key :
325  kdebug("unrefd key %d", key serial number )
326  rb_erase( & serial_node, & key_serial_tree)
327  spin_unlock( & key_serial_lock)
329  list_add_tail - add a new entry*@new: new entry to be added*@head: list head to add it before* Insert a new entry before the specified head.* This is useful for implementing queues.
330  gc_state |= Internal persistent state
331  Go to maybe_resched
336  found_restricted_keyring :
337  spin_unlock( & key_serial_lock)
338  keyring_restriction_gc(key, key_gc_dead_keytype)
339  Go to maybe_resched
346  found_keyring :
347  spin_unlock( & key_serial_lock)
348  keyring_gc(key, limit)
349  Go to maybe_resched
354  destroy_dead_key :
355  spin_unlock( & key_serial_lock)
356  kdebug("destroy key %d", key serial number )
357  lock for writing
358  type of key = Any key whose type gets unregistered will be re-typed to this if it can't be* immediately unlinked.
359  If destroy Then destroy(key)
361  memset( & payload, security/ *********, size of payload )
362  lease a write lock
363  Go to maybe_resched