linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] hfsplus: preserve i_mode if __hfsplus_set_posix_acl() fails
@ 2017-07-27  3:10 Ernesto A. Fernández
  2017-07-27  3:13 ` [PATCH 2/2] hfsplus: add mount option to enable ACL support Ernesto A. Fernández
  2017-07-27  9:18 ` [PATCH 1/2] hfsplus: preserve i_mode if __hfsplus_set_posix_acl() fails Jan Kara
  0 siblings, 2 replies; 12+ messages in thread
From: Ernesto A. Fernández @ 2017-07-27  3:10 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Jan Kara, Andreas Gruenbacher, Alexander Viro,
	Ernesto A. Fernández

When changing a file's acl mask, hfsplus_set_posix_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.

Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
---
The same issue affects several filesystems; some of them have already
applied patches, see for example:

  fe26569 ext2: preserve i_mode if ext2_set_acl() fails

In order to test this I had to add a mount option to enable acls. That
patch is sent next.

 fs/hfsplus/posix_acl.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/hfsplus/posix_acl.c b/fs/hfsplus/posix_acl.c
index 6bb5d7c..24a1cdf 100644
--- a/fs/hfsplus/posix_acl.c
+++ b/fs/hfsplus/posix_acl.c
@@ -102,13 +102,19 @@ static int __hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
 int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
 	int err;
+	int update_mode = 0;
+	umode_t mode = inode->i_mode;
 
 	if (type == ACL_TYPE_ACCESS && acl) {
-		err = posix_acl_update_mode(inode, &inode->i_mode, &acl);
+		err = posix_acl_update_mode(inode, &mode, &acl);
 		if (err)
 			return err;
+		update_mode = 1;
 	}
-	return __hfsplus_set_posix_acl(inode, acl, type);
+	err = __hfsplus_set_posix_acl(inode, acl, type);
+	if (!err && update_mode)
+		inode->i_mode = mode;
+	return err;
 }
 
 int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir)
-- 
2.1.4

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

end of thread, other threads:[~2017-10-17 15:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-27  3:10 [PATCH 1/2] hfsplus: preserve i_mode if __hfsplus_set_posix_acl() fails Ernesto A. Fernández
2017-07-27  3:13 ` [PATCH 2/2] hfsplus: add mount option to enable ACL support Ernesto A. Fernández
2017-07-27  9:41   ` Jan Kara
2017-07-27  9:50     ` Christoph Hellwig
2017-10-14  2:43       ` Ernesto A. Fernández
2017-10-16  7:42         ` Christoph Hellwig
2017-10-16 15:50           ` Viacheslav Dubeyko
2017-10-17  7:53             ` Jan Kara
2017-10-17  8:03               ` Christoph Hellwig
2017-10-17 15:20                 ` Viacheslav Dubeyko
2017-07-27 21:29     ` Ernesto A. Fernández
2017-07-27  9:18 ` [PATCH 1/2] hfsplus: preserve i_mode if __hfsplus_set_posix_acl() fails Jan Kara

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).