From patchwork Wed Feb 5 17:04:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 3587891 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A7BDAC02DC for ; Wed, 5 Feb 2014 17:43:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CA07D20145 for ; Wed, 5 Feb 2014 17:43:34 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DEB0F2013A for ; Wed, 5 Feb 2014 17:43:33 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WB5yR-0005Oq-CM; Wed, 05 Feb 2014 17:09:20 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WB5xT-0001ve-Iy; Wed, 05 Feb 2014 17:08:19 +0000 Received: from mail-wg0-f47.google.com ([74.125.82.47]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WB5vD-0001af-JL for linux-arm-kernel@lists.infradead.org; Wed, 05 Feb 2014 17:06:09 +0000 Received: by mail-wg0-f47.google.com with SMTP id m15so499805wgh.14 for ; Wed, 05 Feb 2014 09:05:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4jFuX23Qkffw42FRFu/Fhvud5znWKVg8wUcdR57/ex8=; b=i93TSPYvfCgSaWHa4d3btN7JCBpl0g0CdWSlg7FZTmu2OoOnT+wN+kvId+FgvMMtpo ng+4wwsTDHOoq+ZcwtpXyb9NbraV7kvG3422KKWWtNeLGVz8BYwXfRot701ASQ4vqbpB uAQw9ap4cOfaew9UqME0EwglBtJdIZysNT7Ry3DfMnpawIM/MrUY8sTT/YoZe8gSekg7 wpuUS7I2Iss5efJ09w6r61RkIYFqzAujaQfq8l5vGFXaUxO2eSJ9atXQzgBgbcPdTdBH z66DLBpBl4ZrMtk1PEXUCBTScUFqVaKlyziaTyHHaDLw9xSu4i8ohUSNMAJdylmLDP3/ 5htg== X-Gm-Message-State: ALoCoQkdmiMXbP2MmQIY89SDqP/GuYLBgHwsUX+jTbo0VNkp9XB7IviQ5U49F7VlFtUufOayjZA5 X-Received: by 10.194.60.37 with SMTP id e5mr2208581wjr.32.1391619938772; Wed, 05 Feb 2014 09:05:38 -0800 (PST) Received: from mohikan.mushroom.smurfnet.nu (cpc4-cmbg17-2-0-cust71.5-4.cable.virginm.net. [86.14.224.72]) by mx.google.com with ESMTPSA id p1sm47427211wie.1.2014.02.05.09.05.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Feb 2014 09:05:38 -0800 (PST) From: Leif Lindholm To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH 21/22] arm: efistub: ignore dtb= when UEFI SecureBoot is enabled Date: Wed, 5 Feb 2014 17:04:12 +0000 Message-Id: <1391619853-10601-22-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1391619853-10601-1-git-send-email-leif.lindholm@linaro.org> References: <1391619853-10601-1-git-send-email-leif.lindholm@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140205_120559_970575_18CB5B6E X-CRM114-Status: GOOD ( 13.23 ) X-Spam-Score: -2.6 (--) Cc: Ard Biesheuvel , Leif Lindholm , patches@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ard Biesheuvel Loading unauthenticated FDT blobs directly from storage is a security hazard, so this should only be allowed when running with UEFI Secure Boot disabled. Signed-off-by: Ard Biesheuvel Signed-off-by: Leif Lindholm --- drivers/firmware/efi/arm-stub.c | 4 +++- drivers/firmware/efi/efi-stub-helper.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/efi/arm-stub.c b/drivers/firmware/efi/arm-stub.c index b505fde..c651082 100644 --- a/drivers/firmware/efi/arm-stub.c +++ b/drivers/firmware/efi/arm-stub.c @@ -95,7 +95,9 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table, /* Load a device tree from the configuration table, if present. */ fdt_addr = (uintptr_t)get_fdt(sys_table); - if (!fdt_addr) { + if (efi_secureboot_enabled(sys_table)) + pr_efi(sys_table, "UEFI Secure Boot is enabled, ignoring dtb= commandline option.\n"); + else if (!fdt_addr) { status = handle_cmdline_files(sys_table, image, cmdline_ptr, "dtb=", ~0UL, (unsigned long *)&fdt_addr, diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c index 2ee69ea..6221be7 100644 --- a/drivers/firmware/efi/efi-stub-helper.c +++ b/drivers/firmware/efi/efi-stub-helper.c @@ -721,3 +721,27 @@ static char *efi_convert_cmdline(efi_system_table_t *sys_table_arg, *cmd_line_len = options_bytes; return (char *)cmdline_addr; } + +static int __init efi_secureboot_enabled(efi_system_table_t *sys_table_arg) +{ + static efi_guid_t const var_guid __initconst = EFI_GLOBAL_VARIABLE_GUID; + static efi_char16_t const var_name[] __initconst = { + 'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', 0 }; + + efi_get_variable_t *f_getvar = sys_table_arg->runtime->get_variable; + unsigned long size = sizeof(u8); + efi_status_t status; + u8 val; + + status = efi_call_phys5(f_getvar, (efi_char16_t *)var_name, + (efi_guid_t *)&var_guid, NULL, &size, &val); + + switch (status) { + case EFI_SUCCESS: + return val; + case EFI_NOT_FOUND: + return 0; + default: + return 1; + } +}