Re: [PATCH v5 05/10] vfs: lookup_open(): use vfs_create_no_perm()
From: Christian Brauner
Date: Mon Aug 31 2026 - 05:23:45 EST
On Sun, Aug 23, 2026 at 06:07:01PM +0200, Jori Koolstra wrote:
> We can replace the code in the no create_error/negative dentry found
> from lookup case in lookup_open() with the vfs_create_no_perm() helper.
>
> Reviewed-by: NeilBrown <neil@xxxxxxxxxx>
> Signed-off-by: Jori Koolstra <jkoolstra@xxxxxxxxx>
> ---
> fs/namei.c | 20 +++++++-------------
> 1 file changed, 7 insertions(+), 13 deletions(-)
>
> diff --git a/fs/namei.c b/fs/namei.c
> index 55ba23f95c5b..3afae6e87825 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -4430,8 +4430,14 @@ static struct dentry *atomic_open(const struct path *path, struct dentry *dentry
> }
> dput(dentry);
> dentry = ERR_PTR(error);
> + } else {
> + if (file->f_mode & FMODE_CREATED)
> + fsnotify_create(dir_inode, dentry);
> + if (file->f_mode & FMODE_OPENED)
> + fsnotify_open(file);
Note that this causes duplicate IN_CREATE/IN_OPEN as both atomic_open()
and dentry_create() now notify.
> }
>
> +
> return dentry;
> }
>
> @@ -4581,22 +4587,10 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
> goto out_dput;
> }
>
> - error = try_break_deleg(dir_inode, LEASE_BREAK_DIR_CREATE, &delegated_inode);
> - if (error)
> - goto out_dput;
> -
> - error = dir_inode->i_op->create(idmap, dir_inode, dentry, mode);
> - if (error)
> - goto out_dput;
> + error = vfs_create_no_perm(idmap, dentry, mode, &delegated_inode);
Afaict, this has a latent bug until later in the series. Right now
failing ->create/try_break_deleg() sets FMODE_CREATED on a negative
dentry. That causes a splat in any sticky directory. And some nastiness
with failing to break a delegation as well.
>
> file->f_mode |= FMODE_CREATED;
> out:
> - if (!IS_ERR(dentry)) {
> - if (file->f_mode & FMODE_CREATED)
> - fsnotify_create(dir_inode, dentry);
> - if (file->f_mode & FMODE_OPENED)
> - fsnotify_open(file);
> - }
> if ((open_flag & O_CREAT) || create_error)
> inode_unlock(dir_inode);
> else
> --
> 2.55.0
>
--