linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: k.khlebnikov@samsung.com (Konstantin Khlebnikov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: fix overflow of vmalloc_limit in sanity_check_meminfo
Date: Tue, 18 Nov 2014 19:48:27 +0400	[thread overview]
Message-ID: <20141118164827.9686.68369.stgit@buzz> (raw)

vmalloc_limit easily overflows if CONFIG_VMSPLIT_1G=y and CONFIG_ARM_LPAE=n,
in this case whole memory turns into "highmem" and system cannot boot.
For example if PHYS_OFFSET=0x80000000 and PAGE_OFFSET=0x40000000 then
vmalloc_limit should be 0x1_2F800000, but value does not fit into variable.

Signed-off-by: Konstantin Khlebnikov <k.khlebnikov@samsung.com>
---
 arch/arm/mm/mmu.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 9f98cec..9d2cdda 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1075,10 +1075,14 @@ phys_addr_t arm_lowmem_limit __initdata = 0;
 void __init sanity_check_meminfo(void)
 {
 	phys_addr_t memblock_limit = 0;
+	phys_addr_t vmalloc_limit = -1;
 	int highmem = 0;
-	phys_addr_t vmalloc_limit = __pa(vmalloc_min - 1) + 1;
 	struct memblock_region *reg;
 
+	if ((unsigned long)vmalloc_min - PAGE_OFFSET <
+			vmalloc_limit - PHYS_OFFSET)
+		vmalloc_limit = __pa(vmalloc_min - 1) + 1;
+
 	for_each_memblock(memory, reg) {
 		phys_addr_t block_start = reg->base;
 		phys_addr_t block_end = reg->base + reg->size;

                 reply	other threads:[~2014-11-18 15:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20141118164827.9686.68369.stgit@buzz \
    --to=k.khlebnikov@samsung.com \
    --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).