From patchwork Thu Jan 26 03:15:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 647040 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp34128pvb; Wed, 25 Jan 2023 19:12:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXt55eXbQPspsMmLnsAzckIbIG2z8lMK2K5gqWYSi7lyzcAwF4eP9WuuG9Su65gND8iA9yan X-Received: by 2002:a4a:c594:0:b0:4ff:4687:dc6c with SMTP id x20-20020a4ac594000000b004ff4687dc6cmr11499263oop.0.1674702772984; Wed, 25 Jan 2023 19:12:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674702772; cv=none; d=google.com; s=arc-20160816; b=oFI1oOzkq9lPVTlym4k6UhOmiCxTb2ocMbENe1husSI1KDgbmLj3RXYb8Ckom2Civ4 fKgkbjmfrmD26w+Ql5TWD2OkUQsULQLZYORoxdajiJexZ38UkjQLflVzPETytwi+w/BB j3L/GBKgxxPUS4PG44/YgEnEcF+bBSPb/agskfJ+0tmNm3sXN6jVESS6wW8uMxnvyAWE qPFr8ZRH95dQLjCG1ilTbjk7eOeImijZH6IVEl16iEtSytwYkaKx/SsKyHFp5gU97tVS cLFXbymsCGKR9yLNKP3jBEUlrTHhG2sp7yR7CJuJsRpdv5LNAaO5pFFwVSPyv7MVQ9y4 aI+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=09EW/7hMQAVIgImJpOVnjojZ0pOdlJlU6DRnWccIU+g=; b=arHnQTA/XHx8G7TdP3EQuO4vgCGxWg/FN+rv+Vc9Ui3UQ9sG9bfh9m9etShzfPuwoX 09mKmlZKLUnKXBCNoqXIVnsKS7S6exYyajlnYGmZxFk4rQhsFEudIC28N42dr0zMB0+m rmRB/AnozkGv8mgWby2aW6iGKVATpwK7RvDi3/5brTD2S50xJ5XSbc/DGbGncdBpJkSS zJ27HxfFdjss6REpbf0HbSoqgwADtVR3e2NEGubysW+rP6/i1PgREtduedeGLgox0g/r hSl6bfegBVlywAcZtS4kVzGn4JxHDegaw4ZZJ2K2NyHPBGoSB207esnJKRsiXiMQzXKu c5uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=suYNZGzk; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a184-20020a4a7ac1000000b004fc9937cb59si310066ooc.20.2023.01.25.19.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 19:12:52 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=suYNZGzk; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7FCB0854F1; Thu, 26 Jan 2023 04:12:46 +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=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="suYNZGzk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0D021854D8; Thu, 26 Jan 2023 04:12:44 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) (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 CA044854D8 for ; Thu, 26 Jan 2023 04:12:40 +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=masahisa.kojima@linaro.org Received: by mail-pj1-x102c.google.com with SMTP id rm7-20020a17090b3ec700b0022c05558d22so565649pjb.5 for ; Wed, 25 Jan 2023 19:12:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=09EW/7hMQAVIgImJpOVnjojZ0pOdlJlU6DRnWccIU+g=; b=suYNZGzkPF0TJ+vNq+yOYcATghO5kM3rBlBDZN/A81B9AlxO2mBY4bFK0XCkhXdjfU A9vsosF/XMh9rdkjvxxzbg6qbICsHy8mXYCsFScZgaFwG2eVcbtxcHmdMmGonPqbfXY1 RcCYMCl1beNubcmEVdcXvFoYA0Nnd5pSCvi95NtV46CpL4czdUsuXuN3Jk6Z+pMfZRxr HAqLPvm3tLXmgCaZEn+ItsvUfn7mEbQOVB8oyaUw8LaWgTSg7JQk30zGdvnCJ4isuYiz VmhBkKSKSuhVkrDIYs1po7U41xo9Vr4LbNXYK2/6R7x67eWd15ZTy2wOsQ94b/agsGHM Eziw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=09EW/7hMQAVIgImJpOVnjojZ0pOdlJlU6DRnWccIU+g=; b=Z5AV2V2WdGoE96ywxNtXXMfw2QV/nTOnIiAdUe9AseF1i+CH+p5LMVwwBaVOUY3B5g 3Jk0sBMHJ87aZH/gnRucAtCvdC7i0/7X/bBZN86dCJLwLCktqQiuoCSyTBprmSyifkxy UKWt2+lzKfSiDEdBWHdkDXHiSiyoFxWt3hXHNLmrZ5Orm0SZIu7iHFawnSTdkowCNUiY QIrn4Yf4prxssO0AfMGFi8fOMn2uW2P8cWg7Ux3k8G7n9NP0AA5XlNWG9SzZxd2uOA2D p7dO1GP69/ZccW1IVTas/ZaFiDRxzTw5C1VDSUId26DtVSYoXKISuZJ+GbrylimGjDDI kRtQ== X-Gm-Message-State: AFqh2kqhpIcR8cpBJ3QPVLnNFgyw5Pmy40SK2DKON7VZbjU8JvRhzKYk sMJRgPFCZdmTkSgcIRr0AZRyVejixawXN+kP X-Received: by 2002:a17:902:988f:b0:194:8fbd:1eb4 with SMTP id s15-20020a170902988f00b001948fbd1eb4mr33415463plp.1.1674702759009; Wed, 25 Jan 2023 19:12:39 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id iw3-20020a170903044300b00196217f1219sm136170plb.70.2023.01.25.19.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 19:12:38 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Masahisa Kojima , Heinrich Schuchardt , Ilias Apalodimas Subject: [PATCH] efi_loader: leave attribute check to StMM variable service Date: Thu, 26 Jan 2023 12:15:12 +0900 Message-Id: <20230126031512.17450-1-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean Current U-Boot supports two EFI variable service, U-Boot own implementation and op-tee based StMM variable service. For latter case, parameter check should leave to StMM. This commit removes the attribute check from the common function(efi_query_variable_info) and moves it to lib/efi_loader/efi_variable.c. Signed-off-by: Masahisa Kojima --- lib/efi_loader/efi_var_common.c | 10 +--------- lib/efi_loader/efi_variable.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c index eb83702781..ad50bffd2b 100644 --- a/lib/efi_loader/efi_var_common.c +++ b/lib/efi_loader/efi_var_common.c @@ -165,17 +165,9 @@ efi_status_t EFIAPI efi_query_variable_info( if (!maximum_variable_storage_size || !remaining_variable_storage_size || - !maximum_variable_size || - !(attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS)) + !maximum_variable_size) return EFI_EXIT(EFI_INVALID_PARAMETER); - if ((attributes & ~(u32)EFI_VARIABLE_MASK) || - (attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) || - (attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) || - (!IS_ENABLED(CONFIG_EFI_SECURE_BOOT) && - (attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS))) - return EFI_EXIT(EFI_UNSUPPORTED); - ret = efi_query_variable_info_int(attributes, maximum_variable_storage_size, remaining_variable_storage_size, diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 7c32adf6e5..86f39181e0 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -349,6 +349,16 @@ efi_status_t efi_query_variable_info_int(u32 attributes, u64 *remaining_variable_storage_size, u64 *maximum_variable_size) { + if (!(attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS)) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + if ((attributes & ~(u32)EFI_VARIABLE_MASK) || + (attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) || + (attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) || + (!IS_ENABLED(CONFIG_EFI_SECURE_BOOT) && + (attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS))) + return EFI_EXIT(EFI_UNSUPPORTED); + *maximum_variable_storage_size = EFI_VAR_BUF_SIZE - sizeof(struct efi_var_file); *remaining_variable_storage_size = efi_var_mem_free();