Otherwise, unlinked file will reappear on the next boot.

Reported-by: Kees Cook <[email protected]>
Signed-off-by: Anton Vorontsov <[email protected]>
---
 fs/pstore/ram.c            |    1 +
 fs/pstore/ram_core.c       |    6 ++++++
 include/linux/pstore_ram.h |    1 +
 3 files changed, 8 insertions(+)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 3a7724b..43d9727 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -186,6 +186,7 @@ static int ramoops_pstore_erase(enum pstore_type_id type, 
u64 id,
                return -EINVAL;
 
        persistent_ram_free_old(cxt->przs[id]);
+       persistent_ram_zap(cxt->przs[id]);
 
        return 0;
 }
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index dff5127..28b6d7f 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -336,6 +336,12 @@ void persistent_ram_free_old(struct persistent_ram_zone 
*prz)
        prz->old_log_size = 0;
 }
 
+void persistent_ram_zap(struct persistent_ram_zone *prz)
+{
+       atomic_set(&prz->buffer->size, 0);
+       persistent_ram_update_header_ecc(prz);
+}
+
 static void *persistent_ram_vmap(phys_addr_t start, size_t size)
 {
        struct page **pages;
diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h
index 07d59b7..085199e 100644
--- a/include/linux/pstore_ram.h
+++ b/include/linux/pstore_ram.h
@@ -69,6 +69,7 @@ struct persistent_ram_zone * __init 
persistent_ram_new(phys_addr_t start,
                                                       size_t size,
                                                       bool ecc);
 void persistent_ram_free(struct persistent_ram_zone *prz);
+void persistent_ram_zap(struct persistent_ram_zone *prz);
 struct persistent_ram_zone *persistent_ram_init_ringbuffer(struct device *dev,
                bool ecc);
 
-- 
1.7.9.2

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Reply via email to