[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <lsq.1587683028.540912170@decadent.org.uk>
Date: Fri, 24 Apr 2020 00:07:33 +0100
From: Ben Hutchings <ben@...adent.org.uk>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
CC: akpm@...ux-foundation.org, Denis Kirjanov <kda@...ux-powerpc.org>,
"Lee Schermerhorn" <lee.schermerhorn@...com>,
"Linus Torvalds" <torvalds@...ux-foundation.org>,
"Entropy Moe" <3ntr0py1337@...il.com>,
"Randy Dunlap" <rdunlap@...radead.org>,
syzbot+b055b1a6b2b958707a21@...kaller.appspotmail.com
Subject: [PATCH 3.16 226/245] mm: mempolicy: require at least one nodeid
for MPOL_PREFERRED
3.16.83-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <rdunlap@...radead.org>
commit aa9f7d5172fac9bf1f09e678c35e287a40a7b7dd upstream.
Using an empty (malformed) nodelist that is not caught during mount option
parsing leads to a stack-out-of-bounds access.
The option string that was used was: "mpol=prefer:,". However,
MPOL_PREFERRED requires a single node number, which is not being provided
here.
Add a check that 'nodes' is not empty after parsing for MPOL_PREFERRED's
nodeid.
Fixes: 095f1fc4ebf3 ("mempolicy: rework shmem mpol parsing and display")
Reported-by: Entropy Moe <3ntr0py1337@...il.com>
Reported-by: syzbot+b055b1a6b2b958707a21@...kaller.appspotmail.com
Signed-off-by: Randy Dunlap <rdunlap@...radead.org>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
Tested-by: syzbot+b055b1a6b2b958707a21@...kaller.appspotmail.com
Cc: Lee Schermerhorn <lee.schermerhorn@...com>
Link: http://lkml.kernel.org/r/89526377-7eb6-b662-e1d8-4430928abde9@infradead.org
Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Ben Hutchings <ben@...adent.org.uk>
---
mm/mempolicy.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -2711,7 +2711,9 @@ int mpol_parse_str(char *str, struct mem
switch (mode) {
case MPOL_PREFERRED:
/*
- * Insist on a nodelist of one node only
+ * Insist on a nodelist of one node only, although later
+ * we use first_node(nodes) to grab a single node, so here
+ * nodelist (or nodes) cannot be empty.
*/
if (nodelist) {
char *rest = nodelist;
@@ -2719,6 +2721,8 @@ int mpol_parse_str(char *str, struct mem
rest++;
if (*rest)
goto out;
+ if (nodes_empty(nodes))
+ goto out;
}
break;
case MPOL_INTERLEAVE:
Powered by blists - more mailing lists