Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2729494ybl; Thu, 29 Aug 2019 12:03:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtfP/beQDmlD4P7OfYjU37hwqb2Nuzcs7J+VUR7wRGHqFbJQYcZ11fA3eud+cm/YGLg4kD X-Received: by 2002:a17:902:3281:: with SMTP id z1mr11488729plb.302.1567105436653; Thu, 29 Aug 2019 12:03:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567105436; cv=none; d=google.com; s=arc-20160816; b=beTTaBCfSyaZ38HkKLWwJJMLQrAGCAfATymu378EUINX81SiNl+lTxCJtzJFQFjUXl nHI7d1s3UefHwUEEckjJyicpSH2VES5Ti4aFnXRCM9ukOBw7/ohgjAS9P6VeI4uvMmQv HPjz7AsaSbTRTYt4NnE9PbS3Ip4FVj1eqf297JzWEADcU3u2ENwMD/3OXJzWfzaZHUw6 mqYA1MJQZ54Q8oZaJ3T4zWuumAy4EnNX4OleyoDU9rpfE4+TT0zScwVPRTdVRI1bE+ZU aPXfoAe5Inf3yrp73Dn0ndP1ChTr1oMt+hz630vZKRG6JXO8XSgsQc6znyKFTvbE/UJk RtQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=5Kt/WzfYdQalWKZTtWdLY3bhyYbF9YzMiBWIdFk1ikk=; b=gIQPZmjtChrXe7i8gzAD8YxvzzKlaNDE1XMEnE7nVEvXF7kb+pQOb1746IasehHFZ+ qSyJgM0LYhg2nivwKvUOfkLVRn7tUuluZVq3usqVA/aaumHSOKdY9LQXq5TpP0T3wHif SnC8E4zNlPtgD8PXt8miL9j7uL5IePHYFebjxkawaaiwZCjW7zdMqkb+lxpym+qC5NI1 5uvhXRz0vIdEQDr6EH9qXO+Xm4jL0F1+ba3ibeTxad7BWIXz+QT66A/xwzRRVBMYM5rl vrrR2rDHbrjyJlNcAEn5BhgPEc/6vGbi0/Gj0j/cD9r81Qjc8+Jqm2SOZnrjWfJRwQ9J VLpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a37si2588821pla.294.2019.08.29.12.03.40; Thu, 29 Aug 2019 12:03:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728973AbfH2TCV (ORCPT + 99 others); Thu, 29 Aug 2019 15:02:21 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:51563 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728949AbfH2TCT (ORCPT ); Thu, 29 Aug 2019 15:02:19 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1i3Pg3-00051d-CA; Thu, 29 Aug 2019 21:01:47 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id D07B51C07C3; Thu, 29 Aug 2019 21:01:46 +0200 (CEST) Date: Thu, 29 Aug 2019 19:01:46 -0000 From: "tip-bot2 for Igor Lubashev" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf tools: Use CAP_SYS_ADMIN with perf_event_paranoid checks Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Mathieu Poirier , Alexander Shishkin , Alexey Budankov , James Morris , Namhyung Kim , Peter Zijlstra , Suzuki Poulouse , linux-arm-kernel@lists.infradead.org, Igor Lubashev , Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <1566869956-7154-3-git-send-email-ilubashe@akamai.com> References: <1566869956-7154-3-git-send-email-ilubashe@akamai.com> MIME-Version: 1.0 Message-ID: <156710530660.10513.2537710745065079196.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: dda1bf8ea78add78739d128a20b555c4a1a19c27 Gitweb: https://git.kernel.org/tip/dda1bf8ea78add78739d128a20b555c4a1a19c27 Author: Igor Lubashev AuthorDate: Mon, 26 Aug 2019 21:39:13 -04:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Wed, 28 Aug 2019 17:18:08 -03:00 perf tools: Use CAP_SYS_ADMIN with perf_event_paranoid checks The kernel is using CAP_SYS_ADMIN instead of euid==0 to override perf_event_paranoid check. Make perf do the same. Signed-off-by: Arnaldo Carvalho de Melo Acked-by: Jiri Olsa Tested-by: Mathieu Poirier Reviewed-by: Mathieu Poirier # coresight part Cc: Alexander Shishkin Cc: Alexey Budankov Cc: James Morris Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Suzuki Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1566869956-7154-3-git-send-email-ilubashe@akamai.com Signed-off-by: Igor Lubashev Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm/util/cs-etm.c | 3 ++- tools/perf/arch/arm64/util/arm-spe.c | 3 ++- tools/perf/arch/x86/util/intel-bts.c | 3 ++- tools/perf/arch/x86/util/intel-pt.c | 2 +- tools/perf/util/evsel.c | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index a185dab..5d856ed 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -18,6 +18,7 @@ #include "../../util/record.h" #include "../../util/auxtrace.h" #include "../../util/cpumap.h" +#include "../../util/event.h" #include "../../util/evlist.h" #include "../../util/evsel.h" #include "../../util/pmu.h" @@ -254,7 +255,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; struct evsel *evsel, *cs_etm_evsel = NULL; struct perf_cpu_map *cpus = evlist->core.cpus; - bool privileged = (geteuid() == 0 || perf_event_paranoid() < 0); + bool privileged = perf_event_paranoid_check(-1); int err = 0; ptr->evlist = evlist; diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c index cdd5c0c..c7b38f0 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -12,6 +12,7 @@ #include #include "../../util/cpumap.h" +#include "../../util/event.h" #include "../../util/evsel.h" #include "../../util/evlist.h" #include "../../util/session.h" @@ -67,7 +68,7 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, container_of(itr, struct arm_spe_recording, itr); struct perf_pmu *arm_spe_pmu = sper->arm_spe_pmu; struct evsel *evsel, *arm_spe_evsel = NULL; - bool privileged = geteuid() == 0 || perf_event_paranoid() < 0; + bool privileged = perf_event_paranoid_check(-1); struct evsel *tracking_evsel; int err; diff --git a/tools/perf/arch/x86/util/intel-bts.c b/tools/perf/arch/x86/util/intel-bts.c index 1f2cf61..16d26ea 100644 --- a/tools/perf/arch/x86/util/intel-bts.c +++ b/tools/perf/arch/x86/util/intel-bts.c @@ -12,6 +12,7 @@ #include #include "../../util/cpumap.h" +#include "../../util/event.h" #include "../../util/evsel.h" #include "../../util/evlist.h" #include "../../util/session.h" @@ -108,7 +109,7 @@ static int intel_bts_recording_options(struct auxtrace_record *itr, struct perf_pmu *intel_bts_pmu = btsr->intel_bts_pmu; struct evsel *evsel, *intel_bts_evsel = NULL; const struct perf_cpu_map *cpus = evlist->core.cpus; - bool privileged = geteuid() == 0 || perf_event_paranoid() < 0; + bool privileged = perf_event_paranoid_check(-1); btsr->evlist = evlist; btsr->snapshot_mode = opts->auxtrace_snapshot_mode; diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c index 44cfe72..746981c 100644 --- a/tools/perf/arch/x86/util/intel-pt.c +++ b/tools/perf/arch/x86/util/intel-pt.c @@ -579,7 +579,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, bool have_timing_info, need_immediate = false; struct evsel *evsel, *intel_pt_evsel = NULL; const struct perf_cpu_map *cpus = evlist->core.cpus; - bool privileged = geteuid() == 0 || perf_event_paranoid() < 0; + bool privileged = perf_event_paranoid_check(-1); u64 tsc_bit; int err; diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index fa67635..7c704b8 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -282,7 +282,7 @@ struct evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx) static bool perf_event_can_profile_kernel(void) { - return geteuid() == 0 || perf_event_paranoid() == -1; + return perf_event_paranoid_check(-1); } struct evsel *perf_evsel__new_cycles(bool precise)