linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: mempolicy: Fix wrong use of maxnode in mempolicy API
@ 2019-11-08 15:49 Li Xinhai
  2019-11-08 16:04 ` Michal Hocko
  0 siblings, 1 reply; 4+ messages in thread
From: Li Xinhai @ 2019-11-08 15:49 UTC (permalink / raw)
  To: linux-mm; +Cc: Andrew Morton, Michal Hocko, Vlastimil Babka, Hugh Dickins

The maxnode used by mbind(), set_mempolicy() and migrate_pages() is not
correctly handled in get_nodes(), where --maxnode cause the calculation
  endmask = (1UL << (maxnode % BITS_PER_LONG)) - 1;
ignores the highest node ID bit. Then, at
  nodes_addr(*nodes)[nlongs-1] &= endmask;
the highest node ID bit is cleared. Finally, cause mpol_new() think user
does not pass in any node ID, and return EINVAL.

The results are:
- Application receives EINVAL when only the highest node ID bit is set.
- Application recevies no error when other bits set together with the
  highest node ID bit, but that highest ID is ignored.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
---
 mm/mempolicy.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 4ae967b..2bdc365 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1328,7 +1328,6 @@ static int get_nodes(nodemask_t *nodes, const unsigned long __user *nmask,
 	unsigned long nlongs;
 	unsigned long endmask;
 
-	--maxnode;
 	nodes_clear(*nodes);
 	if (maxnode == 0 || !nmask)
 		return 0;
-- 
1.8.3.1



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

end of thread, other threads:[~2019-11-11 10:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08 15:49 [PATCH] mm: mempolicy: Fix wrong use of maxnode in mempolicy API Li Xinhai
2019-11-08 16:04 ` Michal Hocko
2019-11-08 16:48   ` lixinhai.lxh
2019-11-11 10:04     ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).