Skip to contentSkip to conversation

ext4: Don't reduce symlink i_mode by umask if no ACL support

PATCH In review David Howells 4 participants 4 messages May 10, 2024 – May 17, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ext4: Don't reduce symlink i_mode by umask if no ACL support

If CONFIG_EXT4_FS_POSIX_ACL=n then the fallback version of ext4_init_acl() will mask off the umask bits from the new inode's i_mode. This should not be done if the inode is a symlink. If CONFIG_EXT4_FS_POSIX_ACL=y, then we go through posix_acl_create() instead which does the right thing with symlinks.

However, this is actually unnecessary now as vfs_prepare_mode() has already done this where appropriate, so fix this by making the fallback version of ext4_init_acl() do nothing.

Fixes 484fd6c1de13 ("ext4: apply umask if ACL support is disabled")
cc Max Kellermann <[email protected]>
cc Jan Kara <[email protected]>
cc Christian Brauner <[email protected]>
---
 fs/ext4/acl.h |    5 -----
 1 file changed, 5 deletions(-)
fs/ext4/acl.h +0 -5
index ef4c19e5f570..0c5a79c3b5d4 100644
@@ -68,11 +68,6 @@ extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
 static inline int
 ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
 {
-	/* usually, the umask is applied by posix_acl_create(), but if
-	   ext4 ACL support is disabled at compile time, we need to do
-	   it here, because posix_acl_create() will never be called */
-	inode->i_mode &= ~current_umask();
-
 	return 0;
 }
 #endif  /* CONFIG_EXT4_FS_POSIX_ACL */
reviewer Reviewed-by on v3 1/1
#1 lore raw
Quoted 11 lines · David Howells

If CONFIG_EXT4_FS_POSIX_ACL=n then the fallback version of ext4_init_acl() will mask off the umask bits from the new inode's i_mode. This should not be done if the inode is a symlink. If CONFIG_EXT4_FS_POSIX_ACL=y, then we go through posix_acl_create() instead which does the right thing with symlinks.

However, this is actually unnecessary now as vfs_prepare_mode() has already done this where appropriate, so fix this by making the fallback version of ext4_init_acl() do nothing.

Quoted 8 lines
Fixes 484fd6c1de13 ("ext4: apply umask if ACL support is disabled")
cc Max Kellermann <[email protected]>
cc Jan Kara <[email protected]>
cc Christian Brauner <[email protected]>

Looks good. Feel free to add:

Honza

Quoted 21 lines
---
 fs/ext4/acl.h |    5 -----
 1 file changed, 5 deletions(-)
fs/ext4/acl.h +0 -5
index ef4c19e5f570..0c5a79c3b5d4 100644
@@ -68,11 +68,6 @@ extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
 static inline int
 ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
 {
-	/* usually, the umask is applied by posix_acl_create(), but if
-	   ext4 ACL support is disabled at compile time, we need to do
-	   it here, because posix_acl_create() will never be called */
-	inode->i_mode &= ~current_umask();
-
 	return 0;
 }
 #endif  /* CONFIG_EXT4_FS_POSIX_ACL */
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Reviewed-by on v3 1/1
#2 lore raw
In reply to David Howells
Quoted 19 lines · David Howells

If CONFIG_EXT4_FS_POSIX_ACL=n then the fallback version of ext4_init_acl() will mask off the umask bits from the new inode's i_mode. This should not be done if the inode is a symlink. If CONFIG_EXT4_FS_POSIX_ACL=y, then we go through posix_acl_create() instead which does the right thing with symlinks.

However, this is actually unnecessary now as vfs_prepare_mode() has already done this where appropriate, so fix this by making the fallback version of ext4_init_acl() do nothing.

Fixes 484fd6c1de13 ("ext4: apply umask if ACL support is disabled")
cc Max Kellermann <[email protected]>
cc Jan Kara <[email protected]>
cc Christian Brauner <[email protected]>
Quoted 1 line

---

maintainer
#3 lore raw
In reply to David Howells
Quoted 10 lines · David Howells

If CONFIG_EXT4_FS_POSIX_ACL=n then the fallback version of ext4_init_acl() will mask off the umask bits from the new inode's i_mode. This should not be done if the inode is a symlink. If CONFIG_EXT4_FS_POSIX_ACL=y, then we go through posix_acl_create() instead which does the right thing with symlinks.

However, this is actually unnecessary now as vfs_prepare_mode() has already done this where appropriate, so fix this by making the fallback version of ext4_init_acl() do nothing.

Thanks for this patch; however, as I had mentioned in the discussion of the v1 version the patch, this change is already in the ext4 tree and linux-next in commit c77194965dd0 ('Revert "ext4: apply umask if ACL support is disabled"').

- Ted