From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 00F86C56202 for ; Sat, 31 Oct 2020 22:10:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B46CB208B6 for ; Sat, 31 Oct 2020 22:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604182200; bh=CzWlU7YvaDDFQzbnSIqzxHmegNpaCZuzfUzquzwdRZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Uqty7tAnrCTFvRyR6s76J1kmb7WRcWW7Sm8cIax+1jCSogUd3AWkR39TcnNvlkfbx M8lQysdyoOdgHIRkNCtbkyaHBziw8n5A6Ku6LhEzpzqDoRRwzVfL7Cx3+3h2EpzapP 2qXxZpRgoQCiAe5jzl89lr+izaWrQP1i1q2SP/j4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726021AbgJaWJ4 (ORCPT ); Sat, 31 Oct 2020 18:09:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:39766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725974AbgJaWJy (ORCPT ); Sat, 31 Oct 2020 18:09:54 -0400 Received: from sol.attlocal.net (172-10-235-113.lightspeed.sntcca.sbcglobal.net [172.10.235.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BFED320791; Sat, 31 Oct 2020 22:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604182193; bh=CzWlU7YvaDDFQzbnSIqzxHmegNpaCZuzfUzquzwdRZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yY0RxRPv8oHtiWbHUr9Cr2hlbEOFT32S6HC5VLY8J6n47d3f61wfgWHeOUEMFvw+T NppNyTohL9FVQlvG6x9FMrs9/vt89g7/rn16uLbEkTCRvUtqwoKFauyfLfChrFaKm+ j1pyh4yr7ZVe3MoRzJf6NfdkBTvrNL2ub+GvZT6Q= From: Eric Biggers To: stable@vger.kernel.org Cc: linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, Theodore Ts'o Subject: [PATCH 4.19 4/5] fscrypt: only set dentry_operations on ciphertext dentries Date: Sat, 31 Oct 2020 15:05:52 -0700 Message-Id: <20201031220553.1085782-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201031220553.1085782-1-ebiggers@kernel.org> References: <20201031220553.1085782-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Eric Biggers commit d456a33f041af4b54f3ce495a86d00c246165032 upstream. Plaintext dentries are always valid, so only set fscrypt_d_ops on ciphertext dentries. Besides marginally improved performance, this allows overlayfs to use an fscrypt-encrypted upperdir, provided that all the following are true: (1) The fscrypt encryption key is placed in the keyring before mounting overlayfs, and remains while the overlayfs is mounted. (2) The overlayfs workdir uses the same encryption policy. (3) No dentries for the ciphertext names of subdirectories have been created in the upperdir or workdir yet. (Since otherwise d_splice_alias() will reuse the old dentry with ->d_op set.) One potential use case is using an ephemeral encryption key to encrypt all files created or changed by a container, so that they can be securely erased ("crypto-shredded") after the container stops. Signed-off-by: Eric Biggers Signed-off-by: Theodore Ts'o --- fs/crypto/hooks.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/crypto/hooks.c b/fs/crypto/hooks.c index 2e7498a821a48..9d8910e86ee5d 100644 --- a/fs/crypto/hooks.c +++ b/fs/crypto/hooks.c @@ -115,9 +115,8 @@ int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry) spin_lock(&dentry->d_lock); dentry->d_flags |= DCACHE_ENCRYPTED_NAME; spin_unlock(&dentry->d_lock); + d_set_d_op(dentry, &fscrypt_d_ops); } - - d_set_d_op(dentry, &fscrypt_d_ops); return 0; } EXPORT_SYMBOL_GPL(__fscrypt_prepare_lookup); -- 2.29.1 From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 889F5C388F9 for ; Sat, 31 Oct 2020 22:10:22 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 25B872072C; Sat, 31 Oct 2020 22:10:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="K7FX9KpV"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="QwBc/vSZ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="yY0RxRPv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25B872072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1kYz4n-0005Fm-SG; Sat, 31 Oct 2020 22:10:21 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYz4m-0005Fc-1Z for linux-f2fs-devel@lists.sourceforge.net; Sat, 31 Oct 2020 22:10:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=3EI2sc1czXDboJdTu+vyae5wnhJmljnRPkpjqAaLJhs=; b=K7FX9KpVZOmLA1b97uGYsBlAPo 5Rna+w3cQbY3bQJRZ0gAZYZFJBZsfYHwD3NzNY/4C+9Xd+52cuT44o6GDmO+vDfWjiefU2EfswEBo IElrDo4AlgroswHTiljCqcTw241RjkqcuKRQGG7E9jtz2eMrf8XZ7ap/6vYUFXhl5rLA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=3EI2sc1czXDboJdTu+vyae5wnhJmljnRPkpjqAaLJhs=; b=QwBc/vSZANJY9gW77BE/2wnwqS Ws1jRaBEZbNc1hmPqkSXpr5bnJAjxE89QluVTmcIajsxI1UhkEplTzIZEQY8fG78+4GLUHdEhUKwG qX/tzrFVsYqnIb8qh3tdWeO/XKEbbgYLonE2ZR+eytgKUu1Zv/woaLMXIfGD4EOZLEuo=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kYz4X-00Ece5-SZ for linux-f2fs-devel@lists.sourceforge.net; Sat, 31 Oct 2020 22:10:19 +0000 Received: from sol.attlocal.net (172-10-235-113.lightspeed.sntcca.sbcglobal.net [172.10.235.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BFED320791; Sat, 31 Oct 2020 22:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604182193; bh=CzWlU7YvaDDFQzbnSIqzxHmegNpaCZuzfUzquzwdRZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yY0RxRPv8oHtiWbHUr9Cr2hlbEOFT32S6HC5VLY8J6n47d3f61wfgWHeOUEMFvw+T NppNyTohL9FVQlvG6x9FMrs9/vt89g7/rn16uLbEkTCRvUtqwoKFauyfLfChrFaKm+ j1pyh4yr7ZVe3MoRzJf6NfdkBTvrNL2ub+GvZT6Q= From: Eric Biggers To: stable@vger.kernel.org Date: Sat, 31 Oct 2020 15:05:52 -0700 Message-Id: <20201031220553.1085782-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201031220553.1085782-1-ebiggers@kernel.org> References: <20201031220553.1085782-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Headers-End: 1kYz4X-00Ece5-SZ Subject: [f2fs-dev] [PATCH 4.19 4/5] fscrypt: only set dentry_operations on ciphertext dentries X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Theodore Ts'o , linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mtd@lists.infradead.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Eric Biggers commit d456a33f041af4b54f3ce495a86d00c246165032 upstream. Plaintext dentries are always valid, so only set fscrypt_d_ops on ciphertext dentries. Besides marginally improved performance, this allows overlayfs to use an fscrypt-encrypted upperdir, provided that all the following are true: (1) The fscrypt encryption key is placed in the keyring before mounting overlayfs, and remains while the overlayfs is mounted. (2) The overlayfs workdir uses the same encryption policy. (3) No dentries for the ciphertext names of subdirectories have been created in the upperdir or workdir yet. (Since otherwise d_splice_alias() will reuse the old dentry with ->d_op set.) One potential use case is using an ephemeral encryption key to encrypt all files created or changed by a container, so that they can be securely erased ("crypto-shredded") after the container stops. Signed-off-by: Eric Biggers Signed-off-by: Theodore Ts'o --- fs/crypto/hooks.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/crypto/hooks.c b/fs/crypto/hooks.c index 2e7498a821a48..9d8910e86ee5d 100644 --- a/fs/crypto/hooks.c +++ b/fs/crypto/hooks.c @@ -115,9 +115,8 @@ int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry) spin_lock(&dentry->d_lock); dentry->d_flags |= DCACHE_ENCRYPTED_NAME; spin_unlock(&dentry->d_lock); + d_set_d_op(dentry, &fscrypt_d_ops); } - - d_set_d_op(dentry, &fscrypt_d_ops); return 0; } EXPORT_SYMBOL_GPL(__fscrypt_prepare_lookup); -- 2.29.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 C598FC388F9 for ; Sat, 31 Oct 2020 22:10:59 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 674152072C for ; Sat, 31 Oct 2020 22:10:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Nhe/2Wlr"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="yY0RxRPv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 674152072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Yfz10KuQ1vwcf15QcvnJzaJDA0qHsBfqFvGpkFbqgqs=; b=Nhe/2WlrdUOiLO3dsogpp1xxf u7z4KPaDoY9ZAuYGuiR63KdY36ghPvfkpNXpwIMNXa0O3k3enehEdzZszDBYeFKoIjssTluMkxazJ NYntvDu0Rn8H62+LtGcV1AfhxJPaEY5O5reAP/fKA2KxXzKZfFPKlt3XoUATlJT30bKN6Y+y8nch8 wND53jd2O8w6p4msM6FsUzweI4dZHEuowvmR2mcfz7jWSyDE00zUG5wtHLIlSIU3rD00JF0EzeuuT GAPyexQiTxwo4Kgm96ydq5j0cm7VCf3PdIa/CH3ecGbscqDGi/DFvpH2F6vl6WFAjIpvRs0r3mLIt 8c3BdtjNQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYz4R-0007Mp-Jz; Sat, 31 Oct 2020 22:09:59 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYz4M-0007Kb-Hj for linux-mtd@lists.infradead.org; Sat, 31 Oct 2020 22:09:55 +0000 Received: from sol.attlocal.net (172-10-235-113.lightspeed.sntcca.sbcglobal.net [172.10.235.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BFED320791; Sat, 31 Oct 2020 22:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604182193; bh=CzWlU7YvaDDFQzbnSIqzxHmegNpaCZuzfUzquzwdRZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yY0RxRPv8oHtiWbHUr9Cr2hlbEOFT32S6HC5VLY8J6n47d3f61wfgWHeOUEMFvw+T NppNyTohL9FVQlvG6x9FMrs9/vt89g7/rn16uLbEkTCRvUtqwoKFauyfLfChrFaKm+ j1pyh4yr7ZVe3MoRzJf6NfdkBTvrNL2ub+GvZT6Q= From: Eric Biggers To: stable@vger.kernel.org Subject: [PATCH 4.19 4/5] fscrypt: only set dentry_operations on ciphertext dentries Date: Sat, 31 Oct 2020 15:05:52 -0700 Message-Id: <20201031220553.1085782-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201031220553.1085782-1-ebiggers@kernel.org> References: <20201031220553.1085782-1-ebiggers@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201031_180954_840456_51599D23 X-CRM114-Status: GOOD ( 14.62 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Theodore Ts'o , linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mtd@lists.infradead.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org From: Eric Biggers commit d456a33f041af4b54f3ce495a86d00c246165032 upstream. Plaintext dentries are always valid, so only set fscrypt_d_ops on ciphertext dentries. Besides marginally improved performance, this allows overlayfs to use an fscrypt-encrypted upperdir, provided that all the following are true: (1) The fscrypt encryption key is placed in the keyring before mounting overlayfs, and remains while the overlayfs is mounted. (2) The overlayfs workdir uses the same encryption policy. (3) No dentries for the ciphertext names of subdirectories have been created in the upperdir or workdir yet. (Since otherwise d_splice_alias() will reuse the old dentry with ->d_op set.) One potential use case is using an ephemeral encryption key to encrypt all files created or changed by a container, so that they can be securely erased ("crypto-shredded") after the container stops. Signed-off-by: Eric Biggers Signed-off-by: Theodore Ts'o --- fs/crypto/hooks.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/crypto/hooks.c b/fs/crypto/hooks.c index 2e7498a821a48..9d8910e86ee5d 100644 --- a/fs/crypto/hooks.c +++ b/fs/crypto/hooks.c @@ -115,9 +115,8 @@ int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry) spin_lock(&dentry->d_lock); dentry->d_flags |= DCACHE_ENCRYPTED_NAME; spin_unlock(&dentry->d_lock); + d_set_d_op(dentry, &fscrypt_d_ops); } - - d_set_d_op(dentry, &fscrypt_d_ops); return 0; } EXPORT_SYMBOL_GPL(__fscrypt_prepare_lookup); -- 2.29.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/