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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20090205201448.3a0f4182.kamezawa.hiroyu@jp.fujitsu.com>
Date:	Thu, 5 Feb 2009 20:14:48 +0900
From:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To:	Mel Gorman <mel@....ul.ie>
Cc:	David Miller <davem@...emloft.net>, heiko.carstens@...ibm.com,
	akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
	sparclinux@...r.kernel.org
Subject: [BUGFIX][PATCH] fix memmap init to initialize  valid memmap for
 memory hole. (Was Re: HOLES_IN_ZONE...

On Thu, 5 Feb 2009 10:39:25 +0000
Mel Gorman <mel@....ul.ie> wrote:

> ====
> If a PFN is not in early_node_map[] then the struct page for it is not
> initialised. If there are holes within a MAX_ORDER_NR_PAGES range of
> pages, then PG_reserved will not be set. Code that walks PFNs within
> MAX_ORDER_NR_PAGES will then use uninitialised struct pages.
> 
> To avoid any problems, this patch initialises holes within a MAX_ORDER_NR_PAGES
> that valid memmap exists but is otherwise unused.
> ====
> 
Thank you, I use this text.
==
If PFN is not in early_node_map[] then struct page for it is not initialized.
If there are holes within a MAX_ORDER_NE_PAGES range of pages, then PG_reserved
will not be set. Code that walks PFNs within MAX_ORDER_NR_PAGES will the use
uninitialized struct pages.

To avoid any problems, this patch initializes holes within a MAX_ORDER_NR_PAGES
that valid memmap exists but is otherwise unused.

Changelog:
  - renamed variable from "tmp" to "actual_nid"

Reported-by: David Miller <davem@...emlloft.net>
Acked-by: Mel Gorman <mel@....ul.ie>
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
---
 include/linux/mmzone.h |    6 ------
 mm/page_alloc.c        |   13 +++++++++++--
 2 files changed, 11 insertions(+), 8 deletions(-)

Index: linux-2.6.28-rc3/mm/page_alloc.c
===================================================================
--- linux-2.6.28-rc3.orig/mm/page_alloc.c
+++ linux-2.6.28-rc3/mm/page_alloc.c
@@ -2632,9 +2632,18 @@ void __meminit memmap_init_zone(unsigned
 		 * exist on hotplugged memory.
 		 */
 		if (context == MEMMAP_EARLY) {
+			int nid_from_node_memory_map;
+
 			if (!early_pfn_valid(pfn))
 				continue;
-			if (!early_pfn_in_nid(pfn, nid))
+			/*
+			 * early_pfn_to_nid() returns -1 if the page doesn't
+			 * exist in early_node_map[]. Initialize it in force
+			 * and set PG_reserved at el.
+			 */
+			nid_from_node_memory_map = early_pfn_to_nid(pfn);
+			if (nid_from_node_memory_map > -1 &&
+				nid_from_node_memory_map != nid)
 				continue;
 		}
 		page = pfn_to_page(pfn);
@@ -3001,7 +3010,7 @@ int __meminit early_pfn_to_nid(unsigned 
 			return early_node_map[i].nid;
 	}
 
-	return 0;
+	return -1;
 }
 #endif /* CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID */
 
Index: linux-2.6.28-rc3/include/linux/mmzone.h
===================================================================
--- linux-2.6.28-rc3.orig/include/linux/mmzone.h
+++ linux-2.6.28-rc3/include/linux/mmzone.h
@@ -1070,12 +1070,6 @@ void sparse_init(void);
 #define sparse_index_init(_sec, _nid)  do {} while (0)
 #endif /* CONFIG_SPARSEMEM */
 
-#ifdef CONFIG_NODES_SPAN_OTHER_NODES
-#define early_pfn_in_nid(pfn, nid)	(early_pfn_to_nid(pfn) == (nid))
-#else
-#define early_pfn_in_nid(pfn, nid)	(1)
-#endif
-
 #ifndef early_pfn_valid
 #define early_pfn_valid(pfn)	(1)
 #endif

--
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