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=-7.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 3A445C433E2 for ; Tue, 1 Sep 2020 00:26:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D73902073A for ; Tue, 1 Sep 2020 00:26:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="VzVNnOpB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D73902073A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5FB696B0003; Mon, 31 Aug 2020 20:26:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5ABB16B0037; Mon, 31 Aug 2020 20:26:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44C6B6B0055; Mon, 31 Aug 2020 20:26:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0088.hostedemail.com [216.40.44.88]) by kanga.kvack.org (Postfix) with ESMTP id 2B4DF6B0003 for ; Mon, 31 Aug 2020 20:26:37 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id DD9E73638 for ; Tue, 1 Sep 2020 00:26:36 +0000 (UTC) X-FDA: 77212601592.25.oil73_5509f0d27093 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id A2D021804E3A1 for ; Tue, 1 Sep 2020 00:26:36 +0000 (UTC) X-HE-Tag: oil73_5509f0d27093 X-Filterd-Recvd-Size: 4237 Received: from mail-qv1-f65.google.com (mail-qv1-f65.google.com [209.85.219.65]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Tue, 1 Sep 2020 00:26:36 +0000 (UTC) Received: by mail-qv1-f65.google.com with SMTP id m14so2036039qvt.1 for ; Mon, 31 Aug 2020 17:26:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=25EP6lDyA/VCn85jeEaspBr9VnHNH+CoU2Es2Lg6BDE=; b=VzVNnOpB/iZRtjs0/1dL+nyroS8pJ/JR/teYVPRC7ehg6J0uj6p4zAJr6eqtSZ2zcS rmxMytC4VbsLpe5JIp8JF1WcWZZLy3GlDY23qNPj+/ABik90fsRKa+S4ki9e8FJ+CvoR A8xblUuWz+yRHu4JwqhUE2Jzdun6FWJ0Ytx+/0mAeJ82Y47xkJ8nvg184gjVdiyrxAaG inDzKjNxRp63B1/Nooabo6cFApB3xKxZYphB4eN1imAT6tQO1SDWWLNoFEJBZhszfD6c TAQeF0yEsXqa9+LFUvUvXi6GNT7UNIUO7yWizAYb4Bk2vSaH40Cb9pvN+ZD6T4uhR0yt buKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=25EP6lDyA/VCn85jeEaspBr9VnHNH+CoU2Es2Lg6BDE=; b=P/Io059nJO3ttXPniU5Ms5wbArjQQyLgEeUpFmvIkfNnLVJEX2IWgTwLUyHehl2vK5 VUFEnx2GYkSMTl/M5nEaA7JVn3RL9bxNoyVVI+oWKtERGbox1uNr6aaj4lVtfXigeRDG IeB3OCFAJMSJ9c3d5qSVlmBWqZLvXPP2H3abRecL63Rbbuik6PUThFHq+svlXX5tgLqA fsKFNQGA7svvUdl8K3FlvOPzvzSNZguEQiLmlPcwW/L21o16L+B1yh1vhdhlATXn6ArL sDI4V4MlvlbnFjQwejL68XzahSVz9dlSSuBa4jz2wxUcIVgviz8+R0o/GgBNb1tJPWWm CkYg== X-Gm-Message-State: AOAM531X//9JKoQ3pWCTdVYuAR4uVr3MACdIEmdkq810289NBkKqtM4n vyx/d/rgjkjWqy6ZC5/vEfrgRg== X-Google-Smtp-Source: ABdhPJzJhMCsv9DIr2p50bKrzX+/ZhDja6UADS9AoiMBVU3C3F/pJwgZhRS+rIVYPK+5D15jnq+I8A== X-Received: by 2002:a05:6214:5c8:: with SMTP id t8mr3683557qvz.86.1598919995600; Mon, 31 Aug 2020 17:26:35 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id d15sm10918024qka.91.2020.08.31.17.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 17:26:35 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kCu8A-003WwX-Ad; Mon, 31 Aug 2020 21:26:34 -0300 Date: Mon, 31 Aug 2020 21:26:34 -0300 From: Jason Gunthorpe To: Jann Horn Cc: Andrew Morton , linux-mm@kvack.org, John Hubbard , Christoph Hellwig , linux-kernel@vger.kernel.org, Christian =?utf-8?B?S8O2bmln?= Subject: Re: [PATCH] mm/mmu_notifier: Fix mmget() assert in __mmu_interval_notifier_insert Message-ID: <20200901002634.GD24045@ziepe.ca> References: <20200901000143.207585-1-jannh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200901000143.207585-1-jannh@google.com> X-Rspamd-Queue-Id: A2D021804E3A1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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, Sep 01, 2020 at 02:01:43AM +0200, Jann Horn wrote: > The comment talks about having to hold mmget() (which means mm_users), but > the actual check is on mm_count (which would be mmgrab()). > > Given that MMU notifiers are torn down in > mmput() -> __mmput() -> exit_mmap() -> mmu_notifier_release(), > I believe that the comment is correct and the check should be on > mm->mm_users. Fix it up accordingly. > > Fixes: 99cb252f5e68 ("mm/mmu_notifier: add an interval tree notifier") > Signed-off-by: Jann Horn > --- > Can someone please double-check this? I'm like 90% sure that I fixed > this the right way around, but it'd be good if someone more familiar > with mmu notifiers could confirm. Hmm.. I added the comment but copied the expression from older code. The intent is certainly that the caller must have a mmget, this function must not race with __mmu_notifier_release() and the mmget is what prevents that. Reviewed-by: Jason Gunthorpe Jason