From: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
To: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, linux-efi@vger.kernel.org,
kernel-dev@igalia.com, kernel@gpiccoli.net,
keescook@chromium.org, anton@enomsg.org, ccross@android.com,
tony.luck@intel.com, ardb@kernel.org,
"Guilherme G. Piccoli" <gpiccoli@igalia.com>
Subject: [PATCH V2 1/3] pstore: Alert on backend write error
Date: Thu, 13 Oct 2022 18:06:46 -0300 [thread overview]
Message-ID: <20221013210648.137452-2-gpiccoli@igalia.com> (raw)
In-Reply-To: <20221013210648.137452-1-gpiccoli@igalia.com>
The pstore dump function doesn't alert at all on errors - despite
pstore is usually a last resource and if it fails users won't be
able to read the kernel log, this is not the case for server users
with serial access, for example.
So, let's at least attempt to inform such advanced users on the first
backend writing error detected during the kmsg dump - this is also
very useful for pstore debugging purposes.
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
---
V2:
- Show error message late, outside of the critical region
(thanks Kees for the idea!).
fs/pstore/platform.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 06c2c66af332..cbc0b468c1ab 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -393,6 +393,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
const char *why;
unsigned int part = 1;
unsigned long flags = 0;
+ int saved_ret = 0;
int ret;
why = kmsg_dump_reason_str(reason);
@@ -463,12 +464,21 @@ static void pstore_dump(struct kmsg_dumper *dumper,
if (ret == 0 && reason == KMSG_DUMP_OOPS) {
pstore_new_entry = 1;
pstore_timer_kick();
+ } else {
+ /* Preserve only the first non-zero returned value. */
+ if (!saved_ret)
+ saved_ret = ret;
}
total += record.size;
part++;
}
spin_unlock_irqrestore(&psinfo->buf_lock, flags);
+
+ if (saved_ret) {
+ pr_err_once("backend (%s) writing error (%d)\n", psinfo->name,
+ saved_ret);
+ }
}
static struct kmsg_dumper pstore_dumper = {
--
2.38.0
next prev parent reply other threads:[~2022-10-13 21:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 21:06 [PATCH V2 0/3] Some pstore improvements V2 Guilherme G. Piccoli
2022-10-13 21:06 ` Guilherme G. Piccoli [this message]
2022-10-14 14:46 ` [PATCH V2 1/3] pstore: Alert on backend write error Ard Biesheuvel
2022-10-14 17:41 ` (subset) " Kees Cook
2022-10-13 21:06 ` [PATCH V2 2/3] efi: pstore: Follow convention for the efi-pstore backend name Guilherme G. Piccoli
2022-10-13 21:06 ` [PATCH V2 3/3] efi: pstore: Add module parameter for setting the record size Guilherme G. Piccoli
2022-10-14 14:46 ` Ard Biesheuvel
2022-10-14 14:57 ` Guilherme G. Piccoli
2022-10-14 15:00 ` Ard Biesheuvel
2022-10-14 15:19 ` Guilherme G. Piccoli
2022-10-14 17:42 ` Kees Cook
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=20221013210648.137452-2-gpiccoli@igalia.com \
--to=gpiccoli@igalia.com \
--cc=anton@enomsg.org \
--cc=ardb@kernel.org \
--cc=ccross@android.com \
--cc=keescook@chromium.org \
--cc=kernel-dev@igalia.com \
--cc=kernel@gpiccoli.net \
--cc=linux-efi@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
/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