kasan: fix wrong kasan report when resume [1/1]
authorTao Zeng <tao.zeng@amlogic.com>
Wed, 24 Apr 2019 08:10:03 +0000 (16:10 +0800)
committerNick Xie <nick@khadas.com>
Mon, 5 Aug 2019 06:31:41 +0000 (14:31 +0800)
commit04699e52508c432297ec9292941dec7bf858b7e9
tree93f612ee2b839b4f9e83cf41fb43b8efec99479c
parent36aca84a713d6f26aada82314e0da0bbbe5b8667
kasan: fix wrong kasan report when resume [1/1]

PD#SWPL-7676

Problem:
If we open kasan on 32bit kernel, after resume we usually will
get a stack-out-of-bounds KASAN error report. But infact that's
a fake report. Because On arm architecture, cpu suspend/resume
routine is done in function call path:
    cpu_suspend -> psci_cpu_suspend -> __invoke_psci_fn_smc
during this call path, some parts of stack will be marked as
shadow memory. But when cpu resume from smc call, it directly
return to point which saved in cpu_suspend and call resume
procedure. Which do not comeback as a reverse return path:
    __invoke_psci_fn_smc -> psci_cpu_suspend -> cpu_suspend
So some residual shadow memory may affect KASAN report when
cpu is calling resume hooks.

Solution:
We just need to clear all shadow in stack for this case.

Verify:
p212

Change-Id: Ic6c877212240d03902b11184e54ac363455e0094
Signed-off-by: Tao Zeng <tao.zeng@amlogic.com>
arch/arm/kernel/sleep.S
arch/arm/mm/kasan_init.c