f2fs: preserve i_mode if __f2fs_set_acl() fails
PATCH 1/1 f2fs: preserve i_mode if __f2fs_set_acl() fails
When changing a file's acl mask, __f2fs_set_acl() will first set the group bits of i_mode to the value of the mask, and only then set the actual extended attribute representing the new acl.
If the second part fails (due to lack of space, for example) and the file had no acl attribute to begin with, the system will from now on assume that the mask permission bits are actual group permission bits, potentially granting access to the wrong users.
Prevent this by only changing the inode mode after the acl has been set.
---
This bug is covered by generic/449 in xfstests, though that test may not run for f2fs unless you change the size in the call to _scratch_mkfs_sized.
Several filesystems are affected; some of them have already applied patches, see for example: "fe26569 ext2: preserve i_mode if ext2_set_acl() fails".
fs/f2fs/acl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/acl.c +3 -2
@@ -207,15 +207,16 @@ static int __f2fs_set_acl(struct inode *inode, int type,void *value =NULL ;size_t size =0 ;int error; +umode_t mode = inode->i_mode;switch (type) {case ACL_TYPE_ACCESS : name_index =F2FS_XATTR_INDEX_POSIX_ACL_ACCESS ;if (acl && !ipage) { - error =posix_acl_update_mode (inode, &inode->i_mode, &acl); + error =posix_acl_update_mode (inode, &mode, &acl);if (error)return error; -set_acl_inode (inode, inode->i_mode); +set_acl_inode (inode, mode); }break ;
Signature · 10 lines
2.1.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 4 lines · Ernesto A. Fernández
When changing a file's acl mask,
__f2fs_set_acl()will first set the group bits ofi_modeto the value of the mask, and only then set the actual extended attribute representing the new acl.
Quoted 8 lines
If the second part fails (due to lack of space, for example) and the file had no acl attribute to begin with, the system will from now on assume that the mask permission bits are actual group permission bits, potentially granting access to the wrong users.
Prevent this by only changing the inode mode after the acl has been set.
Signed-off-by Ernesto A. Fernández <[email protected]>
Thanks,
Quoted 24 lines
---
This bug is covered by generic/449 in xfstests, though that test may not run for f2fs unless you change the size in the call to_scratch_mkfs_sized.Several filesystems are affected; some of them have already applied patches, see for example: "fe26569 ext2: preserve
i_modeifext2_set_acl()fails".fs/f2fs/acl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)fs/f2fs/acl.c +1
-0@@ -207,15 +207,16 @@ static int __f2fs_set_acl(struct inode *inode, int type,void *value =NULL ;size_t size =0 ;int error; +umode_t mode = inode->i_mode;switch (type) {case ACL_TYPE_ACCESS : name_index =F2FS_XATTR_INDEX_POSIX_ACL_ACCESS ;
fs/f2fs/acl.c static int __f2fs_set_acl(struct inode *inode, int type, · line 222
Quoted 10 lines
fs/f2fs/acl.c +2
-2if (acl && !ipage) { - error =posix_acl_update_mode (inode, &inode->i_mode, &acl); + error =posix_acl_update_mode (inode, &mode, &acl);if (error)return error; -set_acl_inode (inode, inode->i_mode); +set_acl_inode (inode, mode); }break ;
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel