diff options
author | Randy Dunlap <rdunlap@infradead.org> | 2020-04-01 21:10:58 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-04-13 10:34:28 +0200 |
commit | c51609ac4c48d31a8881af669f1192d2ee405928 (patch) | |
tree | f9263ab316d3a6cd9dcbbc769d5415fd4e72e1c1 /mm | |
parent | 2d8260be1c2cc83a0e43b0304db490421a531d9a (diff) | |
download | linux-stable-c51609ac4c48d31a8881af669f1192d2ee405928.tar.gz linux-stable-c51609ac4c48d31a8881af669f1192d2ee405928.tar.bz2 linux-stable-c51609ac4c48d31a8881af669f1192d2ee405928.zip |
mm: mempolicy: require at least one nodeid for MPOL_PREFERRED
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@gmail.com>
Reported-by: syzbot+b055b1a6b2b958707a21@syzkaller.appspotmail.com
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Tested-by: syzbot+b055b1a6b2b958707a21@syzkaller.appspotmail.com
Cc: Lee Schermerhorn <lee.schermerhorn@hp.com>
Link: http://lkml.kernel.org/r/89526377-7eb6-b662-e1d8-4430928abde9@infradead.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/mempolicy.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 1b34f2e35951..d857e4770cc8 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2748,7 +2748,9 @@ int mpol_parse_str(char *str, struct mempolicy **mpol) 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; @@ -2756,6 +2758,8 @@ int mpol_parse_str(char *str, struct mempolicy **mpol) rest++; if (*rest) goto out; + if (nodes_empty(nodes)) + goto out; } break; case MPOL_INTERLEAVE: |