Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp465133pxu; Tue, 5 Jan 2021 16:45:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6TSuzlUPQ4zk4sIq2aHKCE/h/qa53jXQWEQoGFrxum1NMOvrLk/OFDAQOZS9R7P9H3K+i X-Received: by 2002:aa7:d1c2:: with SMTP id g2mr2328656edp.8.1609893940345; Tue, 05 Jan 2021 16:45:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609893940; cv=none; d=google.com; s=arc-20160816; b=BtcFhTm4a7LNSyqjVjvzt8UtkbD7HH9IC0PGm4DK8Z2wHz8sD0A1Y55UduGp5h6b3v pUgw6xun24zSyXNPeEO7u47D7PSuA6IXh7rdOywBZ0XdhquQt2nG2oZ8rGdtqBs1tnz4 QZRGzFuBtIorbyiIrRxpjpGuii9nAHrHpkQzHKKXDLHC0hOocrc1yfVf850/ZxSjEhkB aoh4UwYzUko58gV4UpxLf4LOVCaHrNhfGyEnJwPm0ZbnVIBi2yoZHgdZ42g9novR12GT EJ3MamZsn4LstCgpWbSBM0AKN7qzdVFuaRC/Vz0j0EUfE+UmoheWrh6C1FwHf2pYP9+N Q73g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=sytGHUS6+oV6O1RDvD3PlV7+VzQHQhyEVXXVwPnCow0=; b=THFqNm/F0ik7dstmy2+L4GWym+od/8nbzxQaL2xX3fo/e9kb4u0OO4AYOCTdhe1n+k iD1vnLc1rDLdkOod3Et+vLYnB+Xj8LB841iLQFnZvY/kkGUdy4yMSdCsDrYX+p1STZLY 95L9IkvcVIIcEOfGp6fKyiwB1+vOrtYXZG0sl4fkRPtOAC45yb4qDXbrxX70u64/ixDs ISUh19ZAt/CkEuoSxT3CDwJM11sntEvb6tIX6pF1OlwJFvWzV6/Dkw4VvCWCDQKvTD8a aOvcn6hz2Fz7puDzeO3HthW/CfTXMr+CWpS36ibPN/hxvIbu/++xVvDB/EzwBcgRFlyP dDMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jZTKdkn6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s13si339190eds.57.2021.01.05.16.45.17; Tue, 05 Jan 2021 16:45:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jZTKdkn6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726917AbhAEWRQ (ORCPT + 99 others); Tue, 5 Jan 2021 17:17:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:41600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726306AbhAEWRP (ORCPT ); Tue, 5 Jan 2021 17:17:15 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A007322DFA; Tue, 5 Jan 2021 22:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609884994; bh=8nsD1cY7j4RI32huXupjNeC+ztbwkBuHR0P7SByRyVo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jZTKdkn6Trle1JstaGd6CGH7IkIqIRBp6RCiTFde/XdLuOXGDxgnlRh5mPAor2BkY WGAh3OCEuBZmfCL8tVEQ5CDHn9FvaVr8RIV2heEr5IUx1E22nAVgjt13x7y/FuQQnB zHxBF3mWb43JCbdKi020nstM1cEvbDgSJI6nKm39LB+lbrOyoif47Uuv5rQo8wrxh1 ZecGRB8xkzVFSWdQVPYTRJKE5axzttzKl6iwGdX9g0NNxSTnhAdWMiC+oizkNBqFNK cgSkuXoKppkCX9HjZfRyGgCGCWBdkm6wLSO/jyOTOqHmg721MY8rSVPJ9joxkckVgQ q2mu2238JzWGQ== Date: Tue, 5 Jan 2021 22:16:29 +0000 From: Will Deacon To: Nadav Amit Cc: Andrea Arcangeli , linux-mm , lkml , Yu Zhao , Andy Lutomirski , Peter Xu , Pavel Emelyanov , Mike Kravetz , Mike Rapoport , Minchan Kim , Peter Zijlstra Subject: Re: [RFC PATCH v2 2/2] fs/task_mmu: acquire mmap_lock for write on soft-dirty cleanup Message-ID: <20210105221628.GA12854@willie-the-truck> References: <20201225092529.3228466-1-namit@vmware.com> <20201225092529.3228466-3-namit@vmware.com> <15758743-B8E3-48C4-A13B-DFFEBF8AF435@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 05, 2021 at 09:22:51PM +0000, Nadav Amit wrote: > > On Jan 5, 2021, at 12:39 PM, Andrea Arcangeli wrote: > > > > On Tue, Jan 05, 2021 at 07:26:43PM +0000, Nadav Amit wrote: > >>> On Jan 5, 2021, at 10:20 AM, Andrea Arcangeli wrote: > >>> > >>> On Fri, Dec 25, 2020 at 01:25:29AM -0800, Nadav Amit wrote: > >>>> Fixes: 0f8975ec4db2 ("mm: soft-dirty bits for user memory changes tracking") > >>> > >>> Targeting a backport down to 2013 when nothing could wrong in practice > >>> with page_mapcount sounds backwards and unnecessarily risky. > >>> > >>> In theory it was already broken and in theory > >>> 09854ba94c6aad7886996bfbee2530b3d8a7f4f4 is absolutely perfect and the > >>> previous code of 2013 is completely wrong, but in practice the code > >>> from 2013 worked perfectly until Aug 21 2020. > >> > >> Well… If you consider the bug that Will recently fixed [1], then soft-dirty > >> was broken (for a different, yet related reason) since 0758cd830494 > >> ("asm-generic/tlb: avoid potential double flush”). > >> > >> This is not to say that I argue that the patch should be backported to 2013, > >> just to say that memory corruption bugs can be unnoticed. > >> > >> [1] https://patchwork.kernel.org/project/linux-mm/patch/20201210121110.10094-2-will@kernel.org/ > > > > Is this a fix or a cleanup? > > > > The above is precisely what I said earlier that tlb_gather had no > > reason to stay in clear_refs and it had to use inc_tlb_flush_pending > > as mprotect, but it's not a fix? Is it? I suggested it as a pure > > cleanup. So again no backport required. The commit says fix this but > > it means "clean this up". > > It is actually a fix. I think the commit log is not entirely correct and > should include: > > Fixes: 0758cd830494 ("asm-generic/tlb: avoid potential double flush”). > > Since 0758cd830494, calling tlb_finish_mmu() without any previous call to > pte_free_tlb() and friends does not flush the TLB. The soft-dirty bug > producer that I sent fails without this patch of Will. Yes, it's a fix, but I didn't rush it for 5.10 because I don't think rushing this sort of thing does anybody any favours. I agree that the commit log should be updated; I mentioned this report in the cover letter: https://lore.kernel.org/linux-mm/CA+32v5zzFYJQ7eHfJP-2OHeR+6p5PZsX=RDJNU6vGF3hLO+j-g@mail.gmail.com/ demonstrating that somebody has independently stumbled over the missing TLB invalidation in userspace, but it's not as bad as the other issues we've been discussing in this thread. Will