[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20230428044500.h5eaabiezuw7duxr@treble>
Date: Thu, 27 Apr 2023 21:45:00 -0700
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: Chen Zhongjin <chenzhongjin@...wei.com>
Cc: linux-kernel@...r.kernel.org, tglx@...utronix.de, mingo@...hat.com,
bp@...en8.de, dave.hansen@...ux.intel.com, x86@...nel.org,
hpa@...or.com, ak@...ux.intel.com, David.Laight@...LAB.COM
Subject: Re: [PATCH v3] x86: profiling: remove lock functions profiling in
profile_pc
On Sun, Apr 23, 2023 at 09:27:44AM +0800, Chen Zhongjin wrote:
> Syzbot has been reporting the problem of stack-out-of-bounds in
> profile_pc for a long time:
> https://syzkaller.appspot.com/bug?extid=84fe685c02cd112a2ac3
>
> profile_pc will get return address for caller if current function
> is lock function. For !CONFIG_FRAME_POINTER it uses a hack way to get
> the caller by directly reading sp[0] or sp [1].
> It not works when KASAN is enabled because KASAN pushes data on stack
> which makes sp[0/1] become KASAN red zone. Then profile_pc reads wrong
> memory and triggers KASAN warning frequently.
>
> This hack might be ok when first added at 2006 but now it's different:
>
> 1. There are some lock functions which have frame longer than two stack
> slots. For these functions sp[0/1] is not a legal return address even
> KASAN is not enabled.
> 2. !CONFIG_FRAME_POINTER is more used today because UNWINDER_ORC.
> 3. Lock function caller information can be prfiled by perf better.
>
> Since profile as a low level facility it's not proper to depend on
> complex generic unwinder to get the next frame. As lock profiling is
> no longer useful, it's fine to remove it.
In that case we can remove the in_lock_functions() check from all the
other arches' implementations of profile_pc().
--
Josh
Powered by blists - more mailing lists