All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: catalin.marinas@arm.com, akpm@linux-foundation.org,
	hanjun.guo@linaro.org, xieyisheng1@huawei.com,
	rrichter@cavium.com, james.morse@arm.com,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH 1/2] mm: don't dereference struct page fields of invalid pages
Date: Wed, 14 Dec 2016 09:11:46 +0000	[thread overview]
Message-ID: <1481706707-6211-2-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1481706707-6211-1-git-send-email-ard.biesheuvel@linaro.org>

The VM_BUG_ON() check in move_freepages() checks whether the node
id of a page matches the node id of its zone. However, it does this
before having checked whether the struct page pointer refers to a
valid struct page to begin with. This is guaranteed in most cases,
but may not be the case if CONFIG_HOLES_IN_ZONE=y.

So reorder the VM_BUG_ON() with the pfn_valid_within() check.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 mm/page_alloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index f64e7bcb43b7..4e298e31fa86 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1864,14 +1864,14 @@ int move_freepages(struct zone *zone,
 #endif
 
 	for (page = start_page; page <= end_page;) {
-		/* Make sure we are not inadvertently changing nodes */
-		VM_BUG_ON_PAGE(page_to_nid(page) != zone_to_nid(zone), page);
-
 		if (!pfn_valid_within(page_to_pfn(page))) {
 			page++;
 			continue;
 		}
 
+		/* Make sure we are not inadvertently changing nodes */
+		VM_BUG_ON_PAGE(page_to_nid(page) != zone_to_nid(zone), page);
+
 		if (!PageBuddy(page)) {
 			page++;
 			continue;
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: catalin.marinas@arm.com, akpm@linux-foundation.org,
	hanjun.guo@linaro.org, xieyisheng1@huawei.com,
	rrichter@cavium.com, james.morse@arm.com,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH 1/2] mm: don't dereference struct page fields of invalid pages
Date: Wed, 14 Dec 2016 09:11:46 +0000	[thread overview]
Message-ID: <1481706707-6211-2-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1481706707-6211-1-git-send-email-ard.biesheuvel@linaro.org>

The VM_BUG_ON() check in move_freepages() checks whether the node
id of a page matches the node id of its zone. However, it does this
before having checked whether the struct page pointer refers to a
valid struct page to begin with. This is guaranteed in most cases,
but may not be the case if CONFIG_HOLES_IN_ZONE=y.

So reorder the VM_BUG_ON() with the pfn_valid_within() check.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 mm/page_alloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index f64e7bcb43b7..4e298e31fa86 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1864,14 +1864,14 @@ int move_freepages(struct zone *zone,
 #endif
 
 	for (page = start_page; page <= end_page;) {
-		/* Make sure we are not inadvertently changing nodes */
-		VM_BUG_ON_PAGE(page_to_nid(page) != zone_to_nid(zone), page);
-
 		if (!pfn_valid_within(page_to_pfn(page))) {
 			page++;
 			continue;
 		}
 
+		/* Make sure we are not inadvertently changing nodes */
+		VM_BUG_ON_PAGE(page_to_nid(page) != zone_to_nid(zone), page);
+
 		if (!PageBuddy(page)) {
 			page++;
 			continue;
-- 
2.7.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] mm: don't dereference struct page fields of invalid pages
Date: Wed, 14 Dec 2016 09:11:46 +0000	[thread overview]
Message-ID: <1481706707-6211-2-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1481706707-6211-1-git-send-email-ard.biesheuvel@linaro.org>

The VM_BUG_ON() check in move_freepages() checks whether the node
id of a page matches the node id of its zone. However, it does this
before having checked whether the struct page pointer refers to a
valid struct page to begin with. This is guaranteed in most cases,
but may not be the case if CONFIG_HOLES_IN_ZONE=y.

So reorder the VM_BUG_ON() with the pfn_valid_within() check.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 mm/page_alloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index f64e7bcb43b7..4e298e31fa86 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1864,14 +1864,14 @@ int move_freepages(struct zone *zone,
 #endif
 
 	for (page = start_page; page <= end_page;) {
-		/* Make sure we are not inadvertently changing nodes */
-		VM_BUG_ON_PAGE(page_to_nid(page) != zone_to_nid(zone), page);
-
 		if (!pfn_valid_within(page_to_pfn(page))) {
 			page++;
 			continue;
 		}
 
+		/* Make sure we are not inadvertently changing nodes */
+		VM_BUG_ON_PAGE(page_to_nid(page) != zone_to_nid(zone), page);
+
 		if (!PageBuddy(page)) {
 			page++;
 			continue;
-- 
2.7.4

  reply	other threads:[~2016-12-14  9:12 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-14  9:11 [PATCH 0/2] arm64: numa: fix spurious BUG() on NOMAP regions Ard Biesheuvel
2016-12-14  9:11 ` Ard Biesheuvel
2016-12-14  9:11 ` Ard Biesheuvel
2016-12-14  9:11 ` Ard Biesheuvel [this message]
2016-12-14  9:11   ` [PATCH 1/2] mm: don't dereference struct page fields of invalid pages Ard Biesheuvel
2016-12-14  9:11   ` Ard Biesheuvel
2017-01-04 12:16   ` Will Deacon
2017-01-04 12:16     ` Will Deacon
2017-01-04 12:16     ` Will Deacon
2016-12-14  9:11 ` [PATCH 2/2] arm64: mm: enable CONFIG_HOLES_IN_ZONE for NUMA Ard Biesheuvel
2016-12-14  9:11   ` Ard Biesheuvel
2016-12-14  9:11   ` Ard Biesheuvel
2016-12-15 15:39   ` Robert Richter
2016-12-15 15:39     ` Robert Richter
2016-12-15 15:39     ` Robert Richter
2016-12-15 16:07     ` Ard Biesheuvel
2016-12-15 16:07       ` Ard Biesheuvel
2016-12-15 16:07       ` Ard Biesheuvel
2016-12-16 17:10       ` Robert Richter
2016-12-16 17:10         ` Robert Richter
2016-12-16 17:10         ` Robert Richter
2016-12-16  1:57     ` Hanjun Guo
2016-12-16  1:57       ` Hanjun Guo
2016-12-16  1:57       ` Hanjun Guo
2016-12-16 17:14       ` Robert Richter
2016-12-16 17:14         ` Robert Richter
2016-12-16 17:14         ` Robert Richter
2017-01-04 13:28   ` Will Deacon
2017-01-04 13:28     ` Will Deacon
2017-01-04 13:28     ` Will Deacon
2017-01-04 13:50     ` Ard Biesheuvel
2017-01-04 13:50       ` Ard Biesheuvel
2017-01-04 13:50       ` Ard Biesheuvel
2017-01-04 14:02       ` Will Deacon
2017-01-04 14:02         ` Will Deacon
2017-01-04 14:02         ` Will Deacon
2017-01-05 11:24         ` Robert Richter
2017-01-05 11:24           ` Robert Richter
2017-01-05 11:24           ` Robert Richter
2017-01-05 12:08           ` Will Deacon
2017-01-05 12:08             ` Will Deacon
2017-01-05 12:08             ` Will Deacon
2017-01-05 12:22             ` Robert Richter
2017-01-05 12:22               ` Robert Richter
2017-01-05 12:22               ` Robert Richter
2017-01-05 19:49               ` Robert Richter
2017-01-05 19:49                 ` Robert Richter
2017-01-05 19:49                 ` Robert Richter
2017-01-06 12:03                 ` Will Deacon
2017-01-06 12:03                   ` Will Deacon
2017-01-06 12:03                   ` Will Deacon
2017-01-06 12:22                   ` Ard Biesheuvel
2017-01-06 12:22                     ` Ard Biesheuvel
2017-01-06 12:22                     ` Ard Biesheuvel
2017-02-06 13:36   ` Robert Richter
2017-02-06 13:36     ` Robert Richter
2017-02-06 13:36     ` Robert Richter

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=1481706707-6211-2-git-send-email-ard.biesheuvel@linaro.org \
    --to=ard.biesheuvel@linaro.org \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=hanjun.guo@linaro.org \
    --cc=james.morse@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rrichter@cavium.com \
    --cc=will.deacon@arm.com \
    --cc=xieyisheng1@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.