Message ID | 20190819192706.46ce2c1d@xhacker.debian (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | arm64: KPROBES_ON_FTRACE | expand |
Jisheng Zhang wrote: > This patch implements KPROBES_ON_FTRACE for arm64. > > ~ # mount -t debugfs debugfs /sys/kernel/debug/ > ~ # cd /sys/kernel/debug/ > /sys/kernel/debug # echo 'p _do_fork' > tracing/kprobe_events > > before the patch: > > /sys/kernel/debug # cat kprobes/list > ffffff801009ff7c k _do_fork+0x4 [DISABLED] This looks wrong -- we should not be allowing kprobe to be registered on ftrace address without KPROBES_ON_FTRACE. Is _do_fork+0x4 the location of ftrace entry on arm64? - Naveen
On Mon, 19 Aug 2019 22:22:12 +0530 "Naveen N. Rao" wrote: > > > Jisheng Zhang wrote: > > This patch implements KPROBES_ON_FTRACE for arm64. > > > > ~ # mount -t debugfs debugfs /sys/kernel/debug/ > > ~ # cd /sys/kernel/debug/ > > /sys/kernel/debug # echo 'p _do_fork' > tracing/kprobe_events > > > > before the patch: > > > > /sys/kernel/debug # cat kprobes/list > > ffffff801009ff7c k _do_fork+0x4 [DISABLED] > > This looks wrong -- we should not be allowing kprobe to be registered on Yes. I made a mistake when dumping this log. The kernel isn't as clean as "before the patch". > ftrace address without KPROBES_ON_FTRACE. Is _do_fork+0x4 the location > of ftrace entry on arm64? Indeed, w/o KPROBES_ON_FTRACE, it should be _do_fork+0x0 Thanks
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 663392d1eae2..928700f15e23 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -167,6 +167,7 @@ config ARM64 select HAVE_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS select HAVE_KPROBES + select HAVE_KPROBES_ON_FTRACE select HAVE_KRETPROBES select HAVE_GENERIC_VDSO select IOMMU_DMA if IOMMU_SUPPORT diff --git a/arch/arm64/kernel/probes/Makefile b/arch/arm64/kernel/probes/Makefile index 8e4be92e25b1..4020cfc66564 100644 --- a/arch/arm64/kernel/probes/Makefile +++ b/arch/arm64/kernel/probes/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_KPROBES) += kprobes.o decode-insn.o \ simulate-insn.o obj-$(CONFIG_UPROBES) += uprobes.o decode-insn.o \ simulate-insn.o +obj-$(CONFIG_KPROBES_ON_FTRACE) += ftrace.o diff --git a/arch/arm64/kernel/probes/ftrace.c b/arch/arm64/kernel/probes/ftrace.c new file mode 100644 index 000000000000..1fe8f105e02e --- /dev/null +++ b/arch/arm64/kernel/probes/ftrace.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Dynamic Ftrace based Kprobes Optimization + * + * Copyright (C) 2019 Synaptics Incorporated + * + * Author: Jisheng Zhang <jszhang@kernel.org> + */ + +#include <linux/kprobes.h> + +int arch_prepare_kprobe_ftrace(struct kprobe *p) +{ + p->ainsn.api.insn = NULL; + return 0; +}
This patch implements KPROBES_ON_FTRACE for arm64. ~ # mount -t debugfs debugfs /sys/kernel/debug/ ~ # cd /sys/kernel/debug/ /sys/kernel/debug # echo 'p _do_fork' > tracing/kprobe_events before the patch: /sys/kernel/debug # cat kprobes/list ffffff801009ff7c k _do_fork+0x4 [DISABLED] after the patch: /sys/kernel/debug # cat kprobes/list ffffff801009ff7c k _do_fork+0x4 [DISABLED][FTRACE] Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com> --- arch/arm64/Kconfig | 1 + arch/arm64/kernel/probes/Makefile | 1 + arch/arm64/kernel/probes/ftrace.c | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 arch/arm64/kernel/probes/ftrace.c