Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6479590ybi; Wed, 31 Jul 2019 15:22:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQRO/ZJNt9ARmhRYVeeqdOoJ/Y9hsYl6EKC4lPVSSGIrD5SbK43Gew61FmLuN/1ByQbo8H X-Received: by 2002:a17:902:5998:: with SMTP id p24mr47424608pli.110.1564611728234; Wed, 31 Jul 2019 15:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564611728; cv=none; d=google.com; s=arc-20160816; b=xlrH1q67d2tfdm4tdtkGGQ63H8w43/4BRQ8R7aeEWqs1PHT1vQo850szbCLT2kB5Tf j0xjNTEEM16XoA/UENQvtj8OFWU6ksJcNYLQiEE+JYTGf7PNAS9Fs/TDXHIEiSuWTPdv a7uvlJp4btRtd7CPcqe4rKoi6ED+b8lJVguX5v9bk3oNpBxLckbThylaS/I1rqHtsGZt 1RmD6RohO2kCENq5VKgSiDIZu60owq4WoV1Yszyk4ZRJNbgdfwPtSJVKXzscQ826mQ6z 0i3CDnAgWH3k7MiiwHFbr8o3v3JjjsAkSFNxKIQB8rfPIN+i/jBXqS0A8zPGFCZwApGV Fovg== 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=AhUz4lJBRmz/b05TOXW8QIOVaAi8cU23gmsOIpZu+w35cUggqjwK7YUVA49/rmaQll etb9y0xkxIwgZFIuwX1O41HOTly4ix+nC/I1hrGu+EVBwf2nLnfx8nH2ovVy5f2xNaxf 9G9NSTg4WKcPbhvgVmIMME0wuLIjdZDX8SBGllMO4l+NLLC/hAGj8y/ByhmP6kYoLQP1 pw6Iu5xDcW8Y6+c5OSd77UJvnh/T4Ns0+3t5l4Ya4jxwS/KyS+zBhxeu/3ROO88fvxhv P6GR515JidHHL0GBA4afGZvrbZ6EBQB38fnYvi9fGIGuQjGjv4XFl3W6TYUtStMuf3ia HIPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=NQeE8brz; 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 f6si29108727plo.382.2019.07.31.15.21.53; Wed, 31 Jul 2019 15:22:08 -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=NQeE8brz; 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 S1730380AbfGaWRm (ORCPT + 99 others); Wed, 31 Jul 2019 18:17:42 -0400 Received: from mail-vs1-f73.google.com ([209.85.217.73]:44675 "EHLO mail-vs1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731430AbfGaWRj (ORCPT ); Wed, 31 Jul 2019 18:17:39 -0400 Received: by mail-vs1-f73.google.com with SMTP id j186so18230637vsc.11 for ; Wed, 31 Jul 2019 15:17:38 -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=NQeE8brzaM3nBKem2ZVyyY3FlEol8+CrHwKsZLyG2nOLqNXrqwU1ggJ6taMJBGtcvu u7ivnCOY/vCLH1PL1/ogOR1ufcUTaOZ5A/mx04CAwV3BoOuxIBirZiRs95dk3JRblihh tXPBxMpECDPUl9yY6d9SLCc2j/+TY7PF7+dohxG/zRAacI1a3PqRwnerhdX3/TNysAoS v/R6NSDtkIvFt4+d+hrBiGHwm3+8hQa3NyNj3mVZY9VVwj/L7gOlu1B21IDKaq5Gi8qX tOMgZItvzzSlRYr4GQVKc1U79UZPz8SKxqxaYhkJRhn4p2NfwVnpKyTpZK6Vvz1uJwiT QjVg== 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=kSgAF0g6ovWRssSQSD3YdfJ5Hh4wVbZzCn/FwzGp5PDlUIlfRsvhgQHuZn/Z2YL2UP zxQU0FLvZ+0zdh7e0bWPGBrDxEnPAoa3KR3XEcr4taTqwPFS+a/A2gcxSZ/0phjKiVN3 RVfzZUXcrNsfHnYmNCsBJTbmVFbTzB7P1hCmtW7MsW1ptyLLDrGkpzmm5SuT8dLZp8ii R5sitsnlap8OkmUBCs4djmMEPF2XkzAtKGYMyXdkU3mobTaQbrUnfmhew6L7MJqCjqw7 6bh4L1MflO9PPQhzYIyYytRRyQ9KuZQcKwaX56jrkX/oTQ+TG79K7tEbqy9zHaRmejbq S6Qw== X-Gm-Message-State: APjAAAU67NuSfiO9VyAdk4QcFWyBszaIgYCUvSJBZJZ+BN56Xhv8g5fQ KdnW8MmvSUCvlCAEzZmTkaWJYDeJrZszupY3rWG8QQ== X-Received: by 2002:a67:8907:: with SMTP id l7mr80628361vsd.194.1564611458042; Wed, 31 Jul 2019 15:17:38 -0700 (PDT) Date: Wed, 31 Jul 2019 15:16:16 -0700 In-Reply-To: <20190731221617.234725-1-matthewgarrett@google.com> Message-Id: <20190731221617.234725-29-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190731221617.234725-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.22.0.770.g0f2c4a37fd-goog Subject: [PATCH V37 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