From: Jason Andryuk <jandryuk@gmail.com>
To: grub-devel@gnu.org
Cc: Jason Andryuk <jandryuk@gmail.com>
Subject: [PATCH] gzio: Avoid spurious failures
Date: Tue, 10 Oct 2023 12:24:24 -0400 [thread overview]
Message-ID: <20231010162424.35854-1-jandryuk@gmail.com> (raw)
grub_gzio_read_real() uses grub_errno to identify decompression failures
when the function completes. Its callees in gzio.c are void-returning
functions that set grub_errno on their exit paths.
A Fedora 38 machine was observed to fail `multiboot2 /xen.gz` with
"premature end of file". xen.gz was well formed and could be
successfully gunzip-ed in Linux.
The TPM is flaky and produces errors when the verifier tries to extend
PCRs with measurements. Logs show "Unkown TPM error" and grub_errno is
set to GRUB_ERR_UNKNOWN_DEVICE. This pre-existing grub_errno causes an
otherwise successful grub_gzio_read_real() call to return error.
Clear grub_errno at the start of the function to avoid such errors.
Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
---
grub-core/io/gzio.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c
index ca9355751..1e31a8255 100644
--- a/grub-core/io/gzio.c
+++ b/grub-core/io/gzio.c
@@ -1294,6 +1294,14 @@ grub_gzio_read_real (grub_gzio_t gzio, grub_off_t offset,
{
grub_ssize_t ret = 0;
+ /* Avoid spurious failures on exit when grub_errno is already set. */
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_dprintf ("gzio", "%s: clearing pre-exising errmsg %s\n",
+ __func__, grub_errmsg);
+ grub_errno = GRUB_ERR_NONE;
+ }
+
/* Do we reset decompression to the beginning of the file? */
if (gzio->saved_offset > offset + WSIZE)
initialize_tables (gzio);
--
2.41.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next reply other threads:[~2023-10-10 16:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 16:24 Jason Andryuk [this message]
2023-10-10 18:23 ` [PATCH] gzio: Avoid spurious failures Glenn Washburn
2023-10-11 12:42 ` Jason Andryuk
2023-10-12 1:40 ` Glenn Washburn
2023-10-31 15:10 ` Daniel Kiper
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=20231010162424.35854-1-jandryuk@gmail.com \
--to=jandryuk@gmail.com \
--cc=grub-devel@gnu.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).