* [PATCH 1/2] kprobes: add a new module parameter
@ 2016-05-18 1:36 Huang Shijie
2016-05-18 1:36 ` [PATCH 2/2] kprobes: print out the symbol name for the hooks Huang Shijie
2016-05-18 21:27 ` [PATCH 1/2] kprobes: add a new module parameter Andrew Morton
0 siblings, 2 replies; 4+ messages in thread
From: Huang Shijie @ 2016-05-18 1:36 UTC (permalink / raw)
To: akpm; +Cc: pmladek, linux-kernel, steve.capper, nd, Huang Shijie
This patch adds a new module parameter which can be used as the
symbol name. With this parameter, the module becomes more flexable.
Signed-off-by: Huang Shijie <shijie.huang@arm.com>
---
samples/kprobes/kprobe_example.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c
index 727eb21..2bb190d 100644
--- a/samples/kprobes/kprobe_example.c
+++ b/samples/kprobes/kprobe_example.c
@@ -14,9 +14,13 @@
#include <linux/module.h>
#include <linux/kprobes.h>
+#define MAX_SYMBOL_LEN 64
+static char symbol[MAX_SYMBOL_LEN] = "_do_fork";
+module_param_string(symbol, symbol, sizeof(symbol), 0644);
+
/* For each probe you need to allocate a kprobe structure */
static struct kprobe kp = {
- .symbol_name = "_do_fork",
+ .symbol_name = symbol,
};
/* kprobe pre_handler: called just before the probed instruction is executed */
--
2.5.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] kprobes: print out the symbol name for the hooks
2016-05-18 1:36 [PATCH 1/2] kprobes: add a new module parameter Huang Shijie
@ 2016-05-18 1:36 ` Huang Shijie
2016-05-18 21:27 ` [PATCH 1/2] kprobes: add a new module parameter Andrew Morton
1 sibling, 0 replies; 4+ messages in thread
From: Huang Shijie @ 2016-05-18 1:36 UTC (permalink / raw)
To: akpm; +Cc: pmladek, linux-kernel, steve.capper, nd, Huang Shijie
Print out the symbol name for the hooks, it makes the logs more readable.
Signed-off-by: Huang Shijie <shijie.huang@arm.com>
---
samples/kprobes/kprobe_example.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c
index 2bb190d..ed0ca0c 100644
--- a/samples/kprobes/kprobe_example.c
+++ b/samples/kprobes/kprobe_example.c
@@ -27,24 +27,24 @@ static struct kprobe kp = {
static int handler_pre(struct kprobe *p, struct pt_regs *regs)
{
#ifdef CONFIG_X86
- printk(KERN_INFO "pre_handler: p->addr = 0x%p, ip = %lx,"
+ printk(KERN_INFO "<%s> pre_handler: p->addr = 0x%p, ip = %lx,"
" flags = 0x%lx\n",
- p->addr, regs->ip, regs->flags);
+ p->symbol_name, p->addr, regs->ip, regs->flags);
#endif
#ifdef CONFIG_PPC
- printk(KERN_INFO "pre_handler: p->addr = 0x%p, nip = 0x%lx,"
+ printk(KERN_INFO "<%s> pre_handler: p->addr = 0x%p, nip = 0x%lx,"
" msr = 0x%lx\n",
- p->addr, regs->nip, regs->msr);
+ p->symbol_name, p->addr, regs->nip, regs->msr);
#endif
#ifdef CONFIG_MIPS
- printk(KERN_INFO "pre_handler: p->addr = 0x%p, epc = 0x%lx,"
+ printk(KERN_INFO "<%s> pre_handler: p->addr = 0x%p, epc = 0x%lx,"
" status = 0x%lx\n",
- p->addr, regs->cp0_epc, regs->cp0_status);
+ p->symbol_name, p->addr, regs->cp0_epc, regs->cp0_status);
#endif
#ifdef CONFIG_TILEGX
- printk(KERN_INFO "pre_handler: p->addr = 0x%p, pc = 0x%lx,"
+ printk(KERN_INFO "<%s> pre_handler: p->addr = 0x%p, pc = 0x%lx,"
" ex1 = 0x%lx\n",
- p->addr, regs->pc, regs->ex1);
+ p->symbol_name, p->addr, regs->pc, regs->ex1);
#endif
/* A dump_stack() here will give a stack backtrace */
@@ -56,20 +56,20 @@ static void handler_post(struct kprobe *p, struct pt_regs *regs,
unsigned long flags)
{
#ifdef CONFIG_X86
- printk(KERN_INFO "post_handler: p->addr = 0x%p, flags = 0x%lx\n",
- p->addr, regs->flags);
+ printk(KERN_INFO "<%s> post_handler: p->addr = 0x%p, flags = 0x%lx\n",
+ p->symbol_name, p->addr, regs->flags);
#endif
#ifdef CONFIG_PPC
- printk(KERN_INFO "post_handler: p->addr = 0x%p, msr = 0x%lx\n",
- p->addr, regs->msr);
+ printk(KERN_INFO "<%s> post_handler: p->addr = 0x%p, msr = 0x%lx\n",
+ p->symbol_name, p->addr, regs->msr);
#endif
#ifdef CONFIG_MIPS
- printk(KERN_INFO "post_handler: p->addr = 0x%p, status = 0x%lx\n",
- p->addr, regs->cp0_status);
+ printk(KERN_INFO "<%s> post_handler: p->addr = 0x%p, status = 0x%lx\n",
+ p->symbol_name, p->addr, regs->cp0_status);
#endif
#ifdef CONFIG_TILEGX
- printk(KERN_INFO "post_handler: p->addr = 0x%p, ex1 = 0x%lx\n",
- p->addr, regs->ex1);
+ printk(KERN_INFO "<%s> post_handler: p->addr = 0x%p, ex1 = 0x%lx\n",
+ p->symbol_name, p->addr, regs->ex1);
#endif
}
--
2.5.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] kprobes: add a new module parameter
2016-05-18 1:36 [PATCH 1/2] kprobes: add a new module parameter Huang Shijie
2016-05-18 1:36 ` [PATCH 2/2] kprobes: print out the symbol name for the hooks Huang Shijie
@ 2016-05-18 21:27 ` Andrew Morton
2016-05-19 1:40 ` [PATCH v2] " Huang Shijie
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2016-05-18 21:27 UTC (permalink / raw)
To: Huang Shijie; +Cc: pmladek, linux-kernel, steve.capper, nd
On Wed, 18 May 2016 09:36:56 +0800 Huang Shijie <shijie.huang@arm.com> wrote:
> This patch adds a new module parameter which can be used as the
> symbol name. With this parameter, the module becomes more flexable.
This changelog is too vague. What does "more flexible" mean? Please
describe the benefits of the change in much more detail.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] kprobes: add a new module parameter
2016-05-18 21:27 ` [PATCH 1/2] kprobes: add a new module parameter Andrew Morton
@ 2016-05-19 1:40 ` Huang Shijie
0 siblings, 0 replies; 4+ messages in thread
From: Huang Shijie @ 2016-05-19 1:40 UTC (permalink / raw)
To: akpm; +Cc: nd, pmladek, steve.capper, linux-kernel, Huang Shijie
This patch adds a new module parameter which can be used as the
symbol name. Without this patch, we can only test the "_do_fork" function
with this kernel module. With this patch, the module becomes more flexable,
we can test any functions with this module with:
#insmod kprobe_example.ko symbol="xxx"
Signed-off-by: Huang Shijie <shijie.huang@arm.com>
---
v1 -- > v2:
Add more comment for this patch.
---
samples/kprobes/kprobe_example.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c
index 727eb21..2bb190d 100644
--- a/samples/kprobes/kprobe_example.c
+++ b/samples/kprobes/kprobe_example.c
@@ -14,9 +14,13 @@
#include <linux/module.h>
#include <linux/kprobes.h>
+#define MAX_SYMBOL_LEN 64
+static char symbol[MAX_SYMBOL_LEN] = "_do_fork";
+module_param_string(symbol, symbol, sizeof(symbol), 0644);
+
/* For each probe you need to allocate a kprobe structure */
static struct kprobe kp = {
- .symbol_name = "_do_fork",
+ .symbol_name = symbol,
};
/* kprobe pre_handler: called just before the probed instruction is executed */
--
2.5.5
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-05-19 1:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-18 1:36 [PATCH 1/2] kprobes: add a new module parameter Huang Shijie
2016-05-18 1:36 ` [PATCH 2/2] kprobes: print out the symbol name for the hooks Huang Shijie
2016-05-18 21:27 ` [PATCH 1/2] kprobes: add a new module parameter Andrew Morton
2016-05-19 1:40 ` [PATCH v2] " Huang Shijie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®