Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2469020ybl; Mon, 20 Jan 2020 03:35:03 -0800 (PST) X-Google-Smtp-Source: APXvYqxnIRIMk+oaJkkAN4rF7BN79ZDu78aVEaAIzGOnBHN/P8kajwMtTxZTgCmmgSATm/MCyyg9 X-Received: by 2002:a05:6830:1481:: with SMTP id s1mr12228467otq.66.1579520103736; Mon, 20 Jan 2020 03:35:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579520103; cv=none; d=google.com; s=arc-20160816; b=KbQBbSuZhgyWrGkZXuYX9v5MR4UY6T/UZcOpjUijdIdU8IzSwGqNqhWmkvWpBGhbkX fFCMSgXQVfRnn9oZSMIaqI5yg2LfK5Xl/UlHSGSxuWXEhq6+S9EHto0Gv4iXTmps9IaT VwoeexbhHY6Omi5/Vk70N7nJRFypKAxiqPpCZlmEudMrPPHb8kfRw4hasWxnQ5yvnRJX FnPUF5Q6WM+L/Pefw2uN6m4UFHw4j+ugFAz9zuOUQD/KV7UFNBpvDtFv3wPVHQqVPRf0 WftSMf6zgldkMK6PKqbsNI6FBPLMi2aHFQd2JPlOebwoCtTcS1A4qG3nI+PKK9TCjcE4 qHGQ== 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=mGdgZoMsOULDn8XJ7BzCCSm6MKyfF9IusbjrfwdT52I=; b=v6fhJC1m/r18HpoC9SCWaqmV7xQlvk76kZgtWKE2L5FxGAdjzgImVRDhBQz0+umQ9e 5/Um5Ag+qKve/Y9DAT6DUj9b1bheqLnMfezuw7vfEe2rc7m8J6eLCa6QMh0gQpXZwwcd C8nIYSmA+tThT+6DMJmatiaZGPuzYG/uyQG+P89q1EKIRR0siPiGN67ie8aa9mAcSmBz HX4cX2ot99Qj+Es8UdiE2MAfuEnUjPBNYP5fTSpUnKcHxoNocH+rNzBiec4uDUgFDTuL rm38Lx/nxwYlPxSfdW/WXyoyBayqYgJunr5w8TbJTZDX3yzA6/wrZEpH72QDQpzG+7l7 EJgg== 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 m20si20409193otk.279.2020.01.20.03.34.51; Mon, 20 Jan 2020 03:35:03 -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 S1726991AbgATLdx (ORCPT + 99 others); Mon, 20 Jan 2020 06:33:53 -0500 Received: from mga01.intel.com ([192.55.52.88]:50762 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbgATLdw (ORCPT ); Mon, 20 Jan 2020 06:33:52 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jan 2020 03:33:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,341,1574150400"; d="scan'208";a="374296392" Received: from linux.intel.com ([10.54.29.200]) by orsmga004.jf.intel.com with ESMTP; 20 Jan 2020 03:33:52 -0800 Received: from [10.125.252.193] (abudanko-mobl.ccr.corp.intel.com [10.125.252.193]) by linux.intel.com (Postfix) with ESMTP id E511D5803C5; Mon, 20 Jan 2020 03:33:43 -0800 (PST) Subject: [PATCH v5 10/10] drivers/oprofile: open access for CAP_PERFMON privileged process From: Alexey Budankov To: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , "jani.nikula@linux.intel.com" , "joonas.lahtinen@linux.intel.com" , "rodrigo.vivi@intel.com" , "benh@kernel.crashing.org" , Paul Mackerras , Michael Ellerman , "james.bottomley@hansenpartnership.com" , Serge Hallyn , James Morris , Will Deacon , Mark Rutland , Robert Richter , Alexei Starovoitov Cc: Jiri Olsa , Andi Kleen , Stephane Eranian , Igor Lubashev , Alexander Shishkin , Namhyung Kim , Song Liu , Lionel Landwerlin , Thomas Gleixner , linux-kernel , "linux-security-module@vger.kernel.org" , "selinux@vger.kernel.org" , "intel-gfx@lists.freedesktop.org" , "linux-parisc@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , linux-arm-kernel@lists.infradead.org, "linux-perf-users@vger.kernel.org" , oprofile-list@lists.sf.net References: <0548c832-7f4b-dc4c-8883-3f2b6d351a08@linux.intel.com> Organization: Intel Corp. Message-ID: <196ea578-5079-a27f-07ca-23df0e38485c@linux.intel.com> Date: Mon, 20 Jan 2020 14:33:42 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <0548c832-7f4b-dc4c-8883-3f2b6d351a08@linux.intel.com> 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 processes. 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. Providing the access under CAP_PERFMON capability singly, without the rest of CAP_SYS_ADMIN credentials, excludes chances to misuse the credentials and makes the operations more secure. 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