From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D328C3A59F for ; Tue, 27 Aug 2019 01:40:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CDC5520679 for ; Tue, 27 Aug 2019 01:40:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=akamai.com header.i=@akamai.com header.b="gQHKUvmD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728925AbfH0BkS (ORCPT ); Mon, 26 Aug 2019 21:40:18 -0400 Received: from mx0a-00190b01.pphosted.com ([67.231.149.131]:22068 "EHLO mx0a-00190b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728415AbfH0BkR (ORCPT ); Mon, 26 Aug 2019 21:40:17 -0400 Received: from pps.filterd (m0050093.ppops.net [127.0.0.1]) by m0050093.ppops.net-00190b01. (8.16.0.42/8.16.0.42) with SMTP id x7R1d6cW024326; Tue, 27 Aug 2019 02:39:52 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=jan2016.eng; bh=AaB69LG/tvAxdlZlHAdqM09oq7QNiLPUdC6f71MsOHs=; b=gQHKUvmDK6aEHkqySbrfW26+eRYxMu4iEg97y8fxGH2o2MyBiVmIKYerkvrXZlyhr7zF cAOmEKR7VChOH6fQ+Fsw7+Eltp0+FPuN4NvNV4qMc1p2PIMjs5WTuuiAzLfFVZI5r2C4 Gh0gJJX4wSVV0WShGRZNA3rOrZRp9NzXrJ/3B8Bfue19qRjBTagcDW1AxLV6bW1w5sX0 dA5YzWO0NjBl2qlnhBlrXhqXNxCATKU8kKx0CR6Cp8iPWoLWesSH+FZOHoPAoWGD7ezG KjZxNmODLjriytWvEZ1Wm7QsqaaqVDNJ/Kj5LzQCO/FIpNUcdlaewOenw5wVMVcl0wPP tw== Received: from prod-mail-ppoint2 (prod-mail-ppoint2.akamai.com [184.51.33.19] (may be forged)) by m0050093.ppops.net-00190b01. with ESMTP id 2ujwcmatk9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Aug 2019 02:39:52 +0100 Received: from pps.filterd (prod-mail-ppoint2.akamai.com [127.0.0.1]) by prod-mail-ppoint2.akamai.com (8.16.0.27/8.16.0.27) with SMTP id x7R1VppD032032; Mon, 26 Aug 2019 21:39:50 -0400 Received: from email.msg.corp.akamai.com ([172.27.123.32]) by prod-mail-ppoint2.akamai.com with ESMTP id 2uk0jvvcu8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 26 Aug 2019 21:39:50 -0400 Received: from usma1ex-cas5.msg.corp.akamai.com (172.27.123.53) by usma1ex-dag1mb2.msg.corp.akamai.com (172.27.123.102) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 26 Aug 2019 21:39:50 -0400 Received: from igorcastle.kendall.corp.akamai.com (172.29.170.135) by usma1ex-cas5.msg.corp.akamai.com (172.27.123.53) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Mon, 26 Aug 2019 18:39:44 -0700 Received: by igorcastle.kendall.corp.akamai.com (Postfix, from userid 29659) id 4B37B64C0F; Mon, 26 Aug 2019 21:39:41 -0400 (EDT) From: Igor Lubashev To: Jiri Olsa , Arnaldo Carvalho de Melo , Mathieu Poirier CC: Igor Lubashev , Alexander Shishkin , Alexey Budankov , James Morris , Namhyung Kim , Peter Zijlstra , Suzuki Poulouse , , Linux Kernel Mailing List Subject: [PATCH 4/5] perf symbols: Use CAP_SYSLOG with kptr_restrict checks Date: Mon, 26 Aug 2019 21:39:15 -0400 Message-ID: <1566869956-7154-5-git-send-email-ilubashe@akamai.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1566869956-7154-1-git-send-email-ilubashe@akamai.com> References: <1566869956-7154-1-git-send-email-ilubashe@akamai.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-26_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908270014 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-26_08:2019-08-26,2019-08-26 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 clxscore=1015 adultscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1908270015 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel is using CAP_SYSLOG capability instead of uid==0 and euid==0 when checking kptr_restrict. Make perf do the same. Also, the kernel is a more restrictive than "no restrictions" in case of kptr_restrict==0, so add the same logic to perf. Signed-off-by: Igor Lubashev Cc: Jiri Olsa Cc: Alexander Shishkin Cc: Alexey Budankov Cc: James Morris Cc: Mathieu Poirier Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Suzuki Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/291d2cda6ee75b4cd4c9ce717c177db18bf03a31.1565188228.git.ilubashe@akamai.com Cc: Arnaldo Carvalho de Melo --- tools/perf/util/symbol.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 4efde7879474..035f2e75728c 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -15,8 +16,10 @@ #include #include "annotate.h" #include "build-id.h" +#include "cap.h" #include "util.h" #include "debug.h" +#include "event.h" #include "machine.h" #include "map.h" #include "symbol.h" @@ -2195,13 +2198,19 @@ static bool symbol__read_kptr_restrict(void) char line[8]; if (fgets(line, sizeof(line), fp) != NULL) - value = ((geteuid() != 0) || (getuid() != 0)) ? - (atoi(line) != 0) : - (atoi(line) == 2); + value = perf_cap__capable(CAP_SYSLOG) ? + (atoi(line) >= 2) : + (atoi(line) != 0); fclose(fp); } + /* Per kernel/kallsyms.c: + * we also restrict when perf_event_paranoid > 1 w/o CAP_SYSLOG + */ + if (perf_event_paranoid() > 1 && !perf_cap__capable(CAP_SYSLOG)) + value = true; + return value; } -- 2.7.4