From patchwork Fri Jul 9 13:18:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 472292 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=-19.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 C5BE3C11F6B for ; Fri, 9 Jul 2021 13:19:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B1B926128A for ; Fri, 9 Jul 2021 13:19:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232304AbhGINWb (ORCPT ); Fri, 9 Jul 2021 09:22:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:53376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232277AbhGINW3 (ORCPT ); Fri, 9 Jul 2021 09:22:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 55C75613B6; Fri, 9 Jul 2021 13:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1625836785; bh=LzQScFlq+nvLefsxylDxfr3lrPiQxJhtYv33CzkgE24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lqVoH9nAgEQHRNjCjSPY8QZIO057w6NBqZLoJ82a1OGHfxbe4Yz4ZSleHsdgp2hI0 pb7eu/4cgZg/rW0LdQiD/u4IFYxbOe259f80dPxByGhCeDvYt5gZDAOEbQmH++Gcb4 5g/OVM+xDYyhmhVHH6J08uGOIgDtXBBXoNew2+uQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hugh Dickins , "Kirill A. Shutemov" , Wang Yugui , Alistair Popple , Matthew Wilcox , Peter Xu , Ralph Campbell , Will Deacon , Yang Shi , Zi Yan , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 18/25] mm/thp: another PVMW_SYNC fix in page_vma_mapped_walk() Date: Fri, 9 Jul 2021 15:18:49 +0200 Message-Id: <20210709131638.887630622@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210709131627.928131764@linuxfoundation.org> References: <20210709131627.928131764@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Hugh Dickins [ Upstream commit a7a69d8ba88d8dcee7ef00e91d413a4bd003a814 ] Aha! Shouldn't that quick scan over pte_none()s make sure that it holds ptlock in the PVMW_SYNC case? That too might have been responsible for BUGs or WARNs in split_huge_page_to_list() or its unmap_page(), though I've never seen any. Link: https://lkml.kernel.org/r/1bdf384c-8137-a149-2a1e-475a4791c3c@google.com Link: https://lore.kernel.org/linux-mm/20210412180659.B9E3.409509F4@e16-tech.com/ Fixes: ace71a19cec5 ("mm: introduce page_vma_mapped_walk()") Signed-off-by: Hugh Dickins Acked-by: Kirill A. Shutemov Tested-by: Wang Yugui Cc: Alistair Popple Cc: Matthew Wilcox Cc: Peter Xu Cc: Ralph Campbell Cc: Will Deacon Cc: Yang Shi Cc: Zi Yan Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/page_vma_mapped.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index 16adeef76d00..a612daef5f00 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -271,6 +271,10 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) goto restart; } pvmw->pte++; + if ((pvmw->flags & PVMW_SYNC) && !pvmw->ptl) { + pvmw->ptl = pte_lockptr(mm, pvmw->pmd); + spin_lock(pvmw->ptl); + } } while (pte_none(*pvmw->pte)); if (!pvmw->ptl) {