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=-5.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 156DAC433E0 for ; Tue, 5 Jan 2021 22:16:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 87EBA22E03 for ; Tue, 5 Jan 2021 22:16:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 87EBA22E03 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C6F346B0144; Tue, 5 Jan 2021 17:16:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BF73C6B0146; Tue, 5 Jan 2021 17:16:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A71FA8D006E; Tue, 5 Jan 2021 17:16:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0043.hostedemail.com [216.40.44.43]) by kanga.kvack.org (Postfix) with ESMTP id 8B4B76B0144 for ; Tue, 5 Jan 2021 17:16:36 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4FF8A1F06 for ; Tue, 5 Jan 2021 22:16:36 +0000 (UTC) X-FDA: 77673131592.08.blade83_4f05062274dc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 36D801819E766 for ; Tue, 5 Jan 2021 22:16:36 +0000 (UTC) X-HE-Tag: blade83_4f05062274dc X-Filterd-Recvd-Size: 4669 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 Jan 2021 22:16:35 +0000 (UTC) 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 In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Content-Transfer-Encoding: quoted-printable 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 Tue, Jan 05, 2021 at 09:22:51PM +0000, Nadav Amit wrote: > > On Jan 5, 2021, at 12:39 PM, Andrea Arcangeli w= rote: > >=20 > > On Tue, Jan 05, 2021 at 07:26:43PM +0000, Nadav Amit wrote: > >>> On Jan 5, 2021, at 10:20 AM, Andrea Arcangeli = wrote: > >>>=20 > >>> On Fri, Dec 25, 2020 at 01:25:29AM -0800, Nadav Amit wrote: > >>>> Fixes: 0f8975ec4db2 ("mm: soft-dirty bits for user memory changes = tracking") > >>>=20 > >>> Targeting a backport down to 2013 when nothing could wrong in pract= ice > >>> with page_mapcount sounds backwards and unnecessarily risky. > >>>=20 > >>> 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. > >>=20 > >> Well=E2=80=A6 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=E2=80=9D). > >>=20 > >> 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. > >>=20 > >> [1] https://patchwork.kernel.org/project/linux-mm/patch/202012101211= 10.10094-2-will@kernel.org/ > >=20 > > Is this a fix or a cleanup? > >=20 > > 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". >=20 > It is actually a fix. I think the commit log is not entirely correct an= d > should include: >=20 > Fixes: 0758cd830494 ("asm-generic/tlb: avoid potential double flush=E2= =80=9D). >=20 > 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 rush= ing 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=3DRDJN= U6vGF3hLO+j-g@mail.gmail.com/ demonstrating that somebody has independently stumbled over the missing T= LB invalidation in userspace, but it's not as bad as the other issues we've = been discussing in this thread. Will