Re: [PATCH] configfs: fix a race in configfs_lookup()
From: Christoph Hellwig
Date: Wed Aug 25 2021 - 01:29:06 EST
On Wed, Aug 25, 2021 at 05:19:04AM +0000, Al Viro wrote:
> On Mon, Aug 23, 2021 at 07:08:47PM +0200, Christoph Hellwig wrote:
>
> > We can't hold a spinlock over inode allocation. So it would have to be
> > something like this:
>
> Check for -ENAMETOOLONG first; easier for analysis that way.
Indeed.
> > + dentry->d_fsdata = configfs_get(sd);
> > + sd->s_dentry = dentry;
> > + spin_unlock(&configfs_dirent_lock);
> >
> > - found = 1;
> > - err = configfs_attach_attr(sd, dentry);
> > - break;
> > + inode = configfs_create(dentry, mode);
> > + if (IS_ERR(inode)) {
> > + configfs_put(sd);
> > + return ERR_CAST(inode);
>
> Er... Won't that leave dentry with dangling ->d_fsdata?
Yes. Existing problem, though.