[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210405200737.qurhkqitoxweousx@wittgenstein>
Date: Mon, 5 Apr 2021 22:07:37 +0200
From: Christian Brauner <christian.brauner@...ntu.com>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: Jens Axboe <axboe@...nel.dk>,
syzbot <syzbot+c88a7030da47945a3cc3@...kaller.appspotmail.com>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
syzkaller-bugs@...glegroups.com, io-uring@...r.kernel.org
Subject: Re: [syzbot] WARNING in mntput_no_expire (2)
On Mon, Apr 05, 2021 at 06:28:54PM +0000, Al Viro wrote:
> 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)) {
Bingo. That fixes it.
Powered by blists - more mailing lists