From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heinrich Schuchardt Date: Tue, 14 May 2019 08:35:04 +0200 Subject: [U-Boot] [PATCH] efi_loader: variable: attributes may not be changed if a variable exists In-Reply-To: <20190514045752.10035-1-takahiro.akashi@linaro.org> References: <20190514045752.10035-1-takahiro.akashi@linaro.org> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 5/14/19 6:57 AM, AKASHI Takahiro wrote: > If a variable already exists, efi_set_variable() should not change > the variable's attributes. This patch enforces it. This behavior is mandated by UEFI spec 2.7. Reviewed-by: Heinrich Schuchardt > > Signed-off-by: AKASHI Takahiro > --- > lib/efi_loader/efi_variable.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c > index 37728c3c165d..c4f3a5d2743d 100644 > --- a/lib/efi_loader/efi_variable.c > +++ b/lib/efi_loader/efi_variable.c > @@ -450,6 +450,15 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, > ret = EFI_WRITE_PROTECTED; > goto out; > } > + > + /* > + * attributes won't be changed > + * TODO: take care of APPEND_WRITE once supported > + */ > + if (attr != attributes) { > + ret = EFI_INVALID_PARAMETER; > + goto out; > + } > } > > val = malloc(2 * data_size + strlen("{ro,run,boot}(blob)") + 1); >