initramfs: poison freed initrd memory
authorChristoph Hellwig <hch@lst.de>
Tue, 14 May 2019 00:18:37 +0000 (17:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 14 May 2019 16:47:47 +0000 (09:47 -0700)
Various architectures including x86 poison the freed initrd memory.  Do
the same in the generic free_initrd_mem implementation and switch a few
more architectures that are identical to the generic code over to it now.

Link: http://lkml.kernel.org/r/20190213174621.29297-9-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com> [arm64]
Cc: Geert Uytterhoeven <geert@linux-m68k.org> [m68k]
Cc: Steven Price <steven.price@arm.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Guan Xuetao <gxt@pku.edu.cn>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/mips/mm/init.c
arch/s390/mm/init.c
arch/sparc/mm/init_32.c
arch/sparc/mm/init_64.c
init/initramfs.c

index bbb196ad5f26b08e07b7e808dd905e0818f6bef8..8a038b30d3c4981d3e9bd8fdcbee8d40665bae82 100644 (file)
@@ -504,14 +504,6 @@ void free_init_pages(const char *what, unsigned long begin, unsigned long end)
        printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-void free_initrd_mem(unsigned long start, unsigned long end)
-{
-       free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM,
-                          "initrd");
-}
-#endif
-
 void (*free_init_pages_eva)(void *begin, void *end) = NULL;
 
 void __ref free_initmem(void)
index 7cf48eefec8fc291ee3090c77107327547b85e95..5f48fc7e61d5f82c41fd76bd63eb2d1137435b72 100644 (file)
@@ -157,14 +157,6 @@ void free_initmem(void)
        free_initmem_default(POISON_FREE_INITMEM);
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-void __init free_initrd_mem(unsigned long start, unsigned long end)
-{
-       free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM,
-                          "initrd");
-}
-#endif
-
 unsigned long memory_block_size_bytes(void)
 {
        /*
index a8ff29821bdbc44466481b310fdedf3729c50047..417f89d5e0b206e920e0fecd01fdf159cff748e9 100644 (file)
@@ -299,14 +299,6 @@ void free_initmem (void)
        free_initmem_default(POISON_FREE_INITMEM);
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-void free_initrd_mem(unsigned long start, unsigned long end)
-{
-       free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM,
-                          "initrd");
-}
-#endif
-
 void sparc_flush_page_to_ram(struct page *page)
 {
        unsigned long vaddr = (unsigned long)page_address(page);
index bc2aaa47bc8ac010b9e1d6518bb6c571707a9eb1..4b099dd7a7671566054c3d2c2c51a0ddc7da2b76 100644 (file)
@@ -2572,14 +2572,6 @@ void free_initmem(void)
        }
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-void free_initrd_mem(unsigned long start, unsigned long end)
-{
-       free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM,
-                          "initrd");
-}
-#endif
-
 pgprot_t PAGE_KERNEL __read_mostly;
 EXPORT_SYMBOL(PAGE_KERNEL);
 
index fcb759a106be6b791278cd04ac092764f36cdc4d..435a428c2af1cc3cdd021b08c5976e7e7ba9e64e 100644 (file)
@@ -529,7 +529,8 @@ extern unsigned long __initramfs_size;
 
 void __weak free_initrd_mem(unsigned long start, unsigned long end)
 {
-       free_reserved_area((void *)start, (void *)end, -1, "initrd");
+       free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM,
+                       "initrd");
 }
 
 #ifdef CONFIG_KEXEC_CORE