From patchwork Sat Jun 22 00:03:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Garrett X-Patchwork-Id: 11011025 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 5177A924 for ; Sat, 22 Jun 2019 00:05:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43E5A28B7B for ; Sat, 22 Jun 2019 00:05:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3741E28BB1; Sat, 22 Jun 2019 00:05:58 +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 DA7ED28B7B for ; Sat, 22 Jun 2019 00:05:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726313AbfFVAF4 (ORCPT ); Fri, 21 Jun 2019 20:05:56 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:53207 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726996AbfFVAFN (ORCPT ); Fri, 21 Jun 2019 20:05:13 -0400 Received: by mail-pf1-f201.google.com with SMTP id a20so5301361pfn.19 for ; Fri, 21 Jun 2019 17:05:12 -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=RH4r7kndiMZuzkloO60/eV46GQCIwbbHWtivaOQNx8E=; b=AlJqBCOH77JCstgkPmGAZLgRUSD9zvatMOj3hlS41EdO8GggJp6HBONVpx/jhauvgq 8AJYbxCo4G0bCR/ZL4FQ8B8+IWJY2WfIJ1YRwYg5JXFKA/gXZcRwW59UyJpziaVKPJMD w/V/JtAWur3tBIDTeoEHR7ZUYTOlGArmeV75OKSfGB53kteVVkiD50m114i64uhrcDHW kKiF2N+0rp0kEs0/V6xldaibUNauG2QYFkENtyXQ2vJG3z/F6Xg3uIhwM6tlnXlcDucd /iycXpCPysDjGuvfZjg6xm7UFHlgNwKHAPLDV5kfEXLPXmjXQ7Mys9GnXKhb3JR5lTB6 04eQ== 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=RH4r7kndiMZuzkloO60/eV46GQCIwbbHWtivaOQNx8E=; b=iNsys647dDJpSOj2H3b7W9BC/t6BCiAlD6MvxZOAPQprAdwlaLcJqq9zLKNsR1PVwZ Nxc8l0Mfb9bqOj6Cs5SIR/WwmwSxckO0jm8cz8vHPknIZc/3rsGuPEcq85A9uOSbnfG6 navSprSxGx9WiGMcSCQUzMqf/IJ5SVKQY7Ozw+dmT50J5jDtRs9Aqmi447fPsv6mURJx 9nNV57RilkF7HxUUKLGwju/ZmBi6gckY78xLRbqdZvFRVFYNPZTtfUPxJRE8I7dEnA9p n8o243SScsVnjIhFi9A0InFeo8R+amSbXtj7flpaldom1T1o8Olkzb3K32dLFwwdA/cU zehQ== X-Gm-Message-State: APjAAAVZAs8I48c6Bh1k2xIO/CRnfuc/grddvDWnfXLrZFa2jTmShaLO IUESmhNi1EkeMAnAloqQYPdcuq6LWbpiyAcXK1/tCQ== X-Google-Smtp-Source: APXvYqyVHJVn9d0VYeGJ4jqknCWJTY1KI/Z/06tozEDcOyTsuENI6t9yu2qMQUxyG2gPRdwFuoh5T585JPCvavnyfPVFAQ== X-Received: by 2002:a63:1d5:: with SMTP id 204mr21711270pgb.207.1561161912148; Fri, 21 Jun 2019 17:05:12 -0700 (PDT) Date: Fri, 21 Jun 2019 17:03:57 -0700 In-Reply-To: <20190622000358.19895-1-matthewgarrett@google.com> Message-Id: <20190622000358.19895-29-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190622000358.19895-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH V34 28/29] efi: Restrict efivar_ssdt_load when the kernel is locked down From: Matthew Garrett To: jmorris@namei.org Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Matthew Garrett , Matthew Garrett , Ard Biesheuvel , linux-efi@vger.kernel.org Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP efivar_ssdt_load allows the kernel to import arbitrary ACPI code from an EFI variable, which gives arbitrary code execution in ring 0. Prevent that when the kernel is locked down. Signed-off-by: Matthew Garrett Cc: Ard Biesheuvel Cc: linux-efi@vger.kernel.org Reviewed-by: Kees Cook Acked-by: Ard Biesheuvel --- drivers/firmware/efi/efi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 55b77c576c42..9f92a013ab27 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -242,6 +243,11 @@ static void generic_ops_unregister(void) static char efivar_ssdt[EFIVAR_SSDT_NAME_MAX] __initdata; static int __init efivar_ssdt_setup(char *str) { + int ret = security_locked_down(LOCKDOWN_ACPI_TABLES); + + if (ret) + return ret; + if (strlen(str) < sizeof(efivar_ssdt)) memcpy(efivar_ssdt, str, strlen(str)); else