Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1519065rwn; Thu, 8 Sep 2022 22:41:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR4XSShvRrPwgDVFiK2Lr9zrZjQvF3ViSJDq/RtlGq+DSK4f30/wq20JAhfy4Sp36HSnzRw/ X-Received: by 2002:a05:6512:138f:b0:48d:1e9f:e857 with SMTP id p15-20020a056512138f00b0048d1e9fe857mr3605222lfa.66.1662702085347; Thu, 08 Sep 2022 22:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662702085; cv=none; d=google.com; s=arc-20160816; b=UrLh9UxMM7p/1+82UUrQu0v3z0h4Kgwkr/0lzKRpfCeg9y7D+j7Oh0YKyBq7JT2bAH iduk+Z430DiqGUxP+IEP3RR2S9eVc4EjH8umfIKGhsT7esRlI4A0hqv+HAUOTOY5XCdX iut0tD3Xfnv0eRdUNXkYc5kKZyyArWxg4LTbsRNvlRTL1RT05jT37KQzXrIRsncA1RFI 4QK1xiKnpYY7W8TT64L9SnEkNvug/2qrjSt1uBikaOmOKp7e6ftxaFLNnmEkPs6n7JaS uyWX6HNazWs9POjuRrOzYFPlsaiH6LqlfPU70eoUf2kfTauGEuWQosNOslJZ8nCZ75Mz 8FAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pX5rVBn+1PNNX6d3qLcqQJJa7wZeAep7KqWlpHJxP2c=; b=PrTbwEypgGMyNZvbIRIOMkedogJ/38LJh1Zf5ZVbjQZVMLvC0dsxZBwgBMSvZYIyO8 LW5P7O0+YIEvRQ5utAS5lnrtfHsC3Kio8nEKZ3gLNiaz4+8k+0Bqh8T50h84SD9b6pHR 8A19nDX3bPhuIeuVa8QX2Zadq3XjtkLrMzNnPyuA3PMf+qRCKNZq9jkIClXP37RVdUjD D2c0x0vAkggWE1cBvyBsJ5vl2ZYPXpDKDpU7NmjE4NlMXlh687pQyzb5GztSh2NjNe/7 o8QcmVqiaCyfCph/AQ2Sl9A8Y8CYC1GbmAo4uf7kWc6PaLfPtixk+MBVUG6S9v47FZ+/ gxtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Va2L0J/O"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g19-20020a056512119300b0048cdb14a4f1si429079lfr.164.2022.09.08.22.40.56; Thu, 08 Sep 2022 22:41:25 -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=@linuxfoundation.org header.s=korg header.b="Va2L0J/O"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230076AbiIIFe7 (ORCPT + 99 others); Fri, 9 Sep 2022 01:34:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbiIIFe5 (ORCPT ); Fri, 9 Sep 2022 01:34:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FB9E222B4; Thu, 8 Sep 2022 22:34:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9A9C861EA6; Fri, 9 Sep 2022 05:34:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3ACCC433B5; Fri, 9 Sep 2022 05:34:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662701677; bh=FftL+/rX8uVcJtKMuxks7ytNZrKVramsaEYvfPTDuCk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Va2L0J/OnDvxeGB5/MfZxf9iOQAD6qwFI+nP1mLL34p+Ewd2gfSVLjuCNvhNRF+99 LNyjuUuD2lVy01V5C5W1uE/XuoTk3vlCXFqddBDqOrsYrOrE/YTcY75qBxwY2OTjrx 29kCT6NhpYIEg7WMh7rUiyGcnOLE/VdhUZKU3jpE= Date: Fri, 9 Sep 2022 07:34:34 +0200 From: Greg KH To: Sergei Antonov Cc: linux-mm@kvack.org, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, "Kirill A . Shutemov" Subject: Re: [PATCH] mm: bring back update_mmu_cache() to finish_fault() Message-ID: References: <20220908204809.2012451-1-saproj@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220908204809.2012451-1-saproj@gmail.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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, Sep 08, 2022 at 11:48:09PM +0300, Sergei Antonov wrote: > Running this test program on ARMv4 a few times (sometimes just once) > reproduces the bug. > > int main() > { > unsigned i; > char paragon[SIZE]; > void* ptr; > > memset(paragon, 0xAA, SIZE); > ptr = mmap(NULL, SIZE, PROT_READ | PROT_WRITE, > MAP_ANON | MAP_SHARED, -1, 0); > if (ptr == MAP_FAILED) return 1; > printf("ptr = %p\n", ptr); > for (i=0;i<10000;i++){ > memset(ptr, 0xAA, SIZE); > if (memcmp(ptr, paragon, SIZE)) { > printf("Unexpected bytes on iteration %u!!!\n", i); > break; > } > } > munmap(ptr, SIZE); > } > > In the "ptr" buffer there appear runs of zero bytes which are aligned > by 16 and their lengths are multiple of 16. > > Linux v5.11 does not have the bug, "git bisect" finds the first bad commit: > f9ce0be71d1f ("mm: Cleanup faultaround and finish_fault() codepaths") > > Before the commit update_mmu_cache() was called during a call to > filemap_map_pages() as well as finish_fault(). After the commit > finish_fault() lacks it. > > Bring back update_mmu_cache() to finish_fault() to fix the bug. > Also call update_mmu_tlb() only when returning VM_FAULT_NOPAGE to more > closely reproduce the code of alloc_set_pte() function that existed before > the commit. > > On many platforms update_mmu_cache() is nop: > x86, see arch/x86/include/asm/pgtable > ARMv6+, see arch/arm/include/asm/tlbflush.h > So, it seems, few users ran into this bug. > > Fixes: f9ce0be71d1f ("mm: Cleanup faultaround and finish_fault() codepaths") > Signed-off-by: Sergei Antonov > Cc: Kirill A. Shutemov > --- > mm/memory.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.