Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1845072ioo; Fri, 27 May 2022 19:54:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzufYOSNATB5IQGCcrwOIvF2omwEqRXNJ5mVEakHLqKWO3b5NBeyi/0v3lPvev3w5i3eWr7 X-Received: by 2002:a65:6ccd:0:b0:3c6:2ba2:5f9a with SMTP id g13-20020a656ccd000000b003c62ba25f9amr40274742pgw.216.1653706445327; Fri, 27 May 2022 19:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653706445; cv=none; d=google.com; s=arc-20160816; b=gEwycMlp1qOB7VCpHnzscSA0olULx4hosxAO819C0d+tg8en7pZu11R34EIzqI2hWC dWBXoQ/NKPcpBXS215CwH6M6wKkMzk+0cKpJlUolAvzfJQfcipVZIxHOkU6dy3aWQ8cP 98FhHn5BePuWKWhQjCVgjWv90WFoXbVeI/hyLNSDkbyDcGixVxn8rKcKcfMclCBxxpiR 9vov7X040SNtQGtX2Hb3QM6jZNs65gTcd8n6WhBg6/msJT4H/XiGyewlkuOXHfJAGwRh bYCcteZas7pKgsuC/sorAW/3wv0GiZvt5ZffR+jeEIH3pEj6mxooC83d+MC/5ucqSi2b v5hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/Tums9sSBFm64JACZICEeaJP4n2qB4OZ4M0MNbuB31s=; b=nYCmCCJhFswLDSaqBo3xkbCPO5zaGczhiZQi0+FSTuGzs+sTb9TP3d7s2WxZqwn/5Y /UFiIlAsjX0aLUakIMWMF9070Yj7bvW3UgQ6FL2kSvX1YcMyEBw0mFT87l7HwMZ89YD4 mOA+nKBlAJS4RFwYZ9I0TZ0zMs8Pi+D+2sT/Cvi6zStptnxmg3DT3lIAkQwH2wssN6TB XCfxEvpW+6F4V97nLt330A3XeY5RfzN1OfAbaz4D92f2aF6mfQRRxzRrCu2eafaXFGaI 1CLOUSnV+GMsku6lW+kxyDcOiWA8raioZMrqEsL0KjkXhDZqKMqnn284kScRovmRj1pN cV0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=F04feQsX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 22-20020a631556000000b003f9f41da8c6si8220576pgv.2.2022.05.27.19.53.53; Fri, 27 May 2022 19:54:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=F04feQsX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347480AbiEZNR5 (ORCPT + 99 others); Thu, 26 May 2022 09:17:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345691AbiEZNR4 (ORCPT ); Thu, 26 May 2022 09:17:56 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABB9CD02A2 for ; Thu, 26 May 2022 06:17:53 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id ck4so2897823ejb.8 for ; Thu, 26 May 2022 06:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/Tums9sSBFm64JACZICEeaJP4n2qB4OZ4M0MNbuB31s=; b=F04feQsX0xtaTMBBAIJ0ZM+soGiLto1TlYo8OhYxfKtXyZTXTedLY95EAHuqpAQ2Rw vhGMZLsQ0F1Xm8sCodqH/nso/UcewPDGeJPOFABGTeR2sloWV0vVUaiys3f89CFFwhJC p8yE4d5bu5QX+rSvVTcsbQLgksjy/MZlCeJaPrpFmZMCs1Muzb1smSiB9AMbSuJQJ1ut K+eyrNWUC79mn8xF3N5bNPxOBF9ucs4YO3II8PQESLvWiB3303TXV6YMPuAaQA/lKzl1 L1vRRV+dKBtm8nPyGLuSBEO0MrJ/MjIHWhLUO8CfCiKO91o0XgLpoYaSo8W3MnkbAmmc JwkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/Tums9sSBFm64JACZICEeaJP4n2qB4OZ4M0MNbuB31s=; b=a4nOzQVecLKWrqowC2HPjEWAuB7n6Pej8z1ItbnsDuKdhadbnCUk1bw/AMQBJRGCEY FOfotO3R0p1/dtsP6urydJzFHobumSzeZDb82YUj244sY8F1lVwURFEBd8qxGQGyoAVr En1awnAAnLLeVVJcY8L5hrp4oFDqm0Z4C0Z4fOu4DSW51o1LLhPDOIm0X2lnhVGqj32X wXSYaZY3L8+ll1Akv8VKo3eLboh1znEeOtMNaaVqVIJU5ekS2h8r5JZD4df3vDmF79q/ V2vN7j6Sd7S9erNrKerVKDiC4J51A7/GnsYLX9O9mXsIocu0jyajU+MJ/4e2xrwIH8aG /wbQ== X-Gm-Message-State: AOAM533mIYLxq6pImfNUB8GVqaQhYwfORG/Pi15wLcQ0haJ57X0mz0ZU yUFpBomjHZuJ2eYR4mcRBBmEW6lIucpdnNz5ssFlEA== X-Received: by 2002:a17:907:86a9:b0:6ff:45d:c05b with SMTP id qa41-20020a17090786a900b006ff045dc05bmr12015950ejc.492.1653571072192; Thu, 26 May 2022 06:17:52 -0700 (PDT) MIME-Version: 1.0 References: <20220526113350.30806-1-linmiaohe@huawei.com> In-Reply-To: <20220526113350.30806-1-linmiaohe@huawei.com> From: Pasha Tatashin Date: Thu, 26 May 2022 09:17:14 -0400 Message-ID: Subject: Re: [PATCH] mm/page_table_check: fix accessing unmapped ptep To: Miaohe Lin Cc: Andrew Morton , David Rientjes , linux-mm , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 26, 2022 at 7:33 AM Miaohe Lin wrote: > > ptep is unmapped too early, so ptep will be accessed while it's unmapped. > Fix it by deferring pte_unmap() until page table checking is done. I would re-word this as a cleanup. While pte_unmap() is currently unused, it is still better to call it after we are done with *ptep in case of future changes in other architectures. > > Fixes: 80110bbfbba6 ("mm/page_table_check: check entries at pmd levels") This is more a clean-up, there is no existing bug, so no need to backport to stable. Please remove the above. > Signed-off-by: Miaohe Lin With the above changes: Acked-by: Pasha Tatashin > --- > mm/page_table_check.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/page_table_check.c b/mm/page_table_check.c > index 3692bea2ea2c..971c3129b0e3 100644 > --- a/mm/page_table_check.c > +++ b/mm/page_table_check.c > @@ -234,11 +234,11 @@ void __page_table_check_pte_clear_range(struct mm_struct *mm, > pte_t *ptep = pte_offset_map(&pmd, addr); > unsigned long i; > > - pte_unmap(ptep); > for (i = 0; i < PTRS_PER_PTE; i++) { > __page_table_check_pte_clear(mm, addr, *ptep); > addr += PAGE_SIZE; > ptep++; > } > + pte_unmap(ptep); > } > } > -- > 2.23.0 >