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
Other than openzfs#16612, this is the only place I see where trouble
similar to openzfs#16608 could arise.

I'm not sure all the supported kernel versions will be okay with
these modifications, I'm posting this as a draft to let the bots
chew on it to find out.

Signed-off-by: Pavel Snajdr <snajpa@snajpa.net>
  • Loading branch information
snajpa committed Oct 8, 2024
1 parent c8a5162 commit 3678270
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions module/os/linux/zfs/zpl_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,17 +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);
#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);
if (error == 0)
d_tmpfile(dentry, ip);
#endif
#ifndef HAVE_TMPFILE_DENTRY
error = finish_open_simple(file, error);
#endif
Expand Down

0 comments on commit 3678270

Please sign in to comment.