From dbebae5ec77eee029fb36337643e052eecb50453 Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Fri, 24 May 2019 15:59:02 +0900 Subject: efi_loader: variable: return error for APPEND_WRITE The current efi_st_variable() doesn't support EFI_VARIABLE_APPEND_WRITE attiribute for now, and so should return an error. Signed-off-by: AKASHI Takahiro Fix typos is commit message. Add TODO comment. Reviewed-by: Heinrich Schuchardt Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_variable.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/efi_loader/efi_variable.c') diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 28b1aa7505a..0d973773fa1 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -427,7 +427,9 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, EFI_ENTRY("\"%ls\" %pUl %x %zu %p", variable_name, vendor, attributes, data_size, data); - if (!variable_name || !vendor) { + /* TODO: implement APPEND_WRITE */ + if (!variable_name || !vendor || + (attributes & EFI_VARIABLE_APPEND_WRITE)) { ret = EFI_INVALID_PARAMETER; goto out; } -- cgit v1.2.3 From a2c6983740104c8e608c411eff6a58e2f4feaede Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Fri, 24 May 2019 15:59:03 +0900 Subject: efi_loader: variable: attributes may not be changed if a variable exists If a variable already exists, efi_set_variable() should not change the variable's attributes. This patch enforces it. Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_variable.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/efi_loader/efi_variable.c') diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 0d973773fa1..50bc10537f4 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -451,12 +451,21 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, if (val) { parse_attr(val, &attr); + /* We should not free val */ + val = NULL; if (attr & READ_ONLY) { - /* We should not free val */ - val = NULL; 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); -- cgit v1.2.3