pstore: Move kmsg_bytes default into Kconfig
authorVasile-Laurentiu Stanimir <vasile-laurentiu.stanimir@windriver.com>
Wed, 4 Nov 2020 13:05:32 +0000 (15:05 +0200)
committerKees Cook <keescook@chromium.org>
Tue, 1 Dec 2020 20:09:17 +0000 (12:09 -0800)
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>
fs/pstore/Kconfig
fs/pstore/inode.c
fs/pstore/internal.h
fs/pstore/platform.c

index e16a49ebfe546dbecf0e64c8e5838a180161ebb2..8adabde685f132f2375114bef345e27db85a9265 100644 (file)
@@ -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
index c331efe8de953732b22a385473357ab9ea9f2123..93a217e4f56307ba058e910a1da85922963504e0 100644 (file)
@@ -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;
 }
index 7fb219042f13d149b10502f2969fb7603f27e62a..801d6c0b170c3aaee647ad9fd1f536ae03de331a 100644 (file)
@@ -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
index 36714df37d5d81df8c9b3671cd602c7413579c58..32f64abc277c3f61f29929904e768124dd16e9a8 100644 (file)
@@ -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)
 {