Skip to contentSkip to conversation

pstore/ram: Fix console ramoops to show the previous boot logs

PATCH In review Sai Prakash Ranjan 3 participants 4 messages Jan 17, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pstore/ram: Fix console ramoops to show the previous boot logs

commit b05c950698fe ("pstore/ram: Simplify ramoops_get_next_prz() arguments") changed update assignment in getting next persistent ram zone by adding a check for record type. But the check always returns true since the record type is assigned 0. And this breaks console ramoops by showing current console log instead of previous log on warm reset and hard reset (actually hard reset should not be showing any logs).

Fix this by having persistent ram zone type check instead of record type check. Tested this on SDM845 MTP and dragonboard 410c.

Reproducing this issue is simple as below:

1. Trigger hard reset and mount pstore. Will see console-ramoops record in the mounted location which is the current log.

2. Trigger warm reset and mount pstore. Will see the current console-ramoops record instead of previous record.

Fixes b05c950698fe ("pstore/ram: Simplify ramoops_get_next_prz() arguments")

---

I guess commit msg can be improved.

---
 fs/pstore/ram.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/pstore/ram.c +3 -1
index 96f7d32cd184..441a44215456 100644
@@ -128,7 +128,7 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], int id,
 		     struct pstore_record *record)
 {
 	struct persistent_ram_zone *prz;
-	bool update = (record->type == PSTORE_TYPE_DMESG);
+	bool update;
 
 	/* Give up if we never existed or have hit the end. */
 	if (!przs)
@@ -138,6 +138,8 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], int id,
 	if (!prz)
 		return NULL;
 
+	update = (prz->type == PSTORE_TYPE_DMESG);
+
 	/* Update old/shadowed buffer. */
 	if (update)
 		persistent_ram_save_old(prz);
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Sai Prakash Ranjan

commit b05c950698fe ("pstore/ram: Simplify ramoops_get_next_prz() arguments") changed update assignment in getting next persistent ram zone by adding a check for record type. But the check always returns true since the record type is assigned 0. And this breaks console ramoops by showing current console log instead of previous log on warm reset and hard reset (actually hard reset should not be showing any logs).

Fix this by having persistent ram zone type check instead of record type check. Tested this on SDM845 MTP and dragonboard 410c.

Reproducing this issue is simple as below:

Quoted 8 lines

1. Trigger hard reset and mount pstore. Will see console-ramoops record in the mounted location which is the current log.

2. Trigger warm reset and mount pstore. Will see the current console-ramoops record instead of previous record.

Fixes b05c950698fe ("pstore/ram: Simplify ramoops_get_next_prz() arguments")

thanks!

- Joel

Quoted 34 lines

---

I guess commit msg can be improved.

---
 fs/pstore/ram.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/pstore/ram.c +3 -1
index 96f7d32cd184..441a44215456 100644
@@ -128,7 +128,7 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], int id,
 		     struct pstore_record *record)
 {
 	struct persistent_ram_zone *prz;
-	bool update = (record->type == PSTORE_TYPE_DMESG);
+	bool update;
 
 	/* Give up if we never existed or have hit the end. */
 	if (!przs)
@@ -138,6 +138,8 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], int id,
 	if (!prz)
 		return NULL;
 
+	update = (prz->type == PSTORE_TYPE_DMESG);
+
 	/* Update old/shadowed buffer. */
 	if (update)
 		persistent_ram_save_old(prz);
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#2 lore raw
Quoted 17 lines · Joel Fernandes
Quoted 16 lines · Sai Prakash Ranjan

commit b05c950698fe ("pstore/ram: Simplify ramoops_get_next_prz() arguments") changed update assignment in getting next persistent ram zone by adding a check for record type. But the check always returns true since the record type is assigned 0. And this breaks console ramoops by showing current console log instead of previous log on warm reset and hard reset (actually hard reset should not be showing any logs).

Fix this by having persistent ram zone type check instead of record type check. Tested this on SDM845 MTP and dragonboard 410c.

Reproducing this issue is simple as below:

1. Trigger hard reset and mount pstore. Will see console-ramoops record in the mounted location which is the current log.

Quoted 9 lines
Quoted 5 lines

2. Trigger warm reset and mount pstore. Will see the current console-ramoops record instead of previous record.

Fixes b05c950698fe ("pstore/ram: Simplify ramoops_get_next_prz() arguments")

Thanks Joel.

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#3 lore raw
In reply to Sai Prakash Ranjan
Quoted 14 lines · Sai Prakash Ranjan

commit b05c950698fe ("pstore/ram: Simplify ramoops_get_next_prz() arguments") changed update assignment in getting next persistent ram zone by adding a check for record type. But the check always returns true since the record type is assigned 0. And this breaks console ramoops by showing current console log instead of previous log on warm reset and hard reset (actually hard reset should not be showing any logs).

Fix this by having persistent ram zone type check instead of record type check. Tested this on SDM845 MTP and dragonboard 410c.

Reproducing this issue is simple as below:

Quoted 8 lines

1. Trigger hard reset and mount pstore. Will see console-ramoops record in the mounted location which is the current log.

2. Trigger warm reset and mount pstore. Will see the current console-ramoops record instead of previous record.

Fixes b05c950698fe ("pstore/ram: Simplify ramoops_get_next_prz() arguments")

Whoops! Thanks for catching this! I've adjusted the patch slightly (no need for a local variable), and will send this to Linus.

-Kees

Quoted 34 lines

---

I guess commit msg can be improved.

---
 fs/pstore/ram.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/pstore/ram.c +3 -2
index 96f7d32cd184..441a44215456 100644
@@ -128,7 +128,7 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], int id,
                     struct pstore_record *record)
 {
        struct persistent_ram_zone *prz;
-       bool update = (record->type == PSTORE_TYPE_DMESG);
+       bool update;
 
        /* Give up if we never existed or have hit the end. */
        if (!przs)
@@ -138,6 +138,8 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], int id,
        if (!prz)
                return NULL;
 
+       update = (prz->type == PSTORE_TYPE_DMESG);
+
        /* Update old/shadowed buffer. */
        if (update)
                persistent_ram_save_old(prz);
--

QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

Signature · 1 line
Kees Cook