summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorAleksandr Yashkin <a.yashkin@inango-systems.com>2019-12-23 18:38:16 +0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-01-09 10:17:55 +0100
commit45b0a5affcbe3d7e3ab0dd5bc19338404a60a4b2 (patch)
treed3d3f5976e7b299fa2fa9f44f0c4cb6245879cba /fs
parentabb59358f1c4d9490688ef7e133afcb6b5bcb7ca (diff)
pstore/ram: Write new dumps to start of recycled zones
commit 9e5f1c19800b808a37fb9815a26d382132c26c3d upstream. The ram_core.c routines treat przs as circular buffers. When writing a new crash dump, the old buffer needs to be cleared so that the new dump doesn't end up in the wrong place (i.e. at the end). The solution to this problem is to reset the circular buffer state before writing a new Oops dump. Signed-off-by: Aleksandr Yashkin <a.yashkin@inango-systems.com> Signed-off-by: Nikolay Merinov <n.merinov@inango-systems.com> Signed-off-by: Ariel Gilman <a.gilman@inango-systems.com> Link: https://lore.kernel.org/r/20191223133816.28155-1-n.merinov@inango-systems.com Fixes: 896fc1f0c4c6 ("pstore/ram: Switch to persistent_ram routines") Cc: stable@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/pstore/ram.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 1e675be10926..11c7a171c0a1 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -433,6 +433,17 @@ static int notrace ramoops_pstore_write(struct pstore_record *record)
prz = cxt->dprzs[cxt->dump_write_cnt];
+ /*
+ * Since this is a new crash dump, we need to reset the buffer in
+ * case it still has an old dump present. Without this, the new dump
+ * will get appended, which would seriously confuse anything trying
+ * to check dump file contents. Specifically, ramoops_read_kmsg_hdr()
+ * expects to find a dump header in the beginning of buffer data, so
+ * we must to reset the buffer values, in order to ensure that the
+ * header will be written to the beginning of the buffer.
+ */
+ persistent_ram_zap(prz);
+
/* Build header and append record contents. */
hlen = ramoops_write_kmsg_hdr(prz, record);
size = record->size;