Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3662989img; Mon, 25 Mar 2019 15:12:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsK2vxzRSGG/OV8p9lBbXXufudh9s6+YCwPLfeen96dQo8U1hnJPuTqiGWLOTPVxx6XJwL X-Received: by 2002:a17:902:8d8b:: with SMTP id v11mr28126772plo.241.1553551941803; Mon, 25 Mar 2019 15:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553551941; cv=none; d=google.com; s=arc-20160816; b=kUuewtIuKP9y8Hzn5gLfa0OiDr0aUNnvdXznW65lO6NjvsQpo/DpGbebLMKyNDXC3x MUoiJ/S3jPS7gmrY8haW4MfH2RCsDAKJsf0I5xW53EmAWbW2afP3MKm+Xuec0aLZ+gHw pkDd3GkN26A1uQ3G0HWxvdiBAEP8yMuPjSTX8/W7Ck8cK/crOp3b090v3uCgcFpzIwnU G7QxbYjBJbijTiSZgTnbF/hdPPnBcaiVuAKfyXZl/vPNBGWqXrj7UyHaoPJuRPVZSN4R 5xfRrW6ln0cisrpv+dzBvCEnRwZ/j+XkwvtKjyhjMvHMHslK+8rcD3Z0HZ+M/Bb336PH 0BVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=3+VKqpN9HOYaIvT2+O3RmkFaED64oX5fAU7Jkszi2gg=; b=jK4nCXceXWbBPYE0QGZAeRqPX1GLxARkeKs+/wjNJ3cgxeefl69nH79VWP89LBoWzf KGINugqmc7ipa2O4PK/5aVz25W0pny3AHTvL1TiTFGN8b2F0SLABAMUdAth2IYY2vDZo Tj59rre2JnrdYf3x/xxGvdQ9lApbthUfxkbsIRIUM8MlF7zqRTlgoX9AMO0LiCSQ4bkM jC0DmK0a9xiCxf20cw609OflSQ3vdOEPeenkpF3zsnkbm8IQ2tus6uJfSzo/9VpWa4q+ VVbb/Q1zZBqx9kuk4jMngu+Z4wX5s64vdB5hDmUAF5arn1UouywrMru9ddR9tYUly+2e m5hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mWvLXqUt; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si14847848pln.220.2019.03.25.15.12.06; Mon, 25 Mar 2019 15:12:21 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=mWvLXqUt; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731229AbfCYWLE (ORCPT + 99 others); Mon, 25 Mar 2019 18:11:04 -0400 Received: from mail-ot1-f74.google.com ([209.85.210.74]:49209 "EHLO mail-ot1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731190AbfCYWLC (ORCPT ); Mon, 25 Mar 2019 18:11:02 -0400 Received: by mail-ot1-f74.google.com with SMTP id s22so2754508otk.16 for ; Mon, 25 Mar 2019 15:11:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=3+VKqpN9HOYaIvT2+O3RmkFaED64oX5fAU7Jkszi2gg=; b=mWvLXqUtDJA6ZLQ4rljXx/YaZEYZSY7mEfqNWbs0oXQfF43ZORE6QxhourW5k0jnJR EOW/YzXY2k9Y/KSzznidAk77H9YCAgP6qmLaA8i7271DXENkkL83AXVxTKa/Meu4Q2co m8fTI12PGZS3e44w3/pqpyVKbejs8l+8KA8+tKOSmF5W1GlmrnasS7nHxNENL0GL5XQ+ br75aVOU3PTCH7P9nYFy3uguV+OntpJ2wGZepe2FUIbVWrydycpb+54B1Hdm4WN8q64S zz2puwjsK3PPtJ47euvqUEzpvVrFHK8DvYd+YxQNYnD46/jx2VVSSWYUg1drwzVpSubk Cf8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=3+VKqpN9HOYaIvT2+O3RmkFaED64oX5fAU7Jkszi2gg=; b=ScJQl/WBs0ChBHjz86ztzYfOn1oh1CFQ+V/4a6pyglED6Iqwfkdc8uinnckDS8zqHb /qZXfu5LX+HHdg7mlLHOKBTEO1D/chI0/nweTGCC7/RKa6Xlp8yYQ/bTdPITmVvWTFJO rtHnRDucTuXmOZRpuvydL/GuMXMF7DqaXenVaJMMp2CnKF9gjMpFpptAr0fhTJMvOQWE ptOonbJkOjVvZn57UiLYGsQEcdtMw61Dg2bzq2vM0/bof4+1hxHh/+evdxViWdt+NAta oeQMu5Q9P3e4BvHQz9DcEXvHbifROWGwv6A/giWmdh6u30F6B2OsW7RA6fDTb6gtm9mK 13Ew== X-Gm-Message-State: APjAAAWiz/YVAxs3BDKTPua7ZM4xSglrXgDw9byfbnTPOWSxY1riTOQ9 ZgdvUs1iHLoDWE3h434Rj8PIX0/FmgiPWhjgsgGG4w== X-Received: by 2002:aca:aa91:: with SMTP id t139mr13629092oie.174.1553551861302; Mon, 25 Mar 2019 15:11:01 -0700 (PDT) Date: Mon, 25 Mar 2019 15:09:51 -0700 In-Reply-To: <20190325220954.29054-1-matthewgarrett@google.com> Message-Id: <20190325220954.29054-25-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190325220954.29054-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH 24/27] Lock down perf From: Matthew Garrett To: jmorris@namei.org Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, dhowells@redhat.com, Matthew Garrett , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Howells Disallow the use of certain perf facilities that might allow userspace to access kernel data. Signed-off-by: David Howells Signed-off-by: Matthew Garrett Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo --- kernel/events/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 3cd13a30f732..7748c6f39992 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -10461,6 +10461,11 @@ SYSCALL_DEFINE5(perf_event_open, return -EINVAL; } + if ((attr.sample_type & PERF_SAMPLE_REGS_INTR) && + kernel_is_locked_down("PERF_SAMPLE_REGS_INTR")) + /* REGS_INTR can leak data, lockdown must prevent this */ + return -EPERM; + /* Only privileged users can get physical addresses */ if ((attr.sample_type & PERF_SAMPLE_PHYS_ADDR) && perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN)) -- 2.21.0.392.gf8f6787159e-goog