tracing/probe: Support user-space dereference
Support user-space dereference syntax for probe event arguments to dereference the data-structure or array in user-space. The syntax is just adding 'u' before an offset value. +|-u<OFFSET>(<FETCHARG>) e.g. +u8(%ax), +u0(+0(%si)) For example, if you probe do_sched_setscheduler(pid, policy, param) and record param->sched_priority, you can add new probe as below; p do_sched_setscheduler priority=+u0($arg3) Note that kprobe event provides this and it doesn't change the dereference method automatically because we do not know whether the given address is in userspace or kernel on some archs. So as same as "ustring", this is an option for user, who has to carefully choose the dereference method. Link: http://lkml.kernel.org/r/155789872187.26965.4468456816590888687.stgit@devnote2 Acked-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:

committed by
Steven Rostedt (VMware)

parent
88903c4643
commit
e65f7ae7f4
@@ -64,6 +64,8 @@ static nokprobe_inline int
|
||||
fetch_store_string_user(unsigned long addr, void *dest, void *base);
|
||||
static nokprobe_inline int
|
||||
probe_mem_read(void *dest, void *src, size_t size);
|
||||
static nokprobe_inline int
|
||||
probe_mem_read_user(void *dest, void *src, size_t size);
|
||||
|
||||
/* From the 2nd stage, routine is same */
|
||||
static nokprobe_inline int
|
||||
@@ -77,14 +79,21 @@ process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val,
|
||||
|
||||
stage2:
|
||||
/* 2nd stage: dereference memory if needed */
|
||||
while (code->op == FETCH_OP_DEREF) {
|
||||
lval = val;
|
||||
ret = probe_mem_read(&val, (void *)val + code->offset,
|
||||
sizeof(val));
|
||||
do {
|
||||
if (code->op == FETCH_OP_DEREF) {
|
||||
lval = val;
|
||||
ret = probe_mem_read(&val, (void *)val + code->offset,
|
||||
sizeof(val));
|
||||
} else if (code->op == FETCH_OP_UDEREF) {
|
||||
lval = val;
|
||||
ret = probe_mem_read_user(&val,
|
||||
(void *)val + code->offset, sizeof(val));
|
||||
} else
|
||||
break;
|
||||
if (ret)
|
||||
return ret;
|
||||
code++;
|
||||
}
|
||||
} while (1);
|
||||
|
||||
s3 = code;
|
||||
stage3:
|
||||
@@ -109,6 +118,9 @@ stage3:
|
||||
case FETCH_OP_ST_MEM:
|
||||
probe_mem_read(dest, (void *)val + code->offset, code->size);
|
||||
break;
|
||||
case FETCH_OP_ST_UMEM:
|
||||
probe_mem_read_user(dest, (void *)val + code->offset, code->size);
|
||||
break;
|
||||
case FETCH_OP_ST_STRING:
|
||||
loc = *(u32 *)dest;
|
||||
ret = fetch_store_string(val + code->offset, dest, base);
|
||||
|
Reference in New Issue
Block a user