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.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 E6B95C4338F for ; Tue, 17 Aug 2021 08:25:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7E7A60FBF for ; Tue, 17 Aug 2021 08:25:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239466AbhHQI0B (ORCPT ); Tue, 17 Aug 2021 04:26:01 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:14267 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239329AbhHQIZT (ORCPT ); Tue, 17 Aug 2021 04:25:19 -0400 Received: from dggeme703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4GpkbT5FY4z876x; Tue, 17 Aug 2021 16:24:37 +0800 (CST) Received: from [10.174.179.72] (10.174.179.72) by dggeme703-chm.china.huawei.com (10.1.199.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 17 Aug 2021 16:24:43 +0800 Subject: Re: [PATCH 2/4] mm/hwpoison: fix potential pte_unmap_unlock pte error To: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= CC: "akpm@linux-foundation.org" , "sfr@canb.auug.org.au" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" References: <20210814105131.48814-1-linmiaohe@huawei.com> <20210814105131.48814-3-linmiaohe@huawei.com> <20210817072900.GA452155@hori.linux.bs1.fc.nec.co.jp> From: Miaohe Lin Message-ID: <4b0a5fcd-0b1b-6198-b6a7-d9cab5b9fae2@huawei.com> Date: Tue, 17 Aug 2021 16:24:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210817072900.GA452155@hori.linux.bs1.fc.nec.co.jp> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.72] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggeme703-chm.china.huawei.com (10.1.199.99) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/8/17 15:29, HORIGUCHI NAOYA(堀口 直也) wrote: > On Sat, Aug 14, 2021 at 06:51:29PM +0800, Miaohe Lin wrote: >> If the first pte is equal to poisoned_pfn, i.e. check_hwpoisoned_entry() >> return 1, the wrong ptep - 1 would be passed to pte_unmap_unlock(). >> >> Fixes: ad9c59c24095 ("mm,hwpoison: send SIGBUS with error virutal address") >> Signed-off-by: Miaohe Lin > > I agree with the change itself, so > > Acked-by: Naoya Horiguchi > Many thanks for your review and Acked-by tag! > One question is that according to "grep -r pte_unmap_unlock ." command over > whole kernel source code, pte_unmap_unlock() is called with "ptep - 1" in some places. > I think that none of them seems to have "break in for loop" in locked period, > so the same problem does not occur there. But I'm still not sure why some place > call with "ptep - 1" and the others call with pte returned by pte_offset_map_lock(). IMO pte_unmap_unlock() works as long as the passed in pte belongs to the same page returned from pte_offset_map_lock(). I have fixed some similar place where pte_unmap_unlock() is called with wrong "ptep - 1" when I was learning the related mm code. >