Skip to content

Commit

Permalink
pstore/platform: Pass max_reason to kmesg dump
Browse files Browse the repository at this point in the history
Add a new member to struct pstore_info for passing information about
kmesg dump maximum reason. This allows a finer control of what kmesg
dumps are sent to pstore storage backends.

Those backends that do not explicitly set this field (keeping it equal to
0), get the default behavior: store only Oopses and Panics, or everything
if the printk.always_kmsg_dump boot param is set.

Signed-off-by: Pavel Tatashin <pasha.tatashin@soleen.com>
Link: https://lore.kernel.org/lkml/20200515184434.8470-5-keescook@chromium.org/
Co-developed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
  • Loading branch information
Pavel Tatashin authored and Kees Cook committed May 30, 2020
1 parent fb13cb8 commit 3524e68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/pstore/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,10 @@ int pstore_register(struct pstore_info *psi)

pstore_get_records(0);

if (psi->flags & PSTORE_FLAGS_DMESG)
if (psi->flags & PSTORE_FLAGS_DMESG) {
pstore_dumper.max_reason = psinfo->max_reason;
pstore_register_kmsg();
}
if (psi->flags & PSTORE_FLAGS_CONSOLE)
pstore_register_console();
if (psi->flags & PSTORE_FLAGS_FTRACE)
Expand Down
7 changes: 7 additions & 0 deletions include/linux/pstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ struct pstore_record {
*
* @read_mutex: serializes @open, @read, @close, and @erase callbacks
* @flags: bitfield of frontends the backend can accept writes for
* @max_reason: Used when PSTORE_FLAGS_DMESG is set. Contains the
* kmsg_dump_reason enum value. KMSG_DUMP_UNDEF means
* "use existing kmsg_dump() filtering, based on the
* printk.always_kmsg_dump boot param" (which is either
* KMSG_DUMP_OOPS when false, or KMSG_DUMP_MAX when
* true); see printk.always_kmsg_dump for more details.
* @data: backend-private pointer passed back during callbacks
*
* Callbacks:
Expand Down Expand Up @@ -179,6 +185,7 @@ struct pstore_info {
struct mutex read_mutex;

int flags;
int max_reason;
void *data;

int (*open)(struct pstore_info *psi);
Expand Down

0 comments on commit 3524e68

Please sign in to comment.