linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yisheng Xie <xieyisheng1@huawei.com>
To: akpm@linux-foundation.org, vbabka@suse.cz, mhocko@suse.com,
	mingo@kernel.org, rientjes@google.com, n-horiguchi@ah.jp.nec.com,
	salls@cs.ucsb.edu
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	will.deacon@arm.com, tanxiaojun@huawei.com
Subject: [PATCH] mm/mempolicy: add node_empty check in SYSC_migrate_pages
Date: Wed, 18 Oct 2017 09:37:40 +0800	[thread overview]
Message-ID: <1508290660-60619-1-git-send-email-xieyisheng1@huawei.com> (raw)

As Xiaojun reported the ltp of migrate_pages01 will failed on ARCH arm64
system whoes has 4 nodes[0...3], all have memory and CONFIG_NODES_SHIFT=2:

migrate_pages01    0  TINFO  :  test_invalid_nodes
migrate_pages01   14  TFAIL  :  migrate_pages_common.c:45: unexpected failure - returned value = 0, expected: -1
migrate_pages01   15  TFAIL  :  migrate_pages_common.c:55: call succeeded unexpectedly

In this case the test_invalid_nodes of migrate_pages01 will call:
SYSC_migrate_pages as:

migrate_pages(0, , {0x0000000000000001}, 64, , {0x0000000000000010}, 64) = 0

For MAX_NUMNODES is 4, so 0x10 nodemask will tread as empty set which makes
	nodes_subset(*new, node_states[N_MEMORY])

return true, as empty set is subset of any set.

So this is a common issue which also can happens in X86_64 system eg. 8 nodes[0..7],
all with memory and CONFIG_NODES_SHIFT=3. Fix it by adding node_empty check in
SYSC_migrate_pages.

Reported-by: Tan Xiaojun <tanxiaojun@huawei.com>
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 mm/mempolicy.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index a2af6d5..1dfd3cc 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1388,6 +1388,11 @@ static int copy_nodes_to_user(unsigned long __user *mask, unsigned long maxnode,
 	if (err)
 		goto out;
 
+	if (nodes_empty(*new)) {
+		err = -EINVAL;
+		goto out;
+	}
+
 	/* Find the mm_struct */
 	rcu_read_lock();
 	task = pid ? find_task_by_vpid(pid) : current;
-- 
1.7.12.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>

             reply	other threads:[~2017-10-18  1:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-18  1:37 Yisheng Xie [this message]
2017-10-18  7:54 ` Vlastimil Babka
2017-10-18  9:34   ` Yisheng Xie
2017-10-18 10:46     ` Vlastimil Babka
2017-10-20  6:42       ` Yisheng Xie
2017-10-19 10:31     ` Yisheng Xie

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=1508290660-60619-1-git-send-email-xieyisheng1@huawei.com \
    --to=xieyisheng1@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=rientjes@google.com \
    --cc=salls@cs.ucsb.edu \
    --cc=tanxiaojun@huawei.com \
    --cc=vbabka@suse.cz \
    --cc=will.deacon@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox