Skip to content

Commit 9e5f1c1

Browse files
Aleksandr Yashkinkees
authored andcommitted
pstore/ram: Write new dumps to start of recycled zones
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 <[email protected]> Signed-off-by: Nikolay Merinov <[email protected]> Signed-off-by: Ariel Gilman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Fixes: 896fc1f ("pstore/ram: Switch to persistent_ram routines") Cc: [email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 8df955a commit 9e5f1c1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

fs/pstore/ram.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,17 @@ static int notrace ramoops_pstore_write(struct pstore_record *record)
407407

408408
prz = cxt->dprzs[cxt->dump_write_cnt];
409409

410+
/*
411+
* Since this is a new crash dump, we need to reset the buffer in
412+
* case it still has an old dump present. Without this, the new dump
413+
* will get appended, which would seriously confuse anything trying
414+
* to check dump file contents. Specifically, ramoops_read_kmsg_hdr()
415+
* expects to find a dump header in the beginning of buffer data, so
416+
* we must to reset the buffer values, in order to ensure that the
417+
* header will be written to the beginning of the buffer.
418+
*/
419+
persistent_ram_zap(prz);
420+
410421
/* Build header and append record contents. */
411422
hlen = ramoops_write_kmsg_hdr(prz, record);
412423
if (!hlen)

0 commit comments

Comments
 (0)