mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-23 07:23:12 +02:00
pstore: Change kmsg_bytes storage size to u32
[ Upstream commit 5674609535
]
The types around kmsg_bytes were inconsistent. The global was unsigned
long, the argument to pstore_set_kmsg_bytes() was int, and the filesystem
option was u32. Given other internal limits, there's not much sense
in making a single pstore record larger than INT_MAX and it can't be
negative, so use u32 everywhere. Additionally, use READ/WRITE_ONCE and a
local variable in pstore_dump() to avoid kmsg_bytes changing during a
dump.
Link: https://lore.kernel.org/r/20250206191655.work.798-kees@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
09c3a82664
commit
7ef54a11c1
|
@ -264,7 +264,7 @@ static void parse_options(char *options)
|
||||||
static int pstore_show_options(struct seq_file *m, struct dentry *root)
|
static int pstore_show_options(struct seq_file *m, struct dentry *root)
|
||||||
{
|
{
|
||||||
if (kmsg_bytes != CONFIG_PSTORE_DEFAULT_KMSG_BYTES)
|
if (kmsg_bytes != CONFIG_PSTORE_DEFAULT_KMSG_BYTES)
|
||||||
seq_printf(m, ",kmsg_bytes=%lu", kmsg_bytes);
|
seq_printf(m, ",kmsg_bytes=%u", kmsg_bytes);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <linux/time.h>
|
#include <linux/time.h>
|
||||||
#include <linux/pstore.h>
|
#include <linux/pstore.h>
|
||||||
|
|
||||||
extern unsigned long kmsg_bytes;
|
extern unsigned int kmsg_bytes;
|
||||||
|
|
||||||
#ifdef CONFIG_PSTORE_FTRACE
|
#ifdef CONFIG_PSTORE_FTRACE
|
||||||
extern void pstore_register_ftrace(void);
|
extern void pstore_register_ftrace(void);
|
||||||
|
@ -35,7 +35,7 @@ static inline void pstore_unregister_pmsg(void) {}
|
||||||
|
|
||||||
extern struct pstore_info *psinfo;
|
extern struct pstore_info *psinfo;
|
||||||
|
|
||||||
extern void pstore_set_kmsg_bytes(int);
|
extern void pstore_set_kmsg_bytes(unsigned int bytes);
|
||||||
extern void pstore_get_records(int);
|
extern void pstore_get_records(int);
|
||||||
extern void pstore_get_backend_records(struct pstore_info *psi,
|
extern void pstore_get_backend_records(struct pstore_info *psi,
|
||||||
struct dentry *root, int quiet);
|
struct dentry *root, int quiet);
|
||||||
|
|
|
@ -92,8 +92,8 @@ module_param(compress, charp, 0444);
|
||||||
MODULE_PARM_DESC(compress, "compression to use");
|
MODULE_PARM_DESC(compress, "compression to use");
|
||||||
|
|
||||||
/* How much of the kernel log to snapshot */
|
/* How much of the kernel log to snapshot */
|
||||||
unsigned long kmsg_bytes = CONFIG_PSTORE_DEFAULT_KMSG_BYTES;
|
unsigned int kmsg_bytes = CONFIG_PSTORE_DEFAULT_KMSG_BYTES;
|
||||||
module_param(kmsg_bytes, ulong, 0444);
|
module_param(kmsg_bytes, uint, 0444);
|
||||||
MODULE_PARM_DESC(kmsg_bytes, "amount of kernel log to snapshot (in bytes)");
|
MODULE_PARM_DESC(kmsg_bytes, "amount of kernel log to snapshot (in bytes)");
|
||||||
|
|
||||||
static void *compress_workspace;
|
static void *compress_workspace;
|
||||||
|
@ -107,9 +107,9 @@ static void *compress_workspace;
|
||||||
static char *big_oops_buf;
|
static char *big_oops_buf;
|
||||||
static size_t max_compressed_size;
|
static size_t max_compressed_size;
|
||||||
|
|
||||||
void pstore_set_kmsg_bytes(int bytes)
|
void pstore_set_kmsg_bytes(unsigned int bytes)
|
||||||
{
|
{
|
||||||
kmsg_bytes = bytes;
|
WRITE_ONCE(kmsg_bytes, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tag each group of saved records with a sequence number */
|
/* Tag each group of saved records with a sequence number */
|
||||||
|
@ -278,6 +278,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
|
||||||
enum kmsg_dump_reason reason)
|
enum kmsg_dump_reason reason)
|
||||||
{
|
{
|
||||||
struct kmsg_dump_iter iter;
|
struct kmsg_dump_iter iter;
|
||||||
|
unsigned int remaining = READ_ONCE(kmsg_bytes);
|
||||||
unsigned long total = 0;
|
unsigned long total = 0;
|
||||||
const char *why;
|
const char *why;
|
||||||
unsigned int part = 1;
|
unsigned int part = 1;
|
||||||
|
@ -300,7 +301,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
|
||||||
kmsg_dump_rewind(&iter);
|
kmsg_dump_rewind(&iter);
|
||||||
|
|
||||||
oopscount++;
|
oopscount++;
|
||||||
while (total < kmsg_bytes) {
|
while (total < remaining) {
|
||||||
char *dst;
|
char *dst;
|
||||||
size_t dst_size;
|
size_t dst_size;
|
||||||
int header_size;
|
int header_size;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user