Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4508419ybv; Mon, 17 Feb 2020 00:12:48 -0800 (PST) X-Google-Smtp-Source: APXvYqxYGWIZ9sck2e9JvvdgoVU21z/UiOk+gIu8Xlp5Wg2Z7kXsP5y9aHpUS8JVc7J6AKddwu+S X-Received: by 2002:a9d:7607:: with SMTP id k7mr11137330otl.205.1581927168511; Mon, 17 Feb 2020 00:12:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581927168; cv=none; d=google.com; s=arc-20160816; b=QHWfd3snQIQcZd2iNFHoe04cIVPwiVY0X4P+LT9n+PJjkfxMPVL+F5v0IZdrm1r4YJ p2acmG9ZlSwQlS6EBwP/XCOS6nBjv0l0umRh+kG4YTaOvN9khcZ5lLsJef2M7ywnpodS nPVD87yzpWR6jQqdmN4GjadOHYpoVugfYTT6VhhntbByKwCU3sDmBQ6u77qO20ZpsuSq rAXu5wYfjXGQkXuTJRYnh90yhzjRALToAR2VxI3P7I9OSFBy52SSX4zLuOJarA64H3Vy tVltoC2GhQEnR5dWA2VrQUkk8/xA2kkVk8ukew0xhR5JDh4q/cHFovw/yGKP/847Lb9P 6CMw== 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=x60lxbWpTN9HPfHhL4HJBegMvu2tSon9h58gyfvgFUg=; b=f0FmIWqWkxdpnCgHjGzhpEUHFNqLYVzn8GmKBNTl+MJhHV2a9Og3nDNuSZL+xD9x68 nCanSLW/XNRc+jxm32IuwNCfHLFlgwJ6EqB9C3ox+oc59SeVDF+zLkQc812ewdE9F1wD L+F5Q/jeyZJsn6ME3X1kzco965YbKKS0Ko0DFidW5qWVs9GSytuwVDkgAVpoh1OfPNSb CLgjCeaA9ODoTXlj6VTq9/ySo8AMU4fxN1zo6NS6MKQigQFGj+GYB1G6YZHZdEYqwmJy JkE/eYJzn4TAjZ1ToX63kGVPlTzefnkMsdlfcL5AG9In4CCKyMaq81vL8GAPM6smIgcL jDIA== 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 5si6050721oir.9.2020.02.17.00.12.36; Mon, 17 Feb 2020 00:12:48 -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 S1727953AbgBQIMS (ORCPT + 99 others); Mon, 17 Feb 2020 03:12:18 -0500 Received: from mga11.intel.com ([192.55.52.93]:17774 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726414AbgBQIMS (ORCPT ); Mon, 17 Feb 2020 03:12:18 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Feb 2020 00:12:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,451,1574150400"; d="scan'208";a="258193483" Received: from linux.intel.com ([10.54.29.200]) by fmsmga004.fm.intel.com with ESMTP; 17 Feb 2020 00:12:17 -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 11B485804A2; Mon, 17 Feb 2020 00:12:10 -0800 (PST) Subject: [PATCH v7 10/12] drivers/oprofile: 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: <046beedf-e074-58e2-579d-df535799169c@linux.intel.com> Date: Mon, 17 Feb 2020 11:12:09 +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 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 the monitoring remains open for CAP_SYS_ADMIN privileged processes but CAP_SYS_ADMIN usage for secure monitoring is discouraged with respect to CAP_PERFMON capability. Signed-off-by: Alexey Budankov --- drivers/oprofile/event_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c index 12ea4a4ad607..6c9edc8bbc95 100644 --- a/drivers/oprofile/event_buffer.c +++ b/drivers/oprofile/event_buffer.c @@ -113,7 +113,7 @@ static int event_buffer_open(struct inode *inode, struct file *file) { int err = -EPERM; - if (!capable(CAP_SYS_ADMIN)) + if (!perfmon_capable()) return -EPERM; if (test_and_set_bit_lock(0, &buffer_opened)) -- 2.20.1