From patchwork Wed Apr 14 12:37:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 12202737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26624C43460 for ; Wed, 14 Apr 2021 12:39:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07F36613B3 for ; Wed, 14 Apr 2021 12:39:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351027AbhDNMj1 (ORCPT ); Wed, 14 Apr 2021 08:39:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:34008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347336AbhDNMjV (ORCPT ); Wed, 14 Apr 2021 08:39:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 05A6961242; Wed, 14 Apr 2021 12:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618403939; bh=trjYxEgalZgxYJrHZB3dPQb397DtdefL3Lsm4LvCJWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j5cA7MvJ8u/PxHz/mTf+LlXfEt3LqMQBsmvb29ek09df6dQDeGtD3iUnc3ADbsBJc ryketa8FV75N3FodGyTBY0KSmGrhMSXM2aYceXyVZ1RvA1lKAhDIUwoWFLozEZDFgq aPGq76CSmzC64HUf/0H64P6YYpk8NlDxA1Hu9dMGu3qH07Y9JhmJbCsU5liuaUQB/8 mlFQ44XsnlaaI96OFOESbCp7p7O9VAYkaD7ZncBUzHJ0qxegMUl1BdHsCTiHVhSNX6 OPDQ80yn+0jZ0H4ViTZ2MdmDl7dQ7yxLUjWzvDba55xMTT6T4wml5BPDZF1lpxVQDu AdZ5/6ipoOFjg== From: Christian Brauner To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Christoph Hellwig , Tyler Hicks , David Howells , Miklos Szeredi , Al Viro , ecryptfs@vger.kernel.org, linux-cachefs@redhat.com, Christian Brauner Subject: [PATCH 7/7] ecryptfs: extend ro check to private mount Date: Wed, 14 Apr 2021 14:37:51 +0200 Message-Id: <20210414123750.2110159-8-brauner@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210414123750.2110159-1-brauner@kernel.org> References: <20210414123750.2110159-1-brauner@kernel.org> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=TJq3ADscBRuq3vVMRrZQ25nFLYThkfCmWR4OfInmRrw=; m=1ciTf4lEciTeOTFMYE8Ti/zNFh88dj9ns8fWVydD8Es=; p=z+y7HlsQCE+Knq6tGOyffFIPiZjVOof3onzoRF6Hb6E=; g=0d107768135058226d796803890d0dee0a0e7ec6 X-Patch-Sig: m=pgp; i=christian.brauner@ubuntu.com; s=0x0x91C61BC06578DCA2; b=iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCYHbh4AAKCRCRxhvAZXjcotLBAQDn6l9 aXkwGRy7SXgg32N2NRCvBm3ku22g55ZuZqsqPhwD/TYrdUDq3t7xICbXuJj/8/Y+oSbZh1gRpQ2li RXJyZgI= Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Christian Brauner So far ecryptfs only verified that the superblock wasn't read-only but didn't check whether the mount was. This made sense when we did not use a private mount because the read-only state could change at any point. Now that we have a private mount and mount properties can't change behind our back extend the read-only check to include the vfsmount. The __mnt_is_readonly() helper will check both the mount and the superblock. Note that before we checked root->d_sb and now we check mnt->mnt_sb but since we have a matching pair here this is only syntactical change, not a semantic one. Overlayfs and cachefiles have been changed to check this as well. Cc: Amir Goldstein Cc: Tyler Hicks Cc: ecryptfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Christian Brauner --- fs/ecryptfs/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index 3ba2c0f349a3..4e5aeec91e95 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c @@ -571,7 +571,7 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags * 1) The lower mount is ro * 2) The ecryptfs_encrypted_view mount option is specified */ - if (sb_rdonly(path.dentry->d_sb) || mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED) + if (__mnt_is_readonly(mnt) || mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED) s->s_flags |= SB_RDONLY; s->s_maxbytes = path.dentry->d_sb->s_maxbytes;