Skip to content

Commit d5d44e7

Browse files
linuswRussell King
authored andcommitted
ARM: 9013/2: Disable KASan instrumentation for some code
Disable instrumentation for arch/arm/boot/compressed/* since that code is executed before the kernel has even set up its mappings and definately out of scope for KASan. Disable instrumentation of arch/arm/vdso/* because that code is not linked with the kernel image, so the KASan management code would fail to link. Disable instrumentation of arch/arm/mm/physaddr.c. See commit ec6d06e ("arm64: Add support for CONFIG_DEBUG_VIRTUAL") for more details. Disable kasan check in the function unwind_pop_register because it does not matter that kasan checks failed when unwind_pop_register() reads the stack memory of a task. Cc: Andrey Ryabinin <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: [email protected] Reviewed-by: Ard Biesheuvel <[email protected]> Tested-by: Ard Biesheuvel <[email protected]> # QEMU/KVM/mach-virt/LPAE/8G Tested-by: Florian Fainelli <[email protected]> # Brahma SoCs Tested-by: Ahmad Fatoum <[email protected]> # i.MX6Q Reported-by: Florian Fainelli <[email protected]> Reported-by: Marc Zyngier <[email protected]> Signed-off-by: Abbott Liu <[email protected]> Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent 7a1be31 commit d5d44e7

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

arch/arm/boot/compressed/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ OBJS += hyp-stub.o
2424
endif
2525

2626
GCOV_PROFILE := n
27+
KASAN_SANITIZE := n
2728

2829
# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
2930
KCOV_INSTRUMENT := n

arch/arm/kernel/unwind.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ static int unwind_pop_register(struct unwind_ctrl_block *ctrl,
236236
if (*vsp >= (unsigned long *)ctrl->sp_high)
237237
return -URC_FAILURE;
238238

239-
ctrl->vrs[reg] = *(*vsp)++;
239+
/* Use READ_ONCE_NOCHECK here to avoid this memory access
240+
* from being tracked by KASAN.
241+
*/
242+
ctrl->vrs[reg] = READ_ONCE_NOCHECK(*(*vsp));
243+
(*vsp)++;
240244
return URC_OK;
241245
}
242246

arch/arm/mm/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ obj-y := extable.o fault.o init.o iomap.o
77
obj-y += dma-mapping$(MMUEXT).o
88
obj-$(CONFIG_MMU) += fault-armv.o flush.o idmap.o ioremap.o \
99
mmap.o pgd.o mmu.o pageattr.o
10+
KASAN_SANITIZE_mmu.o := n
1011

1112
ifneq ($(CONFIG_MMU),y)
1213
obj-y += nommu.o
@@ -16,6 +17,7 @@ endif
1617
obj-$(CONFIG_ARM_PTDUMP_CORE) += dump.o
1718
obj-$(CONFIG_ARM_PTDUMP_DEBUGFS) += ptdump_debugfs.o
1819
obj-$(CONFIG_MODULES) += proc-syms.o
20+
KASAN_SANITIZE_physaddr.o := n
1921
obj-$(CONFIG_DEBUG_VIRTUAL) += physaddr.o
2022

2123
obj-$(CONFIG_ALIGNMENT_TRAP) += alignment.o

arch/arm/vdso/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ GCOV_PROFILE := n
4242
# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
4343
KCOV_INSTRUMENT := n
4444

45+
KASAN_SANITIZE := n
46+
4547
# Force dependency
4648
$(obj)/vdso.o : $(obj)/vdso.so
4749

0 commit comments

Comments
 (0)