summaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_kprobe.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@kernel.org>2018-04-25 14:19:59 +0200
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2018-10-11 04:19:09 +0200
commit9b960a38835fcaf977f20dcc34ce9e54ff9563bd (patch)
tree667aad6f436e5228009e5eedeb5600d43148088a /kernel/trace/trace_kprobe.c
parenttracing: probeevent: Append traceprobe_ for exported function (diff)
downloadlinux-9b960a38835fcaf977f20dcc34ce9e54ff9563bd.tar.xz
linux-9b960a38835fcaf977f20dcc34ce9e54ff9563bd.zip
tracing: probeevent: Unify fetch_insn processing common part
Unify the fetch_insn bottom process (from stage 2: dereference indirect data) from kprobe and uprobe events, since those are mostly same. Link: http://lkml.kernel.org/r/152465879965.26224.8547240824606804815.stgit@devbox Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace_kprobe.c')
-rw-r--r--kernel/trace/trace_kprobe.c47
1 files changed, 7 insertions, 40 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 4895ca85ec79..fdd43f2f1fd1 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -899,13 +899,18 @@ fetch_store_string(unsigned long addr, void *dest, void *base)
return ret;
}
+static nokprobe_inline int
+probe_mem_read(void *dest, void *src, size_t size)
+{
+ return probe_kernel_read(dest, src, size);
+}
+
/* Note that we don't verify it, since the code does not come from user space */
static int
process_fetch_insn(struct fetch_insn *code, struct pt_regs *regs, void *dest,
void *base)
{
unsigned long val;
- int ret = 0;
/* 1st stage: get value from context */
switch (code->op) {
@@ -932,45 +937,7 @@ process_fetch_insn(struct fetch_insn *code, struct pt_regs *regs, void *dest,
}
code++;
- /* 2nd stage: dereference memory if needed */
- while (code->op == FETCH_OP_DEREF) {
- ret = probe_kernel_read(&val, (void *)val + code->offset,
- sizeof(val));
- if (ret)
- return ret;
- code++;
- }
-
- /* 3rd stage: store value to buffer */
- if (unlikely(!dest)) {
- if (code->op == FETCH_OP_ST_STRING)
- return fetch_store_strlen(val + code->offset);
- else
- return -EILSEQ;
- }
-
- switch (code->op) {
- case FETCH_OP_ST_RAW:
- fetch_store_raw(val, code, dest);
- break;
- case FETCH_OP_ST_MEM:
- probe_kernel_read(dest, (void *)val + code->offset, code->size);
- break;
- case FETCH_OP_ST_STRING:
- ret = fetch_store_string(val + code->offset, dest, base);
- break;
- default:
- return -EILSEQ;
- }
- code++;
-
- /* 4th stage: modify stored value if needed */
- if (code->op == FETCH_OP_MOD_BF) {
- fetch_apply_bitfield(code, dest);
- code++;
- }
-
- return code->op == FETCH_OP_END ? ret : -EILSEQ;
+ return process_fetch_insn_bottom(code, val, dest, base);
}
NOKPROBE_SYMBOL(process_fetch_insn)