The commit is pushed to "branch-rh8-4.18.0-193.6.3.vz8.4.x-ovz" and will appear 
at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-193.6.3.vz8.4.9
------>
commit 56a5186d29d7373d71fd1519d90b785585840a2f
Author: Randy Dunlap <[email protected]>
Date:   Wed Apr 1 21:10:58 2020 -0700

    ms/mm: mempolicy: require at least one nodeid for MPOL_PREFERRED
    
    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 <[email protected]>
    Reported-by: [email protected]
    Signed-off-by: Randy Dunlap <[email protected]>
    Signed-off-by: Andrew Morton <[email protected]>
    Tested-by: [email protected]
    Cc: Lee Schermerhorn <[email protected]>
    Link: 
http://lkml.kernel.org/r/[email protected]
    Signed-off-by: Linus Torvalds <[email protected]>
    
    https://jira.sw.ru/browse/PSBM-120642
    CVE-2020-11565: out-of-bounds write in mpol_parse_str function in 
mm/mempolicy.c
    
    (cherry picked from commit aa9f7d5172fac9bf1f09e678c35e287a40a7b7dd)
    Signed-off-by: Konstantin Khorenko <[email protected]>
---
 mm/mempolicy.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index dab3b16534f0..b24738101414 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -2797,7 +2797,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;
@@ -2805,6 +2807,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:
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to