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]
Message-ID: <CAMZfGtWUkW3AViM+vy6ffb44s_vjm0p0aXi=jdLkqKmN9HWJFA@mail.gmail.com>
Date:   Fri, 24 Jul 2020 17:04:28 +0800
From:   Muchun Song <songmuchun@...edance.com>
To:     Michal Hocko <mhocko@...nel.org>
Cc:     mike.kravetz@...cle.com, Andrew Morton <akpm@...ux-foundation.org>,
        Linux Memory Management List <linux-mm@...ck.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Jianchao Guo <guojianchao@...edance.com>
Subject: Re: [Phishing Risk] [External] Re: [PATCH] mm/hugetlb: add mempolicy
 check in the reservation routine

On Fri, Jul 24, 2020 at 3:39 PM Michal Hocko <mhocko@...nel.org> wrote:
>
> On Thu 23-07-20 15:44:17, Muchun Song 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
>
> Cpusets and mempolicy interaction has always been a nightmare and

Yeah, I agree with you.

> semantic might get really awkward in some cases. In this case I am not
> really sure anybody really does soemthing like that but anyway...

Someone may like to use numactl to bind memory nodes. So I think
that it is better to add a mempolicy check.

>
> [...]
>
> > -static unsigned int cpuset_mems_nr(unsigned int *array)
> > +static nodemask_t *mempolicy_current_bind_nodemask(void)
> > +{
> > +     struct mempolicy *mpol;
> > +     nodemask_t *nodemask;
> > +
> > +     mpol = get_task_policy(current);
> > +     if (mpol->mode == MPOL_BIND)
> > +             nodemask = &mpol->v.nodes;
> > +     else
> > +             nodemask = NULL;
> > +
> > +     return nodemask;
> > +}
>
> We already have policy_nodemask which tries to do this. Is there any
> reason to not reuse it?

Yeah, we can reuse it, I didn't know it before. Thanks.

> --
> Michal Hocko
> SUSE Labs



-- 
Yours,
Muchun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ