Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp263686rwb; Thu, 27 Jul 2023 12:20:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlEw+p+BdF7qD4c0vQS8bnTohhEmxCfugFTI39Yn6qWiBgjPFKpbisi/6hcmAPoVxSLkmAnm X-Received: by 2002:aa7:d656:0:b0:51e:24e1:c0e9 with SMTP id v22-20020aa7d656000000b0051e24e1c0e9mr2596735edr.10.1690485618563; Thu, 27 Jul 2023 12:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690485618; cv=none; d=google.com; s=arc-20160816; b=lJPDqKhCMxrcskneylGhzCcofCioW2pnNnM2CD41J3EYbmhma/IwB6PcyYbAHA3QRR aUkF0/urYoQvWCaP0YXFa6hs8OVCNzkM+foDqrsG6vRRUt63F10pKpnw2oKBvxoUJFhx gUD3uSWdJvdfpSSb2tfOeh3b796jW9kbSsqVqWYgeqS7Ge82faUTNF5SCQDH80s3oLv6 3kSpYLxFtX42CxiDy7hzrsInJM/rIp6/P1EDOpnqebFM9G2zTHYjlSJCVwYVwr0j/Kge v84ch2oncp88e1AsfkckDvOtNqDbv2vV7X7uhp/Ja32Cy3ZghdNxzKLCDWW7T203VvMu i3iA== 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=v+2d2fz9rEME7Y0Xsx/fiwIu2EBkpqU7AjglSy6mvgw=; fh=0QldH+j8X9SYRPEZwIgKhS2t6t9gbuTLe2tW64jI9Q4=; b=hZ8Gz6WxqlVC6faA7N7K6lsLkJoK42n2UNG3X87znjBhUU8gpH73YukA2JP/2ydaq4 b3zMM38x7kTZG56v56AhheMzv842S5xqk/a15ibmHi/L4CYmQZRscAnNIScNIW06VEqa SOgl+oELcCFhlqSrIeyUQs95BvkZVJFIe8XzDW6J4YztSqMMxmKEguwdewmuC0RPYR6I lKZ6J1OqQ9jYIddgcGZVWp0XmRzyuV+6xRqvz06xb65SBRK5suTksmD9fj260D4Ves4R vGl2o9rkJFcZbEAmS6v/w8M1Hc2JfQzfswRWEh81zpjw0kLAlpouAZe4TJzbM4CnrAxl 6gpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="h1plePO/"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m16-20020aa7c490000000b005223b94c705si1249994edq.536.2023.07.27.12.19.52; Thu, 27 Jul 2023 12:20:18 -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=@infradead.org header.s=casper.20170209 header.b="h1plePO/"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231308AbjG0SrL (ORCPT + 99 others); Thu, 27 Jul 2023 14:47:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230468AbjG0SrJ (ORCPT ); Thu, 27 Jul 2023 14:47:09 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FA93358D for ; Thu, 27 Jul 2023 11:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=v+2d2fz9rEME7Y0Xsx/fiwIu2EBkpqU7AjglSy6mvgw=; b=h1plePO/YXRkcTPAxTeQ9SuQ8p 5Ta7Znt8oEbDNYWorNcsi7Hhf4raQKG7hIo34yo7OfsM3+cnIF/A3djQ5LrFfE4lUpeIqXMWGYM7D P+eLz1Bo/zMZdRqZ30SavW5bxsJv9M1pvl7c2Ch/h5lamhNjQqeQTxSttmh7LrIGGmoWHjx3SOFBi 8rCk3YBDL1syjT5Ld5cL3aU9wA8O1Q/9kv7ZpxH2O5H5Mm5pIga82icpoXuB0+P/8lYhXi2am22J1 h8hycSzAwE8Ichk8xq4a5e44ObjKBYEKvfC0O4cON6OMNfws6+qIZioBQ4bJXsGIApvw0WJ9O2GXy g9LOXXVA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qP60V-007m3X-CS; Thu, 27 Jul 2023 18:46:39 +0000 Date: Thu, 27 Jul 2023 19:46:39 +0100 From: Matthew Wilcox To: Suren Baghdasaryan Cc: Jann Horn , "Liam R. Howlett" , akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com, syzbot Subject: Re: [syzbot] [mm?] WARNING: suspicious RCU usage in mas_walk (2) Message-ID: References: <000000000000607ff905ffc8e477@google.com> <0000000000000aeb7f06015e5cbd@google.com> <20230727164757.e2di75xjybxncohn@revolver> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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, Jul 27, 2023 at 11:31:01AM -0700, Suren Baghdasaryan wrote: > A comment for __anon_vma_prepare() says "This must be called with the > mmap_lock held for reading." > I think adding an explicit mmap_assert_locked() in this function would > help catch such issues. Would it catch them faster than syzbot? > > +++ b/mm/memory.c > > @@ -3197,6 +3197,12 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) > > struct mmu_notifier_range range; > > int ret; > > > > + if (!vma->anon_vma) { > > + // check if there are other things to undo here > > + vma_end_read(vmf->vma); > > + return VM_FAULT_RETRY; > > + } > > + > > This one bails out later but if the path is not taken too often I > think it's cleaner. OK, then I think the right place to put this check is slightly before this function is called, to avoid bouncing the folio refcount: +++ b/mm/memory.c @@ -3567,6 +3567,12 @@ static vm_fault_t do_wp_page(struct vm_fault *vmf) return 0; } copy: + if ((vmf->flags & FAULT_FLAG_VMA_LOCK) && !vma->anon_vma) { + pte_unmap_unlock(vmf->pte, vmf->ptl); + vma_end_read(vmf->vma); + return VM_FAULT_RETRY; + } + /* * Ok, we need to copy. Oh, well.. */ ... it compiles. Guess I should figure out the syntax to ask syzbot to test it.