Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4506728ybv; Mon, 17 Feb 2020 00:10:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzN+IFXz0F2Lqke2+8pmhjKuaxU5IA5KTvS+aGVxwoNsctwssk8lr60cHjGLQ97mOGdu0Ve X-Received: by 2002:a9d:24c8:: with SMTP id z66mr11549561ota.52.1581927026431; Mon, 17 Feb 2020 00:10:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581927026; cv=none; d=google.com; s=arc-20160816; b=rYonjF89Yv2UJh731AT1FLs4xLwEgGA3xZap94dks6XxzhAlVEBj3bGyiVquvsIC0U 17sq3CnviiAjwTIgJ7gyWhmhbbeXMRCsI+8w8GVhYk8iMIkB3NANVWfL4d4bz4Rx614N TWEDl2ldFW/Xr1u2zGRJxvWkiBaHzmUo4tGDFK7lN5+wF0byzg+fdrnuX3TTUC9flVsM MtH7ErbbMPSyw7ZTHVB0c1Aw0njW8LMZ28efKH1xLim4Ckfqvhk3Q/k4C71EAS4NeDkf mMzSapNsSSf9bu+9vzBgPKD+wZ5Sa8GgGxG5wHBP+GdD8wmWNioSaj9Xrdjzb5A5PegW rgbA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:references:cc:to:from:subject; bh=aWcBKTuKkvb69Kjpi+7bUyQtc7icp4InljQsKYBibEU=; b=M7jfWBmTmoumZGDXVP4DsgGDWy63iv5MKfm2OQIewT3M4MbDvqmaDxUCnhqAvVyK5a /4jxNd1dPXUub4ekYsjvOLe8t6iTcGlTUP6S1q9RcQPT63GuFeLMm2X1YefWxVhrDpXu yaxIgwosz9uWJfCLegTQuHafdg9puMX+XPSK6uCdACleBA9l29xFv3DXaQpWMinesy6Z mgaQ2bFyzsz42ZlI5KFR9WWIKGyAbOnXN/bOPJjzaJzE4gQlugMidqdRpK8PUhZwo5uD mLqissq2dpEuGrQcjxELDm/W68SbqGSAYwRuwLRir5C3IP5laDxvfl2SSUpWuKq6IvkY /jdQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si6662015oth.182.2020.02.17.00.10.14; Mon, 17 Feb 2020 00:10:26 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727576AbgBQIJi (ORCPT + 99 others); Mon, 17 Feb 2020 03:09:38 -0500 Received: from mga11.intel.com ([192.55.52.93]:17567 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726932AbgBQIJh (ORCPT ); Mon, 17 Feb 2020 03:09:37 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Feb 2020 00:09:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,451,1574150400"; d="scan'208";a="229122673" Received: from linux.intel.com ([10.54.29.200]) by fmsmga008.fm.intel.com with ESMTP; 17 Feb 2020 00:09:36 -0800 Received: from [10.125.252.180] (abudanko-mobl.ccr.corp.intel.com [10.125.252.180]) by linux.intel.com (Postfix) with ESMTP id 8F97A5804A2; Mon, 17 Feb 2020 00:09:30 -0800 (PST) Subject: [PATCH v7 06/12] trace/bpf_trace: open access for CAP_PERFMON privileged process From: Alexey Budankov To: James Morris , Serge Hallyn , Stephen Smalley , Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , "joonas.lahtinen@linux.intel.com" , Alexei Starovoitov , Will Deacon , Paul Mackerras , Helge Deller , Thomas Gleixner Cc: Andi Kleen , Stephane Eranian , Igor Lubashev , Jiri Olsa , linux-kernel , "intel-gfx@lists.freedesktop.org" , "linux-security-module@vger.kernel.org" , "selinux@vger.kernel.org" , linux-arm-kernel , "linuxppc-dev@lists.ozlabs.org" , "linux-parisc@vger.kernel.org" , oprofile-list@lists.sf.net, "linux-doc@vger.kernel.org" , linux-man@vger.kernel.org References: Organization: Intel Corp. Message-ID: Date: Mon, 17 Feb 2020 11:09:29 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Open access to bpf_trace monitoring for CAP_PERFMON privileged process. Providing the access under CAP_PERFMON capability singly, without the rest of CAP_SYS_ADMIN credentials, excludes chances to misuse the credentials and makes operation more secure. CAP_PERFMON implements the principal of least privilege for performance monitoring and observability operations (POSIX IEEE 1003.1e 2.2.2.39 principle of least privilege: A security design principle that states that a process or program be granted only those privileges (e.g., capabilities) necessary to accomplish its legitimate function, and only for the time that such privileges are actually required) For backward compatibility reasons access to bpf_trace monitoring remains open for CAP_SYS_ADMIN privileged processes but CAP_SYS_ADMIN usage for secure bpf_trace monitoring is discouraged with respect to CAP_PERFMON capability. Signed-off-by: Alexey Budankov --- kernel/trace/bpf_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 19e793aa441a..70e8249eebe5 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -1416,7 +1416,7 @@ int perf_event_query_prog_array(struct perf_event *event, void __user *info) u32 *ids, prog_cnt, ids_len; int ret; - if (!capable(CAP_SYS_ADMIN)) + if (!perfmon_capable()) return -EPERM; if (event->attr.type != PERF_TYPE_TRACEPOINT) return -EINVAL; -- 2.20.1