aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTyler Hicks <tyhicks@canonical.com>2012-06-11 18:42:32 -0400
committerTyler Hicks <tyhicks@canonical.com>2012-07-08 13:51:43 -0400
commit069ddcda37b2cf5bb4b6031a944c0e9359213262 (patch)
treec47a199c2a84947a3f98370008c001c85e05b2e6 /fs
parentbd0a521e88aa7a06ae7aabaed7ae196ed4ad867a (diff)
eCryptfs: Copy up POSIX ACL and read-only flags from lower mount
When the eCryptfs mount options do not include '-o acl', but the lower filesystem's mount options do include 'acl', the MS_POSIXACL flag is not flipped on in the eCryptfs super block flags. This flag is what the VFS checks in do_last() when deciding if the current umask should be applied to a newly created inode's mode or not. When a default POSIX ACL mask is set on a directory, the current umask is incorrectly applied to new inodes created in the directory. This patch ignores the MS_POSIXACL flag passed into ecryptfs_mount() and sets the flag on the eCryptfs super block depending on the flag's presence on the lower super block. Additionally, it is incorrect to allow a writeable eCryptfs mount on top of a read-only lower mount. This missing check did not allow writes to the read-only lower mount because permissions checks are still performed on the lower filesystem's objects but it is best to simply not allow a rw mount on top of ro mount. However, a ro eCryptfs mount on top of a rw mount is valid and still allowed. https://launchpad.net/bugs/1009207 Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Reported-by: Stefan Beller <stefanbeller@googlemail.com> Cc: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ecryptfs/main.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 68954937a071..df217dc9f1d9 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -505,7 +505,6 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
505 goto out; 505 goto out;
506 } 506 }
507 507
508 s->s_flags = flags;
509 rc = bdi_setup_and_register(&sbi->bdi, "ecryptfs", BDI_CAP_MAP_COPY); 508 rc = bdi_setup_and_register(&sbi->bdi, "ecryptfs", BDI_CAP_MAP_COPY);
510 if (rc) 509 if (rc)
511 goto out1; 510 goto out1;
@@ -541,6 +540,15 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
541 } 540 }
542 541
543 ecryptfs_set_superblock_lower(s, path.dentry->d_sb); 542 ecryptfs_set_superblock_lower(s, path.dentry->d_sb);
543
544 /**
545 * Set the POSIX ACL flag based on whether they're enabled in the lower
546 * mount. Force a read-only eCryptfs mount if the lower mount is ro.
547 * Allow a ro eCryptfs mount even when the lower mount is rw.
548 */
549 s->s_flags = flags & ~MS_POSIXACL;
550 s->s_flags |= path.dentry->d_sb->s_flags & (MS_RDONLY | MS_POSIXACL);
551
544 s->s_maxbytes = path.dentry->d_sb->s_maxbytes; 552 s->s_maxbytes = path.dentry->d_sb->s_maxbytes;
545 s->s_blocksize = path.dentry->d_sb->s_blocksize; 553 s->s_blocksize = path.dentry->d_sb->s_blocksize;
546 s->s_magic = ECRYPTFS_SUPER_MAGIC; 554 s->s_magic = ECRYPTFS_SUPER_MAGIC;