[PATCH 4/6] fuse: return correct dentry for ->mkdir
NeilBrown
neilb at suse.de
Sun Feb 23 18:26:18 PST 2025
On Sat, 22 Feb 2025, Al Viro wrote:
> On Fri, Feb 21, 2025 at 10:36:33AM +1100, NeilBrown wrote:
>
> > @@ -871,7 +870,12 @@ static int fuse_mknod(struct mnt_idmap *idmap, struct inode *dir,
> > args.in_args[0].value = &inarg;
> > args.in_args[1].size = entry->d_name.len + 1;
> > args.in_args[1].value = entry->d_name.name;
> > - return create_new_entry(idmap, fm, &args, dir, entry, mode);
> > + de = create_new_entry(idmap, fm, &args, dir, entry, mode);
> > + if (IS_ERR(de))
> > + return PTR_ERR(de);
> > + if (de)
> > + dput(de);
> > + return 0;
>
> Can that really happen?
Probably now. It would require S_IFDIR to be passed in the mode to
vfs_mknod(). I don't think any current callers do that, but I don't see
any code in vfs_mknod() to prevent it.
>
> > @@ -934,7 +939,12 @@ static int fuse_symlink(struct mnt_idmap *idmap, struct inode *dir,
> > args.in_args[1].value = entry->d_name.name;
> > args.in_args[2].size = len;
> > args.in_args[2].value = link;
> > - return create_new_entry(idmap, fm, &args, dir, entry, S_IFLNK);
> > + de = create_new_entry(idmap, fm, &args, dir, entry, S_IFLNK);
> > + if (IS_ERR(de))
> > + return PTR_ERR(de);
> > + if (de)
> > + dput(de);
> > + return 0;
>
> Same question.
That definitely cannot happen. - because we *know* that d_splice_alias()
never returns a dentry for any but an S_IFDIR inode (how might we
explain that to the rust type system I wonder :-).
I was going for "obviously correct" without try to optimise, but you are
correct that testing for a non-NULL non-ERR dentry should be optimsed
away as impossible in all cases except mkdir.
Thanks,
NeilBrown
>
> > + de = create_new_entry(&invalid_mnt_idmap, fm, &args, newdir, newent, inode->i_mode);
> > + if (!IS_ERR(de)) {
> > + if (de)
> > + dput(de);
> > + de = NULL;
>
> Whoa... Details, please. What's going on here?
>
More information about the linux-um
mailing list