From: Yang Xu Date: Thu, 14 Jul 2022 06:11:26 +0000 (+0800) Subject: fs: Add missing umask strip in vfs_tmpfile X-Git-Tag: v5.15.73~1763 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd28cf0f69b4a81e19b542d88ad89141700b025d;p=platform%2Fkernel%2Flinux-rpi.git fs: Add missing umask strip in vfs_tmpfile commit ac6800e279a22b28f4fc21439843025a0d5bf03e upstream. All creation paths except for O_TMPFILE handle umask in the vfs directly if the filesystem doesn't support or enable POSIX ACLs. If the filesystem does then umask handling is deferred until posix_acl_create(). Because, O_TMPFILE misses umask handling in the vfs it will not honor umask settings. Fix this by adding the missing umask handling. Link: https://lore.kernel.org/r/1657779088-2242-2-git-send-email-xuyang2018.jy@fujitsu.com Fixes: 60545d0d4610 ("[O_TMPFILE] it's still short a few helpers, but infrastructure should be OK now...") Cc: # 4.19+ Reported-by: Christian Brauner (Microsoft) Reviewed-by: Darrick J. Wong Reviewed-and-Tested-by: Jeff Layton Acked-by: Christian Brauner (Microsoft) Signed-off-by: Yang Xu Signed-off-by: Christian Brauner (Microsoft) Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/namei.c b/fs/namei.c index 2ea15d0..66e0fe2 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3523,6 +3523,8 @@ struct dentry *vfs_tmpfile(struct user_namespace *mnt_userns, child = d_alloc(dentry, &slash_name); if (unlikely(!child)) goto out_err; + if (!IS_POSIXACL(dir)) + mode &= ~current_umask(); error = dir->i_op->tmpfile(mnt_userns, dir, child, mode); if (error) goto out_err;