From: Sasha Levin Date: Tue, 7 Jan 2020 20:27:26 +0000 (-0500) Subject: fixes for 4.9 X-Git-Tag: v4.14.163~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a54e1b9fc9d459fbca073057e657290536e2d37c;p=thirdparty%2Fkernel%2Fstable-queue.git fixes for 4.9 Signed-off-by: Sasha Levin --- diff --git a/queue-4.9/pstore-ram-write-new-dumps-to-start-of-recycled-zone.patch b/queue-4.9/pstore-ram-write-new-dumps-to-start-of-recycled-zone.patch new file mode 100644 index 00000000000..46150c32a95 --- /dev/null +++ b/queue-4.9/pstore-ram-write-new-dumps-to-start-of-recycled-zone.patch @@ -0,0 +1,54 @@ +From 5f948b966998936fbddd015247416d113e133752 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 7 Jan 2020 10:25:16 -0800 +Subject: pstore/ram: Write new dumps to start of recycled zones + +From: Aleksandr Yashkin + +[ Upstream commit 9e5f1c19800b808a37fb9815a26d382132c26c3d ] + +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 +Signed-off-by: Nikolay Merinov +Signed-off-by: Ariel Gilman +Link: https://lore.kernel.org/r/20191223133816.28155-1-n.merinov@inango-systems.com +Fixes: 896fc1f0c4c6 ("pstore/ram: Switch to persistent_ram routines") +[kees: backport to v4.9] +Link: https://lore.kernel.org/stable/157831399811194@kroah.com +Signed-off-by: Kees Cook +Signed-off-by: Sasha Levin +--- + fs/pstore/ram.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c +index 8b09271e5d66..a73959e6ae32 100644 +--- a/fs/pstore/ram.c ++++ b/fs/pstore/ram.c +@@ -321,6 +321,17 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type, + + prz = cxt->przs[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); ++ + hlen = ramoops_write_kmsg_hdr(prz, compressed); + if (size + hlen > prz->buffer_size) + size = prz->buffer_size - hlen; +-- +2.20.1 + diff --git a/queue-4.9/series b/queue-4.9/series index 4a09cd4871c..d8bc8e6320a 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -53,3 +53,4 @@ net-add-annotations-on-hh-hh_len-lockless-accesses.patch s390-smp-fix-physical-to-logical-cpu-map-for-smt.patch xen-blkback-avoid-unmapping-unmapped-grant-pages.patch locking-x86-remove-the-unused-atomic_inc_short-methd.patch +pstore-ram-write-new-dumps-to-start-of-recycled-zone.patch