Skip to content

Commit

Permalink
powerpc: disable KASAN instrumentation on early/critical files.
Browse files Browse the repository at this point in the history
All files containing functions run before kasan_early_init() is called
must have KASAN instrumentation disabled.

For those file, branch profiling also have to be disabled otherwise
each if () generates a call to ftrace_likely_update().

Signed-off-by: Christophe Leroy <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
chleroy authored and mpe committed May 2, 2019
1 parent b4abe38 commit f072015
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions arch/powerpc/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ CFLAGS_REMOVE_btext.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_prom.o = $(CC_FLAGS_FTRACE)
endif

KASAN_SANITIZE_early_32.o := n
KASAN_SANITIZE_cputable.o := n
KASAN_SANITIZE_prom_init.o := n
KASAN_SANITIZE_btext.o := n

ifdef CONFIG_KASAN
CFLAGS_early_32.o += -DDISABLE_BRANCH_PROFILING
CFLAGS_cputable.o += -DDISABLE_BRANCH_PROFILING
CFLAGS_prom_init.o += -DDISABLE_BRANCH_PROFILING
CFLAGS_btext.o += -DDISABLE_BRANCH_PROFILING
endif

obj-y := cputable.o ptrace.o syscalls.o \
irq.o align.o signal_32.o pmc.o vdso.o \
process.o systbl.o idle.o \
Expand Down
8 changes: 8 additions & 0 deletions arch/powerpc/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC)
CFLAGS_REMOVE_code-patching.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_feature-fixups.o = $(CC_FLAGS_FTRACE)

KASAN_SANITIZE_code-patching.o := n
KASAN_SANITIZE_feature-fixups.o := n

ifdef CONFIG_KASAN
CFLAGS_code-patching.o += -DDISABLE_BRANCH_PROFILING
CFLAGS_feature-fixups.o += -DDISABLE_BRANCH_PROFILING
endif

obj-y += alloc.o code-patching.o feature-fixups.o

ifndef CONFIG_KASAN
Expand Down
6 changes: 6 additions & 0 deletions arch/powerpc/mm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC)

KASAN_SANITIZE_ppc_mmu_32.o := n

ifdef CONFIG_KASAN
CFLAGS_ppc_mmu_32.o += -DDISABLE_BRANCH_PROFILING
endif

obj-y := fault.o mem.o pgtable.o mmap.o \
init_$(BITS).o pgtable_$(BITS).o \
pgtable-frag.o \
Expand Down
6 changes: 6 additions & 0 deletions arch/powerpc/platforms/powermac/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
CFLAGS_bootx_init.o += -fPIC
CFLAGS_bootx_init.o += $(call cc-option, -fno-stack-protector)

KASAN_SANITIZE_bootx_init.o := n

ifdef CONFIG_KASAN
CFLAGS_bootx_init.o += -DDISABLE_BRANCH_PROFILING
endif

ifdef CONFIG_FUNCTION_TRACER
# Do not trace early boot code
CFLAGS_REMOVE_bootx_init.o = $(CC_FLAGS_FTRACE)
Expand Down
3 changes: 3 additions & 0 deletions arch/powerpc/purgatory/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# SPDX-License-Identifier: GPL-2.0

KASAN_SANITIZE := n

targets += trampoline.o purgatory.ro kexec-purgatory.c

LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/xmon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ subdir-ccflags-y := $(call cc-disable-warning, builtin-requires-header)
GCOV_PROFILE := n
KCOV_INSTRUMENT := n
UBSAN_SANITIZE := n
KASAN_SANITIZE := n

# Disable ftrace for the entire directory
ORIG_CFLAGS := $(KBUILD_CFLAGS)
Expand Down

0 comments on commit f072015

Please sign in to comment.