From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D2EFC3A5A1 for ; Thu, 22 Aug 2019 17:26:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03F20206DD for ; Thu, 22 Aug 2019 17:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566494818; bh=HZrj+XMtyosh2Tvu6fEBkovpHZXexMnaifEDww0LYbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=CH1VqXn6ndH9Y3nJQxlH5lwl2vsR8SYD/bVzOHbMgaYbEukyTVxVhlOvSHGJM2q6u DEC5GaUH8BXF4zcJb71/LU6WArcy+lC/QXMiTInPyGc5ZFKu5RIMAhlIbWdpSDK/+I mu5N9cLzMcF3Y5REuAFyQ9sqcT7bkw9rW8SS+dbY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404785AbfHVR04 (ORCPT ); Thu, 22 Aug 2019 13:26:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:49594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404462AbfHVRZi (ORCPT ); Thu, 22 Aug 2019 13:25:38 -0400 Received: from localhost (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6D57E23405; Thu, 22 Aug 2019 17:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566494737; bh=HZrj+XMtyosh2Tvu6fEBkovpHZXexMnaifEDww0LYbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I31JabTZC5hlhI0Nj0OpW/6jJkq8cTDbq3OM4SBUH3sO7GEm/IcGQaCGv150S02Wt kIWL4cazXudm6rWyr5ghNoTKSl4ivQdJdvVqSvyVkvU+aVa4Ts2lpgnVONYHgc2u8a BGYV9D5Dx2O7QZCNoxQEaMtulldocM5QPyENlZJk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ralph Campbell , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , "Kirill A. Shutemov" , Mike Kravetz , Christoph Hellwig , Jason Gunthorpe , John Hubbard , Andrea Arcangeli , Andrey Ryabinin , Christoph Lameter , Dan Williams , Dave Hansen , Ira Weiny , Jan Kara , Lai Jiangshan , Logan Gunthorpe , Martin Schwidefsky , Matthew Wilcox , Mel Gorman , Michal Hocko , Pekka Enberg , Randy Dunlap , Vlastimil Babka , Andrew Morton , Linus Torvalds Subject: [PATCH 4.19 03/85] mm/hmm: fix bad subpage pointer in try_to_unmap_one Date: Thu, 22 Aug 2019 10:18:36 -0700 Message-Id: <20190822171731.151653399@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190822171731.012687054@linuxfoundation.org> References: <20190822171731.012687054@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ralph Campbell commit 1de13ee59225dfc98d483f8cce7d83f97c0b31de upstream. 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". [rcampbell@nvidia.com: add comment] Link: http://lkml.kernel.org/r/20190724232700.23327-4-rcampbell@nvidia.com Link: http://lkml.kernel.org/r/20190719192955.30462-4-rcampbell@nvidia.com Fixes: a5430dda8a3a1c ("mm/migrate: support un-addressable ZONE_DEVICE page in migration") Signed-off-by: Ralph Campbell Cc: "Jérôme Glisse" Cc: "Kirill A. Shutemov" Cc: Mike Kravetz Cc: Christoph Hellwig Cc: Jason Gunthorpe Cc: John Hubbard Cc: Andrea Arcangeli Cc: Andrey Ryabinin Cc: Christoph Lameter Cc: Dan Williams Cc: Dave Hansen Cc: Ira Weiny Cc: Jan Kara Cc: Lai Jiangshan Cc: Logan Gunthorpe Cc: Martin Schwidefsky Cc: Matthew Wilcox Cc: Mel Gorman Cc: Michal Hocko Cc: Pekka Enberg Cc: Randy Dunlap Cc: Vlastimil Babka Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/rmap.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1467,7 +1467,15 @@ static bool try_to_unmap_one(struct page /* * No need to invalidate here it will synchronize on * against the special swap migration pte. + * + * The assignment to subpage above was computed from a + * swap PTE which results in an invalid pointer. + * Since only PAGE_SIZE pages can currently be + * migrated, just set it to page. This will need to be + * changed when hugepage migrations to device private + * memory are supported. */ + subpage = page; goto discard; }