Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1404637ybl; Thu, 22 Aug 2019 14:04:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjJ6dinObhJQltsFavllKJZj0HLI7+7saKW/6kGPKTARGZKsXNed8YDP1uFWo67gxjeeXQ X-Received: by 2002:a62:33c3:: with SMTP id z186mr1333514pfz.212.1566507892714; Thu, 22 Aug 2019 14:04:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566507892; cv=none; d=google.com; s=arc-20160816; b=IVeQjXwi7tUSW9ZgtV3/ebUMEIFfqpzi+QLERviER5fhDyvvH9QzUL03onrG9oHB4Y WwEjxeR7hYJlljr8Jgnuuh0K7zCe8MWqqDaWiar2QIp7oWVNETist9x4bVEqeEJ49aun 5nPuPisWIKRkzfwp5xgbLkjjzzHo5vGu+xGbP7tKO/PqzqXPkXK9ISOOm7rDy2Gh9V1T khOMeZK6mwP5JEAfZrsoyeiLtrghAZ//BN2KNvEPNA/Ti1LrORexZlnDAFlgvC+DPZbU 6+KkqeKDXr5VugiKDHaIuKBqWNuRGTzdTsNqcGWvR2wcMBmsXvXmQzdypvbP0Zl+wsQB BhTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OMiDxUDzOI0LyN825ZHKBGZ0TLg4rjqxcVdtb80pMUc=; b=bubDIu+F7ikbLaDExSRYM8hbNn1WjxzJVdj08g+4cj/cpvP2+OoegV3sYwu9YT4QGx fqzCQhu3+EMa/9iB1i6CO7SaEDhgL9rq3OcY5yRTdOrQTl552TFbNchyh8ENltdkJ7Ug MWoO8wj0iD4rW8CS1O1xBwChKoaG5lOYKRX0XUst5tlvN0QJPGxHGTvNgaD6OKQNJKme d8udg2IJMaxf2KoqprQ0ne97XOzEp0Ph9Ad21YupVkd0EpPHsesP+aI/D4+akMKrGY5M ZCk1bYlOUGIylCZhv/igR8/K9qP+YVCjXXQXYC74W1O69+WvHZ/HeGg8qtKb5fv+/BRv bCSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ECeQwqsz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si489487plp.304.2019.08.22.14.04.37; Thu, 22 Aug 2019 14:04:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ECeQwqsz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390257AbfHVRIS (ORCPT + 99 others); Thu, 22 Aug 2019 13:08:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:57618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390237AbfHVRIR (ORCPT ); Thu, 22 Aug 2019 13:08:17 -0400 Received: from sasha-vm.mshome.net (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E1AF023400; Thu, 22 Aug 2019 17:08:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566493696; bh=qilmrSz0Yqh8giWWt9Gr7R/6ySvCEXEHCsxy9Pi5a+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ECeQwqszIuyu/n8fDFHaWKiT5KlJxMKdc/EM0cO5h+DsimuYahDwuyYiEcdIrfRIg ujg45itQmEcFicst8izsjgKQfImc2O0zbBv5VxxzAk9Xv+xI6FnvTZHwJvmf5PnJVu lcz9lwxEaPYv5x7qarVO7fRpvPgG/eIrX5C4kJTk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: 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 , Greg Kroah-Hartman Subject: [PATCH 5.2 004/135] mm/hmm: fix bad subpage pointer in try_to_unmap_one Date: Thu, 22 Aug 2019 13:06:00 -0400 Message-Id: <20190822170811.13303-5-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190822170811.13303-1-sashal@kernel.org> References: <20190822170811.13303-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.10-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.2.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.2.10-rc1 X-KernelTest-Deadline: 2019-08-24T17:07+00:00 X-stable: review X-Patchwork-Hint: Ignore 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(+) diff --git a/mm/rmap.c b/mm/rmap.c index e5dfe2ae6b0d5..003377e242323 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1475,7 +1475,15 @@ 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. + * + * 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; } -- 2.20.1