Commit 47358b64 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pstore-v5.2-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull pstore fixes from Kees Cook:

 - Avoid NULL deref when unloading/reloading ramoops module (Pi-Hsun
   Shih)

 - Run ramoops without crash dump region

* tag 'pstore-v5.2-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  pstore/ram: Run without kernel crash dump region
  pstore: Set tfm to NULL on free_buf_for_compression
parents 788a0249 8880fa32
...@@ -347,8 +347,10 @@ static void allocate_buf_for_compression(void) ...@@ -347,8 +347,10 @@ static void allocate_buf_for_compression(void)
static void free_buf_for_compression(void) static void free_buf_for_compression(void)
{ {
if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && tfm) if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && tfm) {
crypto_free_comp(tfm); crypto_free_comp(tfm);
tfm = NULL;
}
kfree(big_oops_buf); kfree(big_oops_buf);
big_oops_buf = NULL; big_oops_buf = NULL;
big_oops_buf_sz = 0; big_oops_buf_sz = 0;
...@@ -606,7 +608,8 @@ int pstore_register(struct pstore_info *psi) ...@@ -606,7 +608,8 @@ int pstore_register(struct pstore_info *psi)
return -EINVAL; return -EINVAL;
} }
allocate_buf_for_compression(); if (psi->flags & PSTORE_FLAGS_DMESG)
allocate_buf_for_compression();
if (pstore_is_mounted()) if (pstore_is_mounted())
pstore_get_records(0); pstore_get_records(0);
......
...@@ -800,26 +800,36 @@ static int ramoops_probe(struct platform_device *pdev) ...@@ -800,26 +800,36 @@ static int ramoops_probe(struct platform_device *pdev)
cxt->pstore.data = cxt; cxt->pstore.data = cxt;
/* /*
* Since bufsize is only used for dmesg crash dumps, it * Prepare frontend flags based on which areas are initialized.
* must match the size of the dprz record (after PRZ header * For ramoops_init_przs() cases, the "max count" variable tells
* and ECC bytes have been accounted for). * if there are regions present. For ramoops_init_prz() cases,
* the single region size is how to check.
*/ */
cxt->pstore.bufsize = cxt->dprzs[0]->buffer_size; cxt->pstore.flags = 0;
cxt->pstore.buf = kzalloc(cxt->pstore.bufsize, GFP_KERNEL); if (cxt->max_dump_cnt)
if (!cxt->pstore.buf) { cxt->pstore.flags |= PSTORE_FLAGS_DMESG;
pr_err("cannot allocate pstore crash dump buffer\n");
err = -ENOMEM;
goto fail_clear;
}
cxt->pstore.flags = PSTORE_FLAGS_DMESG;
if (cxt->console_size) if (cxt->console_size)
cxt->pstore.flags |= PSTORE_FLAGS_CONSOLE; cxt->pstore.flags |= PSTORE_FLAGS_CONSOLE;
if (cxt->ftrace_size) if (cxt->max_ftrace_cnt)
cxt->pstore.flags |= PSTORE_FLAGS_FTRACE; cxt->pstore.flags |= PSTORE_FLAGS_FTRACE;
if (cxt->pmsg_size) if (cxt->pmsg_size)
cxt->pstore.flags |= PSTORE_FLAGS_PMSG; cxt->pstore.flags |= PSTORE_FLAGS_PMSG;
/*
* Since bufsize is only used for dmesg crash dumps, it
* must match the size of the dprz record (after PRZ header
* and ECC bytes have been accounted for).
*/
if (cxt->pstore.flags & PSTORE_FLAGS_DMESG) {
cxt->pstore.bufsize = cxt->dprzs[0]->buffer_size;
cxt->pstore.buf = kzalloc(cxt->pstore.bufsize, GFP_KERNEL);
if (!cxt->pstore.buf) {
pr_err("cannot allocate pstore crash dump buffer\n");
err = -ENOMEM;
goto fail_clear;
}
}
err = pstore_register(&cxt->pstore); err = pstore_register(&cxt->pstore);
if (err) { if (err) {
pr_err("registering with pstore failed\n"); pr_err("registering with pstore failed\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment