All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ralph Campbell <rcampbell@nvidia.com>
To: <linux-mm@kvack.org>
Cc: linux-kernel@vger.kernel.org,
	"Ralph Campbell" <rcampbell@nvidia.com>,
	"Jérôme Glisse" <jglisse@redhat.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	"Mike Kravetz" <mike.kravetz@oracle.com>,
	"Christoph Hellwig" <hch@lst.de>,
	"Jason Gunthorpe" <jgg@mellanox.com>,
	stable@vger.kernel.org,
	"Andrew Morton" <akpm@linux-foundation.org>
Subject: [PATCH 3/3] mm/hmm: Fix bad subpage pointer in try_to_unmap_one
Date: Tue, 16 Jul 2019 17:14:46 -0700	[thread overview]
Message-ID: <20190717001446.12351-4-rcampbell@nvidia.com> (raw)
In-Reply-To: <20190717001446.12351-1-rcampbell@nvidia.com>

When migrating an anonymous private page to a ZONE_DEVICE private page,
the source page->mapping and page->index fields are copied to the
destination ZONE_DEVICE struct page and the page_mapcount() is increased.
This is so rmap_walk() can be used to unmap and migrate the page back to
system memory. However, try_to_unmap_one() computes the subpage pointer
from a swap pte which computes an invalid page pointer and a kernel panic
results such as:

BUG: unable to handle page fault for address: ffffea1fffffffc8

Currently, only single pages can be migrated to device private memory so
no subpage computation is needed and it can be set to "page".

Fixes: a5430dda8a3a1c ("mm/migrate: support un-addressable ZONE_DEVICE page in migration")
Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
Cc: "Jérôme Glisse" <jglisse@redhat.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Jason Gunthorpe <jgg@mellanox.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
 mm/rmap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/rmap.c b/mm/rmap.c
index e5dfe2ae6b0d..ec1af8b60423 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1476,6 +1476,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
 			 * No need to invalidate here it will synchronize on
 			 * against the special swap migration pte.
 			 */
+			subpage = page;
 			goto discard;
 		}
 
-- 
2.20.1


  parent reply	other threads:[~2019-07-17  0:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-17  0:14 [PATCH 0/3] mm/hmm: fixes for device private page migration Ralph Campbell
2019-07-17  0:14 ` [PATCH 1/3] mm: document zone device struct page reserved fields Ralph Campbell
2019-07-17  1:20   ` John Hubbard
2019-07-17  4:22     ` Christoph Hellwig
2019-07-17  4:31       ` John Hubbard
2019-07-17  4:38         ` Christoph Hellwig
2019-07-17 17:50           ` Ralph Campbell
2019-07-17  0:14 ` [PATCH 2/3] mm/hmm: fix ZONE_DEVICE anon page mapping reuse Ralph Campbell
2019-07-17  1:40   ` John Hubbard
2019-07-17  0:14 ` Ralph Campbell [this message]
2019-07-17  1:51   ` [PATCH 3/3] mm/hmm: Fix bad subpage pointer in try_to_unmap_one John Hubbard
2019-07-17 15:14   ` Sasha Levin
2019-07-19 19:06 [PATCH 0/3] mm/hmm: fixes for device private page migration Ralph Campbell
2019-07-19 19:06 ` [PATCH 3/3] mm/hmm: Fix bad subpage pointer in try_to_unmap_one Ralph Campbell

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=20190717001446.12351-4-rcampbell@nvidia.com \
    --to=rcampbell@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@lst.de \
    --cc=jgg@mellanox.com \
    --cc=jglisse@redhat.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=stable@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.