* [PATCH v2] arm: port KCOV to arm
@ 2018-05-11 14:32 Dmitry Vyukov
2018-05-11 14:36 ` Dmitry Vyukov
2018-05-11 14:37 ` Mark Rutland
0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Vyukov @ 2018-05-11 14:32 UTC (permalink / raw)
To: linux, mark.rutland, liuwenliang, catalin.marinas,
inux-arm-kernel, linux-mm
Cc: Dmitry Vyukov, Koguchi Takuo, linux-arm-kernel, syzkaller
KCOV is code coverage collection facility used, in particular, by syzkaller
system call fuzzer. There is some interest in using syzkaller on arm devices.
So port KCOV to arm.
On implementation level this merely declares that KCOV is supported and
disables instrumentation of 3 special cases. Reasons for disabling are
commented in code.
Tested with qemu-system-arm/vexpress-a15.
Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Abbott Liu <liuwenliang@huawei.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Koguchi Takuo <takuo.koguchi.sw@hitachi.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mm@kvack.org
Cc: syzkaller@googlegroups.com
---
Changes since v1:
- remove disable of instrumentation for arch/arm/mm/fault.c
- disable instrumentation of arch/arm/kvm/hyp/*
- resort ARCH_HAS_KCOV alphabetically
---
arch/arm/Kconfig | 3 ++-
arch/arm/boot/compressed/Makefile | 3 +++
arch/arm/kvm/hyp/Makefile | 8 ++++++++
arch/arm/vdso/Makefile | 3 +++
4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3493f840e89c..34591796c36f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -8,9 +8,10 @@ config ARM
select ARCH_HAS_DEVMEM_IS_ALLOWED
select ARCH_HAS_ELF_RANDOMIZE
select ARCH_HAS_FORTIFY_SOURCE
+ select ARCH_HAS_KCOV
select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
- select ARCH_HAS_SET_MEMORY
select ARCH_HAS_PHYS_TO_DMA
+ select ARCH_HAS_SET_MEMORY
select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
select ARCH_HAS_STRICT_MODULE_RWX if MMU
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 6a4e7341ecd3..5f5f081e4879 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -25,6 +25,9 @@ endif
GCOV_PROFILE := n
+# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
+KCOV_INSTRUMENT := n
+
#
# Architecture dependencies
#
diff --git a/arch/arm/kvm/hyp/Makefile b/arch/arm/kvm/hyp/Makefile
index 7fc0638f263a..d2b5ec9c4b92 100644
--- a/arch/arm/kvm/hyp/Makefile
+++ b/arch/arm/kvm/hyp/Makefile
@@ -23,3 +23,11 @@ obj-$(CONFIG_KVM_ARM_HOST) += hyp-entry.o
obj-$(CONFIG_KVM_ARM_HOST) += switch.o
CFLAGS_switch.o += $(CFLAGS_ARMV7VE)
obj-$(CONFIG_KVM_ARM_HOST) += s2-setup.o
+
+# KVM code is run at a different exception code with a different map, so
+# compiler instrumentation that inserts callbacks or checks into the code may
+# cause crashes. Just disable it.
+GCOV_PROFILE := n
+KASAN_SANITIZE := n
+UBSAN_SANITIZE := n
+KCOV_INSTRUMENT := n
diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile
index bb4118213fee..f4efff9d3afb 100644
--- a/arch/arm/vdso/Makefile
+++ b/arch/arm/vdso/Makefile
@@ -30,6 +30,9 @@ CFLAGS_vgettimeofday.o = -O2
# Disable gcov profiling for VDSO code
GCOV_PROFILE := n
+# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
+KCOV_INSTRUMENT := n
+
# Force dependency
$(obj)/vdso.o : $(obj)/vdso.so
--
2.17.0.441.gb46fe60e1d-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] arm: port KCOV to arm
2018-05-11 14:32 [PATCH v2] arm: port KCOV to arm Dmitry Vyukov
@ 2018-05-11 14:36 ` Dmitry Vyukov
2018-05-11 14:37 ` Mark Rutland
1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Vyukov @ 2018-05-11 14:36 UTC (permalink / raw)
To: Russell King - ARM Linux, Mark Rutland, Abbott Liu,
Catalin Marinas, Linux-MM, Andrew Morton
Cc: Dmitry Vyukov, Koguchi Takuo, Linux ARM, syzkaller
On Fri, May 11, 2018 at 4:32 PM, Dmitry Vyukov <dvyukov@google.com> wrote:
> KCOV is code coverage collection facility used, in particular, by syzkaller
> system call fuzzer. There is some interest in using syzkaller on arm devices.
> So port KCOV to arm.
>
> On implementation level this merely declares that KCOV is supported and
> disables instrumentation of 3 special cases. Reasons for disabling are
> commented in code.
>
> Tested with qemu-system-arm/vexpress-a15.
>
> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Abbott Liu <liuwenliang@huawei.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Koguchi Takuo <takuo.koguchi.sw@hitachi.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-mm@kvack.org
> Cc: syzkaller@googlegroups.com
>
> ---
>
> Changes since v1:
> - remove disable of instrumentation for arch/arm/mm/fault.c
> - disable instrumentation of arch/arm/kvm/hyp/*
> - resort ARCH_HAS_KCOV alphabetically
Andrew, this is for MM tree because this depends on the following
patches in MM tree:
kcov: prefault the kcov_area
kcov: ensure irq code sees a valid area
sched/core / kcov: avoid kcov_area during task switch
> ---
> arch/arm/Kconfig | 3 ++-
> arch/arm/boot/compressed/Makefile | 3 +++
> arch/arm/kvm/hyp/Makefile | 8 ++++++++
> arch/arm/vdso/Makefile | 3 +++
> 4 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 3493f840e89c..34591796c36f 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -8,9 +8,10 @@ config ARM
> select ARCH_HAS_DEVMEM_IS_ALLOWED
> select ARCH_HAS_ELF_RANDOMIZE
> select ARCH_HAS_FORTIFY_SOURCE
> + select ARCH_HAS_KCOV
> select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
> - select ARCH_HAS_SET_MEMORY
> select ARCH_HAS_PHYS_TO_DMA
> + select ARCH_HAS_SET_MEMORY
> select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
> select ARCH_HAS_STRICT_MODULE_RWX if MMU
> select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
> diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
> index 6a4e7341ecd3..5f5f081e4879 100644
> --- a/arch/arm/boot/compressed/Makefile
> +++ b/arch/arm/boot/compressed/Makefile
> @@ -25,6 +25,9 @@ endif
>
> GCOV_PROFILE := n
>
> +# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
> +KCOV_INSTRUMENT := n
> +
> #
> # Architecture dependencies
> #
> diff --git a/arch/arm/kvm/hyp/Makefile b/arch/arm/kvm/hyp/Makefile
> index 7fc0638f263a..d2b5ec9c4b92 100644
> --- a/arch/arm/kvm/hyp/Makefile
> +++ b/arch/arm/kvm/hyp/Makefile
> @@ -23,3 +23,11 @@ obj-$(CONFIG_KVM_ARM_HOST) += hyp-entry.o
> obj-$(CONFIG_KVM_ARM_HOST) += switch.o
> CFLAGS_switch.o += $(CFLAGS_ARMV7VE)
> obj-$(CONFIG_KVM_ARM_HOST) += s2-setup.o
> +
> +# KVM code is run at a different exception code with a different map, so
> +# compiler instrumentation that inserts callbacks or checks into the code may
> +# cause crashes. Just disable it.
> +GCOV_PROFILE := n
> +KASAN_SANITIZE := n
> +UBSAN_SANITIZE := n
> +KCOV_INSTRUMENT := n
> diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile
> index bb4118213fee..f4efff9d3afb 100644
> --- a/arch/arm/vdso/Makefile
> +++ b/arch/arm/vdso/Makefile
> @@ -30,6 +30,9 @@ CFLAGS_vgettimeofday.o = -O2
> # Disable gcov profiling for VDSO code
> GCOV_PROFILE := n
>
> +# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
> +KCOV_INSTRUMENT := n
> +
> # Force dependency
> $(obj)/vdso.o : $(obj)/vdso.so
>
> --
> 2.17.0.441.gb46fe60e1d-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] arm: port KCOV to arm
2018-05-11 14:32 [PATCH v2] arm: port KCOV to arm Dmitry Vyukov
2018-05-11 14:36 ` Dmitry Vyukov
@ 2018-05-11 14:37 ` Mark Rutland
1 sibling, 0 replies; 3+ messages in thread
From: Mark Rutland @ 2018-05-11 14:37 UTC (permalink / raw)
To: Dmitry Vyukov
Cc: linux, liuwenliang, catalin.marinas, inux-arm-kernel, linux-mm,
Koguchi Takuo, linux-arm-kernel, syzkaller
On Fri, May 11, 2018 at 04:32:48PM +0200, Dmitry Vyukov wrote:
> KCOV is code coverage collection facility used, in particular, by syzkaller
> system call fuzzer. There is some interest in using syzkaller on arm devices.
> So port KCOV to arm.
>
> On implementation level this merely declares that KCOV is supported and
> disables instrumentation of 3 special cases. Reasons for disabling are
> commented in code.
>
> Tested with qemu-system-arm/vexpress-a15.
>
> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Abbott Liu <liuwenliang@huawei.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Koguchi Takuo <takuo.koguchi.sw@hitachi.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-mm@kvack.org
> Cc: syzkaller@googlegroups.com
>
> ---
>
> Changes since v1:
> - remove disable of instrumentation for arch/arm/mm/fault.c
> - disable instrumentation of arch/arm/kvm/hyp/*
> - resort ARCH_HAS_KCOV alphabetically
> ---
> arch/arm/Kconfig | 3 ++-
> arch/arm/boot/compressed/Makefile | 3 +++
> arch/arm/kvm/hyp/Makefile | 8 ++++++++
> arch/arm/vdso/Makefile | 3 +++
> 4 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 3493f840e89c..34591796c36f 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -8,9 +8,10 @@ config ARM
> select ARCH_HAS_DEVMEM_IS_ALLOWED
> select ARCH_HAS_ELF_RANDOMIZE
> select ARCH_HAS_FORTIFY_SOURCE
> + select ARCH_HAS_KCOV
> select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
> - select ARCH_HAS_SET_MEMORY
> select ARCH_HAS_PHYS_TO_DMA
> + select ARCH_HAS_SET_MEMORY
> select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
> select ARCH_HAS_STRICT_MODULE_RWX if MMU
> select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
It might be worth mentioning in the commit message that this also cleans
up an existing unordered entry in the arm Kconfig.
Otherwise, this looks good to me, assumign it goes in after my kcov core
fixups. FWIW:
Acked-by: Mark Rutland <mark.rutland@arm.com>
Thanks,
Mark.
> diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
> index 6a4e7341ecd3..5f5f081e4879 100644
> --- a/arch/arm/boot/compressed/Makefile
> +++ b/arch/arm/boot/compressed/Makefile
> @@ -25,6 +25,9 @@ endif
>
> GCOV_PROFILE := n
>
> +# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
> +KCOV_INSTRUMENT := n
> +
> #
> # Architecture dependencies
> #
> diff --git a/arch/arm/kvm/hyp/Makefile b/arch/arm/kvm/hyp/Makefile
> index 7fc0638f263a..d2b5ec9c4b92 100644
> --- a/arch/arm/kvm/hyp/Makefile
> +++ b/arch/arm/kvm/hyp/Makefile
> @@ -23,3 +23,11 @@ obj-$(CONFIG_KVM_ARM_HOST) += hyp-entry.o
> obj-$(CONFIG_KVM_ARM_HOST) += switch.o
> CFLAGS_switch.o += $(CFLAGS_ARMV7VE)
> obj-$(CONFIG_KVM_ARM_HOST) += s2-setup.o
> +
> +# KVM code is run at a different exception code with a different map, so
> +# compiler instrumentation that inserts callbacks or checks into the code may
> +# cause crashes. Just disable it.
> +GCOV_PROFILE := n
> +KASAN_SANITIZE := n
> +UBSAN_SANITIZE := n
> +KCOV_INSTRUMENT := n
> diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile
> index bb4118213fee..f4efff9d3afb 100644
> --- a/arch/arm/vdso/Makefile
> +++ b/arch/arm/vdso/Makefile
> @@ -30,6 +30,9 @@ CFLAGS_vgettimeofday.o = -O2
> # Disable gcov profiling for VDSO code
> GCOV_PROFILE := n
>
> +# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
> +KCOV_INSTRUMENT := n
> +
> # Force dependency
> $(obj)/vdso.o : $(obj)/vdso.so
>
> --
> 2.17.0.441.gb46fe60e1d-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-11 14:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-11 14:32 [PATCH v2] arm: port KCOV to arm Dmitry Vyukov
2018-05-11 14:36 ` Dmitry Vyukov
2018-05-11 14:37 ` Mark Rutland
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox