Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\livepatch\shadow.c Create Date:2022-07-28 10:31:26
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:__klp_shadow_get_or_alloc

Proto:static void *__klp_shadow_get_or_alloc(void *obj, unsigned long id, size_t size, gfp_t gfp_flags, klp_shadow_ctor_t ctor, void *ctor_data, bool warn_on_exist)

Type:void

Parameter:

TypeParameterName
void *obj
unsigned longid
size_tsize
gfp_tgfp_flags
klp_shadow_ctor_tctor
void *ctor_data
boolwarn_on_exist
114  shadow_data = klp_shadow_get() - retrieve a shadow variable data pointer*@obj: pointer to parent object*@id: data identifier* Return: the shadow variable data element, NULL on failure.
115  If shadow_data Then Go to exists
123  new_shadow = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
124  If Not new_shadow Then Return NULL
128  spin_lock_irqsave( & klp_shadow_lock provides exclusive access to the klp_shadow_hash and* the shadow variables it references., flags)
129  shadow_data = klp_shadow_get() - retrieve a shadow variable data pointer*@obj: pointer to parent object*@id: data identifier* Return: the shadow variable data element, NULL on failure.
130  If Value for the false possibility is greater at compile time(shadow_data) Then
135  spin_unlock_irqrestore( & klp_shadow_lock provides exclusive access to the klp_shadow_hash and* the shadow variables it references., flags)
136  kfree(new_shadow)
137  Go to exists
140  obj = obj
141  id = id
143  If ctor Then
146  err = ctor(obj, data, ctor_data)
147  If err Then
149  kfree(new_shadow)
150  pr_err("Failed to construct shadow variable <%p, %lx> (%d)\n", obj, id, err)
152  Return NULL
157  hash_add_rcu - add an object to a rcu enabled hashtable*@hashtable: hashtable to add to*@node: the &struct hlist_node of the object to be added*@key: the key of the object to be added(klp_shadow_hash, & node, (unsignedlong)obj)
159  spin_unlock_irqrestore( & klp_shadow_lock provides exclusive access to the klp_shadow_hash and* the shadow variables it references., flags)
161  Return data
163  exists :
164  If warn_on_exist Then
165  WARN(1, "Duplicate shadow variable <%p, %lx>\n", obj, id)
166  Return NULL
169  Return shadow_data
Caller
NameDescribe
klp_shadow_allocklp_shadow_alloc() - allocate and add a new shadow variable*@obj: pointer to parent object*@id: data identifier*@size: size of attached data*@gfp_flags: GFP mask for allocation*@ctor: custom constructor to initialize the shadow data (optional)*@ctor_data:
klp_shadow_get_or_allocklp_shadow_get_or_alloc() - get existing or allocate a new shadow variable*@obj: pointer to parent object*@id: data identifier*@size: size of attached data*@gfp_flags: GFP mask for allocation*@ctor: custom constructor to initialize the shadow data