From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C1A1C4320A for ; Fri, 27 Aug 2021 04:47:23 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5984C608FB for ; Fri, 27 Aug 2021 04:47:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5984C608FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EA097831E7; Fri, 27 Aug 2021 06:47:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (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=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="lgLSyC/y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 150CA831ED; Fri, 27 Aug 2021 06:47:18 +0200 (CEST) Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (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 517E682EBB for ; Fri, 27 Aug 2021 06:47:08 +0200 (CEST) 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-pl1-x62e.google.com with SMTP id u15so3151252plg.13 for ; Thu, 26 Aug 2021 21:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=ot3X3Cslbvxot5Uv4RtTVDkjCZpp9UnGMCrlwgFP2Dk=; b=lgLSyC/yP+p1PYpvIKMZJWLP12m2X6rcZV1A7HM27RpX2kT8Igx2CYJSNo/8jFo8Ry Ks1gsS2693e73U9GIUp/b5yMLoR1MZecXFNAbEiOzfZMkDW6EgZbOueFM7Jkj8eYDJcE s5xsVlJr6dCm7D2cm9IL4Amp8rRkWArcnzdz1Kn3dbyoURkU0KwbtEvGOdtIaVZYPJ98 tfYRDHPT7S0tT7iAapIWn45WI4WFlCN5yPT4duBAswSYI8z11rpsTVWGiqBRIOw86giK ornlYB04roeHfD4Y60gx3fEqRkQ3IjhZJwio1Ftq2LNCpZmwz9U1G3LRWZmgmWH4Fy2L KL9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=ot3X3Cslbvxot5Uv4RtTVDkjCZpp9UnGMCrlwgFP2Dk=; b=QWmMpip67DEv7NElkAfQkBJjODr2JzDpL9MaTgX4mquGOgCEfqz+SfOayb5jyDNF+n xG9K/F++IxjKI1I+ChpPY4uKsTlfYip2Ehmkf9CGQZUiJWFb+5OaAKGuUcJOyL55HT6K luKtQ5nFS800D199qOAWnGVg1JHtjV8VEkpJMKUt2PFEVSxRPhh1VySMMoDaFKoJA5KI ss9WP5nIGaqWbZfw+ev7KfD01GwXWHOGuMraVtV7af/IMCgffNtNhFp+hM8vPes5Ftwt XohQt9t3zqtp5BIpv5fr/O8+smAAyw8v31mrIxk/Pm5nBJNZ7EQqcZrCnRvuKk34rKD6 2k3Q== X-Gm-Message-State: AOAM530+dNjKgObJRUTlXoCj2rzTmGOMAR4MmUmQZJIc8uqnrOC0J09M P8ILAqjlwJpMpSQ7PmZpxO4KWg== X-Google-Smtp-Source: ABdhPJzqUnUVb+SjToAsA3YZV0EIrdGlTSQ8hkcMdHwXqSznwCBso9fqCU2hvUmnMGxv39j8B7K7yA== X-Received: by 2002:a17:90a:f994:: with SMTP id cq20mr2448283pjb.188.1630039626396; Thu, 26 Aug 2021 21:47:06 -0700 (PDT) Received: from laputa (p784a6698.tkyea130.ap.so-net.ne.jp. [120.74.102.152]) by smtp.gmail.com with ESMTPSA id f10sm5211947pgm.77.2021.08.26.21.47.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 21:47:05 -0700 (PDT) Date: Fri, 27 Aug 2021 13:47:01 +0900 From: AKASHI Takahiro To: Heinrich Schuchardt Cc: Ilias Apalodimas , Heinrich Schuchardt , Alexander Graf , u-boot@lists.denx.de Subject: Re: [PATCH v2 6/6] efi_loader: always initialize the secure boot state Message-ID: <20210827044701.GF52912@laputa> Mail-Followup-To: AKASHI Takahiro , Heinrich Schuchardt , Ilias Apalodimas , Heinrich Schuchardt , Alexander Graf , u-boot@lists.denx.de References: <20210826134805.148975-1-heinrich.schuchardt@canonical.com> <20210826134805.148975-7-heinrich.schuchardt@canonical.com> <20210827035336.GC52912@laputa> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Fri, Aug 27, 2021 at 06:34:30AM +0200, Heinrich Schuchardt wrote: > On 8/27/21 5:53 AM, AKASHI Takahiro wrote: > > On Thu, Aug 26, 2021 at 03:48:05PM +0200, Heinrich Schuchardt wrote: > > > Even if we cannot read the variable store from disk we still need to > > > initialize the secure boot state. > > > > > > Don't continue to boot if the variable preseed is invalid as this indicates > > > that the variable store has been tampered. > > > > > > Signed-off-by: Heinrich Schuchardt > > > --- > > > v2: > > > no change > > > --- > > > lib/efi_loader/efi_variable.c | 12 ++++++++---- > > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > > > diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c > > > index 80996d0f47..6d92229e2a 100644 > > > --- a/lib/efi_loader/efi_variable.c > > > +++ b/lib/efi_loader/efi_variable.c > > > @@ -427,13 +427,17 @@ efi_status_t efi_init_variables(void) > > > if (IS_ENABLED(CONFIG_EFI_VARIABLES_PRESEED)) { > > > ret = efi_var_restore((struct efi_var_file *) > > > __efi_var_file_begin, true); > > > - if (ret != EFI_SUCCESS) > > > + if (ret != EFI_SUCCESS) { > > > log_err("Invalid EFI variable seed\n"); > > > + return ret; > > > + } > > > } > > > - > > > - ret = efi_var_from_file(); > > > + ret = efi_init_secure_state(); > > > if (ret != EFI_SUCCESS) > > > return ret; > > > > > > - return efi_init_secure_state(); > > > + /* Don't stop booting if variable store is not available */ > > > + efi_var_from_file(); > > > > I think we have to think about two different cases: > > 1) there is no "variable store" file available. > > 2) it does exists, but reading from it (efi_var_restore()) failed > > > > For (2), we should return with an error as in the case of > > CONFIG_EFI_VARIABLES_PRESEED. > > Otherwise, the behavior is inconsistent. > > The preseed store is used for secure boot related variables. Where does this restriction come from? Kconfig says: Include a file with the initial values for non-volatile UEFI variables into the U-Boot binary. If this configuration option is set, changes to authentication related variables (PK, KEK, db, dbx) are not allowed. # oops: I didn't notice the last sentence. # but anyhow, it seems too restrictive. > If this > store is inconsistent, failing is required to ensure secure boot. As I said, a file-based variable configuration cannot work as a secure platform any way. Why do we need this kind of restriction? -Takahiro Akashi > With my patches applied the file store can not contain any secure boot > related variables but it may contain boot options. > > Your suggestion could mean that if the file store is corrupted the board > is bricked. > > If the boot options cannot be read either because the file does not > exist or because the file is corrupt, I still want the user to have a > chance to load shim, GRUB, or the kernel and boot via the bootefi command. > > I cannot see any inconsistency here. > > Best regards > > Heinrich