Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3538270ybz; Mon, 20 Apr 2020 04:56:20 -0700 (PDT) X-Google-Smtp-Source: APiQypJOm355h6gUXtg6wA6P2zgJzaHV6iaRsT4Pcjuo1xNYHcGsY889ETQaNS4fT2VoiFjCwMXq X-Received: by 2002:a50:85c4:: with SMTP id q4mr13042195edh.147.1587383780190; Mon, 20 Apr 2020 04:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587383780; cv=none; d=google.com; s=arc-20160816; b=H6eibjNxFhGKQKFm5oh5n1ngqB4qiOXsdAu9SXpJRsFAMcrpo7x9lGaQWzBPEpwhW+ idNZZwBQGoUbKdEZ3QwohfY7ujFv5KVMHKcdgqBKlvqIu+sN2SyrkPBfZ6X2VKdp5Spc kk/iZXMC3DbrmwCsH/QEd0d9oRwaUHo3r0/k4Bw3cwjiqiOPWkBk5j0MonqMH8EMtOWD b9ktv8924zZrCG3YN1hSJm9VZtgyYmEndTot7b1oDQ8ZZOL1PIocqkYYTmNi3NIBIdNg L4TTUbiUgHQQ3xiAKKgVZrud0pHgsAyLEoR7OQ11967sR4yI/7mhgSdBl5WFc4UyT0TR VWJw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ig+vQZRVbt5cNl/Ut33diNYcdKVt+88hVCfbosSoWps=; b=FWdegYZmXwoG0lmwtldrne77uMLNVl2MpyeUmz+8YjUpDVy/8rwUw71NAq22HWtEsg H2RYXPJzN5XN7LAXzBhVUX97n0c2yc9U7AkZOxh5yJwShJlO4NGMyUofv9OChD/RPDf0 JiPgR0ZTt4w/pYNmxiZ3YEcFYkT+7kWh12T75uN9LBZeTobiu4eOOKTOVuP1STecdQm+ npxqAbxm+ng/lc1ojcOv7AbWRtNGnolE/YRjKM7Tc8Xy9M5n322ZwBMtzAScjE3+Zx36 emzkAfsDIPzYGikagwcUCLKEy6CkMVOXwmKTMs1BFJc4WJkaqhE5yPoDT7VzMZAg9B/Z udeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jY2+DKBn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm19si408631edb.223.2020.04.20.04.55.57; Mon, 20 Apr 2020 04:56:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jY2+DKBn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726768AbgDTLya (ORCPT + 99 others); Mon, 20 Apr 2020 07:54:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:38178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbgDTLy3 (ORCPT ); Mon, 20 Apr 2020 07:54:29 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C666822242; Mon, 20 Apr 2020 11:54:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587383668; bh=PXwArPyrCB+9UYBajG3cuzXYyMjKBkArgtx7/t80yDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jY2+DKBnaUefdix+56HKfjrYAILqIoOTLoPXsBbJO0L5LInIgkVs0qCZ8Yg/fPUK6 2tHiRgmIfuIa7QGLClBjTGyAcjdggANZIOwqayLKQ6rqbpLiUXfkfQ3IMnDnMB6VXV 4rvqseNET+8Y/H4ZEnP/LkycQBSNV+sn3xrHLOaI= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Alexey Budankov , James Morris , Helge Deller , Alexei Starovoitov , Andi Kleen , Igor Lubashev , Jiri Olsa , Peter Zijlstra , Serge Hallyn , Song Liu , Stephane Eranian , intel-gfx@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-man@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, Arnaldo Carvalho de Melo Subject: [PATCH 12/60] parisc/perf: open access for CAP_PERFMON privileged process Date: Mon, 20 Apr 2020 08:52:28 -0300 Message-Id: <20200420115316.18781-13-acme@kernel.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200420115316.18781-1-acme@kernel.org> References: <20200420115316.18781-1-acme@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexey Budankov 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 principle 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 Reviewed-by: James Morris Acked-by: Helge Deller Cc: Alexei Starovoitov Cc: Andi Kleen Cc: Igor Lubashev Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Serge Hallyn Cc: Song Liu Cc: Stephane Eranian Cc: Thomas Gleixner Cc: intel-gfx@lists.freedesktop.org Cc: linux-doc@vger.kernel.org Cc: linux-man@vger.kernel.org Cc: linux-security-module@vger.kernel.org Cc: selinux@vger.kernel.org Link: http://lore.kernel.org/lkml/8cc98809-d35b-de0f-de02-4cf554f3cf62@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- arch/parisc/kernel/perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c index e1a8fee3ad49..d46b6709ec56 100644 --- a/arch/parisc/kernel/perf.c +++ b/arch/parisc/kernel/perf.c @@ -300,7 +300,7 @@ static ssize_t perf_write(struct file *file, const char __user *buf, else return -EFAULT; - if (!capable(CAP_SYS_ADMIN)) + if (!perfmon_capable()) return -EACCES; if (count != sizeof(uint32_t)) -- 2.21.1