Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3538109ybz; Mon, 20 Apr 2020 04:56:07 -0700 (PDT) X-Google-Smtp-Source: APiQypIdDx8MLuxB3h3js+gTpJK0IOYzJKVDu30JViq0YugGFHRxviFOhD5P10jGJk/lb7TcNYNX X-Received: by 2002:a17:906:da1b:: with SMTP id fi27mr15548390ejb.194.1587383766983; Mon, 20 Apr 2020 04:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587383766; cv=none; d=google.com; s=arc-20160816; b=IbwTqtPF2zxeTO2lM+0+HD9H0zEsZAuoBi0ahSVdkksXORrAiL27jfzErHU7hzn3mD aZWJySdp0/pT9n0FXA6cmkHPsTFXK68Vy6uqJ/+N1Q/SAUPP+cb4qru4N/jqzNjv4mTZ uLYhs03ZWxd0r0Yhm9d2XMTxVGnP9F3qa5kVj+5B9YPeqcGrWuFWaHMYPTZywqNDlrWf 13nUKxXDMqyINy/++XtDTahmG97d9780vXQgP8W/ldE0tDgL+qBhhmp87WlLfxI9MEmu h8/DVIeq0/Iq1YsA43le/wnbdKrhAsGywvtnrE074b/QZt5K3vmMQ+9W/djGbfDiXaMt A6Bw== 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=UYYE7XON8BrmgJHgDQ//ORN/2HjKBHnltLi+0IMna00=; b=BRxe7oxeo0ZAC/zuqfvXTugdA1ZoiJs/ApI4R0Dd2gm3vTe7BaO65PA/95KaCPUOaD 9HKkAb4NF/gD2HxTTtaWNmZb68b9D0+LVCP7KN/Qw2+MlPGrCcOzE2NsRbPgrU4IPP4R 5+3u/ioX8D9oLsQETWxR3/Q+YkTiOx1XPHjb4flJx9GOmx3L69NZKaemEh0OXrxBem8w 3gn1tFcFFcyUT/Fw0GB4kZAZ3JAEAwWLQnVIx4BuWw/SYMryYnJyeVb6DUUlmHpvBRg3 BsYyk+kbNorXmf4K0+OysbB694csXBVV8nzamceNhJmPRWbNn0sA+w+iFbLOfG3JSXSG iCRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1kGbFMlV; 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 ba27si381557edb.586.2020.04.20.04.55.43; Mon, 20 Apr 2020 04:56:06 -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=1kGbFMlV; 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 S1726735AbgDTLyS (ORCPT + 99 others); Mon, 20 Apr 2020 07:54:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:37862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbgDTLyR (ORCPT ); Mon, 20 Apr 2020 07:54:17 -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 72CBD2223D; Mon, 20 Apr 2020 11:54:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587383656; bh=iEHcbd3dsEh+nbBrF8hA7DMxqrfUdFplqLITI+edP6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1kGbFMlV8el+e/SiyC20aoUKm7KCmmcWzC0NCYLBNYBAb+FnkpxtWCYse/Xqrtsu6 2NDEg5qs/wtl0DWBL7RDY4YF23woE7ziJLEoSVANBnqvAAE3otm6HOPS5pgeT31L2l 6lda91V/cLs5kDaC9Dp8mfjaXG3WDy2R6MwTXWgI= 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 , Song Liu , Alexei Starovoitov , Andi Kleen , Igor Lubashev , Jiri Olsa , Peter Zijlstra , Serge Hallyn , 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 10/60] trace/bpf_trace: Open access for CAP_PERFMON privileged process Date: Mon, 20 Apr 2020 08:52:26 -0300 Message-Id: <20200420115316.18781-11-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 bpf_trace 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 bpf_trace monitoring remains open for CAP_SYS_ADMIN privileged processes but CAP_SYS_ADMIN usage for secure bpf_trace monitoring is discouraged with respect to CAP_PERFMON capability. Signed-off-by: Alexey Budankov Reviewed-by: James Morris Acked-by: Song Liu Cc: Alexei Starovoitov Cc: Andi Kleen Cc: Igor Lubashev Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Serge Hallyn 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/c0a0ae47-8b6e-ff3e-416b-3cd1faaf71c0@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- kernel/trace/bpf_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index ca1796747a77..d7d88007dc6d 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -1468,7 +1468,7 @@ int perf_event_query_prog_array(struct perf_event *event, void __user *info) u32 *ids, prog_cnt, ids_len; int ret; - if (!capable(CAP_SYS_ADMIN)) + if (!perfmon_capable()) return -EPERM; if (event->attr.type != PERF_TYPE_TRACEPOINT) return -EINVAL; -- 2.21.1