Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3538237ybz; Mon, 20 Apr 2020 04:56:17 -0700 (PDT) X-Google-Smtp-Source: APiQypLwC64g1n4B5X3ipCB83hoGBKcVU1CgDKyOtXlFw/VhRW4qPtrJMNxzQ3+UybZRMW3FdVjT X-Received: by 2002:a17:906:6a92:: with SMTP id p18mr15947474ejr.351.1587383777723; Mon, 20 Apr 2020 04:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587383777; cv=none; d=google.com; s=arc-20160816; b=d3Mo0R2pNLMKymXOoSy4H6VBp8pEbdGRewOFHxJ3IEUuo8R98PRWKkTJJPwIT9rMYV jtjT42csfz5hqXntLZfj12VPUpWiQYqYEVvvohhTZ2fYvaMWGCCZnIaz6pWW0qkBotkF 6p7aZL1i3EqM0wXCgSOqP0PLV77plRRftIBDa+bxrK3QopuzSTF/akXJ0JSW4/IedIAu IlJurnaF2vXPswm5NGjgB/FVHS5iY2NG7PZVwyCuOgQKF+g0HpN+ZbrTB5JAdGj36mQI o/yruIyBWrWyrx0NFr0R7XXQ1LQaj+KqqoAnV4a1GXEAAVEcy7A8OLuwJ7jP9E6GCg6G mLnw== 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=5QqlNZ/gUKcdeiWDtdfbKoWIpzC+5zpYwShTHEOG2sU=; b=Ve4rmvrag9ZBd4gyydyTNMI2v7aD3HuRSicVaNIwBTKbqoh853CbjdWAHZKMZNsVG1 1df0BLGo9KLqsNHMO97SNz+N06n19D6LR2itHnw65/AI+pwXV1oiOkmiBcay00mR2vQx ivL6TFKo4UZKxUFDcORZzrRyyMjgP560q1oAOzwAUTMVVEWEphoZ2K16pjFbe75nIyuM GgACWXdGYHwVqASSKhNWfR2ZQQNo+v0nqNi4sRC9yYasM0kLHzgKM7FXJqWQCeXyAkRA PaHkN7NqAi0rUhqA91ILkBZLAFjfBIDZCzpU+jc53xkAH5IY0AUx77NZRobQ/uxNDif9 tduA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VXwto54s; 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 p16si399683eja.354.2020.04.20.04.55.54; Mon, 20 Apr 2020 04:56:17 -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=VXwto54s; 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 S1726752AbgDTLyY (ORCPT + 99 others); Mon, 20 Apr 2020 07:54:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:38068 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbgDTLyX (ORCPT ); Mon, 20 Apr 2020 07:54:23 -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 0969C21D94; Mon, 20 Apr 2020 11:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587383662; bh=BOa5Mw0/hpw+98z21+6ed6jZc+vUnN9uwr6UPY2Ps1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VXwto54smORPjo0Ke2LCHi8I/iZHqIoqAIdoHvug3M0BQDLEWe1njfHDGO98wHT+A eIwqkCs5YR8BVWAyu9kGhiVBI6Sys36FvQE0MuLfs+vEUWVECE7Gt8b5MN+EAeLO57 FBgxuPhdNbgEHCzbXSUh9vCwk2eU8ljKMe0c1otI= 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 , Anju T Sudhakar , 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 11/60] powerpc/perf: open access for CAP_PERFMON privileged process Date: Mon, 20 Apr 2020 08:52:27 -0300 Message-Id: <20200420115316.18781-12-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: Anju T Sudhakar 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/ac98cd9f-b59e-673c-c70d-180b3e7695d2@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- arch/powerpc/perf/imc-pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c index eb82dda884e5..0edcfd0b491d 100644 --- a/arch/powerpc/perf/imc-pmu.c +++ b/arch/powerpc/perf/imc-pmu.c @@ -976,7 +976,7 @@ static int thread_imc_event_init(struct perf_event *event) if (event->attr.type != event->pmu->type) return -ENOENT; - if (!capable(CAP_SYS_ADMIN)) + if (!perfmon_capable()) return -EACCES; /* Sampling not supported */ @@ -1412,7 +1412,7 @@ static int trace_imc_event_init(struct perf_event *event) if (event->attr.type != event->pmu->type) return -ENOENT; - if (!capable(CAP_SYS_ADMIN)) + if (!perfmon_capable()) return -EACCES; /* Return if this is a couting event */ -- 2.21.1