Received: by 10.192.165.156 with SMTP id m28csp1729114imm; Thu, 12 Apr 2018 02:26:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx491gT1l9qy1RzgP68RBWDQfwxRXBOvdOIUzEAmAzjpSbYoQ6NIgMfO9dgLSJjkalzc0wOsz X-Received: by 2002:a17:902:b2c8:: with SMTP id x8-v6mr171570plw.83.1523525186761; Thu, 12 Apr 2018 02:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523525186; cv=none; d=google.com; s=arc-20160816; b=tHvvhkasSQ23kPJgKTxm+2VfYllFu8wKtwFNeKTxxHuRLMey34m+ON+cSHpBbNZTG/ MPzDU9/tqLuMBOCRHJEeOeg47kEkXPfCFAcYsGdAfx6t351ydj1uiIjxnSkWC/+Gyn6n qmKdKwIpFA/HE/Nd45G5+EKcdw0+f7RxFlk0pkvgIp9swo+QE0wqxdajG9i/ub0XcaSc ASCf2mje1Zl19Eq3fls/nStFVOxxwvPJ+1cwItiHaqDetfm0X8PuF88ZAuIE7tjHcDXX GUg++LpotJkxbu/8fjBymNog7EbaYqEPGdOVZcVo8ixTvSIqBgRJiklsGsxDvHzQCUDs qGaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=7DfcZlLtGQXGpCuQDGx5rGwbbvBj04RWXelKxx520Wg=; b=Ow8P8MouYDrmuSLcU0YjHgOVxE58Il9RqbPcdhtJHZVZMwvQMmxB3QAA6iGFIHMxQB JyVeGgmD0fY9oFkc9UxwEcbKyQ2iVPeYWVI8vgVom1coXK7O0F5/46UraE2QHbtuWJHB DLBMl/aJza2UHSIQzKdPttGkK9N6T9lwogY6XTrgayv7H7TllpZD6p6hjl2D3QNGDDI5 o784095dznTiWHHT+wHwSGGXLYfk7YmuolXaFQPlOQr4p2xqyreUdg9As8ykd9hG9fcw y8epGjmer97wqNWmdddgZBO9B30nzYIYmuh7DW33/SXQXUXUf0DUrkgz9zukHrAjO/66 UNDg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w187si2038746pgb.283.2018.04.12.02.25.49; Thu, 12 Apr 2018 02:26:26 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752746AbeDLJWp (ORCPT + 99 others); Thu, 12 Apr 2018 05:22:45 -0400 Received: from terminus.zytor.com ([198.137.202.136]:33941 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751583AbeDLJWo (ORCPT ); Thu, 12 Apr 2018 05:22:44 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w3C9MCMV3008060; Thu, 12 Apr 2018 02:22:12 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w3C9MBC13008057; Thu, 12 Apr 2018 02:22:11 -0700 Date: Thu, 12 Apr 2018 02:22:11 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Song Liu Message-ID: Cc: songliubraving@fb.com, mingo@kernel.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, hpa@zytor.com, vincent.weaver@maine.edu, tglx@linutronix.de, peterz@infradead.org Reply-To: linux-kernel@vger.kernel.org, songliubraving@fb.com, mingo@kernel.org, peterz@infradead.org, torvalds@linux-foundation.org, vincent.weaver@maine.edu, tglx@linutronix.de, hpa@zytor.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf/core: Need CAP_SYS_ADMIN to create k/uprobe with perf_event_open() Git-Commit-ID: 32e6e967fb36bf77ed99221ae3ce1909f045d8f9 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 32e6e967fb36bf77ed99221ae3ce1909f045d8f9 Gitweb: https://git.kernel.org/tip/32e6e967fb36bf77ed99221ae3ce1909f045d8f9 Author: Song Liu AuthorDate: Wed, 11 Apr 2018 18:02:37 +0000 Committer: Ingo Molnar CommitDate: Thu, 12 Apr 2018 09:55:50 +0200 perf/core: Need CAP_SYS_ADMIN to create k/uprobe with perf_event_open() Non-root user cannot create kprobe or uprobe through the text-based interface (kprobe_events, uprobe_events),so they should not be able to create probes via perf_event_open() either. Reported-by: Vince Weaver Signed-off-by: Song Liu Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Fixes: 33ea4b24277b ("perf/core: Implement the 'perf_uprobe' PMU") Fixes: e12f03d7031a ("perf/core: Implement the 'perf_kprobe' PMU") Link: http://lkml.kernel.org/r/C0B2EFB5-C403-4BDB-9046-C14B3EE66999@fb.com Signed-off-by: Ingo Molnar --- kernel/events/core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index d7af82827373..2d5fe26551f8 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -8400,6 +8400,10 @@ static int perf_kprobe_event_init(struct perf_event *event) if (event->attr.type != perf_kprobe.type) return -ENOENT; + + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; + /* * no branch sampling for probe events */ @@ -8437,6 +8441,10 @@ static int perf_uprobe_event_init(struct perf_event *event) if (event->attr.type != perf_uprobe.type) return -ENOENT; + + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; + /* * no branch sampling for probe events */