Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1645843rwl; Fri, 7 Apr 2023 22:04:01 -0700 (PDT) X-Google-Smtp-Source: AKy350ZNfRwN2BooZhE73AHekCIzYHKXTItwV7Kcx5RQhsHsMirzswFzIlZgcQVDHP/JZrgFgLhS X-Received: by 2002:aa7:d715:0:b0:500:50f6:dd33 with SMTP id t21-20020aa7d715000000b0050050f6dd33mr5152358edq.2.1680930241344; Fri, 07 Apr 2023 22:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680930241; cv=none; d=google.com; s=arc-20160816; b=GNtNPqBBwx1I2cM6ZJHYjFIiyy50zMsuaX2UWDxoRO7VUHE0VXv/5p0IVIBlbwBdm/ sqYZV4iDz6tpLPQN3ZPHFWvIr1IDvBuxhNT2GTbPChbKdeD0Wt9lBAkK8ycPkER0fMwo blpJY/5tRKgR/3gg1Boo+FsfypGzztR4MAZTJpJCXL4Yp1b2JZRylBgjyipbItgKVJy4 R03M3SzlJ7CYNLjkEduItCDSmW2NML7rqIf1TamrtMKfjBuw0VSDwhrminR1a1akT6pw G7jgvXTbyHNwTKNhjnsQyLK+InJTp/LyO9IHlcufn3YzMj6zAAJ4+LQehOXbAO1SVcgD trOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dre6SFHJc9D2hjcfI04VU9OgU8Km5H/YG1KfF/90ByU=; b=nI+MNOApS72lRLKvSs8XTm6k0cJ3eNtXdEHsEy8uX1j5eL/DCl4K5WzVhfrnTToo06 4wLjmUclv2x1yjTcU0E0DSvXmf/nwcD87dfS6a2E0xvAQmExe15Su9PXMgAHcuZy6guq rpLg26RsqPk2wX4ewq3OJDT8NJZ08MZ8ln4gWxQZmt2Pfb9aQ1silDplgA1Wje/atWCH TRFZ53fbhl0G2S7r+jvWcAHvx5cib4vYxuYQ2Qw0U3WB3E1A5nKtWN04eQ5NYBZhAdAV tvflIgtjQYfHnMVjWtiTtekJobRRvChHK0R94gSBZQsTttck37jAzAEBNr+cm4nZ1Ozc hs4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OaDlsaYo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f12-20020a056402004c00b005046fe6c63csi3862721edu.524.2023.04.07.22.03.36; Fri, 07 Apr 2023 22:04:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OaDlsaYo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229741AbjDHE4Z (ORCPT + 99 others); Sat, 8 Apr 2023 00:56:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbjDHE4X (ORCPT ); Sat, 8 Apr 2023 00:56:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73FF2CA01 for ; Fri, 7 Apr 2023 21:56:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 062AF61545 for ; Sat, 8 Apr 2023 04:56:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBA0FC433D2; Sat, 8 Apr 2023 04:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680929781; bh=3k2Pl+dZy+mhR1dngOYtBiIpmXB21t7Xe0d4P1VZSZ8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OaDlsaYo6V5yScNVYSS8oS1cCCu3r2wIFkNL9zFefiZoUxfAmVq6UEj1DFMOE/KBq kGzATEDpqvSW+Q6WFJeoA9Akle5BSS79hesoClIgcgBtRgskB1rGwFBHviEwFhuGkA LZ7ARRLiqkbY6kiiW7IZ8SYf/bMlt7ZtsqOKndSfSVAHEG6Ymywl+ywr4MVskKUMce z+qeBNzanU1zIBlQVbNeU1giAQnmk5yekNoi/a0d8dVBh0GLR/GHYX3v0yaIX/uF// 0tjC5yDuvVj4M81QbdpmxbScC2tGyDOycPKnhsZl0WwygbMXqUy9FOW4JRiP9M3jR7 DadDcIspuH82A== Date: Fri, 7 Apr 2023 21:56:19 -0700 From: Josh Poimboeuf To: Qi Zheng Cc: peterz@infradead.org, keescook@chromium.org, dave.hansen@linux.intel.com, bp@alien8.de, mingo@redhat.com, tglx@linutronix.de, rostedt@goodmis.org, x86@kernel.org, linux-kernel@vger.kernel.org, Chen Zhongjin , Andi Kleen Subject: Re: [PATCH 1/2] x86: make profile_pc() use arch_stack_walk() Message-ID: <20230408045619.m5zfbispodf4zjvz@treble> References: <20230330081552.54178-1-zhengqi.arch@bytedance.com> <20230330081552.54178-2-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230330081552.54178-2-zhengqi.arch@bytedance.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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@huawei.com/ 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