From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: mhocko@suse.com, vbabka@suse.cz, akpm@linux-foundation.org
Subject: [RFC] nodemask: Consider MAX_NUMNODES inside node_isset
Date: Tue, 3 Jan 2017 13:57:53 +0530 [thread overview]
Message-ID: <20170103082753.25758-1-khandual@linux.vnet.ibm.com> (raw)
node_isset can give incorrect result if the node number is beyond the
bitmask size (MAX_NUMNODES in this case) which is not checked inside
test_bit. Hence check for the bit limits (MAX_NUMNODES) inside the
node_isset function before calling test_bit.
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
include/linux/nodemask.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index 6e66cfd..0aee588b 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -139,7 +139,13 @@ static inline void __nodes_clear(nodemask_t *dstp, unsigned int nbits)
}
/* No static inline type checking - see Subtlety (1) above. */
-#define node_isset(node, nodemask) test_bit((node), (nodemask).bits)
+#define node_isset(node, nodemask) node_test_bit(node, nodemask, MAX_NUMNODES)
+static inline int node_test_bit(int node, nodemask_t nodemask, int maxnodes)
+{
+ if (node >= maxnodes)
+ return 0;
+ return test_bit((node), (nodemask).bits);
+}
#define node_test_and_set(node, nodemask) \
__node_test_and_set((node), &(nodemask))
--
1.8.3.1
--
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>
next reply other threads:[~2017-01-03 8:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-03 8:27 Anshuman Khandual [this message]
2017-01-03 8:44 ` Michal Hocko
2017-01-03 9:07 ` Anshuman Khandual
2017-01-03 9:17 ` Michal Hocko
2017-01-03 9:47 ` Anshuman Khandual
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=20170103082753.25758-1-khandual@linux.vnet.ibm.com \
--to=khandual@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=vbabka@suse.cz \
/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