mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Hellström (VMware)" <thomas_os@shipmail.org>
To: "Kirill A. Shutemov" <kirill@shutemov.name>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Thomas Hellstrom <thellstrom@vmware.com>,
	Arnd Bergmann <arnd@arndb.de>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH 2/2] mm: Fix a huge pud insertion race during faulting
Date: Mon, 18 Nov 2019 13:58:04 +0100	[thread overview]
Message-ID: <b8600932-517d-99d3-90b4-d9b9e8a6f641@shipmail.org> (raw)
In-Reply-To: <20191118102219.om5monxih7kfodyz@box>

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@shipmail.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@linux.intel.com>
>


  reply	other threads:[~2019-11-18 12:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15 11:58 [PATCH 1/2] mm: Move the backup x_devmap() functions to asm-generic/pgtable.h Thomas Hellström (VMware)
2019-11-15 11:58 ` [PATCH 2/2] mm: Fix a huge pud insertion race during faulting Thomas Hellström (VMware)
2019-11-15 19:58   ` Andrew Morton
2019-11-18 10:22     ` Kirill A. Shutemov
2019-11-18 12:58       ` Thomas Hellström (VMware) [this message]
2019-11-18 21:02         ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b8600932-517d-99d3-90b4-d9b9e8a6f641@shipmail.org \
    --to=thomas_os@shipmail.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=thellstrom@vmware.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®