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=-10.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 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 9C1A7C2D0E4 for ; Thu, 12 Nov 2020 20:29:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40D70216C4 for ; Thu, 12 Nov 2020 20:29:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="zxj+dbdV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727121AbgKLU3T (ORCPT ); Thu, 12 Nov 2020 15:29:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:51968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727115AbgKLU3T (ORCPT ); Thu, 12 Nov 2020 15:29:19 -0500 Received: from sol.localdomain (172-10-235-113.lightspeed.sntcca.sbcglobal.net [172.10.235.113]) (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 EEB0E20872; Thu, 12 Nov 2020 20:29:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605212958; bh=bWaPaaa4cnOfI6CXSQAbGQrxlcQ6NMZjfJQHOkXLyqY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=zxj+dbdVku4GY7DGrqZAdldWBRvuNzq5tefJyTKzQip2wLf5yhadc4Qaiz9yQ9a1y bFNhknLq0kdZj3IIaUTZL7FaUOa3rPPt6Tr32IFlLZPsMYwWxvDrCL8Iuyg0VgwBNl 8uaBPgYbP4elIjL/01UquoCCoBiAL1WGDloW6tTA= Date: Thu, 12 Nov 2020 12:29:16 -0800 From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Satya Tangirala , Jaegeuk Kim Subject: Re: [PATCH] fscrypt: fix inline encryption not used on new files Message-ID: References: <20201111015224.303073-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201111015224.303073-1-ebiggers@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Nov 10, 2020 at 05:52:24PM -0800, Eric Biggers wrote: > From: Eric Biggers > > The new helper function fscrypt_prepare_new_inode() runs before > S_ENCRYPTED has been set on the new inode. This accidentally made > fscrypt_select_encryption_impl() never enable inline encryption on newly > created files, due to its use of fscrypt_needs_contents_encryption() > which only returns true when S_ENCRYPTED is set. > > Fix this by using S_ISREG() directly instead of > fscrypt_needs_contents_encryption(), analogous to what > select_encryption_mode() does. > > I didn't notice this earlier because by design, the user-visible > behavior is the same (other than performance, potentially) regardless of > whether inline encryption is used or not. > > Fixes: a992b20cd4ee ("fscrypt: add fscrypt_prepare_new_inode() and fscrypt_set_context()") > Signed-off-by: Eric Biggers > --- > fs/crypto/inline_crypt.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/crypto/inline_crypt.c b/fs/crypto/inline_crypt.c > index 89bffa82ed74a..c57bebfa48fea 100644 > --- a/fs/crypto/inline_crypt.c > +++ b/fs/crypto/inline_crypt.c > @@ -74,7 +74,7 @@ int fscrypt_select_encryption_impl(struct fscrypt_info *ci) > int i; > > /* The file must need contents encryption, not filenames encryption */ > - if (!fscrypt_needs_contents_encryption(inode)) > + if (!S_ISREG(inode->i_mode)) > return 0; > > /* The crypto mode must have a blk-crypto counterpart */ > > base-commit: 92cfcd030e4b1de11a6b1edb0840e55c26332d31 Applied to fscrypt.git#for-stable for 5.10. - Eric