linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Russell King <linux@armlinux.org.uk>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>, Guan Xuetao <gxt@pku.edu.cn>,
	linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 8/8] initramfs: poison freed initrd memory
Date: Wed, 13 Feb 2019 18:46:21 +0100	[thread overview]
Message-ID: <20190213174621.29297-9-hch@lst.de> (raw)
Message-ID: <20190213174621.ExGbDMbxIadNSuJ1RmbMLTWF0dmVyPZc4j2pU4PSR0c@z> (raw)
In-Reply-To: <20190213174621.29297-1-hch@lst.de>

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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 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(-)

diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index b521d8e2d359..a9a977d75838 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -492,14 +492,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)
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 3e82f66d5c61..25e3113091ea 100644
--- a/arch/s390/mm/init.c
+++ b/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)
 {
 	/*
diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
index d900952bfc5f..f0dbc0bde70f 100644
--- a/arch/sparc/mm/init_32.c
+++ b/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);
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index b4221d3727d0..4179f0e11fd5 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -2602,14 +2602,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);
 
diff --git a/init/initramfs.c b/init/initramfs.c
index f3aaa58ac63d..4a42ff3a2bd1 100644
--- a/init/initramfs.c
+++ b/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
-- 
2.20.1

  parent reply	other threads:[~2019-02-13 17:46 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13 17:46 initramfs tidyups Christoph Hellwig
2019-02-13 17:46 ` Christoph Hellwig
2019-02-13 17:46 ` [PATCH 1/8] mm: unexport free_reserved_area Christoph Hellwig
2019-02-13 17:46   ` Christoph Hellwig
2019-02-13 17:46 ` [PATCH 2/8] initramfs: free initrd memory if opening /initrd.image fails Christoph Hellwig
2019-02-13 17:46   ` Christoph Hellwig
2019-02-14 13:51   ` Steven Price
2019-02-14 13:51     ` Steven Price
2019-02-13 17:46 ` [PATCH 3/8] initramfs: cleanup initrd freeing Christoph Hellwig
2019-02-13 17:46   ` Christoph Hellwig
2019-02-13 17:46 ` [PATCH 4/8] initramfs: factor out a helper to populate the initrd image Christoph Hellwig
2019-02-13 17:46   ` Christoph Hellwig
2019-02-13 17:46 ` [PATCH 5/8] initramfs: cleanup populate_rootfs Christoph Hellwig
2019-02-13 17:46   ` Christoph Hellwig
2019-02-13 17:46 ` [PATCH 6/8] initramfs: move the legacy keepinitrd parameter to core code Christoph Hellwig
2019-02-13 17:46   ` Christoph Hellwig
2019-02-14 16:56   ` Catalin Marinas
2019-02-14 16:56     ` Catalin Marinas
2019-02-13 17:46 ` [PATCH 7/8] initramfs: proide a generic free_initrd_mem implementation Christoph Hellwig
2019-02-13 17:46   ` Christoph Hellwig
2019-02-13 18:41   ` Mike Rapoport
2019-02-13 18:41     ` Mike Rapoport
2019-02-13 18:44     ` Christoph Hellwig
2019-02-13 18:44       ` Christoph Hellwig
2019-02-13 21:41       ` Mike Rapoport
2019-02-13 21:41         ` Mike Rapoport
2019-02-14  8:03   ` Geert Uytterhoeven
2019-02-14  8:03     ` Geert Uytterhoeven
2019-02-14 16:20   ` Mike Rapoport
2019-02-14 16:20     ` Mike Rapoport
2019-02-13 17:46 ` Christoph Hellwig [this message]
2019-02-13 17:46   ` [PATCH 8/8] initramfs: poison freed initrd memory Christoph Hellwig
2019-02-13 21:54 ` initramfs tidyups Mike Rapoport
2019-02-13 21:54   ` Mike Rapoport

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190213174621.29297-9-hch@lst.de \
    --to=hch@lst.de \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=gxt@pku.edu.cn \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@armlinux.org.uk \
    --cc=viro@zeniv.linux.org.uk \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).