linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: fix to set inode->i_mode correctly for posix_acl_update_mode
@ 2020-12-14  3:54 Weichao Guo
  2020-12-16  9:16 ` Chao Yu
  2020-12-22  8:24 ` Chao Yu
  0 siblings, 2 replies; 12+ messages in thread
From: Weichao Guo @ 2020-12-14  3:54 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: Bin Shu, fh, linux-f2fs-devel

We should update the ~S_IRWXUGO part of inode->i_mode in __setattr_copy,
because posix_acl_update_mode updates mode based on inode->i_mode,
which finally overwrites the ~S_IRWXUGO part of i_acl_mode with old i_mode.

Testcase to reproduce this bug:
0. adduser abc
1. mkfs.f2fs /dev/sdd
2. mount -t f2fs /dev/sdd /mnt/f2fs
3. mkdir /mnt/f2fs/test
4. setfacl -m u:abc:r /mnt/f2fs/test
5. chmod +s /mnt/f2fs/test

Signed-off-by: Weichao Guo <guoweichao@oppo.com>
Signed-off-by: Bin Shu <shubin@oppo.com>
---
 fs/f2fs/file.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 16ea10f..4d355f9 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -850,6 +850,7 @@ static void __setattr_copy(struct inode *inode, const struct iattr *attr)
 
 		if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
 			mode &= ~S_ISGID;
+		inode->i_mode = (inode->i_mode & S_IRWXUGO) | (mode & ~S_IRWXUGO);
 		set_acl_inode(inode, mode);
 	}
 }
-- 
2.7.4



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-12-23  8:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-14  3:54 [f2fs-dev] [PATCH] f2fs: fix to set inode->i_mode correctly for posix_acl_update_mode Weichao Guo
2020-12-16  9:16 ` Chao Yu
2020-12-16  9:21   ` Chao Yu
2020-12-17  6:24     ` Jaegeuk Kim
2020-12-22  8:24 ` Chao Yu
2020-12-22  9:32   ` Weichao Guo
2020-12-22 10:49     ` Chao Yu
2020-12-22 12:14       ` Weichao Guo
2020-12-23  1:14         ` Chao Yu
2020-12-23  4:38           ` Weichao Guo
2020-12-23  4:42             ` Weichao Guo
2020-12-23  8:48             ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).