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: <a3ed000de83d9958b6bd921cbc22f9c6363efa0b.camel@surriel.com>
Date:   Tue, 26 Sep 2023 19:57:34 -0400
From:   Rik van Riel <riel@...riel.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-kernel@...r.kernel.org, kernel-team@...a.com,
        linux-mm@...ck.org, muchun.song@...ux.dev, mike.kravetz@...cle.com,
        leit@...a.com, willy@...radead.org
Subject: Re: [PATCH 2/3] hugetlbfs: close race between MADV_DONTNEED and
 page fault

On Tue, 2023-09-26 at 14:15 -0700, Andrew Morton wrote:
> On Mon, 25 Sep 2023 23:10:51 -0400 riel@...riel.com wrote:
> 
> > From: Rik van Riel <riel@...riel.com>
> > 
> > Malloc libraries, like jemalloc and tcalloc, take decisions on when
> > to call madvise independently from the code in the main
> > application.
> > 
> > This sometimes results in the application page faulting on an
> > address,
> > right after the malloc library has shot down the backing memory
> > with
> > MADV_DONTNEED.
> > 
> > Usually this is harmless, because we always have some 4kB pages
> > sitting around to satisfy a page fault. However, with hugetlbfs
> > systems often allocate only the exact number of huge pages that
> > the application wants.
> > 
> > Due to TLB batching, hugetlbfs MADV_DONTNEED will free pages
> > outside of
> > any lock taken on the page fault path, which can open up the
> > following
> > race condition:
> > 
> >        CPU 1                            CPU 2
> > 
> >        MADV_DONTNEED
> >        unmap page
> >        shoot down TLB entry
> >                                        page fault
> >                                        fail to allocate a huge page
> >                                        killed with SIGBUS
> >        free page
> > 
> > Fix that race by pulling the locking from
> > __unmap_hugepage_final_range
> > into helper functions called from zap_page_range_single. This
> > ensures
> > page faults stay locked out of the MADV_DONTNEED VMA until the
> > huge pages have actually been freed.
> > 
> 
> Was a -stable backport considered?
> 
That's a good idea. I'll have to see how far back 
the hugetlb_vma_*_lock stuff exists.

We probably don't want to backport all the required
infrastructure everywhere.

-- 
All Rights Reversed.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ