From d423f352a1a105b977ceae346cd2726d74780516 Mon Sep 17 00:00:00 2001 From: Pavel Snajdr Date: Tue, 8 Oct 2024 18:48:35 +0200 Subject: [PATCH] Linux: zpl_tmpfile: ensure ACL init succeeds before d_tmpfile Other than #16612, this is the only place I see where trouble similar to #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 --- module/os/linux/zfs/zpl_inode.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index c4b5087ca5e7..dfe2c82215a5 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -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