Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4527261imb; Wed, 6 Mar 2019 16:01:33 -0800 (PST) X-Google-Smtp-Source: APXvYqwPxrzU3NqMft17tQtvxf6gQNRinAPRjdJd+evaPVNE8B92cXAasZCDdhyenFhYzIY+Dz7a X-Received: by 2002:a63:2a89:: with SMTP id q131mr8766051pgq.193.1551916893493; Wed, 06 Mar 2019 16:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551916893; cv=none; d=google.com; s=arc-20160816; b=Q/7rvvbDfApsb9O8MV1EOXvp4/B8IQKDoxF1hbZrl1lwaqlBSRLubgiL2jipOWibYy TwpYqGZ3V2AsEo/AqrK3g8GKOIZkdlgOHFRn9VNuOhh9pJ7Lz9tWVkHeFOuyAGkT0REL C3K0LmZAC/bZ5VmUKQpkU7o4F8QfJ6zvV4y5PXkXwg89A3tvkO0Uh6kbpUf/n0oHL8ef MAD9Pebp3OpmT8H0Q9ElgLII4uNfB0itCx0vjO6dlIPtVVl1P9oMDbrOe19szuybM3x2 dyYFkbGL8DsRZgGYHlJ1jTwrO8irDVNIQ1RfnKD6lnLEiCrqtA+9x9hNgkzi5WTk9jIv NP5w== 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=2ZzvoWSyW5HTZoeTqFWgg34ixTiNCj89jLrYIWViRl0=; b=QrHmozGvkJHp/dWOdeqvrRd+iBvH3wAagrEWTEuHnjrDGse+7qEqc3zi8ZaNb42bZG YNTGsIP67Dj/KGk3GPStzii/S3fTUe6dxLq+qjpzE4bijSj+3tHT0I+dXwNB9AoJl/6y VWQ9TO6hFTthF+XJjEdvQzquTDU2SLzLrirHavqniNCo/apN226DNgdNC269vSxJRFdD oQAReEvWcmM+puhZC/d8S8LMgUYoOCRgW58ExxiQbl1LwGEdXxCUYPWaoDrwcp0eRezK r0hQ1fTJLncaVMGdM/KJEuEbVN4fH3YM5p5i1JTdz9Wo9qsPl429rXjtfeKTDC/QA2Mn Qaqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=joKpMu8Z; 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 a8si2747942ple.346.2019.03.06.16.01.18; Wed, 06 Mar 2019 16:01:33 -0800 (PST) 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=joKpMu8Z; 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 S1726748AbfCGAAh (ORCPT + 99 others); Wed, 6 Mar 2019 19:00:37 -0500 Received: from mail-it1-f202.google.com ([209.85.166.202]:52316 "EHLO mail-it1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726732AbfCGAAe (ORCPT ); Wed, 6 Mar 2019 19:00:34 -0500 Received: by mail-it1-f202.google.com with SMTP id z131so7079833itb.2 for ; Wed, 06 Mar 2019 16:00:33 -0800 (PST) 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=2ZzvoWSyW5HTZoeTqFWgg34ixTiNCj89jLrYIWViRl0=; b=joKpMu8ZGY15PM01/2KwGjHB3xEMV66i1KxgvTSL+1mba0Ycnp54vvwcsr5147kbND HcmViD1WphwEuzoWcJ4H1/sv96EAylP80mqoUg0iOZfvL+dzMavW3U1OAEyTa1YWH4Vn GUJyN4qGi22LgMAOY/b7ZppRgmDrY7lAgA3zJPCf8y1mlCHfBZ/w4PZmdHsrArINQSUO +O0CMFhaKttpJXlUG0g8EejPBD3z+u4R/iTnyzrtCwu7XKbYpELQmoWInlNQFRH8S82c /lgwwBJE78+C/d91iDKyGYt4HyCEtrQm3ZbbpNfUQ1BisJ/tNxPXHUnrJvVsOZy35ShU CwDQ== 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=2ZzvoWSyW5HTZoeTqFWgg34ixTiNCj89jLrYIWViRl0=; b=U6rC3dAEd5GqRucS24uwl2iNAYoFhI06hNv7XoDsZMA7KqtH4oO2u1QTGYKAPRH+yq zqDdNWKkZpEQpadocXs9q3DGj4OVVyYmmG9uzeJMxgVaLKdHJHKK7s2Q47J4Gy4nNW2S Br6z1amGcdm5rRgf5JyDb0KI5dNBdoodLTG/fRrTgcR40OynE1rU/45BARFVPfIImxwj GoztdjDskpjJfS1BIUwnRIMCrZUmDJpFl8MEWYQLah/s3iRn4AXfRKDB71RihfwRwQFu SBHvnGfF6NviMUJDNYl+kimVF48ieZchxBBEZQfrFCcrpGYR4UcSZiKIOgVQEKRUyQvC nEWA== X-Gm-Message-State: APjAAAWcgFCGLLNasGUlXqbD202+3943i+24fu+FvUZZCusMo5W8JziN bDgzE2EcWn7lP2ZlzrfX2PitLuWtH497yX+FuhHeXw== X-Received: by 2002:a24:c1:: with SMTP id 184mr7378710ita.21.1551916833546; Wed, 06 Mar 2019 16:00:33 -0800 (PST) Date: Wed, 6 Mar 2019 15:59:11 -0800 In-Reply-To: <20190306235913.6631-1-matthewgarrett@google.com> Message-Id: <20190306235913.6631-26-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190306235913.6631-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.21.0.352.gf09ad66450-goog Subject: [PATCH 25/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 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 --- 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.352.gf09ad66450-goog