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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 759A6C433ED for ; Mon, 5 Apr 2021 18:29:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3797D613B8 for ; Mon, 5 Apr 2021 18:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235297AbhDES3O (ORCPT ); Mon, 5 Apr 2021 14:29:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235155AbhDES3K (ORCPT ); Mon, 5 Apr 2021 14:29:10 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91107C061756; Mon, 5 Apr 2021 11:29:03 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lTTy2-002o1H-4D; Mon, 05 Apr 2021 18:28:54 +0000 Date: Mon, 5 Apr 2021 18:28:54 +0000 From: Al Viro To: Christian Brauner Cc: Jens Axboe , syzbot , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, io-uring@vger.kernel.org Subject: Re: [syzbot] WARNING in mntput_no_expire (2) Message-ID: References: <20210404164040.vtxdcfzgliuzghwk@wittgenstein> <20210404170513.mfl5liccdaxjnpls@wittgenstein> <20210405114437.hjcojekyp5zt6huu@wittgenstein> <20210405170801.zrdhnon6g4ggb6c7@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org On Mon, Apr 05, 2021 at 06:23:49PM +0000, Al Viro wrote: > On Mon, Apr 05, 2021 at 07:08:01PM +0200, Christian Brauner wrote: > > > Ah dentry count of -127 looks... odd. > > dead + 1... > > void lockref_mark_dead(struct lockref *lockref) > { > assert_spin_locked(&lockref->lock); > lockref->count = -128; > } > > IOW, a leaked (uncounted) reference to dentry, that got dget() called on > it after dentry had been freed. > > IOW, current->fs->pwd.dentry happens to point to an already freed > struct dentry here. Joy... > > Could you slap > > spin_lock(¤t->fs->lock); > WARN_ON(d_count(current->fs->pwd.dentry) < 0); > spin_unlock(¤t->fs->lock); > > before and after calls of io_issue_sqe() and see if it triggers? We definitely > are seeing buggered dentry refcounting here. Check if this helps, please. diff --git a/fs/namei.c b/fs/namei.c index 216f16e74351..82344f1139ff 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2289,6 +2289,9 @@ static const char *path_init(struct nameidata *nd, unsigned flags) int error; const char *s = nd->name->name; + nd->path.mnt = NULL; + nd->path.dentry = NULL; + /* LOOKUP_CACHED requires RCU, ask caller to retry */ if ((flags & (LOOKUP_RCU | LOOKUP_CACHED)) == LOOKUP_CACHED) return ERR_PTR(-EAGAIN); @@ -2322,8 +2325,6 @@ static const char *path_init(struct nameidata *nd, unsigned flags) } nd->root.mnt = NULL; - nd->path.mnt = NULL; - nd->path.dentry = NULL; /* Absolute pathname -- fetch the root (LOOKUP_IN_ROOT uses nd->dfd). */ if (*s == '/' && !(flags & LOOKUP_IN_ROOT)) {