Skip to contentSkip to conversation

pstore: skip zero size persistent ram buffer in traverse

PATCH In review [email protected] 3 participants 3 messages Feb 28, 2014 – Mar 3, 2014 Pstore filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pstore: skip zero size persistent ram buffer in traverse

From: Liu ShuoX <[email protected]>

In ramoops_pstore_read, a valid prz pointer with zero size buffer will break traverse of all persistent ram buffers. The latter buffer might be lost.

---
 fs/pstore/ram.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/pstore/ram.c +5 -5
index a5d0cab..929ea55 100644
@@ -119,12 +119,12 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max,
 
 	prz = przs[i];
 
-	if (update) {
-		/* Update old/shadowed buffer. */
+	/* Update old/shadowed buffer. */
+	if (update)
 		persistent_ram_save_old(prz);
-		if (!persistent_ram_old_size(prz))
-			return NULL;
-	}
+
+	if (!persistent_ram_old_size(prz))
+		return NULL;
 
 	*typep = type;
 	*id = i;
Signature · 1 line
1.8.3.2
#1 lore raw
Quoted 5 lines · On 2014/2/28 14:38, [email protected] wrote:

From: Liu ShuoX <[email protected]>

In ramoops_pstore_read, a valid prz pointer with zero size buffer will break traverse of all persistent ram buffers. The latter buffer might be lost.

Andrew,

Would you like to merge it to your testing tree? pstore is a very important feature for debugging hard issues on Android mobiles.

Yanmin

Quoted 28 lines
---
  fs/pstore/ram.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
fs/pstore/ram.c +5 -5
index a5d0cab..929ea55 100644
@@ -119,12 +119,12 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max,
 
  	prz = przs[i];
 
-	if (update) {
-		/* Update old/shadowed buffer. */
+	/* Update old/shadowed buffer. */
+	if (update)
  		persistent_ram_save_old(prz);
-		if (!persistent_ram_old_size(prz))
-			return NULL;
-	}
+
+	if (!persistent_ram_old_size(prz))
+		return NULL;
 
  	*typep = type;
  	*id = i;
Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 23 lines · On Thu, Feb 27, 2014 at 10:38 PM, <[email protected]> wrote:

From: Liu ShuoX <[email protected]>

In ramoops_pstore_read, a valid prz pointer with zero size buffer will break traverse of all persistent ram buffers. The latter buffer might be lost.

---
 fs/pstore/ram.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/pstore/ram.c +2 -2
index a5d0cab..929ea55 100644
@@ -119,12 +119,12 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max,
 
        prz = przs[i];
 
-       if (update) {
-               /* Update old/shadowed buffer. */
+       /* Update old/shadowed buffer. */
+       if (update)

fs/pstore/ram.c ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max, · line 130

Quoted 10 lines
fs/pstore/ram.c +3 -3
                persistent_ram_save_old(prz);
-               if (!persistent_ram_old_size(prz))
-                       return NULL;
-       }
+
+       if (!persistent_ram_old_size(prz))
+               return NULL;
 
        *typep = type;
        *id = i;

Good catch; this change makes sense to me.

-Kees

Signature · 2 lines
Kees Cook
Chrome OS Security