From ac0998a456493e30e497fb6f94102b6d34554a0f Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 15 Jul 2011 14:49:21 +0200 Subject: UBUNTU: ubuntu: overlayfs -- ovl: make lower mount read-only If a file only existing on the lower fs is operned for O_RDONLY and fchmod/fchown/etc is performed on the open file then this will modify the lower fs, which is not what we want. Copying up at this point is not possible. The best solution is to return an error for this corner case and hope applications are not relying on it. Reported-by: "J. R. Okajima" Signed-off-by: Miklos Szeredi Signed-off-by: Andy Whitcroft --- fs/overlayfs/super.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'fs') diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index a64f0f4820e..508cf19a217 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -569,6 +569,12 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) goto out_put_upper_mnt; } + /* + * Make lower_mnt R/O. That way fchmod/fchown on lower file + * will fail instead of modifying lower fs. + */ + ufs->lower_mnt->mnt_flags |= MNT_READONLY; + /* If the upper fs is r/o, we mark overlayfs r/o too */ if (ufs->upper_mnt->mnt_sb->s_flags & MS_RDONLY) sb->s_flags |= MS_RDONLY; -- cgit v1.2.3