From patchwork Mon Aug 6 20:57:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 175452 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id CD0852C0092 for ; Tue, 7 Aug 2012 06:59:43 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SyUOk-00070K-GL; Mon, 06 Aug 2012 20:59:34 +0000 Received: from mail.tpi.com ([70.99.223.143]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SyUOi-0006yo-5E for kernel-team@lists.ubuntu.com; Mon, 06 Aug 2012 20:59:32 +0000 Received: from [10.0.2.6] (host-174-45-43-11.hln-mt.client.bresnan.net [174.45.43.11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mail.tpi.com (Postfix) with ESMTP id 6499231FFDB; Mon, 6 Aug 2012 13:58:56 -0700 (PDT) Message-ID: <50202FA9.2070204@canonical.com> Date: Mon, 06 Aug 2012 14:57:13 -0600 From: Tim Gardner User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Tyler Hicks Subject: Re: Lucid backport for 069ddcda37b2cf5bb4b6031a944c0e9359213262 References: <50202E0A.9000805@canonical.com> In-Reply-To: <50202E0A.9000805@canonical.com> X-Enigmail-Version: 1.5a1pre Cc: kernel-team X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com On 08/06/2012 02:50 PM, Tim Gardner wrote: > Tyler - as far as I can tell the super block flags get initialized > outside of the ecryptfs code. Is this patch sufficient for 2.6.32.y ? > > rtg > Doh! see attached. From e573cb89603f26bfcdab92d510eb92a45d0d75b0 Mon Sep 17 00:00:00 2001 From: Tyler Hicks Date: Mon, 11 Jun 2012 15:42:32 -0700 Subject: [PATCH] eCryptfs: Copy up POSIX ACL and read-only flags from lower mount BugLink: http://bugs.launchpad.net/bugs/1009207 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 Reported-by: Stefan Beller Cc: John Johansen (back ported from commit 069ddcda37b2cf5bb4b6031a944c0e9359213262) Signed-off-by: Tim Gardner --- fs/ecryptfs/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index e2f18ad..783f7fc 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c @@ -589,6 +589,15 @@ static int ecryptfs_read_super(struct super_block *sb, const char *dev_name, } ecryptfs_set_superblock_lower(sb, path.dentry->d_sb); + + /** + * Set the POSIX ACL flag based on whether they're enabled in the lower + * mount. Force a read-only eCryptfs mount if the lower mount is ro. + * Allow a ro eCryptfs mount even when the lower mount is rw. + */ + sb->s_flags &= ~MS_POSIXACL; + sb->s_flags |= path.dentry->d_sb->s_flags & (MS_RDONLY | MS_POSIXACL); + sb->s_maxbytes = path.dentry->d_sb->s_maxbytes; sb->s_blocksize = path.dentry->d_sb->s_blocksize; ecryptfs_set_dentry_lower(sb->s_root, path.dentry); -- 1.7.9.5