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:	Fri, 24 Apr 2015 11:44:06 +0900
From:	AKASHI Takahiro <takahiro.akashi@...aro.org>
To:	rostedt@...dmis.org, mingo@...nel.org, jpoimboe@...hat.com,
	sjenning@...hat.com, jkosina@...e.cz, vojtech@...e.cz,
	catalin.marinas@....com, will.deacon@....com
Cc:	broonie@...nel.org, masami.hiramatsu.pt@...achi.com,
	live-patching@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org,
	linaro-kernel@...ts.linaro.org, linux-kernel@...r.kernel.org,
	AKASHI Takahiro <takahiro.akashi@...aro.org>
Subject: [RFC 1/4] ftrace: add a helper function for livepatch

ftrace_lookup_mcount() will return an address of mcount call in a function.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@...aro.org>
---
 include/linux/ftrace.h |    2 ++
 kernel/trace/ftrace.c  |   26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 1da6029..1d0271f 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -699,6 +699,8 @@ static inline void __ftrace_enabled_restore(int enabled)
 # define trace_preempt_off(a0, a1) do { } while (0)
 #endif
 
+extern unsigned long ftrace_lookup_mcount(unsigned long addr);
+
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
 extern void ftrace_init(void);
 #else
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 4f22802..fcfb04f 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -4857,6 +4857,32 @@ static int ftrace_process_locs(struct module *mod,
 	return ret;
 }
 
+unsigned long ftrace_lookup_mcount(unsigned long addr)
+{
+	struct ftrace_page *pg;
+	struct dyn_ftrace *rec;
+	char str[KSYM_SYMBOL_LEN];
+	char *modname;
+	const char *name;
+	unsigned long mcount = 0;
+	unsigned long offset;
+
+	mutex_lock(&ftrace_lock);
+
+	do_for_each_ftrace_rec(pg, rec) {
+		name = kallsyms_lookup(rec->ip, NULL, &offset, &modname, str);
+		if (name && rec->ip == (addr + offset)) {
+			mcount = rec->ip;
+			goto out_unlock;
+		}
+	} while_for_each_ftrace_rec();
+
+ out_unlock:
+	mutex_unlock(&ftrace_lock);
+
+	return mcount;
+}
+
 #ifdef CONFIG_MODULES
 
 #define next_to_ftrace_page(p) container_of(p, struct ftrace_page, next)
-- 
1.7.9.5

--
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