Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2004509pxb; Mon, 22 Feb 2021 17:28:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKPl9pPlCDFBIwUVt2sIJKG3Ca6/vP/JEeTKKQWf1ofcDVCiB4ulJ/K6G2xY7XyiENckj+ X-Received: by 2002:a05:6402:b03:: with SMTP id bm3mr14428830edb.13.1614043732410; Mon, 22 Feb 2021 17:28:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614043732; cv=none; d=google.com; s=arc-20160816; b=JmcZuLxSu1qyt8kS4Yn+3//wVzYnpbTNn/w3UOcJPn1X8na4eij2Nzo6cKtwC+cdeL FshHhcF4Nac0VDWMmzfwgCEsM2h+MFpjcl/nj3mkx8Fg/xcTEPpRgpuw++4/XWmqKPY2 Zx+ram70GfLzQ2RmFZJgPIfv5m8c7k6jj4PsYfwDiA/V+P4S5wXIGjeIMK0azRpmdlDq 76f//By4CNy6k0DNl2qjOwDVyG7v/nGx9pmSHxgvCLkBeegwyPFXyW8Ud8DX/rKEpf9c lsTYeZwdLMVY38ole/Rxqb50iXsc0lu3iyd7eRR+jcpbfS6hg6SwJAnB1TxwHeGIFO1V 43Kw== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=mm+gn4j8Xib9e8MTir0rYGNXW7NDmdKgamNszOUzdCU=; b=zH4lquRBbpsaZtw77H26iCTjFJW5TiV7Ws/HDbBa9KquRR4k2mIl9hWRLXXlq/+jyE PlZ/7O+N/fOniCtoA6rRIR9DUipaY6io0uEZgeAHY1dykM9lwO/jY1guSDhhsRHn2dKD PPJROabRt3Pty2m3DClVXmuCUo3inHeC/2foN9qwNpBxCz7kqP2s4EhXop9fAK1j94ix 1pVZN3SAywazegaTxXeZCiU37JEgXYOcNg//i6gI4bpGDhBY6sE0ncUxXVKv47akdR8G RA3JSvX5ORVrbHeppJBpLj+N8PyhA+SkwnkldvyXgOFfqweTu8CnxLUjM6sklzMKE/hK sAHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ct3gFvNn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si5635874edi.554.2021.02.22.17.28.28; Mon, 22 Feb 2021 17:28:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ct3gFvNn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231143AbhBWBZ5 (ORCPT + 99 others); Mon, 22 Feb 2021 20:25:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:38280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229967AbhBWBYP (ORCPT ); Mon, 22 Feb 2021 20:24:15 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 661F860232; Tue, 23 Feb 2021 01:23:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614043415; bh=VQBJvAaPvVk3ewwCQ9qqE3Oyikga6Xw0ZOguULkFO0U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ct3gFvNnmoFf+fH0MuzKVyWNchfaSBuU8VO5TF42pVs7kTGWv9u5ZerxhLCveUkQz z+909UKLqMA3c9alZcAMivXemWqP97XoZ942HLtmTgzNpXt6bcqMVyIicdVOXxVxbj cNI0qhERdBPVeXNtfYWaQ5QQWOprxIXi8cuoXrFsjk5etB//VX3SLeBLZYGWzX8sD8 cQ8i7RXhYd3RLRZHVIQKX30mxhwXTjFR5zYGxh/vcdLHY7A8joJtt0bSgNADNDVS6F KEHES3vgj4xVWu2q7t4PyxX2J4rYFX4JPm8B6cqqiASpMMK04W2Q7Axo8S6kHwGxkN qh6xrK/Atygkg== Date: Tue, 23 Feb 2021 10:23:31 +0900 From: Masami Hiramatsu To: Josh Poimboeuf Cc: Evgenii Shatokhin , Arnaldo Carvalho de Melo , Kristen Carlson Accardi , live-patching@vger.kernel.org, Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Konstantin Khorenko Subject: Re: 'perf probe' and symbols from .text. Message-Id: <20210223102331.147d62de88886a75013c10e0@kernel.org> In-Reply-To: <20210222175150.yxgw3sxxaqjqgq56@treble> References: <09257fb8-3ded-07b0-b3cc-55d5431698d8@virtuozzo.com> <20210223000508.cab3cddaa3a3790525f49247@kernel.org> <20210222175150.yxgw3sxxaqjqgq56@treble> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 22 Feb 2021 11:51:50 -0600 Josh Poimboeuf wrote: > On Tue, Feb 23, 2021 at 12:05:08AM +0900, Masami Hiramatsu wrote: > > > Of course, one could place probes using absolute addresses of the > > > functions but that would be less convenient. > > > > > > This also affects many livepatch modules where the kernel code can be > > > compiled with -ffunction-sections and each function may end up in a > > > separate section .text.. 'perf probe' cannot be used > > > there, except with the absolute addresses. > > > > > > Moreover, if FGKASLR patches are merged > > > (https://lwn.net/Articles/832434/) and the kernel is built with FGKASLR > > > enabled, -ffunction-sections will be used too. 'perf probe' will be > > > unable to see the kernel functions then. > > > > Hmm, if the FGKASLAR really randomizes the symbol address, perf-probe > > should give up "_text-relative" probe for that kernel, and must fallback > > to the "symbol-based" probe. (Are there any way to check the FGKASLR is on?) > > The problem of "symbol-based" probe is that local (static) symbols > > may share a same name sometimes. In that case, it can not find correct > > symbol. (Maybe I can find a candidate from its size.) > > Anyway, sometimes the security and usability are trade-off. > > We had a similar issue with FGKASLR and live patching. The proposed > solution is a new linker flag which eliminates duplicates: -z > unique-symbol. > > https://sourceware.org/bugzilla/show_bug.cgi?id=26391 Interesting, but it might not be enough for perf-probe. Since the perf-probe has to handle both dwarf and elf, both must be changed. I think the problem is that the dwarf is generated while compiling, but this -z seems converting elf symbols in linkage. As far as I can see, this appends ".COUNT" suffix to the non-unique symbols in the linkage phase. Is that also applied to dwarf too? Thank you, -- Masami Hiramatsu