[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b8600932-517d-99d3-90b4-d9b9e8a6f641@shipmail.org>
Date: Mon, 18 Nov 2019 13:58:04 +0100
From: Thomas Hellström (VMware)
<thomas_os@...pmail.org>
To: "Kirill A. Shutemov" <kirill@...temov.name>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Thomas Hellstrom <thellstrom@...are.com>,
Arnd Bergmann <arnd@...db.de>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Matthew Wilcox <willy@...radead.org>
Subject: Re: [PATCH 2/2] mm: Fix a huge pud insertion race during faulting
On 11/18/19 11:22 AM, Kirill A. Shutemov wrote:
> On Fri, Nov 15, 2019 at 11:58:00AM -0800, Andrew Morton wrote:
>> On Fri, 15 Nov 2019 12:58:08 +0100 Thomas Hellström (VMware) <thomas_os@...pmail.org> wrote:
>>
>>> A huge pud page can theoretically be faulted in racing with pmd_alloc()
>>> in __handle_mm_fault(). That will lead to pmd_alloc() returning an
>>> invalid pmd pointer. Fix this by adding a pud_trans_unstable() function
>>> similar to pmd_trans_unstable() and check whether the pud is really stable
>>> before using the pmd pointer.
>>>
>>> Race:
>>> Thread 1: Thread 2: Comment
>>> create_huge_pud() Fallback - not taken.
>>> create_huge_pud() Taken.
>>> pmd_alloc() Returns an invalid pointer.
>> What are the user-visible runtime effects of this change?
> Data corruption: kernel writes to a huge page thing it's page table.
>
>> Is a -stable backport warranted?
> I believe it is.
Note that this was caught during a code audit rather than a real
experienced problem. It looks to me like the only implementation that
currently creates huge pud pagetable entries is dev_dax_huge_fault()
which doesn't appear to care much about private (COW) mappings or
write-tracking which is, I believe, a prerequisite for create_huge_pud()
falling back on thread 1, but not in thread 2.
This means (assuming that's intentional) that a stable backport
shouldn't be needed.
For the WIP huge page support for graphics memory we'll be allowing both
COW mappings and write-tracking, though, but that's still some time away.
In any case, I think this patch needs -rc testing to catch potential
pud_devmap issues before submitted to stable.
Thanks,
Thomas
>
> Acked-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
>
Powered by blists - more mailing lists