Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6089788ybh; Wed, 7 Aug 2019 17:09:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwC0RwYeHddoU0qA1512i3lhksnGPFN4t3FgCHwDJRA+RxdyHGkFEVoofmI/w5Nnp6UjBHQ X-Received: by 2002:a17:90a:7787:: with SMTP id v7mr1009740pjk.143.1565222998517; Wed, 07 Aug 2019 17:09:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565222998; cv=none; d=google.com; s=arc-20160816; b=CBACvg/5EBO1jB1AcdiuVXzHOiuRotJBgjHHPhteL0JvvxzWaJL8TNlgkIO2+kcxNj OHSJeSHmw3qybrEmIJEO4WN2ZXijK1ewVh1WibEmhSKmLjtxEGWlm70bVerCEsJkmwI6 7uKNcfLQzhAxbV4u0VJPkObgN8Sjv/VOaDfMRVTDq+hUS/mQ3vLYWGzcc86Har7rYDIa TZD8LJh/5Ltie8a/QkglY1L0CZ+1wZ3P7mMNbDPcCjeLwzadj1Hgq9Y9iR/C5x2ZWlsI UTuUjLAmC/lzfn+ZeAt3vpjNOqs7j0nxP+Po1FtND/4o/7N4Fcv624J/xl3kpjNaIGz1 uZtQ== 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=BzJTfX0sYPsZSKyjJWnAiNewKfNmb8++vKsSknaZcxY=; b=bWBlqRZlwaeeLnNVmdcsRFjym43h4Akvnuoo3NxGQfJI0vqZXOulYhaHkRFwPvbzP9 rDpLhDQOBBXvUMdJAMJrbO+NtJb/ABGGGyaXFHXOOJ17gaZXTHGT/w6ftD9a2NHjDTE1 NLlFfyDHymLCq17wIlHTSlpkv0mBPHQIYCDhUs3toBcozd2R+icRpIp5KY8easWVgKn6 XbZSW2okFNP6kb27MHExQFV+Mcg4E7ib83dwaA/Vn/3eXctnjSH31NUsy4kuRt8AkSqD 1bdm/EiwYdCc5+HEN87tANQAc4rdksVU0J81Ak0Cte3Gj1C4IbDi0OowO8JWXX2KrRYm +MIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nJHg7sy8; 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 ba9si46094998plb.308.2019.08.07.17.09.43; Wed, 07 Aug 2019 17:09:58 -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=nJHg7sy8; 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 S2389803AbfHHAIl (ORCPT + 99 others); Wed, 7 Aug 2019 20:08:41 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:46519 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389786AbfHHAIi (ORCPT ); Wed, 7 Aug 2019 20:08:38 -0400 Received: by mail-qk1-f202.google.com with SMTP id c79so81007758qkg.13 for ; Wed, 07 Aug 2019 17:08:37 -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=BzJTfX0sYPsZSKyjJWnAiNewKfNmb8++vKsSknaZcxY=; b=nJHg7sy82b57LQq6OZ5Pf4z3qb6gZmem/mTeHt5LmL/ZwHqh7qt371cdCMvAqVRODb bwZWz0T0ZOqhRlaeupaidr4a7bJMM+B4xYX67B5jWiaE2yNY81ExTPnuiPCyd4mCYcNq i8I+CcrVNTjxGO4n3pDZJ+7F93wOcwJuMuP8L2A4k1/vHi05KGWHeGV2VG2piwD+cpE/ rggZZOn6CADIkZ33i6wNWnbZyKerxNimATuXIGYxfGICDUNduiyYt5tR+iYZCxAyOg3g XgXLWAfiGsatUaL9beVqeZdGiFZodkVInPxNZzO5DXKH4HZ63I1yh0B8lAyCS9zEKF1B h0xw== 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=BzJTfX0sYPsZSKyjJWnAiNewKfNmb8++vKsSknaZcxY=; b=JTSK0/34gke6/MCZuHZ9R59CztKTd5CGQOXwuCVlvLiOyoh1b4+4jvoSQ4/hhqzdMz VZTJfz3z3q0R71wuOc4hL4C+IDrEvFF++j+c+VSU9XEiyq9RwTySbnyCNjh166m1tLvX QtUGIOiXzAUApSmsIBMTbzwWKUJ/4cwOjtVK7A4nNQOPtR5BpTaSNJ8HK1z678Qz7qHI +CLfems8BoLrdqXmWn+NlRQzfqZr1ySBrxHRcHSCX+83xtXGAKJ21ANmCt9SzkOz+jDM ZJLEN9+pJi51o/x1JrKlGSHLocYBqAuX06bJeUbIX9GeWlUY0MLM/eZVqMBLj1vRySf9 nqtA== X-Gm-Message-State: APjAAAVsCa26Me+CNhgVpZR+OMvIjNCQRhAGiwDxiZIQKp/sk6mWPZ3O ABucORL9HEv/otsY4rTlRvkMlk/NqhP0T72VOk/cfw== X-Received: by 2002:ae9:ef0b:: with SMTP id d11mr10735109qkg.295.1565222917093; Wed, 07 Aug 2019 17:08:37 -0700 (PDT) Date: Wed, 7 Aug 2019 17:07:20 -0700 In-Reply-To: <20190808000721.124691-1-matthewgarrett@google.com> Message-Id: <20190808000721.124691-29-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190808000721.124691-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.22.0.770.g0f2c4a37fd-goog Subject: [PATCH V38 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 , Kees Cook , linux-efi@vger.kernel.org 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 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 Acked-by: Ard Biesheuvel Reviewed-by: Kees Cook Cc: Ard Biesheuvel Cc: linux-efi@vger.kernel.org --- 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 ad3b1f4866b3..776f479e5499 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -30,6 +30,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 -- 2.22.0.770.g0f2c4a37fd-goog