lkml.org 
[lkml]   [2013]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC PATCH 2/2] tracing: Teach FETCH_MTD_symbol to handle per-cpu data
FETCH_FUNC_NAME(symbol) blindly dereferences sc->addr + sc->offset,
this is not what we want if this symbol is per-cpu. Change this code
to use this_cpu_ptr(sc->addr) in this case.

Note: this doesn't work for modules, but module's per-cpu data is
not visible for kallsyms_lookup_name() anyway.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/trace/trace_probe.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index 097cc80..a0144b6 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -252,14 +252,28 @@ static struct symbol_cache *alloc_symbol_cache(const char *sym, long offset)
return sc;
}

+static void *sc_calc_addr(struct symbol_cache *sc)
+{
+ void *addr = (void*)sc->addr;
+
+ if (addr) {
+ if (addr >= (void *)__per_cpu_start &&
+ addr < (void *)__per_cpu_end)
+ addr = this_cpu_ptr(addr);
+
+ addr += sc->offset;
+ }
+
+ return addr;
+}
+
#define DEFINE_FETCH_symbol(type) \
static __kprobes void FETCH_FUNC_NAME(symbol, type)(struct pt_regs *regs,\
void *data, void *dest) \
{ \
- struct symbol_cache *sc = data; \
- long off = sc->offset; \
- if (sc->addr) \
- fetch_memory_##type(regs, (void *)sc->addr + off, dest);\
+ void *addr = sc_calc_addr(data); \
+ if (addr) \
+ fetch_memory_##type(regs, addr, dest); \
else \
*(type *)dest = 0; \
}
--
1.5.5.1



\
 
 \ /
  Last update: 2013-11-26 19:01    [W:0.237 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site