Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp821424pxb; Tue, 3 Nov 2020 13:30:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2W3r9zWu9goPvNzdkfL+zmIDflfMX6Z3rCcQYK+wYCJiJTduB5NWp3rDSyI5KlA3XQpqZ X-Received: by 2002:a50:8a9c:: with SMTP id j28mr17349264edj.254.1604439034786; Tue, 03 Nov 2020 13:30:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439034; cv=none; d=google.com; s=arc-20160816; b=CT3H4Pg5e7C3vlpY1phifrfvvsWNt2NT3nLyjPUqfI5L0Umi2tllq7i+dnTn2DHgyo X/9+EROjVuSMvrpG8kVBXnDm3J+m9AIRHBe4S/whs4ueCIjc8nmAx8RqlcU/spI/hzHZ 9hBaPfr+/0tcVL8smcbmEsL0AbHHEq19TOvkM0YFTck0m2zs9Xrg0MSJwf5f4Kuzib3n es4F2B6cdFkLYXXpmHmLL69szzKqnb897V5s68eptaTSuHS6XJg8HuQWXdQFoIA+et3e M2Lzczrq5X8AEBsCZXDMfACGJRi7lqkGbfywHvpG0EmGcGyhtrj8AGETRGUNHmcHm2ph fWBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=C1PnXVuatIou4nIW9OUhy9iNznLpbyWfslrgY9Ayeeg=; b=LBfChxiXeU7/UJrGJRD4tmWHfiibXEaksXuEwAt6HKq7Gir02oPoHLh5B99tHCrTlN pFZ8k7F7hmAuJ1ih6jmvS2R/bUE1uuEGWM8FnHZnRqZvQVP7rk8u0tEeDw5lGuSP4DtP q/NylB4xHVXjGvuT5LJwhrfqIVZiDIi5tBXbu2QD6cIDW9w8s0H6ymXWSWYwFOyzt0Qd hUcwVKZ0RqbrVGiHMyfnYuhlVkTBWUjGAQfq1L7PWWPsQOMZNZkPDbbL8vaBX7E2XNdU JEvS8XHSisSC30Jvyu80eWlS/OhvauJCpjvJ/5htp3wbsPugC424navSPN3tpJsx18BT 2JlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ke4pVpum; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l14si12237715edq.543.2020.11.03.13.30.11; Tue, 03 Nov 2020 13:30:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ke4pVpum; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733067AbgKCVZn (ORCPT + 99 others); Tue, 3 Nov 2020 16:25:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:39380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387614AbgKCVCU (ORCPT ); Tue, 3 Nov 2020 16:02:20 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9762220658; Tue, 3 Nov 2020 21:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437340; bh=NCgEeXgIGtG26G81EP7Rjb5PupTf60OODIdNFZgVuYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ke4pVpumifRFuJA06vdJ+TMgX7AfGmt1vdggeQZt7lVQP4OU2/dPXL+hBC0uhiZjk nS3fFIteQ2GaAknP9gk0GMLl/sbgc4/z7s53LkpyhZlrL+QTNq+LxufidPQfi+xlAQ yJxUCO+MlB6X0SbZC4qnUvlB7UMmjdNS+wilAhX4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , "linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, Theodore Tso" , Eric Biggers , Theodore Ts'o Subject: [PATCH 4.19 033/191] fscrypt: only set dentry_operations on ciphertext dentries Date: Tue, 3 Nov 2020 21:35:25 +0100 Message-Id: <20201103203237.007655514@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 Signed-off-by: Greg Kroah-Hartman --- fs/crypto/hooks.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/fs/crypto/hooks.c +++ b/fs/crypto/hooks.c @@ -115,9 +115,8 @@ int __fscrypt_prepare_lookup(struct inod 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);