Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1602743rwr; Thu, 27 Apr 2023 22:03:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5rdjYK7N5bHMOsTwCTq9mqO4Bwc8qG4jmC/kWrrkOlEfUIWBYZ6MbIcu9hfwluEqJnso3n X-Received: by 2002:a17:90a:8548:b0:23d:4e9d:2eb0 with SMTP id a8-20020a17090a854800b0023d4e9d2eb0mr4097350pjw.36.1682658239498; Thu, 27 Apr 2023 22:03:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682658239; cv=none; d=google.com; s=arc-20160816; b=iGsn9khNP+FeC4YJJ3YB3cSzzTZJhbnASXG5Tw8qQzLazSQ3lvbgoUrYUsnnWepgkv FFs9iDLztF73CRHun31Xcx8HZy5X0MADBA9dvtE9kR7mcDvkHjT9UJrzZ+a7PKhVM2QN awy5B/AbXmi5hJTOPf9AsXCb70yDZFz4axxQu/fvgl34k3BIXhbE/hn0M9kV/23pUs+z CuaIA2cpiZRdf3CiVZu9+mKZcQX2HMEy2m8ftA8iGsRfvaZJRJ26vstf/NzDeV5QT5lm IseCZyUlVv29AovZa5cYydy6gY0/57CzVaCJdPk2+ALxzL9/qvdG1N4gjmmZ9BvOxJd3 TRMA== 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=vWgesLsJLgbSbAIY1kX9Ag4JmAe836NeEvnh0hg2e94=; b=UEuTzE60J+k9NJZWn8dIiQGWp7nBHwCnU5H8uY6XsbX8fg11og4ZJxHSlIxFHjGRq7 sFtZorAEeppOD5AmP1zPWt5MQpIcF1ZQssXvcXFPlR2zmdDfUFe4akgm9fsWyX2yuqUR SdrMs0YAYFlt1Co75/BY1evJitjwPXqXginQnfBN4qhp6tluG81OstnaDhT5QzlJibZh taGURALw63lvQgDeI3jRK1smAkhtmOQ9q1U4MNGZ6AS7FdYXDpIP5ka40k2MAtIsqBcs ltnnrEMvptOywzjRs5AzI/GEva1sIDcoHXDXrJlAoPs0Z29KN3iegf1/B3DL8r5rtndY ib+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MHTufx1B; 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 g33-20020a635221000000b00513234112b6si1127498pgb.898.2023.04.27.22.03.32; Thu, 27 Apr 2023 22:03:59 -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=MHTufx1B; 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 S1345317AbjD1EpH (ORCPT + 99 others); Fri, 28 Apr 2023 00:45:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229502AbjD1EpF (ORCPT ); Fri, 28 Apr 2023 00:45:05 -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 93B2A2696 for ; Thu, 27 Apr 2023 21:45:03 -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 1E49B63EA7 for ; Fri, 28 Apr 2023 04:45:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10820C433EF; Fri, 28 Apr 2023 04:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682657102; bh=Omj+SL5zqTsoKaLqrqXUY1PyXUHPTRyCAvEul9HQv8M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MHTufx1BvoVAN/sP7vEbGBBVMysIynmpWajofD1UGvid6AhWj2FUZRXJ0bTTnJTsF HgpW12cAND2I2MiUMCYJSNk3LIJHYUGwtdrHoGk9oZ2+OyQGKHAhMfski6Q/YKUNYV CLi5r+zu4Cb4Yrp8tofpBJV/KJI5fYAO2hBzSEpRR+MtQAgBK5/5FulPnZ5Wd0eLia TraRD9gPr886vQD34GrZfNXaczVbUFQFEPKoR8WVZeOD7Q5dSaWH9RFXV5MawPFKSg 6Wd6V4TWu32cwHTlj9chgegk7nV35Eo/QVjZfkVDl/KZKh6QXRBiV7c/uvfWSOxS3n OvILD//WJ3zWQ== Date: Thu, 27 Apr 2023 21:45:00 -0700 From: Josh Poimboeuf To: Chen Zhongjin Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, ak@linux.intel.com, David.Laight@ACULAB.COM Subject: Re: [PATCH v3] x86: profiling: remove lock functions profiling in profile_pc Message-ID: <20230428044500.h5eaabiezuw7duxr@treble> References: <20230423012744.24320-1-chenzhongjin@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230423012744.24320-1-chenzhongjin@huawei.com> X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 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