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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0A73ECAAD3 for ; Fri, 9 Sep 2022 05:34:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BEDA8D0003; Fri, 9 Sep 2022 01:34:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 06EBF8D0001; Fri, 9 Sep 2022 01:34:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E779C8D0003; Fri, 9 Sep 2022 01:34:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D65598D0001 for ; Fri, 9 Sep 2022 01:34:38 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id ACBCDAAFB4 for ; Fri, 9 Sep 2022 05:34:38 +0000 (UTC) X-FDA: 79891432236.30.DAB414B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 5031E14008E for ; Fri, 9 Sep 2022 05:34:38 +0000 (UTC) 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 9252461EA4; 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> ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b="Va2L0J/O"; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf09.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662701678; a=rsa-sha256; cv=none; b=6M9bhZyxBNbtHnx90XaSvop/X+zx0mWjgDLUcHPN7vL6Q13yS82MPlLzs95Uqb60HuiBiT oO9tzyPa3QRe2G0hGUSy+DMZHQp+epdCeuz75UHE1GrEWG1y+CChtmzp2kxdt4AXu8jf/4 eafApvV3nZeyLrX1yYhvKJU6JLi9QUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662701678; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pX5rVBn+1PNNX6d3qLcqQJJa7wZeAep7KqWlpHJxP2c=; b=fwjsXTbfdpB2I2rh/Kh4ltsp5EG6jObdZ0WxQGbiuiWQ0eeF6IRFc6b/1hBSAoF9g2LI3R j6Q9/ZiUPVBtcgtG/LTyhdUtxP2pD1t0dGfGHa0W+AP9/sPoMNu+73LiNqS3mrRUJU0DuC OmOQqeAUOjv0F3GqdJl5/wwsOyoEXC0= Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b="Va2L0J/O"; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf09.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org X-Rspam-User: X-Rspamd-Server: rspam01 X-Stat-Signature: t7xpc59zff878eh5y335d1n1kh39691d X-Rspamd-Queue-Id: 5031E14008E X-HE-Tag: 1662701678-791043 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: 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.