From patchwork Tue Jan 28 08:25:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1230210 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=bIoJcsA1; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 486KWN0qgGz9sP6 for ; Tue, 28 Jan 2020 19:28:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E0F9B81A16; Tue, 28 Jan 2020 09:26:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="bIoJcsA1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A2C3381A12; Tue, 28 Jan 2020 09:26:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 264B7819DA for ; Tue, 28 Jan 2020 09:26:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x543.google.com with SMTP id z124so6560061pgb.13 for ; Tue, 28 Jan 2020 00:26:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TEAEDj9erVipp4yLLE2gQ4KtxKQihSj29/GQcgpNpqU=; b=bIoJcsA1ylDz80twtCwdftsvhdKY/77wgDI6Y7Nwz/r6cLwcZIeM8PODmZeJM79uoy MKm4sgznhYJRbZ2FmS9USQmClz2LZDb06imnPsmO9gsGnB1ss/qdPfg4hvuMGNbcSZhi QY5/27QS9mf/svtch45YlTfv5RAMtOt/vmQHFjRAmFkidvwGpYjSaZ7cXOVgegIFP7QW KVWBaSGsqEcd65E/RV+8CUCoRUkdNC1jsNkufYe+srV0mrKXJS0HSVvQRAyBJpt/pf6+ JEg8pICqL8hdcTNRSt4wA8B77/lvVLQXtHmiyCbXt1kEAl2bWt9zwN0+91FjAhe/4dFk d+zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TEAEDj9erVipp4yLLE2gQ4KtxKQihSj29/GQcgpNpqU=; b=fpb9NBOAf+MuOR+wh+vRFgrbE5SFr87Y1nzmeARf+6RBT9YkpEZBhOkyEUgl6CJ3b1 HFEjmbMVbCO2uElgsw42/j8LhwJ4S81Uv80uDPq9KvKzoSxCyluneHT/W/5XPThU/1yx KJ7jCA34AtN8NGbSwuYyb6VZkZPk84E+EFg4xk+ZlltzcxfnU158W6hwGogrxNA8BdTA RiKAB36HWJJX78IhP+174TO5pupBtkN1frLjOBMvecVtCBFU3POs8UpF/jyiY/Ea7xnC mw2rG7Y2p4CD0Sk9A2On0Cwgyz0MxjhbgkDAQ0mK3pRyqgwOVJbIdd+XPIVlxLqKRSir zHbA== X-Gm-Message-State: APjAAAVB31s1cQrsSS20t959E6lL+YHTtZ/i7wSi2N5ypD5jHOmkjAlr IvDMSYl8Zcw1LBq3heomqAx4tA== X-Google-Smtp-Source: APXvYqwwU52YQnl9zAQqZGEuB3oTLMnaOvm5hmlQoaIIld280Gs81SlTWXxDoxoPxWOn5LMx6o2dhA== X-Received: by 2002:a63:fe43:: with SMTP id x3mr24644681pgj.119.1580200006279; Tue, 28 Jan 2020 00:26:46 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id z27sm14774620pfj.107.2020.01.28.00.26.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2020 00:26:45 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, trini@konsulko.com Subject: [PATCH v5 08/16] efi_loader: set up secure boot Date: Tue, 28 Jan 2020 17:25:24 +0900 Message-Id: <20200128082532.15943-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200128082532.15943-1-takahiro.akashi@linaro.org> References: <20200128082532.15943-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: u-boot@lists.denx.de, mail@patrick-wildt.de Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean The following variable is exported as UEFI specification defines: SignatureSupport: array of GUIDs representing the type of signatures supported by the platform firmware Signed-off-by: AKASHI Takahiro --- lib/efi_loader/efi_setup.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index de7b616c6daa..50cef1b4dfde 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -82,6 +82,39 @@ out: return ret; } +#ifdef CONFIG_EFI_SECURE_BOOT +/** + * efi_init_secure_boot - initialize secure boot state + * + * Return: EFI_SUCCESS on success, status code (negative) on error + */ +static efi_status_t efi_init_secure_boot(void) +{ + efi_guid_t signature_types[] = { + EFI_CERT_SHA256_GUID, + EFI_CERT_X509_GUID, + }; + efi_status_t ret; + + /* TODO: read-only */ + ret = EFI_CALL(efi_set_variable(L"SignatureSupport", + &efi_global_variable_guid, + EFI_VARIABLE_BOOTSERVICE_ACCESS + | EFI_VARIABLE_RUNTIME_ACCESS, + sizeof(signature_types), + &signature_types)); + if (ret != EFI_SUCCESS) + printf("EFI: cannot initialize SignatureSupport variable\n"); + + return ret; +} +#else +static efi_status_t efi_init_secure_boot(void) +{ + return EFI_SUCCESS; +} +#endif /* CONFIG_EFI_SECURE_BOOT */ + /** * efi_init_obj_list() - Initialize and populate EFI object list * @@ -122,6 +155,11 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; + /* Secure boot */ + ret = efi_init_secure_boot(); + if (ret != EFI_SUCCESS) + goto out; + /* Indicate supported runtime services */ ret = efi_init_runtime_supported(); if (ret != EFI_SUCCESS)