From patchwork Mon Mar 25 22:09:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Garrett X-Patchwork-Id: 10870201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6784514DE for ; Mon, 25 Mar 2019 22:11:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 500742905C for ; Mon, 25 Mar 2019 22:11:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E87F28C1D; Mon, 25 Mar 2019 22:11:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF26028C1D for ; Mon, 25 Mar 2019 22:11:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731211AbfCYWLD (ORCPT ); Mon, 25 Mar 2019 18:11:03 -0400 Received: from mail-oi1-f201.google.com ([209.85.167.201]:53824 "EHLO mail-oi1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731205AbfCYWLB (ORCPT ); Mon, 25 Mar 2019 18:11:01 -0400 Received: by mail-oi1-f201.google.com with SMTP id c21so4456471oig.20 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=rfmj6OQsogAGYiJ2BP42lX/HNV+5XzRMynUpbogk7I38po6/V9zA5u3NCXlfxew06K c1k2O2TkuJZZRy/p3r6PrZ4/EgNPaGaU74kahvbCN5iHga43W4zQXxWFmB3Etq4gWygn kKQscYc5+iKuBaarRSIjAmFgHAYgA+UjHY7fNq/dbnYNn9+FX8jQw5i9RaEdPxjvN9GL a7FLT0XxiFybVs9ZwYvsh70x5EUBh48CAZu3OnQLNsv1zY70Jzn72Bi9dwVhrmN/Fh/4 FdSNwOKFktLGyLbLWBykKqXtUPKrktbItUVy7bOqxryF+PGGDTfFdf8zMBkHAftIn51F mTlg== X-Gm-Message-State: APjAAAXpuvYJ4ue4tisCTbguDOLC1PTObXOrOKjc+ZNZ6+OlBg5VhfY9 3foRm7fyhhNmQA5VTorEnP3E3mLOnNanqVYgjudhlw== X-Google-Smtp-Source: APXvYqwWnnRUoY5R/OT5gcEm/ggiwDceTHXuykWXRhTc4QGkHiNci4Egd2xX6G579iCHrIPXxi6s8Cbr11+1Z/L75xFCVQ== 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 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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))