/usr/share/ksplice/ksplice-patch/ksplice-shadow.h is in ksplice 0.9.9-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | #include <linux/list.h>
#include <linux/gfp.h>
#include "ksplice-patch.h"
struct shadow_field {
void *obj;
void *data;
int *key;
struct list_head list;
};
LIST_HEAD(shadow_list);
DEFINE_SPINLOCK(shadow_lock);
int init_shadow_field_type(int *shadow_key, typeof(GFP_KERNEL) gfp_flags)
{
return 0;
}
void *init_shadow_field(int *shadow_key, void *obj, int size,
typeof(GFP_KERNEL) gfp_flags)
{
struct shadow_field *shadow = kmalloc(sizeof(*shadow), gfp_flags);
if (shadow == NULL)
return NULL;
shadow->obj = obj;
shadow->key = shadow_key;
shadow->data = kmalloc(size, gfp_flags);
if (shadow->data == NULL) {
kfree(shadow);
return NULL;
}
spin_lock(&shadow_lock);
list_add(&shadow->list, &shadow_list);
spin_unlock(&shadow_lock);
return shadow->data;
}
void cleanup_shadow_field(int *shadow_key, void *obj)
{
struct shadow_field *shadow;
spin_lock(&shadow_lock);
list_for_each_entry(shadow, &shadow_list, list) {
if (shadow->obj == obj && shadow->key == shadow_key) {
list_del(&shadow->list);
kfree(shadow->data);
kfree(shadow);
goto out;
}
}
out:
spin_unlock(&shadow_lock);
}
void *get_shadow_field(int *shadow_key, void *obj)
{
struct shadow_field *shadow;
void *data = NULL;
spin_lock(&shadow_lock);
list_for_each_entry(shadow, &shadow_list, list) {
if (shadow->obj == obj && shadow->key == shadow_key) {
data = shadow->data;
goto out;
}
}
out:
spin_unlock(&shadow_lock);
return data;
}
void cleanup_shadow_field_type(int *shadow_key)
{
struct shadow_field *shadow, *n;
spin_lock(&shadow_lock);
list_for_each_entry_safe(shadow, n, &shadow_list, list) {
if (shadow->key == shadow_key) {
list_del(&shadow->list);
kfree(shadow->data);
kfree(shadow);
}
}
spin_unlock(&shadow_lock);
}
|