[PATCH] efiboot: Return success after large ESP file stats

Thomas Habets <[email protected]> Mon, 13 Jul 2026 09:15:37 -0500
Newsgroups gmane.os.openbsd.tech
Message-ID <CA+kHd+feUTTwQyaGSKHVOztEk1W=hOoNOmatR6yNDLcNyNTWOg@mail.gmail.com>
Return success after large ESP file stats

esp_stat() handled EFI_BUFFER_TOO_SMALL by allocating a larger
EFI_FILE_INFO buffer, but kept rv set to -1 even when the second
GetInfo() succeeded. This left callers with an error return for ESP
files whose metadata did not fit in the stack buffer.

Found with LLM. Looks right.

diff --git a/sys/arch/amd64/stand/efiboot/efidev.c
b/sys/arch/amd64/stand/efiboot/efidev.c
index a9b760126..078443131 100644
--- a/sys/arch/amd64/stand/efiboot/efidev.c
+++ b/sys/arch/amd64/stand/efiboot/efidev.c
@@ -934,6 +934,7 @@ esp_stat(struct open_file *f, struct stat *sb)
                goto done;

        sb->st_size = fip->FileSize;
+       rv = 0;

 done:
        free(fip, filen);
diff --git a/sys/arch/arm64/stand/efiboot/efidev.c
b/sys/arch/arm64/stand/efiboot/efidev.c
index 14b4debde..0a06d8add 100644
--- a/sys/arch/arm64/stand/efiboot/efidev.c
+++ b/sys/arch/arm64/stand/efiboot/efidev.c
@@ -720,6 +720,7 @@ esp_stat(struct open_file *f, struct stat *sb)
                goto done;

        sb->st_size = fip->FileSize;
+       rv = 0;

 done:
        free(fip, filen);