All of lore.kernel.org
 help / color / mirror / Atom feed
* mbind() breaks its API definition since v5.2 by commit d883544515aa (mm: mempolicy: make the behavior consistent when MPOL_MF_MOVE* and MPOL_MF_STRICT were specified)
@ 2019-10-30  2:27 Li Xinhai
  2019-10-30  2:50 ` Yang Shi
  0 siblings, 1 reply; 5+ messages in thread
From: Li Xinhai @ 2019-10-30  2:27 UTC (permalink / raw)
  To: linux-mm, akpm, torvalds
  Cc: Vlastimil Babka, yang.shi, Linux API, Michal Hocko, Hugh Dickins,
	linux-kernel, lixinhai_lxh

One change in do_mbind() of this commit has suspicious usage of return value of 
queue_pages_range(), excerpt as below:

---
@@ -1243,10 +1265,15 @@ static long do_mbind(unsigned long start, unsigned long len,
 	if (err)
 		goto mpol_out;
 
-	err = queue_pages_range(mm, start, end, nmask,
+	ret = queue_pages_range(mm, start, end, nmask,
 			  flags | MPOL_MF_INVERT, &pagelist);
-	if (!err)
-		err = mbind_range(mm, start, end, new);
+
+	if (ret < 0) {      /////// convert to all possible 'ret' to '-EIO' <<<<
+		err = -EIO;
+		goto up_out;
+	}
+
+	err = mbind_range(mm, start, end, new);
 
 	if (!err) {
 		int nr_failed = 0;
---

Note that inside queue_pages_range(), the call to walk_page_range() may return 
errors from 'test_walk' of 'struct mm_walk_ops', e.g. -EFAULT. Now, those error 
codes are no longer reported to user space application.

From user space, the mbind() call need to reported error, with EFAULT, as example:
EFAULT
Part or all of the memory range specified by nodemask and maxnode points 
outside your accessible address space. Or, there was an unmapped hole in the 
specified memory range specified by addr and len.

Please correct me if this is the intended change(and will have updated API 
definition), or something was misunderstood.

-Xinhai

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-10-30  6:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30  2:27 mbind() breaks its API definition since v5.2 by commit d883544515aa (mm: mempolicy: make the behavior consistent when MPOL_MF_MOVE* and MPOL_MF_STRICT were specified) Li Xinhai
2019-10-30  2:50 ` Yang Shi
2019-10-30  3:12   ` Li Xinhai
2019-10-30  4:32     ` Yang Shi
2019-10-30  5:59       ` Li Xinhai

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.