Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5160918pxj; Wed, 26 May 2021 04:25:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5jIT/B2LmXxk3m5iQD32VfV56prrPH8WWjqZy9mI2lKvJawGjyHG0sbO+FOezUPxsQ2kH X-Received: by 2002:a05:6e02:1bae:: with SMTP id n14mr28533115ili.129.1622028330729; Wed, 26 May 2021 04:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622028330; cv=none; d=google.com; s=arc-20160816; b=gHhKMWKDb5N6r/KqSl/gKE+95NvMb+tPSKCBM0aJ5HuojzLhZAvC+8bIVFHzlZLAbd 9blQndwlN+Swvspm+zluKYxCAnryHcsz7Z1Pjstvf/QJt9LPX8IT4FQbd5CzDSFECQqR Mw/BqGOUTEE243zzWAItqT/FMp5bytt5ES0sHPN9ZonW/t4x3ty17H2JuqoN5+1niDX4 qFNohJzS+Mbnbqh611kz4Hmd5vAKL+En/H3Ud56n1TSYcJ5gBEwu0GOzNOqKWOhuBkjn 1KbcXv8+GbI7Vb5EY68IoEwrEMmOm4N7sosxv24/rCHoBKjwWXxqgDFHZxGwPKh+gNsc 6NnA== 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=fZAACMzJcPYlKeXzYrSH6fOQ3k7m36ZcoznWZOSXY40=; b=I4eARUatYieE/KtBsuV1Er1dzNs1Q9VCb4+llC3gfjm6PEsbcKZeYJKo0xNjJujXan CNf6vwW4ORWRo370tGq/588FTMkW91QaWnHnzzHzjvhqs9Ff17QSRRBmE58DubLFl89J rsq9g89hfGjoWmNX9R5iiPJowX3XqeO3vfjG7xJGzFizDWV6FR+BmIL2TtAXfIVhYYGM TNMTF2hy7ZTGvS9gtFf0ZScUk3jF5MG/27Ld/NSR4G34Pnvz7vTSKe5QM9QQ/lIQeVQx 21/OnxkPRKe+a2jtDgMzsiRWFvmLhIqBUQUDFX4ziNu8R9gQGB1VZbnARcFa4fM6DpcY kx3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NFzYrEFH; 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 s4si23101380ilv.33.2021.05.26.04.25.13; Wed, 26 May 2021 04:25:30 -0700 (PDT) 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=NFzYrEFH; 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 S232609AbhEZGfO (ORCPT + 99 others); Wed, 26 May 2021 02:35:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:56212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232514AbhEZGfO (ORCPT ); Wed, 26 May 2021 02:35:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AD42361090; Wed, 26 May 2021 06:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622010823; bh=//HIC0wWxbiKsea2wsR5H038/7YI4tnT/OaBYgjVYRU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NFzYrEFHgxupPIPrHrsmPAdG3hUVS842r7TADpXHyf+ikf9M8thSLERxAQ7t9O4Rh NK2WBLMSB0AhmszVlIhhxZ2xC50Mbu6xywcOdXq+52A3WsMz+1HzrOmg3VXgacweMY FHE0IiT3cUySQkEwrgqzrgMzMJyeK6RYfAnKQq2Vmz65VP14cHFxMvI+TzOQA8QkzJ q+Vs2azcUtNXOKa4gB0wDvd8UBHc9X4iJ1D3W121eg3ofzSXjs7eewFeE5JHVHQZVY pHczQpmsccFZnVS1FCnVGKl58rYfi5ZjygYlxqiGtvl0mWWxDDQW1aAB/ADxTYSiog dNX94usJ5GUDQ== Date: Wed, 26 May 2021 15:33:40 +0900 From: Masami Hiramatsu To: Ravi Bangoria Cc: acme@kernel.org, jolsa@redhat.com, linux-kernel@vger.kernel.org, aneesh.kumar@linux.ibm.com Subject: Re: [PATCH] perf probe: Provide more detail with relocation warning Message-Id: <20210526153340.a49ba8292f201493990f210c@kernel.org> In-Reply-To: <05e32c82-1009-03ba-d973-8b1bc0582ce2@linux.ibm.com> References: <20210525043744.193297-1-ravi.bangoria@linux.ibm.com> <20210525214858.33a66846ac09e499c3268a63@kernel.org> <05e32c82-1009-03ba-d973-8b1bc0582ce2@linux.ibm.com> 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 Wed, 26 May 2021 10:23:18 +0530 Ravi Bangoria wrote: > > > On 5/25/21 6:18 PM, Masami Hiramatsu wrote: > > On Tue, 25 May 2021 10:07:44 +0530 > > Ravi Bangoria wrote: > > > >> When run as normal user with default sysctl kernel.kptr_restrict=0 > >> and kernel.perf_event_paranoid=2, perf probe fails with: > >> > >> $ ./perf probe move_page_tables > >> Relocated base symbol is not found! > >> > >> The warning message is not much informative. The reason perf fails > >> is because /proc/kallsyms is restricted by perf_event_paranoid=2 > >> for normal user and thus perf fails to read relocated address of > >> the base symbol. > >> > >> Tweaking kptr_restrict and perf_event_paranoid can change the > >> behavior of perf probe. Also, running as root or privileged user > >> works too. Add these details in the warning message. > >> > >> Plus, kmap->ref_reloc_sym might not be always set even if > >> host_machine is initialized. Above is the example of the same. > >> Remove that comment. > > > > Yes, those are restricted in some cases. Anyway without priviledged > > (super) user, perf probe can not set the probe in ftrace. > > > > Hmm, I think it should check the effective user-id at first. If it > > is not super user and the action will access tracefs and kallsyms, > > it should warn at that point. > > If kptr_restrict=2, perf probe fails with same error even for root user. > That's why I thought to just change this warning message. Ah, yes. In that case, perf probe must not use the base symbol. (like -D option) OK, then, let's merge this fix. Acked-by: Masami Hiramatsu Thank you, > > Different combinations of privilege, perf_event_paranoid, kptr_restrict: > > Normal/Root user > | perf_event_paranoid > V V kptr_restrict perf probe error > ---------------------------------------------------------------- > N -1 0 Failed to open kprobe_events: Permission denied > N 0 0 Failed to open kprobe_events: Permission denied > N 1 0 Failed to open kprobe_events: Permission denied > N 2 0 Relocated base symbol is not found! > > N -1 1 Relocated base symbol is not found! > N 0 1 Relocated base symbol is not found! > N 1 1 Relocated base symbol is not found! > N 2 1 Relocated base symbol is not found! > > N -1 2 Relocated base symbol is not found! > N 0 2 Relocated base symbol is not found! > N 1 2 Relocated base symbol is not found! > N 2 2 Relocated base symbol is not found! > > R -1 0 No error. > R 0 0 No error. > R 1 0 No error. > R 2 0 No error. > > R -1 1 No error. > R 0 1 No error. > R 1 1 No error. > R 2 1 No error. > > R -1 2 Relocated base symbol is not found! > R 0 2 Relocated base symbol is not found! > R 1 2 Relocated base symbol is not found! > R 2 2 Relocated base symbol is not found! > > Ravi -- Masami Hiramatsu