aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/kernel/probes
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@arm.com>2016-07-21 05:54:54 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2016-07-21 06:47:53 -0400
commitf7e35c5ba4322838ce84b23a2f1a6d6b7f0b57ec (patch)
tree79442036f6553cc9efb40acec0eec18c5ab48161 /arch/arm64/kernel/probes
parent3b7d14e9f3f1efd4c4348800e977fd1ce4ca660e (diff)
arm64: kprobes: Add KASAN instrumentation around stack accesses
This patch disables KASAN around the memcpy from/to the kernel or IRQ stacks to avoid warnings like below: BUG: KASAN: stack-out-of-bounds in setjmp_pre_handler+0xe4/0x170 at addr ffff800935cbbbc0 Read of size 128 by task swapper/0/1 page:ffff7e0024d72ec0 count:0 mapcount:0 mapping: (null) index:0x0 flags: 0x1000000000000000() page dumped because: kasan: bad access detected CPU: 4 PID: 1 Comm: swapper/0 Not tainted 4.7.0-rc4+ #1 Hardware name: ARM Juno development board (r0) (DT) Call trace: [<ffff20000808ad88>] dump_backtrace+0x0/0x280 [<ffff20000808b01c>] show_stack+0x14/0x20 [<ffff200008563a64>] dump_stack+0xa4/0xc8 [<ffff20000824a1fc>] kasan_report_error+0x4fc/0x528 [<ffff20000824a5e8>] kasan_report+0x40/0x48 [<ffff20000824948c>] check_memory_region+0x144/0x1a0 [<ffff200008249814>] memcpy+0x34/0x68 [<ffff200008c3ee2c>] setjmp_pre_handler+0xe4/0x170 [<ffff200008c3ec5c>] kprobe_breakpoint_handler+0xec/0x1d8 [<ffff2000080853a4>] brk_handler+0x5c/0xa0 [<ffff2000080813f0>] do_debug_exception+0xa0/0x138 Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/kernel/probes')
-rw-r--r--arch/arm64/kernel/probes/kprobes.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c
index 973c15df5211..bf9768588288 100644
--- a/arch/arm64/kernel/probes/kprobes.c
+++ b/arch/arm64/kernel/probes/kprobes.c
@@ -16,6 +16,7 @@
16 * General Public License for more details. 16 * General Public License for more details.
17 * 17 *
18 */ 18 */
19#include <linux/kasan.h>
19#include <linux/kernel.h> 20#include <linux/kernel.h>
20#include <linux/kprobes.h> 21#include <linux/kprobes.h>
21#include <linux/module.h> 22#include <linux/module.h>
@@ -498,8 +499,10 @@ int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
498 * we also save and restore enough stack bytes to cover 499 * we also save and restore enough stack bytes to cover
499 * the argument area. 500 * the argument area.
500 */ 501 */
502 kasan_disable_current();
501 memcpy(kcb->jprobes_stack, (void *)stack_ptr, 503 memcpy(kcb->jprobes_stack, (void *)stack_ptr,
502 min_stack_size(stack_ptr)); 504 min_stack_size(stack_ptr));
505 kasan_enable_current();
503 506
504 instruction_pointer_set(regs, (unsigned long) jp->entry); 507 instruction_pointer_set(regs, (unsigned long) jp->entry);
505 preempt_disable(); 508 preempt_disable();
@@ -551,8 +554,10 @@ int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
551 } 554 }
552 unpause_graph_tracing(); 555 unpause_graph_tracing();
553 *regs = kcb->jprobe_saved_regs; 556 *regs = kcb->jprobe_saved_regs;
557 kasan_disable_current();
554 memcpy((void *)stack_addr, kcb->jprobes_stack, 558 memcpy((void *)stack_addr, kcb->jprobes_stack,
555 min_stack_size(stack_addr)); 559 min_stack_size(stack_addr));
560 kasan_enable_current();
556 preempt_enable_no_resched(); 561 preempt_enable_no_resched();
557 return 1; 562 return 1;
558} 563}