linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix off-by-one bug in mbind() syscall implementation
@ 2010-07-26  9:28 Andre Przywara
  2010-07-26  9:49 ` Andi Kleen
  0 siblings, 1 reply; 6+ messages in thread
From: Andre Przywara @ 2010-07-26  9:28 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Andi Kleen, Christoph Lameter, linux-kernel, linux-mm,
	Andre Przywara

When the mbind() syscall implementation processes the node mask
provided by the user, the last node is accidentally masked out.
This is present since the dawn of time (aka Before Git), I guess
nobody realized that because libnuma as the most prominent user of
mbind() uses large masks (sizeof(long)) and nobody cared if the
64th node is not handled properly. But if the user application
defers the masking to the kernel and provides the number of valid bits
in maxnodes, there is always the last node missing.
However this also affect the special case with maxnodes=0, the manpage
reads that mbind(ptr, len, MPOL_DEFAULT, &some_long, 0, 0); should
reset the policy to the default one, but in fact it returns EINVAL.
This patch just removes the decrease-by-one statement, I hope that
there is no workaround code in the wild that relies on the bogus
behavior.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
 mm/mempolicy.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 5bc0a96..e70025b 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1174,7 +1174,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.6.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>

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

end of thread, other threads:[~2010-07-29 16:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-26  9:28 [PATCH] Fix off-by-one bug in mbind() syscall implementation Andre Przywara
2010-07-26  9:49 ` Andi Kleen
2010-07-26 10:23   ` Andre Przywara
2010-07-26 10:40     ` Andi Kleen
2010-07-29  8:50       ` Andre Przywara
2010-07-29 16:15         ` Jack Steiner

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