lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <89526377-7eb6-b662-e1d8-4430928abde9@infradead.org>
Date:   Wed, 25 Mar 2020 17:45:26 -0700
From:   Randy Dunlap <rdunlap@...radead.org>
To:     Entropy Moe <3ntr0py1337@...il.com>, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, akpm@...ux-foundation.org
Subject: [PATCH] mm: mempolicy: require at least one nodeid for MPOL_PREFERRED

From: Randy Dunlap <rdunlap@...radead.org>

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>
Signed-off-by: Randy Dunlap <rdunlap@...radead.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-mm@...ck.org
Cc: Lee Schermerhorn <lee.schermerhorn@...com>
---
 mm/mempolicy.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- lnx-56-rc6.orig/mm/mempolicy.c
+++ lnx-56-rc6/mm/mempolicy.c
@@ -2841,7 +2841,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;
@@ -2849,6 +2851,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

Powered by Openwall GNU/*/Linux Powered by OpenVZ