linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pstore: Move kmsg_bytes default into Kconfig
@ 2020-12-01 20:12 Kees Cook
  2020-12-02 21:42 ` Konstantin Ryabitsev
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2020-12-01 20:12 UTC (permalink / raw)
  To: Vasile-Laurentiu Stanimir
  Cc: Kees Cook, Anton Vorontsov, Colin Cross, Tony Luck, linux-kernel

From: Vasile-Laurentiu Stanimir <vasile-laurentiu.stanimir@windriver.com>

While kmsg_bytes can be set for pstore via mount, if a crash occurs
before the mount only partial console log will be stored as kmsg_bytes
defaults to a potentially different hardcoded value in the kernel
(PSTORE_DEFAULT_KMSG_BYTES). This makes it impossible to analyze valuable
post-mortem data especially on the embedded development or in the process
of bringing up new boards. Change this value to be a Kconfig option
with the default of old PSTORE_DEFAULT_KMSG_BYTES

Signed-off-by: Vasile-Laurentiu Stanimir <vasile-laurentiu.stanimir@windriver.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
This was sent off-list, so I'm resending it to lkml (with the commit log
cleaned up sligthly) before I push it into for-next/pstore.
---
 fs/pstore/Kconfig    | 8 ++++++++
 fs/pstore/inode.c    | 2 +-
 fs/pstore/internal.h | 1 -
 fs/pstore/platform.c | 2 +-
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig
index e16a49ebfe54..8adabde685f1 100644
--- a/fs/pstore/Kconfig
+++ b/fs/pstore/Kconfig
@@ -14,6 +14,14 @@ config PSTORE
 	   If you don't have a platform persistent store driver,
 	   say N.
 
+config PSTORE_DEFAULT_KMSG_BYTES
+	int "Default kernel log storage space" if EXPERT
+	depends on PSTORE
+	default "10240"
+	help
+	  Defines default size of pstore kernel log storage.
+	  Can be enlarged if needed, not recommended to shrink it.
+
 config PSTORE_DEFLATE_COMPRESS
 	tristate "DEFLATE (ZLIB) compression"
 	default y
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index c331efe8de95..93a217e4f563 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -266,7 +266,7 @@ static void parse_options(char *options)
  */
 static int pstore_show_options(struct seq_file *m, struct dentry *root)
 {
-	if (kmsg_bytes != PSTORE_DEFAULT_KMSG_BYTES)
+	if (kmsg_bytes != CONFIG_PSTORE_DEFAULT_KMSG_BYTES)
 		seq_printf(m, ",kmsg_bytes=%lu", kmsg_bytes);
 	return 0;
 }
diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h
index 7fb219042f13..801d6c0b170c 100644
--- a/fs/pstore/internal.h
+++ b/fs/pstore/internal.h
@@ -6,7 +6,6 @@
 #include <linux/time.h>
 #include <linux/pstore.h>
 
-#define PSTORE_DEFAULT_KMSG_BYTES 10240
 extern unsigned long kmsg_bytes;
 
 #ifdef CONFIG_PSTORE_FTRACE
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 36714df37d5d..32f64abc277c 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -101,7 +101,7 @@ static char *big_oops_buf;
 static size_t big_oops_buf_sz;
 
 /* How much of the console log to snapshot */
-unsigned long kmsg_bytes = PSTORE_DEFAULT_KMSG_BYTES;
+unsigned long kmsg_bytes = CONFIG_PSTORE_DEFAULT_KMSG_BYTES;
 
 void pstore_set_kmsg_bytes(int bytes)
 {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] pstore: Move kmsg_bytes default into Kconfig
  2020-12-01 20:12 [PATCH] pstore: Move kmsg_bytes default into Kconfig Kees Cook
@ 2020-12-02 21:42 ` Konstantin Ryabitsev
  2020-12-02 22:30   ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Konstantin Ryabitsev @ 2020-12-02 21:42 UTC (permalink / raw)
  To: Kees Cook; +Cc: linux-kernel

On Tue, Dec 01, 2020 at 12:12:34PM -0800, Kees Cook wrote:
> ---
> This was sent off-list, so I'm resending it to lkml (with the commit log
> cleaned up sligthly) before I push it into for-next/pstore.

Also, nice:

Writing /tmp/20201201_keescook_pstore_move_kmsg_bytes_default_into_kconfig.mbx
  ✔ [PATCH] pstore: Move kmsg_bytes default into Kconfig
  ---
  ✔ Attestation-by: Kees Cook <keescook@chromium.org> (pgp: 8972F4DFDC6DC026)

Did you use the sendemail-validate hook for this?

:)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pstore: Move kmsg_bytes default into Kconfig
  2020-12-02 21:42 ` Konstantin Ryabitsev
@ 2020-12-02 22:30   ` Kees Cook
  2020-12-02 22:36     ` Konstantin Ryabitsev
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2020-12-02 22:30 UTC (permalink / raw)
  To: Konstantin Ryabitsev; +Cc: linux-kernel

On Wed, Dec 02, 2020 at 04:42:57PM -0500, Konstantin Ryabitsev wrote:
> On Tue, Dec 01, 2020 at 12:12:34PM -0800, Kees Cook wrote:
> > ---
> > This was sent off-list, so I'm resending it to lkml (with the commit log
> > cleaned up sligthly) before I push it into for-next/pstore.
> 
> Also, nice:
> 
> Writing /tmp/20201201_keescook_pstore_move_kmsg_bytes_default_into_kconfig.mbx
>   ✔ [PATCH] pstore: Move kmsg_bytes default into Kconfig
>   ---
>   ✔ Attestation-by: Kees Cook <keescook@chromium.org> (pgp: 8972F4DFDC6DC026)

Yay! :)

> Did you use the sendemail-validate hook for this?

In my scripts right now, I'm doing this before "git send-email":

# Construct header-based attestations
b4 attest outgoing/*

I haven't yet converted to using the git hook.

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pstore: Move kmsg_bytes default into Kconfig
  2020-12-02 22:30   ` Kees Cook
@ 2020-12-02 22:36     ` Konstantin Ryabitsev
  0 siblings, 0 replies; 4+ messages in thread
From: Konstantin Ryabitsev @ 2020-12-02 22:36 UTC (permalink / raw)
  To: Kees Cook; +Cc: linux-kernel

On Wed, Dec 02, 2020 at 02:30:08PM -0800, Kees Cook wrote:
> > Did you use the sendemail-validate hook for this?
> 
> In my scripts right now, I'm doing this before "git send-email":
> 
> # Construct header-based attestations
> b4 attest outgoing/*
> 
> I haven't yet converted to using the git hook.

You don't have to if you're already using wrapper scripts. It's more 
useful for folks who call git-send-email directly and don't want to 
remember to call "b4 attest" first.

Best regards,
-K

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-02 22:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-01 20:12 [PATCH] pstore: Move kmsg_bytes default into Kconfig Kees Cook
2020-12-02 21:42 ` Konstantin Ryabitsev
2020-12-02 22:30   ` Kees Cook
2020-12-02 22:36     ` Konstantin Ryabitsev

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).