Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3355117ybl; Mon, 19 Aug 2019 17:22:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxi/zfAAAcg5noSvk7GYTA+XgLHO8XQUKrz53yaLTp8+ET4fgPpgtzCUtVGmEqNgD9iREZi X-Received: by 2002:aa7:8ad0:: with SMTP id b16mr26892998pfd.45.1566260521009; Mon, 19 Aug 2019 17:22:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566260521; cv=none; d=google.com; s=arc-20160816; b=y0Lib8O9+Xk8/mOmiCRnb1p/itD0Ok3+udiACrTdBmk9PEbpHpyS2drYksAmVNYZr2 JJK8DKCA2ZJTqpZ73Z0QnK5mIRYjQIBAIARydwpDZU+7osQd5cBcTINqVWWh/Eek6Tcd GbKc5ROZnRRpBW2l8Vt9xKrBCwqO4a4+T3YFI+yICT5S7JMBnPXmzM046gchi3jVUkfd DuAw2a9AeEG/c2CxY9m0hkzNpUEgcEu62Ng2coAzxR9BSpUVqjF78whvbCiJ7v7fkSnB jPSdXLvSiXt/iAmOfWbOtOxhQITUQuVkvQmghPusIjgzH3o4g3SbchESmWCy3zUh+dXc UElg== 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=+olFNxFYhjL9QRL4ImBQxYfzLxvoDTRC2EU1toIBTB8=; b=GG2ZcCbulCcM3BqJiac/FO408qEuV36FNHy5VaXx0XUYd/R1quK1kgLPkz/IlBY1hj 4nd/bimUQriFs4daQvXoR2R5ZrBaqztHoXSugWDdHfiIwiX74Ib89CEmzN2xVLJ9cplJ FmHHkZ9GPbfGzY4JGWwieoBxSM+iRx/P5nbQ0DzZHJe8pzhs7Nx9OHrH/tFRtoKIPojO 19H+iJZB9+VfefXxUJQWp5aizh7Ig8W93YeTVYy6ymPbwTSVv9iUZqm0b7yldHZRWGrW 2D1/rjIgaHq4/qy3z0bQLlbN9iUMdgUccp7Zu8XB6DueJLhQOabtq6OrBQx5ByfxKeXa vzYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=g1htn3p5; 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 c5si10968552plr.291.2019.08.19.17.21.45; Mon, 19 Aug 2019 17:22:00 -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=g1htn3p5; 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 S1729224AbfHTAT0 (ORCPT + 99 others); Mon, 19 Aug 2019 20:19:26 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:54644 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729205AbfHTATX (ORCPT ); Mon, 19 Aug 2019 20:19:23 -0400 Received: by mail-qk1-f202.google.com with SMTP id x28so5215329qki.21 for ; Mon, 19 Aug 2019 17:19:23 -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=+olFNxFYhjL9QRL4ImBQxYfzLxvoDTRC2EU1toIBTB8=; b=g1htn3p5MZXFXzHIA+Jjt6jTrPQQXmo5akMJNxXZhfwpce3QyP067kNbJy/zfSbTxP cqz6lYhGVH0Y58/jTvOZi73Je+dj6hcnU1VPmFh5JWW26socuEY2ootWG3DEUR1iI5Nj FkuD5Sr2MnqIJJ0/mQ2m1R+Gatojxz/0YnCKFlSUhlohVO86a0EARley9S0ZUdIQjx2/ PHareqg3wUQzuEQVwba2lcWN6esQv5jG3FrggakTQ/4Pq46kBazhFsDcmiyM2nxDFwVX 7HJPcEoP4vJw5ivPgLu++46qCQuAEe782JNqba2Z2LlbukNPdEi26D4bMgjB2C4twbvo XJvQ== 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=+olFNxFYhjL9QRL4ImBQxYfzLxvoDTRC2EU1toIBTB8=; b=eZlYsNddS1tuIZYI2CBjej9ntMf4DwGlnSBTVqKdZU7HXIuMzi2L0D87LgVP8Vqof0 2LEznJmGFzM4w/m6zmXiQe8+DXVQH71O6WiB9wy5TFShQ8dd91RNyChrqWZaipQdZ4Hn OLBtxRCEx634n98DeTgJgDLC781DNIHQA8biKPEZV7hLSKkg87ZneicFqPnodW8Wt6kl OMEiwYYpRo9UHFNu8igR7ha3WzMd00mi3hOWmedQIkK8b7Kzv6O6T+5ZXiqRxJ4aD0qM ZsTl2XWoJgCkhT3fITyZ/jnpcVsGH8+8LAxUkwCjZECtwFJUc8SPeBHr+8ceMhO6/WMc beDA== X-Gm-Message-State: APjAAAVpzl3f20lMDoghqL2CWMkhXwC7YmPpXGbFaWIlfKcT+0EJ5ShT wOsmDcKVTLjCjDb8qYGbwHHvXEpVvAOTVqfGwcbK1A== X-Received: by 2002:a05:620a:4c8:: with SMTP id 8mr21987278qks.366.1566260362547; Mon, 19 Aug 2019 17:19:22 -0700 (PDT) Date: Mon, 19 Aug 2019 17:18:04 -0700 In-Reply-To: <20190820001805.241928-1-matthewgarrett@google.com> Message-Id: <20190820001805.241928-29-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190820001805.241928-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog Subject: [PATCH V40 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 Signed-off-by: James Morris --- 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 4b7cf7bc0ded..5f98374f77f4 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -241,6 +242,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.23.0.rc1.153.gdeed80330f-goog