Skip to content

Commit

Permalink
Linux: zpl_tmpfile: ensure ACL init succeeds before d_tmpfile
Browse files Browse the repository at this point in the history
Inode should be linked to dentry and hashed only after both
zpl_xattr_security_init and zpl_init_acl were successful, which
apparently isn't always true for example when memory is tight.

Signed-off-by: Pavel Snajdr <[email protected]>
  • Loading branch information
snajpa committed Oct 9, 2024
1 parent efeb60b commit fecd440
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions module/os/linux/zfs/zpl_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,19 +317,19 @@ zpl_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
/* d_tmpfile will do drop_nlink, so we should set it first */
set_nlink(ip, 1);
#ifndef HAVE_TMPFILE_DENTRY
d_tmpfile(file, ip);

error = zpl_xattr_security_init(ip, dir,
&file->f_path.dentry->d_name);
if (error == 0)
error = zpl_init_acl(ip, dir);
if (error == 0)
d_tmpfile(file, ip);
error = finish_open_simple(file, error);
#else
d_tmpfile(dentry, ip);

error = zpl_xattr_security_init(ip, dir, &dentry->d_name);
#endif
if (error == 0)
error = zpl_init_acl(ip, dir);
#ifndef HAVE_TMPFILE_DENTRY
error = finish_open_simple(file, error);
if (error == 0)
d_tmpfile(dentry, ip);
#endif
/*
* don't need to handle error here, file is already in
Expand Down

0 comments on commit fecd440

Please sign in to comment.