lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 22 Dec 2014 12:17:29 +0900
From:	Masahiro Yamada <yamada.m@...panasonic.com>
To:	linux-arm-kernel@...ts.infradead.org
Cc:	Geert Uytterhoeven <geert@...ux-m68k.org>,
	Ard Biesheuvel <ard.biesheuvel@...aro.org>,
	Russell King - ARM Linux <linux@....linux.org.uk>,
	Masahiro Yamada <yamada.m@...panasonic.com>,
	Santosh Shilimkar <santosh.shilimkar@...com>,
	Catalin Marinas <catalin.marinas@....com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Will Deacon <will.deacon@....com>,
	Olof Johansson <olof@...om.net>,
	Laura Abbott <lauraa@...eaurora.org>,
	Daniel Thompson <daniel.thompson@...aro.org>,
	linux-kernel@...r.kernel.org
Subject: [PATCH v2] ARM: mm: fix size rounding-down of arm_add_memory() function

The current rounding of "size" is wrong:

 - If "start" is sufficiently near the next page boundary, "size"
   is decremented by more than enough and the last page is lost.

 - If "size" is sufficiently small, it is wrapped around and gets
   a bogus value.

Signed-off-by: Masahiro Yamada <yamada.m@...panasonic.com>
Acked-by: Geert Uytterhoeven <geert@...ux-m68k.org>
---

Changes in v2:
 - Avoid wrap around of "size"

 arch/arm/kernel/setup.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index f9c8639..d13f185 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -657,10 +657,13 @@ int __init arm_add_memory(u64 start, u64 size)
 
 	/*
 	 * Ensure that start/size are aligned to a page boundary.
-	 * Size is appropriately rounded down, start is rounded up.
+	 * Size is rounded down, start is rounded up.
 	 */
-	size -= start & ~PAGE_MASK;
 	aligned_start = PAGE_ALIGN(start);
+	if (aligned_start > start + size)
+		size = 0;
+	else
+		size -= aligned_start - start;
 
 #ifndef CONFIG_ARCH_PHYS_ADDR_T_64BIT
 	if (aligned_start > ULONG_MAX) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ