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]
Message-ID: <1423743680-13029-1-git-send-email-wangnan0@huawei.com>
Date:	Thu, 12 Feb 2015 20:21:20 +0800
From:	Wang Nan <wangnan0@...wei.com>
To:	<linux@....linux.org.uk>, <tglx@...utronix.de>, <mingo@...hat.com>,
	<hpa@...or.com>, <rostedt@...dmis.org>, <ananth@...ibm.com>,
	<anil.s.keshavamurthy@...el.com>, <davem@...emloft.net>,
	<masami.hiramatsu.pt@...achi.com>, <luto@...capital.net>,
	<keescook@...omium.org>, <oleg@...hat.com>, <wangnan0@...wei.com>,
	<dave.long@...aro.org>, <tixy@...aro.org>, <nico@...aro.org>,
	<yalin.wang2010@...il.com>, <catalin.marinas@....com>,
	<Yalin.Wang@...ymobile.com>, <mark.rutland@....com>,
	<dave.hansen@...ux.intel.com>, <jkenisto@...ibm.com>,
	<anton@...ba.org>, <stefani@...bold.net>, <JBeulich@...e.com>,
	<akpm@...ux-foundation.org>, <rusty@...tcorp.com.au>,
	<peterz@...radead.org>, <prarit@...hat.com>, <fabf@...net.be>,
	<hannes@...xchg.org>
CC:	<x86@...nel.org>, <linux-kernel@...r.kernel.org>,
	<linux-arm-kernel@...ts.infradead.org>, <lizefan@...wei.com>
Subject: [RFC PATCH v2 23/26] early kprobes: x86: arch_restore_optimized_kprobe().

arch_restore_optimized_kprobe() can be used to temporarily restore
probed instruction. It will actually disable optimized kprobe.

Signed-off-by: Wang Nan <wangnan0@...wei.com>
---
 arch/x86/kernel/kprobes/opt.c | 26 ++++++++++++++++++++++++++
 include/linux/kprobes.h       |  1 +
 2 files changed, 27 insertions(+)

diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
index f3ea954..12332c2 100644
--- a/arch/x86/kernel/kprobes/opt.c
+++ b/arch/x86/kernel/kprobes/opt.c
@@ -28,6 +28,7 @@
 #include <linux/kdebug.h>
 #include <linux/kallsyms.h>
 #include <linux/ftrace.h>
+#include <linux/stop_machine.h>
 
 #include <asm/cacheflush.h>
 #include <asm/desc.h>
@@ -486,4 +487,29 @@ void arch_fix_ftrace_early_kprobe(struct optimized_kprobe *op)
 		memcpy(&list_p->opcode, correct_nop5, sizeof(kprobe_opcode_t));
 
 }
+
+static int do_restore_kprobe(void *p)
+{
+	struct optimized_kprobe *op = p;
+	u8 insn_buf[RELATIVEJUMP_SIZE];
+
+	memcpy(insn_buf, &op->kp.opcode, sizeof(kprobe_opcode_t));
+	memcpy(insn_buf + INT3_SIZE,
+			op->optinsn.copied_insn,
+			RELATIVE_ADDR_SIZE);
+	text_poke(op->kp.addr, insn_buf, RELATIVEJUMP_SIZE);
+	return 0;
+}
+
+void arch_restore_optimized_kprobe(struct optimized_kprobe *op)
+{
+	u32 mask = KPROBE_FLAG_EARLY |
+		KPROBE_FLAG_OPTIMIZED |
+		KPROBE_FLAG_FTRACE;
+
+	if ((op->kp.flags & mask) != mask)
+		return;
+
+	stop_machine(do_restore_kprobe, op, NULL);
+}
 #endif
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 990d04b..92aafa7 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -461,6 +461,7 @@ extern int arch_prepare_kprobe_ftrace(struct kprobe *p);
 
 #ifdef CONFIG_EARLY_KPROBES
 extern void arch_fix_ftrace_early_kprobe(struct optimized_kprobe *p);
+extern void arch_restore_optimized_kprobe(struct optimized_kprobe *p);
 #endif
 
 #endif
-- 
1.8.4

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