linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lauraa@codeaurora.org (Laura Abbott)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 5/5] arm: Don't free init text if CONFIG_STRICT_MEMORY_RWX is enabled
Date: Tue,  8 Oct 2013 18:31:32 -0700	[thread overview]
Message-ID: <1381282292-25251-6-git-send-email-lauraa@codeaurora.org> (raw)
In-Reply-To: <1381282292-25251-1-git-send-email-lauraa@codeaurora.org>

CONFIG_STRICT_MEMORY_RWX makes the text section be RX only. This
is incompatible with freeing the text back to general memory.
Skip the text free when freeing initmem. This does result in
less memory freed back into the system but we cannot easily
change the protections on the text section back to RWNX.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>
---
 arch/arm/mm/init.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 15225d8..a23c99c 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -681,6 +681,9 @@ void __init mem_init(void)
 
 void free_initmem(void)
 {
+#ifdef CONFIG_STRICT_MEMORY_RWX
+	unsigned long reclaimed_initmem;
+#endif
 #ifdef CONFIG_HAVE_TCM
 	extern char __tcm_start, __tcm_end;
 
@@ -688,9 +691,18 @@ void free_initmem(void)
 	free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
 #endif
 
+#ifdef CONFIG_STRICT_MEMORY_RWX
+	poison_init_mem((char *)__arch_info_begin,
+		__init_end - (char *)__arch_info_begin);
+	reclaimed_initmem = free_reserved_area(__arch_info_begin,
+					__init_end, -1,
+				    "init");
+	totalram_pages += reclaimed_initmem;
+#else
 	poison_init_mem(__init_begin, __init_end - __init_begin);
 	if (!machine_is_integrator() && !machine_is_cintegrator())
 		free_initmem_default(-1);
+#endif
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

  parent reply	other threads:[~2013-10-09  1:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-09  1:31 [RFC] Stricter kernel memory permissions Laura Abbott
2013-10-09  1:31 ` [RFC PATCH 1/5] arm: mm: add CONFIG_STRICT_MEMORY_RWX Laura Abbott
2013-10-09 16:47   ` Larry Bassel
2013-10-09 20:04   ` Kees Cook
2013-10-10  0:18     ` Laura Abbott
2013-10-09  1:31 ` [RFC PATCH 2/5] arm: mm: add new memory mapping types Laura Abbott
2013-10-09  1:31 ` [RFC PATCH 3/5] arm: align init, text, rodata to PMD_SIZE if CONFIG_STRICT_MEMORY_RWX is set Laura Abbott
2013-10-09  1:31 ` [RFC PATCH 4/5] arm: mm: restrict kernel memory permissions if CONFIG_STRICT_MEMORY_RWX set Laura Abbott
2013-10-09  1:31 ` Laura Abbott [this message]
2013-10-17 21:15 ` [RFC] Stricter kernel memory permissions Kees Cook

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=1381282292-25251-6-git-send-email-lauraa@codeaurora.org \
    --to=lauraa@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).