The patch titled Subject: initramfs: poison freed initrd memory has been added to the -mm tree. Its filename is initramfs-poison-freed-initrd-memory.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/initramfs-poison-freed-initrd-memory.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/initramfs-poison-freed-initrd-memory.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Christoph Hellwig <hch@xxxxxx> Subject: initramfs: poison freed initrd memory 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@xxxxxx Signed-off-by: Christoph Hellwig <hch@xxxxxx> Acked-by: Mike Rapoport <rppt@xxxxxxxxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> [arm64] Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> [m68k] Cc: Steven Price <steven.price@xxxxxxx> Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Guan Xuetao <gxt@xxxxxxxxxx> Cc: Russell King <linux@xxxxxxxxxxxxxxx> Cc: Will Deacon <will.deacon@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- arch/mips/mm/init.c | 8 -------- arch/s390/mm/init.c | 8 -------- arch/sparc/mm/init_32.c | 8 -------- arch/sparc/mm/init_64.c | 8 -------- init/initramfs.c | 3 ++- 5 files changed, 2 insertions(+), 33 deletions(-) --- a/arch/mips/mm/init.c~initramfs-poison-freed-initrd-memory +++ a/arch/mips/mm/init.c @@ -504,14 +504,6 @@ void free_init_pages(const char *what, u 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) --- a/arch/s390/mm/init.c~initramfs-poison-freed-initrd-memory +++ a/arch/s390/mm/init.c @@ -154,14 +154,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) { /* --- a/arch/sparc/mm/init_32.c~initramfs-poison-freed-initrd-memory +++ a/arch/sparc/mm/init_32.c @@ -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); --- a/arch/sparc/mm/init_64.c~initramfs-poison-freed-initrd-memory +++ a/arch/sparc/mm/init_64.c @@ -2610,14 +2610,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); --- a/init/initramfs.c~initramfs-poison-freed-initrd-memory +++ a/init/initramfs.c @@ -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 _ Patches currently in -mm which might be from hch@xxxxxx are initramfs-free-initrd-memory-if-opening-initrdimage-fails.patch initramfs-cleanup-initrd-freeing.patch initramfs-factor-out-a-helper-to-populate-the-initrd-image.patch initramfs-cleanup-populate_rootfs.patch initramfs-move-the-legacy-keepinitrd-parameter-to-core-code.patch initramfs-proide-a-generic-free_initrd_mem-implementation.patch initramfs-poison-freed-initrd-memory.patch