Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1101740pxa; Thu, 20 Aug 2020 02:29:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXY5ojvvHx7XU86egdGMvQqC4zSsZmloSOkDWGlkVGyqxAkQlKdAD8jUBa3QEq37NlNVJm X-Received: by 2002:a05:6402:12c4:: with SMTP id k4mr1966810edx.358.1597915785442; Thu, 20 Aug 2020 02:29:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597915785; cv=none; d=google.com; s=arc-20160816; b=ssuOqiAmY97bZJwVRvwJNqKrJ8XusUWWE7/1ucUlVuRBWV4eynPCi4AnTmvvGSOHCo XA0AjPgprW8CxnJgIZ/V6BmECkbFFlZhIBJvqicXKwUnaLu/l7PETrqo4p6izuDiYSei gL3W0mPabXnGyZrSgTM+yJHOASu8wufGk7hJFxIFs+axbdqQZrLnRUiGfPjqbVe6ZGQb /V2QJ7G++BgDsRy9O/hY9EyGAgFjUcFnVsIoPHfvpmoIVnbFfLyJYInJlg5xLVV7qjr9 RK5fv4wPcAHTHBx/fLexGeejRo0imgXc/u5h1JF3GBwXoDG7F7JFvsOgX9/0s9/EDej4 Fv1w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BXjj7cXygs4wR2NR3knZ+ft0WDxVLQ+GYdy94gqdUtI=; b=Ezb0CTb1SdKrlDdMFmL6WeRGq2Qazmbll3YNLu7yucB4IBov/E9UWDvy74se0gp8h8 MTvQx2ccT1HSIIWPCJ+JwmCILodRHfxyY8LaNduzUaJjdDbAAhSjBQYrwobydeX+TJ7A F2wS4REvutAnMR0lprHzvcK/sw7kCAusKL5q4pNUGPywayjvv/r2ycMYGiSOPl97xA7z SdWHLpdtq5+gJdy9PljjfimnfN9IS1LVYJ9Z13Z+r38XVYa9Wff7iE1pfGrrasWn6sJP ahQXmJkLIipdguOdYvIZ58d+gN20JHVO1ON9H0nrCLThl5WK29boevou5ed7tTAv7GK0 eqUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HY3fnoba; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v20si1025239edl.269.2020.08.20.02.29.21; Thu, 20 Aug 2020 02:29:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HY3fnoba; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726992AbgHTJ1z (ORCPT + 99 others); Thu, 20 Aug 2020 05:27:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:33620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727949AbgHTJ1A (ORCPT ); Thu, 20 Aug 2020 05:27:00 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 B759122D08; Thu, 20 Aug 2020 09:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915618; bh=7INpsne5XqqcM9dgEgvMScCRO9DTUSEYmf2NWPPV3P4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HY3fnobaP9xShBvvdAxyVoP5IYHKfjG6dwndLcQByu1mQq6zrzwPSqswB30lxJJ4f prFvRv+kY0xuqVmmXOXWh0I9KcjWbFuDZJEp6Pa1k0FTt7k8ktC2kUdw2cyxOwMaUt 9aZ3Ua3wnBb4FN8lpXN3lt8K6wGGi1+X6rV5fFpk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hugh Dickins , Andrew Morton , "Kirill A. Shutemov" , Andrea Arcangeli , Mike Kravetz , Song Liu , Linus Torvalds Subject: [PATCH 5.8 077/232] khugepaged: collapse_pte_mapped_thp() flush the right range Date: Thu, 20 Aug 2020 11:18:48 +0200 Message-Id: <20200820091616.540850550@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@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: Hugh Dickins commit 723a80dafed5c95889d48baab9aa433a6ffa0b4e upstream. pmdp_collapse_flush() should be given the start address at which the huge page is mapped, haddr: it was given addr, which at that point has been used as a local variable, incremented to the end address of the extent. Found by source inspection while chasing a hugepage locking bug, which I then could not explain by this. At first I thought this was very bad; then saw that all of the page translations that were not flushed would actually still point to the right pages afterwards, so harmless; then realized that I know nothing of how different architectures and models cache intermediate paging structures, so maybe it matters after all - particularly since the page table concerned is immediately freed. Much easier to fix than to think about. Fixes: 27e1f8273113 ("khugepaged: enable collapse pmd for pte-mapped THP") Signed-off-by: Hugh Dickins Signed-off-by: Andrew Morton Acked-by: Kirill A. Shutemov Cc: Andrea Arcangeli Cc: Mike Kravetz Cc: Song Liu Cc: [5.4+] Link: http://lkml.kernel.org/r/alpine.LSU.2.11.2008021204390.27773@eggly.anvils Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/khugepaged.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1502,7 +1502,7 @@ void collapse_pte_mapped_thp(struct mm_s /* step 4: collapse pmd */ ptl = pmd_lock(vma->vm_mm, pmd); - _pmd = pmdp_collapse_flush(vma, addr, pmd); + _pmd = pmdp_collapse_flush(vma, haddr, pmd); spin_unlock(ptl); mm_dec_nr_ptes(mm); pte_free(mm, pmd_pgtable(_pmd));