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=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,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 8D106C43457 for ; Thu, 15 Oct 2020 12:16:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9BBA022249 for ; Thu, 15 Oct 2020 12:16:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BBA022249 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C01A36B005D; Thu, 15 Oct 2020 08:16:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB1556B0062; Thu, 15 Oct 2020 08:16:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA0866B0068; Thu, 15 Oct 2020 08:16:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0085.hostedemail.com [216.40.44.85]) by kanga.kvack.org (Postfix) with ESMTP id 78E746B005D for ; Thu, 15 Oct 2020 08:16:05 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0B61F181AC9CC for ; Thu, 15 Oct 2020 12:16:05 +0000 (UTC) X-FDA: 77374056690.20.truck49_520a7a627214 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id DF355180C07A3 for ; Thu, 15 Oct 2020 12:16:04 +0000 (UTC) X-HE-Tag: truck49_520a7a627214 X-Filterd-Recvd-Size: 1822 Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Thu, 15 Oct 2020 12:16:04 +0000 (UTC) Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id BB12D79062E39210F1E9; Thu, 15 Oct 2020 20:16:00 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Thu, 15 Oct 2020 20:15:51 +0800 From: Shijie Luo To: CC: , , , , Subject: [PATCH] mm: fix potential pte_unmap_unlock pte error Date: Thu, 15 Oct 2020 08:15:34 -0400 Message-ID: <20201015121534.50910-1-luoshijie1@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When flags don't have MPOL_MF_MOVE or MPOL_MF_MOVE_ALL bits, code breaks and passing origin pte - 1 to pte_unmap_unlock seems like not a good ide= a. Signed-off-by: Shijie Luo Signed-off-by: linmiaohe --- mm/mempolicy.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 3fde772ef5ef..01f088630d1d 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -571,7 +571,11 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigne= d long addr, } else break; } - pte_unmap_unlock(pte - 1, ptl); + + if (addr >=3D end) + pte =3D pte - 1; + + pte_unmap_unlock(pte, ptl); cond_resched(); =20 if (has_unmovable) --=20 2.19.1