lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 26 Nov 2013 18:44:46 +0100
From:	Oleg Nesterov <oleg@...hat.com>
To:	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Cc:	Steven Rostedt <rostedt@...dmis.org>,
	Namhyung Kim <namhyung.kim@....com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...hat.com>, Jiri Olsa <jolsa@...hat.com>,
	linux-kernel@...r.kernel.org, Rusty Russell <rusty@...tcorp.com.au>
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@...hat.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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ