U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Vincent Stehlé" <vincent.stehle@arm.com>
To: u-boot@lists.u-boot-project.org
Cc: "Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Tom Rini" <trini@konsulko.com>,
	"Vincent Stehlé" <vincent.stehle@arm.com>
Subject: [PATCH 2/2] efi_selftest: verify get_variable() never returns append_write
Date: Fri, 13 Nov 2026 16:07:57 +0100	[thread overview]
Message-ID: <20261113-append-v1-2-4cb63d522562@arm.com> (raw)
In-Reply-To: <20261113-append-v1-0-4cb63d522562@arm.com>

Verify that EFI_VARIABLE_APPEND_WRITE is never set in the Attributes
bitmask returned by GetVariable() when it succeeds.

This can be run on the sandbox with the following command:

  ./u-boot -T -c 'setenv efi_selftest variables; bootefi selftest'

Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
---
 lib/efi_selftest/efi_selftest_variables.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/lib/efi_selftest/efi_selftest_variables.c b/lib/efi_selftest/efi_selftest_variables.c
index 976eee8dcef..35d6387009d 100644
--- a/lib/efi_selftest/efi_selftest_variables.c
+++ b/lib/efi_selftest/efi_selftest_variables.c
@@ -65,6 +65,10 @@ static int execute(void)
 		efi_st_error("GetVariable wrote past the end of the buffer\n");
 		return EFI_ST_FAILURE;
 	}
+	if (attr & EFI_VARIABLE_APPEND_WRITE) {
+		efi_st_error("APPEND_WRITE in returned attributes\n");
+		return EFI_ST_FAILURE;
+	}
 	/* Set variable 1 */
 	ret = st_runtime->set_variable(u"efi_st_var1", &guid_vendor1,
 				       EFI_VARIABLE_BOOTSERVICE_ACCESS, 8, v);
@@ -88,6 +92,10 @@ static int execute(void)
 		efi_st_error("GetVariable returned wrong value\n");
 		return EFI_ST_FAILURE;
 	}
+	if (attr & EFI_VARIABLE_APPEND_WRITE) {
+		efi_st_error("APPEND_WRITE in returned attributes\n");
+		return EFI_ST_FAILURE;
+	}
 	/* Append variable 1 */
 	ret = st_runtime->set_variable(u"efi_st_var1", &guid_vendor1,
 				       EFI_VARIABLE_BOOTSERVICE_ACCESS |
@@ -109,7 +117,10 @@ static int execute(void)
 			    (unsigned int)len);
 	if (memcmp(data, v, len))
 		efi_st_todo("GetVariable returned wrong value\n");
-
+	if (attr & EFI_VARIABLE_APPEND_WRITE) {
+		efi_st_error("APPEND_WRITE in returned attributes\n");
+		return EFI_ST_FAILURE;
+	}
 	/* Append variable 2, write to non-existent variable with datasize=0 */
 	ret = st_runtime->set_variable(u"efi_none", &guid_vendor1,
 				       EFI_VARIABLE_BOOTSERVICE_ACCESS |
@@ -149,6 +160,10 @@ static int execute(void)
 			    (unsigned int)len);
 	if (memcmp(data, v, len))
 		efi_st_todo("GetVariable returned wrong value\n");
+	if (attr & EFI_VARIABLE_APPEND_WRITE) {
+		efi_st_error("APPEND_WRITE in returned attributes\n");
+		return EFI_ST_FAILURE;
+	}
 	/* Delete variable efi_none */
 	ret = st_runtime->set_variable(u"efi_none", &guid_vendor1, 0, 0, NULL);
 	if (ret != EFI_SUCCESS) {

-- 
2.53.0


      parent reply	other threads:[~2026-11-13 15:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 15:07 [PATCH 0/2] efi: fix and verify variables append_write Vincent Stehlé
2026-11-13 15:07 ` [PATCH 1/2] efi_loader: prevent set_variable() to record append_write Vincent Stehlé
2026-11-22 11:55   ` Heinrich Schuchardt
2026-11-24  8:48     ` Vincent Stehlé
2026-11-24  9:53       ` Vincent Stehlé
2026-11-24 10:10         ` Heinrich Schuchardt
2026-11-24 10:41           ` Vincent Stehlé
2026-11-13 15:07 ` Vincent Stehlé [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261113-append-v1-2-4cb63d522562@arm.com \
    --to=vincent.stehle@arm.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox