From patchwork Tue Nov 1 13:48:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 967 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2977273wru; Tue, 1 Nov 2022 06:50:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6obAXCdjLfjqcLY7Qln8RcFBeupxAVEE7QyTqSrjPh4/jm00zwZolm57m4r3X/LSzD6udB X-Received: by 2002:a05:6402:c7:b0:457:cd5d:d777 with SMTP id i7-20020a05640200c700b00457cd5dd777mr19523637edu.245.1667310636555; Tue, 01 Nov 2022 06:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667310636; cv=none; d=google.com; s=arc-20160816; b=cWJ7ES2fwQgzbTZLgcCjLM2B3ZTKD89B4LXZt3WKOlm03XgCblIvzTH3aLLQVbTOo4 uXdeyaCSicdzlX4OTn0QqRT5BiPmsCx30LNtQTvHb4fiEuXttZWgnFWE9O9/XgiVEQxA cyS+6pSxVQMmEVtboUo82bbn3yh49c0q4b5fTjVWQTrDNveUjYStazAriB1NUi8oTLXg t7u1FQXp0ZQ4bKC1sgIqv2lJqtQVer3FrxrUQJppKflb5QYtOydJIH92gvhVT1F+W4B+ GjBAz2P3pUiPZkekLpA5rvLW++8dYTvI5u9ePhHGik1i1ZPHiHMKMI/UqCznGMrEUEio u4og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:date:subject:cc:to:from:dkim-signature; bh=shZKg3DZDu8x8R/JrGdc+SNi1+lMG4JpxvvQyCUBeqY=; b=qjtWrHjSm3/OPDQKKsrgaB9mibeX42qiMBz2LriOm3+DlK2feFZrGXZpAP55Z1HQ6U esgXVYyZ4527NOV4LHchsHsOgQ7+nU+hRzxJeKT3C3Itc3piH62d6mGTOOlDytP4DDUT uEniMAuJPmvyNUBqtCqBVyXHCb8UYSzN1VosAxwrcpPtInSl/fy3nkW0MePBWldjxpK6 oUsK93pLPQng0T2leklnXjy8e+OjSSbKmMK+YWVsP6UPdstGb2SyM7kQaQqAxJhkxHCo wMpCb/tdcJiwbFifv4Yrc8tnvc7XbRbderFxqCW+nwV7P2s24ac/vH/k6PJBwgl/g1VE O6fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u5+TP2f9; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w3-20020a05640234c300b0043dfc949d31si14011955edc.25.2022.11.01.06.50.11; Tue, 01 Nov 2022 06:50:36 -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=u5+TP2f9; 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 S229995AbiKANsb (ORCPT + 99 others); Tue, 1 Nov 2022 09:48:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbiKANs1 (ORCPT ); Tue, 1 Nov 2022 09:48:27 -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 B667C1162; Tue, 1 Nov 2022 06:48:26 -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 16730611E7; Tue, 1 Nov 2022 13:48:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0F14C433D6; Tue, 1 Nov 2022 13:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667310505; bh=2r6RMNudw65t+LrmOPtjGBPzbGcSI8my0xvyNFh7v7c=; h=From:To:Cc:Subject:Date:From; b=u5+TP2f9XGevZNTdAqt4Z6sTDENHb1y8A2EB/sZeIJBNN5gNKhdu7VRPYYjTRbjoR rN+rfjLGrVZv6sOSAAMzo/gVxb9HhjrMCeJYQzhO0fRuZXQzGvHEWmPzfeQ4D68lur UmGTrEWmKkGaTh4fclViL4/nVhGi7GqeSzFPbkKC60Yo5gJXxt8E33slKoN+ePtv1E EsbpwrIlXzxari5SEvfTDmcVq1fKlCRCG8/DNDp9YfhLVSGQ8+AeeIl4fGw1xBZVsr v1cNvJDF9KowiwjFdIOFnb6lF3MLCL/n8DYnURo64OmDJsz9Qd7hHbeOPlrnq9DEJy KEpr1Lh8PEnCg== From: "Masami Hiramatsu (Google)" To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Masami Hiramatsu , Steven Rostedt Subject: [PATCH v2 0/3] tools/perf: Fix perf probe crash by clang DWARF5 file Date: Tue, 1 Nov 2022 22:48:21 +0900 Message-Id: <166731050151.2100653.8202870942871353491.stgit@devnote3> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748301918550959266?= X-GMAIL-MSGID: =?utf-8?q?1748301918550959266?= Hi, Here is the 2nd version of the patches for perf probe which improves the robustness against clang DWARF5 file. Since the Clang generates a bit different DWARF5 file, the perf probe crashes or failes to analyze it. There are actually fragile code against it, so I fixed it ([1/3]) to avoid crash by SEGV. And make it accepts Clang's DWARF5 file ([2/3],[3/3]). Without this series, the perf probe crashes with the DWARF5 file which generated by clang as below; $ ./perf probe -k $BIN_PATH/vmlinux -s $SRC_PATH -L vfs_read:10 Segmentation fault This series fixes it to handle such file correctly; $ ./perf probe -k $BIN_PATH/vmlinux -s $SRC_PATH -L vfs_read:10 11 ret = rw_verify_area(READ, file, pos, count); 12 if (ret) return ret; On the DWARF5 specification, Sec 2.14, there is "The value 0 indicates that no source file has been specified." for DW_AT_decl_file, but clang generated DWARF5 will use the value 0. This issue is discussed on DWARF std ML; https://www.mail-archive.com/dwarf-discuss@lists.dwarfstd.org/msg00884.html And suggested that removing this part from the specification. http://wiki.dwarfstd.org/index.php?title=DWARF5_Line_Table_File_Numbers So as far as I understand, this is out of standard at this moment, but the standard itself has a discussion on this part. And maybe updated as currently clang does in the next release/revision. Thank you, Acked-by: Namhyung Kim --- Masami Hiramatsu (Google) (3): tools/perf: Fix to avoid crashing if DW_AT_decl_file is NULL tools/perf: Fix to use dwarf_attr_integrate for generic attr accessor tools/perf: Fix to get declared file name from clang DWARF5 tools/perf/util/dwarf-aux.c | 58 ++++++++++++++++++++++++++++------------ tools/perf/util/dwarf-aux.h | 3 ++ tools/perf/util/probe-finder.c | 37 +++++++++++++++++--------- 3 files changed, 68 insertions(+), 30 deletions(-) -- Masami Hiramatsu (Google)