From: Kees Cook <keescook@chromium.org>
To: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
kernel-dev@igalia.com, kernel@gpiccoli.net, anton@enomsg.org,
ccross@android.com, tony.luck@intel.com
Subject: Re: [PATCH 2/8] pstore: Expose kmsg_bytes as a module parameter
Date: Wed, 12 Oct 2022 10:58:44 -0700 [thread overview]
Message-ID: <202210120958.37D9621E8C@keescook> (raw)
In-Reply-To: <267ccf8f-1fea-7648-ec2b-e7f4ae822ae4@igalia.com>
On Wed, Oct 12, 2022 at 12:33:36PM -0300, Guilherme G. Piccoli wrote:
> On 06/10/2022 20:32, Kees Cook wrote:
> > [...]
> > Doing a mount will override the result, so I wonder if there should be
> > two variables, etc... not a concern for the normal use case.
> >
> > Also, I've kind of wanted to get rid of a "default" for this and instead
> > use a value based on the compression vs record sizes, etc. But I didn't
> > explore it.
> >
>
> For some reason I forgot to respond that, sorry!
>
> I didn't understand exactly how the mount would override things; I've
> done some tests:
>
> (1) booted with the new kmsg_bytes module parameter set to 64k, and it
> was preserved across multiple mount/umount cycles.
>
> (2) When I manually had "-o kmsg_bytes=16k" set during the mount
> operation, it worked as expected, setting the thing to 16k (and
> reflecting in the module parameter, as observed in /sys/modules).
What I was imagining was the next step:
(3) umount, unload the backend, load a new backend, and mount it
without kmsg_bytes specified -- kmsg_bytes will be 16k, not 64k.
It's a pretty extreme corner-case, I realize. :) However, see below...
> In the end, if you think properly, what is the purpose of kmsg_bytes?
> Wouldn't make sense to just fill the record_size with the maximum amount
> of data it can handle? Of course there is the partitioning thing, but in
> the end kmsg_bytes seems a mechanism to _restrict_ the data collection,
> so maybe the default would be a value that means "save whatever you can
> handle" (maybe 0), and if the parameter/mount option is set, then pstore
> would restrict the saved size.
Right, kmsg_bytes is the maximum size to save from the console on a
crash. The design of the ram backend was to handle really small amounts
of persistent RAM -- if a single crash would eat all of it and possibly
wrap around, it could write over useful parts at the end (since it's
written from the end to the front). However, I think somewhere along
the way, stricter logic was added to the ram backend:
/*
* Explicitly only take the first part of any new crash.
* If our buffer is larger than kmsg_bytes, this can never happen,
* and if our buffer is smaller than kmsg_bytes, we don't want the
* report split across multiple records.
*/
if (record->part != 1)
return -ENOSPC;
This limits it to just a single record.
However, this does _not_ exist for other backends, so they will see up
to kmsg_bytes-size dumps split across psinfo->bufsize many records. For
the backends, this record size is not always fixed:
- efi uses 1024, even though it allocates 4096 (as was pointed out earlier)
- zone uses kmsg_bytes
- acpi-erst uses some ACPI value from ACPI_ERST_GET_ERROR_LENGTH
- ppc-nvram uses the configured size of nvram partition
Honestly, it seems like the 64k default is huge, but I don't think it
should be "unlimited" given the behaviors of ppc-nvram, and acpi-erst.
For ram and efi, it's effectively unlimited because of the small bufsizes
(and the "only 1 record" logic in ram).
Existing documentation I can find online seem to imply making it smaller
(8000 bytes[1], 16000 bytes), but without justification. Even the "main"
documentation[2] doesn't mention it.
-Kees
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/ABI/testing/pstore
[2] https://docs.kernel.org/admin-guide/ramoops.html
--
Kees Cook
next prev parent reply other threads:[~2022-10-12 17:58 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-06 22:42 [PATCH 0/8] Some pstore improvements Guilherme G. Piccoli
2022-10-06 22:42 ` [PATCH 1/8] pstore: Improve error reporting in case of backend overlap Guilherme G. Piccoli
2022-10-06 23:27 ` Kees Cook
2022-10-06 23:35 ` Guilherme G. Piccoli
2022-10-06 22:42 ` [PATCH 2/8] pstore: Expose kmsg_bytes as a module parameter Guilherme G. Piccoli
2022-10-06 23:32 ` Kees Cook
2022-10-12 15:33 ` Guilherme G. Piccoli
2022-10-12 17:58 ` Kees Cook [this message]
2022-11-01 19:08 ` Guilherme G. Piccoli
2022-10-06 22:42 ` [PATCH 3/8] pstore: Inform unregistered backend names as well Guilherme G. Piccoli
2022-10-06 22:42 ` [PATCH 4/8] pstore: Alert on backend write error Guilherme G. Piccoli
2022-10-06 23:27 ` Kees Cook
2022-10-06 23:34 ` Guilherme G. Piccoli
2022-10-06 23:44 ` Kees Cook
2022-10-06 22:42 ` [PATCH 5/8] pstore: Fix long-term implicit conversions in the compression routines Guilherme G. Piccoli
2022-10-06 23:36 ` Kees Cook
2022-10-07 8:47 ` Ard Biesheuvel
2022-10-07 19:37 ` Kees Cook
2022-10-08 14:14 ` Guilherme G. Piccoli
2022-10-08 15:53 ` Ard Biesheuvel
2022-10-08 16:03 ` Guilherme G. Piccoli
2022-10-08 17:52 ` Ard Biesheuvel
2022-10-08 18:12 ` Guilherme G. Piccoli
2022-10-08 19:44 ` Kees Cook
2022-10-10 7:24 ` Ard Biesheuvel
2022-10-06 22:42 ` [PATCH 6/8] MAINTAINERS: Add a mailing-list for the pstore infrastructure Guilherme G. Piccoli
2022-10-06 23:22 ` Kees Cook
2022-10-06 23:29 ` Luck, Tony
2022-10-06 23:37 ` Kees Cook
2022-10-07 16:19 ` Luck, Tony
2022-10-07 16:21 ` Colin Cross
2022-10-07 16:32 ` Guilherme G. Piccoli
2022-10-07 19:25 ` Kees Cook
2022-10-06 22:42 ` [PATCH 7/8] efi: pstore: Follow convention for the efi-pstore backend name Guilherme G. Piccoli
2022-10-06 23:16 ` Kees Cook
2022-10-07 8:47 ` Ard Biesheuvel
2022-10-14 17:41 ` (subset) " Kees Cook
2024-06-03 23:02 ` Stephen Boyd
2024-06-04 19:05 ` Guilherme G. Piccoli
2022-10-06 22:42 ` [PATCH 8/8] efi: pstore: Add module parameter for setting the record size Guilherme G. Piccoli
2022-10-06 23:16 ` Kees Cook
2022-10-07 9:11 ` Ard Biesheuvel
2022-10-07 13:00 ` Guilherme G. Piccoli
2022-10-07 13:19 ` Ard Biesheuvel
2022-10-07 13:45 ` Guilherme G. Piccoli
2022-10-07 15:06 ` Ard Biesheuvel
2022-10-07 17:01 ` Guilherme G. Piccoli
2022-10-07 19:32 ` Kees Cook
2022-10-07 23:29 ` Guilherme G. Piccoli
2022-10-08 2:36 ` Kees Cook
2022-10-06 23:24 ` [PATCH 0/8] Some pstore improvements Kees Cook
2022-10-12 15:50 ` Guilherme G. Piccoli
2022-10-12 17:59 ` 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=202210120958.37D9621E8C@keescook \
--to=keescook@chromium.org \
--cc=anton@enomsg.org \
--cc=ccross@android.com \
--cc=gpiccoli@igalia.com \
--cc=kernel-dev@igalia.com \
--cc=kernel@gpiccoli.net \
--cc=linux-fsdevel@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;
as well as URLs for NNTP newsgroup(s).