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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 52B46C433F5 for ; Wed, 16 Mar 2022 16:08:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1CE5C83BA1; Wed, 16 Mar 2022 17:08:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="YHXfTzhI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 06C4E83BA1; Wed, 16 Mar 2022 17:08:34 +0100 (CET) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2190A82093 for ; Wed, 16 Mar 2022 17:08:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1647446885; bh=ITrZiMosUZoq0dzyPdUcum4ieRI5TFnhbuFejwwIezA=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=YHXfTzhI7mOs+4B+8quHGVda5zl8AfTQ7HzFc2EkAEJJUHWsBLTEIAyxf/k2bzccT U6oTEGMibolPYgHrNjOY823ADflOkyi3FKXCzEBJSP6bPc06zDHie5xwbFfXRHp52a j570FVGquFIB90ejF/5ZWQ/q/u7tGAUjZUU+eTiA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.67] ([88.152.144.107]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MOzOw-1nl6Ay41EK-00PLDl; Wed, 16 Mar 2022 17:08:05 +0100 Message-ID: <10c0b89a-16fe-88a1-fbfd-4e005a2741b6@gmx.de> Date: Wed, 16 Mar 2022 17:08:04 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v2] efi_loader: Set variable attributes when EFI_BUFFER_TOO_SMALL is returned Content-Language: en-US To: Ilias Apalodimas Cc: Stuart.Yoder@arm.com, paul.liu@linaro.org, u-boot@lists.denx.de References: <20220316151337.1497396-1-ilias.apalodimas@linaro.org> From: Heinrich Schuchardt In-Reply-To: <20220316151337.1497396-1-ilias.apalodimas@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:PXb+afRtL4AR0uB7lntbrG5dpJLPoaKyoGhSVmjdxys03mIAhi+ nEFVvTMMwCs6xz6n2KHGTxXeCauLdaQpPiAE2nh3c+KBNcxQN4T3MLxIOQJMwQPxRG2dfgc hJ8W8KG9XtY4soACORq5MAr5yy3C+202oxTR/Gt/z+WIlFPFHqlg93HA75NR7wyAnWNRkH2 I1c+xJQv1aJ6CBs3Io0Mg== X-UI-Out-Filterresults: notjunk:1;V03:K0:Wc16EPhHOHo=:rMu+AmlpQHa5zwEI/y61SF CGuybDVUPfAzcs0FkTSjx6ImCYaG6Ibi+eveyUJD9JkNcjZeEhpz2BzyaOujfmLzvATrMs6+e b6388kYBwYrQiIvjYQWD0AYZO10I5gtIfDWk4KprvgmmtBsYa7arbj4hi5J86scRDS09QTsdg MVR2DdmD9xEjVU9xwZAhA4XGvOzJ3iGdpzZE3ETOlJrrw9p8tXn104Mp4+7OSYMVQOjuExuz5 ZNvoHTvVaAl78+ifiktKKdGYM4r70nqmH+m5vpCQoj3EBq21XXEfjDYxH4MRbTNWOixo4gdgB 2vbwrRCsP6Ekqw5WUzdEvK+1EAzosL7ZxJJ9rpNrxnEfutalv+rNdXmbh1K2TGq3rTn4tQ7LR KbmVWeAnrwHxOUFaMKt7inFAE+IwYWzVAIXQGI23qJ6HxQ1bR/CrPjTYtmhRrS9H8JmP65tsB gr19ywad7behJwAyd70xoumQF13UcEDLHcijXXi63ZOm7Nwj+2reYIEfSueoK+11nE1f6+q6H 7FKhgk/hVkOfE29K7IgXZIcnhzNFz7DZ3VTcRmXfM3Ne0SK8x8f0tYoq9zwfLXigLBP+PhJWJ X47EfwUANGXzQvKuXBwOhbSoVWyXfX7N+Rrgmw28CK1/fWREQ22CiMt5rG/wp8pzSnK0Lom7s /SCX/RY/RpEKf+caQvT/HyIQ6Uqxzsyw1z6XB2QHmZ1YUlNC95kDfRh6531QEoYV5BJMXUXn1 aer8P6qTpm98qEayVOXMa0+TlF1sUbUNNj6eV7O4sSsa3v8Odg1QeJAcL+oOYFLdsUybfGI2C Y4oVKfK37E5zxfwj4h7IACuyMbopad6mwN6lr3mI5if5WKbwsZJU0CLOsaKovDDhI06h6ZV/A S+7D9y+zRindMkyjK7CItC0XYvnH2ld9UQfa8nsqQjZgcR9aW1gRfyAkyxMo5cdRUpSWX1Uu+ o4ghaIeO1BZxu3pi79jBENbbSG49PQlY36yrmtuOVNnd9YsDKJUUSElC6qIa4nOw89PYMP5KZ qpHM1YYRj9mLXs3omDSrtwOzX6dp4EUP29E80NioRvttzerrWZReO0iW6gzGsZnvlVPVxSTJQ 09E66mtbrNMI7o= 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.5 at phobos.denx.de X-Virus-Status: Clean On 3/16/22 16:13, Ilias Apalodimas wrote: > Starting UEFI Spec 2.8 we must fill in the variable attributes when > GetVariable() returns EFI_BUFFER_TOO_SMALL and Attributes is non-NULL. > > This code was written with 2.7 in mind so let's move the code around a > bit and fill in the attributes EFI_BUFFER_TOO_SMALL is returned > > Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt > --- > Changes since v1: > - tmp variables switched to efi_status_t instead of int > - switched (ret =3D=3D EFI_SUCCESS || ret =3D=3D EFI_BUFFER_TOO_SMALL) > to (ret !=3D EFI_SUCCESS && ret !=3D EFI_BUFFER_TOO_SMALL) to > make the code easier to read > - Only call get_property_int() if attributes !=3D NULL > > lib/efi_loader/efi_variable_tee.c | 31 ++++++++++++++++++++----------- > 1 file changed, 20 insertions(+), 11 deletions(-) > > diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_vari= able_tee.c > index 58931c4efd74..dfef18435dfa 100644 > --- a/lib/efi_loader/efi_variable_tee.c > +++ b/lib/efi_loader/efi_variable_tee.c > @@ -368,7 +368,7 @@ efi_status_t efi_get_variable_int(const u16 *variabl= e_name, > efi_uintn_t name_size; > efi_uintn_t tmp_dsize; > u8 *comm_buf =3D NULL; > - efi_status_t ret; > + efi_status_t ret, tmp; > > if (!variable_name || !vendor || !data_size) { > ret =3D EFI_INVALID_PARAMETER; > @@ -407,23 +407,32 @@ efi_status_t efi_get_variable_int(const u16 *varia= ble_name, > > /* Communicate */ > ret =3D mm_communicate(comm_buf, payload_size); > - if (ret =3D=3D EFI_SUCCESS || ret =3D=3D EFI_BUFFER_TOO_SMALL) { > - /* Update with reported data size for trimmed case */ > - *data_size =3D var_acc->data_size; > - } > - if (ret !=3D EFI_SUCCESS) > - goto out; > - > - ret =3D get_property_int(variable_name, name_size, vendor, &var_proper= ty); > - if (ret !=3D EFI_SUCCESS) > + if (ret !=3D EFI_SUCCESS && ret !=3D EFI_BUFFER_TOO_SMALL) > goto out; > > + /* Update with reported data size for trimmed case */ > + *data_size =3D var_acc->data_size; > + /* > + * UEFI > 2.7 needs the attributes set even if the buffer is > + * smaller > + */ > if (attributes) { > + tmp =3D get_property_int(variable_name, name_size, vendor, > + &var_property); > + if (tmp !=3D EFI_SUCCESS) { > + ret =3D tmp; > + goto out; > + } > *attributes =3D var_acc->attr; > - if (var_property.property & VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY) > + if (var_property.property & > + VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY) > *attributes |=3D EFI_VARIABLE_READ_ONLY; > } > > + /* return if ret is EFI_BUFFER_TOO_SMALL */ > + if (ret !=3D EFI_SUCCESS) > + goto out; > + > if (data) > memcpy(data, (u8 *)var_acc->name + var_acc->name_size, > var_acc->data_size);