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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMZfGtXBKvz6wg-N5LpwMcensRiiwnKYa5XDnGi2ueBMa0Q+NA@mail.gmail.com>
Date:   Wed, 24 Feb 2021 19:10:42 +0800
From:   Muchun Song <songmuchun@...edance.com>
To:     Michal Hocko <mhocko@...e.com>
Cc:     Mike Kravetz <mike.kravetz@...cle.com>,
        LKML <linux-kernel@...r.kernel.org>,
        Linux Memory Management List <linux-mm@...ck.org>,
        Gerald Schaefer <gerald.schaefer@...ux.ibm.com>,
        Oscar Salvador <osalvador@...e.de>,
        Heiko Carstens <hca@...ux.ibm.com>,
        Sven Schnelle <svens@...ux.ibm.com>,
        Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [External] Re: [PATCH] hugetlb: fix uninitialized subpool pointer

On Wed, Feb 24, 2021 at 5:43 PM Michal Hocko <mhocko@...e.com> wrote:
>
> On Tue 23-02-21 13:55:44, Mike Kravetz wrote:
> > Gerald Schaefer reported a panic on s390 in hugepage_subpool_put_pages()
> > with linux-next 5.12.0-20210222.
> > Call trace:
> >   hugepage_subpool_put_pages.part.0+0x2c/0x138
> >   __free_huge_page+0xce/0x310
> >   alloc_pool_huge_page+0x102/0x120
> >   set_max_huge_pages+0x13e/0x350
> >   hugetlb_sysctl_handler_common+0xd8/0x110
> >   hugetlb_sysctl_handler+0x48/0x58
> >   proc_sys_call_handler+0x138/0x238
> >   new_sync_write+0x10e/0x198
> >   vfs_write.part.0+0x12c/0x238
> >   ksys_write+0x68/0xf8
> >   do_syscall+0x82/0xd0
> >   __do_syscall+0xb4/0xc8
> >   system_call+0x72/0x98
> >
> > This is a result of the change which moved the hugetlb page subpool
> > pointer from page->private to page[1]->private.  When new pages are
> > allocated from the buddy allocator, the private field of the head
> > page will be cleared, but the private field of subpages is not modified.
> > Therefore, old values may remain.
>
> Very interesting. I have expected that the page->private would be in a
> reasonable state when allocated. On the other hand hugetlb doesn't do
> __GFP_COMP so tail pages are not initialized by the allocator.

It seems that the buddy allocator does not initialize the private field
of the tail page even when we specify __GFP_COMP.


>
> > Fix by initializing hugetlb page subpool pointer in prep_new_huge_page().
> >
> > Fixes: f1280272ae4d ("hugetlb: use page.private for hugetlb specific page flags")
>
> This is not a stable sha to refer to as it comes from linux next.
>
> > Reported-by: Gerald Schaefer <gerald.schaefer@...ux.ibm.com>
> > Signed-off-by: Mike Kravetz <mike.kravetz@...cle.com>
>
> Acked-by: Michal Hocko <mhocko@...e.com>
>
> I think this would be worth a separate patch rather than having it
> folded into the original patch. Thi is really subtle.
>
> > ---
> >  mm/hugetlb.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> > index c232cb67dda2..7ae5c18c98a7 100644
> > --- a/mm/hugetlb.c
> > +++ b/mm/hugetlb.c
> > @@ -1465,6 +1465,7 @@ static void prep_new_huge_page(struct hstate *h, struct page *page, int nid)
> >  {
> >       INIT_LIST_HEAD(&page->lru);
> >       set_compound_page_dtor(page, HUGETLB_PAGE_DTOR);
> > +     hugetlb_set_page_subpool(page, NULL);
> >       set_hugetlb_cgroup(page, NULL);
> >       set_hugetlb_cgroup_rsvd(page, NULL);
> >       spin_lock(&hugetlb_lock);
> > --
> > 2.29.2
> >
>
> --
> Michal Hocko
> SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ