Re: [PATCH 1/2] x86: make profile_pc() use arch_stack_walk()
From: Josh Poimboeuf
Date: Sat Apr 08 2023 - 00:56:29 EST
On Thu, Mar 30, 2023 at 04:15:51PM +0800, Qi Zheng wrote:
> The profile_pc() try to get pc by doing a trick to read
> the contents of the stack. This may cause false positives
> for KASAN, like the following:
>
> BUG: KASAN: stack-out-of-bounds in profile_pc+0x5b/0x90
> Read of size 8 at addr ffff8881062a7a00 by task id/130040
I don't think this was actually a false positive. The !FRAME_POINTER
code in profile_pc() has been badly broken for many years.
BTW, there was a similar patch here:
https://lore.kernel.org/lkml/20230224021858.120078-1-chenzhongjin@xxxxxxxxxx/
I thought CONFIG_PROFILING was obsolete but Andi said previously he
wants to keep it for at least boot-time profiling.
Andi did suggest removing the lock profiling hacks, which means all the
profile_pc() implementations can just be removed in favor of the generic
instruction_pointer().
--
Josh