Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp642505pxb; Thu, 12 Nov 2020 12:31:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTLKzqeBl937vY8tUcUTNuaPChIAViTLFzj2Pl2RXtKEHF0NAjc7SbJM9dfsES9hTzLfPl X-Received: by 2002:a17:906:6156:: with SMTP id p22mr1111339ejl.64.1605213067632; Thu, 12 Nov 2020 12:31:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605213067; cv=none; d=google.com; s=arc-20160816; b=MB50o7voQe4gTel+25btMZiP+8a7UfxKUkp1t98Y16vvN6xSlvgMQFXR+prwH9Y8QZ ptUCrshQFWCdhcS7npSq7NqqKZihA4F3Jjc2BSnv8qasH1nF/ij2qq6kNBQh9CkyBmcj G/PX/Vgo1HZmdI4txxyJe3pSV3LrjmW2Hovp1kuD1MWfZURmSpfinzWjgecjhMOjfMbA 6lK0a26xFAsIRTnGZZ0k10THGubfU/KZRYt63nXblrKCaIdj2JyC0YWSfKqCUNOE7c/5 gw1JYYhRCtA/M6iNy54thA+ZINwADBLg2AzGKg8ddXNI//LWS8C/6VygH4l/+0SsqxZ7 1Z5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MRFSHBtmkNQLGUqSte1BXV/cqbGb7llm9IuVSAqZniU=; b=ToZNWVcNOoRun8vh7MdvqqSdSebqpZRZ3YjQoVNWNvQqYBvkb5FnnUCv9xPEswb+FA eXmbeeSN3ldzjKYMa9SjszLZtlssATSH9vbzIR5qxK/jf4GKCCzGZPvnVG24KENbauDY 34lN7SDu8SoLVOgqx2CgE/QAHK2gFoVnoSEnSlloVhL+Ggx9tWqWftUlDeqSbM4ZfifX agLlY1s3AokyAK4K+IgH7bGNeT4YJAHi3d344dEuLihB9Dbmx/F+pYxmE0rWSPBg9ul1 6YZDq2J/PSA+dCAXh5CHP3vhQjK4gj4fipdMoyHDAJ2s9mRzfHWu4ECY0xSGeL39BkC1 taHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zxj+dbdV; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r15si4706884ejy.36.2020.11.12.12.30.31; Thu, 12 Nov 2020 12:31:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-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=zxj+dbdV; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727116AbgKLU3T (ORCPT + 99 others); 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