Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4545807img; Tue, 26 Mar 2019 11:31:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5Pr+cZOQ1MOnBkU2kAYXVoZUnANFJOM89/ciIbWKGjJAuDWc/8qGWWdKk+mWIlLe5xo45 X-Received: by 2002:a17:902:b481:: with SMTP id y1mr32741544plr.338.1553625083200; Tue, 26 Mar 2019 11:31:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553625083; cv=none; d=google.com; s=arc-20160816; b=qyy1P6CMoHuZPGpPZ/iHN/TL5aIq/jPY7CYNb7NiHfQ9zn+qkilVGXgfcWpKZe/h3O nfCF7vmBl5tCDW8LTUE7zImy4KHmj03SLYoPWtDPFEinxIQc/LjucwJMhNE1AaFP6tij 0VV1p8zT8zBqhX3HJjZOPkOs3AjDOp2+lNjLNnPk0tuJSL1BpG3OJAjUN60xU8bWSob3 w7pRCfqEpdk/xLRUu01YJWSFrgVu0q8C9pdzXn4KPFul93GiJ4aMT7zziFf8wLjVs5LU GNUHo7vLEZCKGxW3sybQhR7p5Et0gofrZm6NiVrTAOvpt5KfYyHo/oHOkEq3CMWBGoeM VEFw== 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=H3HRoHYDWMArQkaxv1MNV9sbVAN4QTLQDsX3m+S9eoU=; b=POXzZnfKOf+mHu19UV92ag5iyVjmY7ZfkOI1rokiM/dgrrNtxHqViqYNOBh9BaMVUY PWIi39TKaqA0ie7elmF036iCdV8DuGwS+AwmpI26NAKzNjxKoPwGoepN4Lm0cey3WELZ VHcETVljvAgdKIYtM89HA0hpPJYZ6FUlKg0TyCSHFdvd+boc04sEJS2BIs6oPO0ZlA7A SotCxUSNmbe0dPyi5DTN0etqDQWzEKyEjjUcHB46O73+fAVk+dDO9p1vRS+YKloSnNjW JqJ0b2xP1rGs4OiXHlFLXVG8GXYOxOtcdcdBG2sWPM4CIMoPrGl0HV9jMD0y+jPERDjD IpKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Cuvbwz8H; 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 c16si17573382plo.412.2019.03.26.11.31.07; Tue, 26 Mar 2019 11:31:23 -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=Cuvbwz8H; 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 S1732893AbfCZS24 (ORCPT + 99 others); Tue, 26 Mar 2019 14:28:56 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:42284 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732881AbfCZS2x (ORCPT ); Tue, 26 Mar 2019 14:28:53 -0400 Received: by mail-pf1-f201.google.com with SMTP id f67so12469631pfh.9 for ; Tue, 26 Mar 2019 11:28:53 -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=H3HRoHYDWMArQkaxv1MNV9sbVAN4QTLQDsX3m+S9eoU=; b=Cuvbwz8H/UPT74uyS/N/4qnzLflOCWavMy5nGUSyYS7YEzjkinR90BjdsCrgcJkE3I nx4KbkC9dnoe9GkBObKBMRpDYEdqno8HqIh6XA2YCeqV6CvG7JzzRNQF6q8pd5BERf2L RFxm3yO2wG89tTrr53Mp5FuBliWeQ+U4jl6R2mVmbyq/irL9EVf0dyxEQAXY+gsnOrUa sjp/qtKV1gEMDqiY5H2Ik89SIJ7l/HNOQiiyV055Dk+vHQVGGJnndcLvaKRB3EJIEJ7P b5O2WEtybYZzvX3/wEfbV1lJ62nVHR0Vg+h1YgKtbRZ41TCuXQBY+ohnhrP2W4Cl8SFS GMMw== 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=H3HRoHYDWMArQkaxv1MNV9sbVAN4QTLQDsX3m+S9eoU=; b=jnKhZnZrGrt6pBB2jz3jAh5ZYhoFxR0fuaveYJ/JQiYZyVMMWOsJ7cqmL5hz4Qjffw Q4vpmo2BALPqDDrf6tHQnb+MYOqII1eMGAaAn9dUvCGGbZDKduEwSVKFzzcP3CyTSbUM uk2Mc0Qu10W3dI74kHze4SjTj5kPO18avjOHuVRu0Be3GaufBiczdH+Fw564Nv0vr7RU uSgEQsbAhMUVS7wuPUHerSKipN3EzFktLLjC6MdPqu1OHwwqCSnZultxPAjRVq4DH7UR 4nyGNgqzOdUrB3yzfUe9cjAfa0lwKnqfdKniI95rn/vtbxwualP3A8zspjvFmo+9hMXu u/eg== X-Gm-Message-State: APjAAAUmPl3SujxayNoTm1MXWk2EnBgr9J8WSqm8Wp4/2ZWq1YIVDLfH Ryo1YszD+1O3edMAo4V4PDatoJLrosSOFV87yX36bg== X-Received: by 2002:a63:f146:: with SMTP id o6mr29796370pgk.360.1553624932579; Tue, 26 Mar 2019 11:28:52 -0700 (PDT) Date: Tue, 26 Mar 2019 11:27:39 -0700 In-Reply-To: <20190326182742.16950-1-matthewgarrett@google.com> Message-Id: <20190326182742.16950-24-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190326182742.16950-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH V31 23/25] Lock down perf when in confidentiality mode From: Matthew Garrett To: jmorris@namei.org Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, dhowells@redhat.com, linux-api@vger.kernel.org, luto@kernel.org, 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 3cd13a30f732..6ad3d83c091c 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -10461,6 +10461,12 @@ SYSCALL_DEFINE5(perf_event_open, return -EINVAL; } + if ((attr.sample_type & PERF_SAMPLE_REGS_INTR) && + kernel_is_locked_down("PERF_SAMPLE_REGS_INTR", + LOCKDOWN_CONFIDENTIALITY)) + /* 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