Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1874142ybl; Thu, 5 Dec 2019 08:20:44 -0800 (PST) X-Google-Smtp-Source: APXvYqziuNCQ3LSrenZuGaD/31Nj1mwCURdsqaASeqnYgo7b1x/GjLn5UdDhwTbBz78sZL+kE1RO X-Received: by 2002:aca:520b:: with SMTP id g11mr1506440oib.167.1575562844789; Thu, 05 Dec 2019 08:20:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575562844; cv=none; d=google.com; s=arc-20160816; b=fnsbEGNRXha11oqA8plBktrvQn7Qtnhd2gBZyN0FmZZ566qAzw11JDWFVg83sYFuvc JoI+eB/MG7qtbhJv8FiABvbcU3ZjiTz5zxhRXJZ+nlLEHFKLga8inBpZ97qajDX4fo6r 56GbPAAthXkoxO02UG+mbPRiZUYIT3NiwbFStP+hoCTO6htrC0k2QZgxqYL9Jpmma6Oq 37U4PNPDI1vseNL2TClaz4vFOjn9aUIaDKs5nky3ezSZpj/XckNMhvUrcC+sJPJo3gWn T01G5c8f8a0yiSZPRDdcNQxj6A1FhYI1oG78vIQN6MzChGxqEbjqcArAe+IM8v/ylnog 4Szg== 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=gnp4ARVnyajM8mmWQoyllTks84xZO3b6kLrQyljXUa0=; b=Pdn21Z9yhGOmleOBo4XVQps/lJtWM1rw2P690+NQ9mbsYOEH6Iz3jaU72i+SrR/5XJ mQZdEIQYddmOZ/2OqfXjzA16amXd+dujE0PUTMhlrbTGfkx9Go5ETepyBU0shbaSgfOb TzB/T5UDtgvSgPRXmOwih0wgjVGNV+lBn+QLCKYvpjmElhULLdLySTsAfgeRzOMytthr JxZqu2QbrwOPGG9nIon0MweSnVS6Hg2U5hxhbtIWlwmXg6zVWf5Sg4+aY599eLy6PmrG keOW2NgUSzSCc1s3raJQxVs0zqw4Xxb2XfOsz5Hr0LKdKqLD7t3B9t3vfJPKIB+PaFyv O1MQ== 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 u131si3743254oib.257.2019.12.05.08.20.31; Thu, 05 Dec 2019 08:20:44 -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 S1729540AbfLEQUD (ORCPT + 99 others); Thu, 5 Dec 2019 11:20:03 -0500 Received: from mga17.intel.com ([192.55.52.151]:55878 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbfLEQUC (ORCPT ); Thu, 5 Dec 2019 11:20:02 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Dec 2019 08:19:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,281,1571727600"; d="scan'208";a="223685585" Received: from linux.intel.com ([10.54.29.200]) by orsmga002.jf.intel.com with ESMTP; 05 Dec 2019 08:19:55 -0800 Received: from [10.125.252.254] (abudanko-mobl.ccr.corp.intel.com [10.125.252.254]) by linux.intel.com (Postfix) with ESMTP id 446C0580418; Thu, 5 Dec 2019 08:19:52 -0800 (PST) Subject: [PATCH v1 1/3] capabilities: introduce CAP_SYS_PERFMON to kernel and user space From: Alexey Budankov To: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar Cc: Jiri Olsa , Andi Kleen , elena.reshetova@intel.com, Alexander Shishkin , Jann Horn , Kees Cook , Stephane Eranian , Namhyung Kim , linux-security-module@vger.kernel.org, selinux@vger.kernel.org, linux-kernel References: <283f09a5-33bd-eac3-bdfd-83d775045bf9@linux.intel.com> Organization: Intel Corp. Message-ID: <4ebe4d05-85c3-20dc-89a4-ed8f052d586e@linux.intel.com> Date: Thu, 5 Dec 2019 19:19:51 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <283f09a5-33bd-eac3-bdfd-83d775045bf9@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 Introduce CAP_SYS_PERFMON capability dedicated to secure performance monitoring activity so that CAP_SYS_PERFMON would assist CAP_SYS_ADMIN capability in its governing role for perf_events based performance monitoring of a system. CAP_SYS_PERFMON aims to harden system security and integrity during performance monitoring by decreasing attack surface that is available to CAP_SYS_ADMIN privileged processes. CAP_SYS_PERFMON aims to take over CAP_SYS_ADMIN credentials related to performance monitoring functionality of perf_events and balance amount of CAP_SYS_ADMIN credentials in accordance with the recommendations provided in the man page for CAP_SYS_ADMIN [3]: "Note: this capability is overloaded; see Notes to kernel developers, below." Signed-off-by: Alexey Budankov --- include/uapi/linux/capability.h | 10 +++++++++- security/selinux/include/classmap.h | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/capability.h b/include/uapi/linux/capability.h index 240fdb9a60f6..c9514f034be1 100644 --- a/include/uapi/linux/capability.h +++ b/include/uapi/linux/capability.h @@ -366,8 +366,16 @@ struct vfs_ns_cap_data { #define CAP_AUDIT_READ 37 +/* + * Allow usage of perf_event_open() syscall (perf_events subsystem): + * http://man7.org/linux/man-pages/man2/perf_event_open.2.html + * beyond the scope permitted by perf_event_paranoid kernel setting. + * See Documentation/admin-guide/perf-security.rst for more information. + */ + +#define CAP_SYS_PERFMON 38 -#define CAP_LAST_CAP CAP_AUDIT_READ +#define CAP_LAST_CAP CAP_SYS_PERFMON #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP) diff --git a/security/selinux/include/classmap.h b/security/selinux/include/classmap.h index 7db24855e12d..bae602c623b0 100644 --- a/security/selinux/include/classmap.h +++ b/security/selinux/include/classmap.h @@ -27,9 +27,9 @@ "audit_control", "setfcap" #define COMMON_CAP2_PERMS "mac_override", "mac_admin", "syslog", \ - "wake_alarm", "block_suspend", "audit_read" + "wake_alarm", "block_suspend", "audit_read", "sys_perfmon" -#if CAP_LAST_CAP > CAP_AUDIT_READ +#if CAP_LAST_CAP > CAP_SYS_PERFMON #error New capability defined, please update COMMON_CAP2_PERMS. #endif -- 2.20.1