From 035f26b4e339baaf99dc26e564bd09aeb9d03e03 Mon Sep 17 00:00:00 2001 From: Vasiliy Ulyanov Date: Mon, 2 Jun 2014 18:18:17 +0400 Subject: [PATCH] [IMPROVE] Add uretprobe_instance data field Change-Id: Ic852d3d40b4b0dcb0dfa5f867aa3f02d3647aa03 Signed-off-by: Vasiliy Ulyanov --- uprobe/swap_uprobes.c | 4 ++-- uprobe/swap_uprobes.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/uprobe/swap_uprobes.c b/uprobe/swap_uprobes.c index ea1436a..6f9237f 100644 --- a/uprobe/swap_uprobes.c +++ b/uprobe/swap_uprobes.c @@ -424,7 +424,7 @@ static int alloc_nodes_uretprobe(struct uretprobe *rp) alloc_nodes = COMMON_URP_NR; for (i = 0; i < alloc_nodes; ++i) { - inst = kmalloc(sizeof(*inst), GFP_ATOMIC); + inst = kmalloc(sizeof(*inst) + rp->data_size, GFP_ATOMIC); if (inst == NULL) { free_urp_inst(rp); return -ENOMEM; @@ -815,7 +815,7 @@ int swap_register_uretprobe(struct uretprobe *rp) INIT_HLIST_HEAD(&rp->free_instances); for (i = 0; i < rp->maxactive; i++) { - inst = kmalloc(sizeof(*inst), GFP_ATOMIC); + inst = kmalloc(sizeof(*inst) + rp->data_size, GFP_ATOMIC); if (inst == NULL) { free_urp_inst(rp); return -ENOMEM; diff --git a/uprobe/swap_uprobes.h b/uprobe/swap_uprobes.h index da06aff..e2a417f 100644 --- a/uprobe/swap_uprobes.h +++ b/uprobe/swap_uprobes.h @@ -92,6 +92,7 @@ struct uretprobe { /** Tracks the number of times the probed function's return was * ignored, due to maxactive being too low. */ int nmissed; + size_t data_size; /**< Instance data size */ struct hlist_head free_instances; /**< Free instances list */ struct hlist_head used_instances; /**< Used instances list */ @@ -113,6 +114,7 @@ struct uretprobe_instance { kprobe_opcode_t *ret_addr; /**< Return address */ kprobe_opcode_t *sp; /**< Pointer to stack */ struct task_struct *task; /**< Pointer to the task struct */ + char data[0]; /**< Custom data */ }; int swap_register_uprobe(struct uprobe *p); -- 2.7.4