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>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 6 Aug 2020 18:22:56 -0700
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Muchun Song <songmuchun@...edance.com>
Cc:     mike.kravetz@...cle.com, David Rientjes <rientjes@...gle.com>,
        mgorman@...e.de, Michel Lespinasse <walken@...gle.com>,
        Linux Memory Management List <linux-mm@...ck.org>,
        Michal Hocko <mhocko@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>, Baoquan He <bhe@...hat.com>
Subject: Re: [PATCH v4] mm/hugetlb: add mempolicy check in the reservation
 routine

On Thu, 6 Aug 2020 15:45:14 +0800 Muchun Song <songmuchun@...edance.com> wrote:

> On Tue, Jul 28, 2020 at 11:49 AM Muchun Song <songmuchun@...edance.com> wrote:
> >
> > In the reservation routine, we only check whether the cpuset meets
> > the memory allocation requirements. But we ignore the mempolicy of
> > MPOL_BIND case. If someone mmap hugetlb succeeds, but the subsequent
> > memory allocation may fail due to mempolicy restrictions and receives
> > the SIGBUS signal. This can be reproduced by the follow steps.
> >
> >  1) Compile the test case.
> >     cd tools/testing/selftests/vm/
> >     gcc map_hugetlb.c -o map_hugetlb
> >
> >  2) Pre-allocate huge pages. Suppose there are 2 numa nodes in the
> >     system. Each node will pre-allocate one huge page.
> >     echo 2 > /proc/sys/vm/nr_hugepages
> >
> >  3) Run test case(mmap 4MB). We receive the SIGBUS signal.
> >     numactl --membind=0 ./map_hugetlb 4
> >
> > With this patch applied, the mmap will fail in the step 3) and throw
> > "mmap: Cannot allocate memory".
> >
> > Signed-off-by: Muchun Song <songmuchun@...edance.com>
> > Reported-by: Jianchao Guo <guojianchao@...edance.com>
> > Suggested-by: Michal Hocko <mhocko@...nel.org>
> > Reviewed-by: Mike Kravetz <mike.kravetz@...cle.com>
> 
> Hi Andrew,
> 
> Any comments or forgot to add this to the queue for the
> merge window?

I think Baoquan He's comment threw me off.

I worry about the use of `current' in mempolicy.h.  It's the first time
this header has referenced current and the patch forgot to include
sched.h to get the definition.  Presumably it works by accident.  I
could toss in the #include but sometimes that blows up.

But it's unlikely that we'll be getting circular includes or other such
nastiness between those two header files, so fingers crossed...

--- a/include/linux/mempolicy.h~mm-hugetlb-add-mempolicy-check-in-the-reservation-routine-fix
+++ a/include/linux/mempolicy.h
@@ -6,7 +6,7 @@
 #ifndef _LINUX_MEMPOLICY_H
 #define _LINUX_MEMPOLICY_H 1
 
-
+#include <linux/sched.h>
 #include <linux/mmzone.h>
 #include <linux/dax.h>
 #include <linux/slab.h>
_

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ