From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AB0D37187C; Mon, 13 Jul 2026 02:39:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783910380; cv=none; b=VnAuavc0djZ8qsq8n73GEBGCM+9dOiw5C27C5vn0f+u7Fh+L2Cv/OKD43/N9QlTzEdcRG9wmLZ5pq8wNBTjvWYNcm4p1VrHEc3YT8+Y/LTMKxLEKHBwxnl/6cpLp2SKaMB9BH/yHMkHv9xC6TO6s6wzZsgX4oHrx2KJP1gwNoyo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783910380; c=relaxed/simple; bh=BICFOTeGJxuw4S3sozP1B1tFp+JwzUlAKsvrXpF6C7k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TAGDla6RSclQgXVKTb8ae3YIVOqswlE+uAbqwbn7vaWZyym9g9V23mqnSOueZu6sC+3KO8i++teBRkV7vxN14X5BO7Advr8P2awrliyCyb1o67wva3VgY3v2AAdB4vk5Q9B23Q1BHwROqmN8MZ1yIg6KBPZ9EZKyzEOXevlPiWQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aPGIZQ3b; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aPGIZQ3b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE6671F00A3D; Mon, 13 Jul 2026 02:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783910377; bh=heJf2lUsfHWx2MluoNOLNNCT5X8VE5KT5lfDTj6MDb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aPGIZQ3b9j+h6Z0MyThuY/ZUQCSxgActPOPVfiyM8xdeZu8TstqIdUTmaMnprF4mr OqcBPDoE41PPE0bZe11h5ABtIn1j/8fdPmz4grktn1zusegI/Kwj/ni4vBbnhyfNn6 pmPGtTaoSpL85dQ/O4DiG+MX6fHofacLEIL6KiVc2Zewi3nucU1OxKcyGEi2Ca7Gl7 BJc6UfJ/+lhqGGPjbB5pq0Dx1ncUJgzhJRRzLhh2G98uk6bhenV+UpuShpgd5XJIeN LfkeI2T9jUISjTYa5vUj5CHw2T4opMTVJjL5RdGS5OTPPH/kVlYm38JMo/A7ubm3+X eZBcUNyGC4ygA== From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-block@vger.kernel.org, Christoph Hellwig , Theodore Ts'o , Andreas Dilger , Baokun Li , Jan Kara , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Jaegeuk Kim , Chao Yu , Eric Biggers Subject: [PATCH v3 04/17] fscrypt: Fully disallow IV_INO_LBLK_32 with s_blocksize != PAGE_SIZE Date: Sun, 12 Jul 2026 22:36:55 -0400 Message-ID: <20260713023708.9245-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260713023708.9245-1-ebiggers@kernel.org> References: <20260713023708.9245-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32 with s_blocksize != PAGE_SIZE works only with the fs-layer implementation of file contents encryption, not blk-crypto. This is a problem for standardizing on blk-crypto. Fortunately, no one should be using this combination anyway. It doesn't make sense because the entire point of IV_INO_LBLK_32 is to support inline encryption hardware that is limited to 32-bit DUNs. Thus, fully disallow IV_INO_LBLK_32 with s_blocksize != PAGE_SIZE. Reviewed-by: Christoph Hellwig Signed-off-by: Eric Biggers --- Documentation/filesystems/fscrypt.rst | 3 +++ fs/crypto/inline_crypt.c | 13 ------------- fs/crypto/policy.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Documentation/filesystems/fscrypt.rst b/Documentation/filesystems/fscrypt.rst index c0dd35f1af12..92b8f311e211 100644 --- a/Documentation/filesystems/fscrypt.rst +++ b/Documentation/filesystems/fscrypt.rst @@ -336,6 +336,9 @@ per I/O request and may have only a small number of keyslots. This format results in some level of IV reuse, so it should only be used when necessary due to hardware limitations. +IV_INO_LBLK_32 is supported only when the filesystem block size is +equal to the page size. + Key identifiers --------------- diff --git a/fs/crypto/inline_crypt.c b/fs/crypto/inline_crypt.c index aaf71f6068b0..83dea8bc2c8c 100644 --- a/fs/crypto/inline_crypt.c +++ b/fs/crypto/inline_crypt.c @@ -112,19 +112,6 @@ int fscrypt_select_encryption_impl(struct fscrypt_inode_info *ci, if (!(sb->s_flags & SB_INLINECRYPT)) return 0; - /* - * When a page contains multiple logically contiguous filesystem blocks, - * some filesystem code only calls fscrypt_mergeable_bio() for the first - * block in the page. This is fine for most of fscrypt's IV generation - * strategies, where contiguous blocks imply contiguous IVs. But it - * doesn't work with IV_INO_LBLK_32. For now, simply exclude - * IV_INO_LBLK_32 with blocksize != PAGE_SIZE from inline encryption. - */ - if ((fscrypt_policy_flags(&ci->ci_policy) & - FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32) && - sb->s_blocksize != PAGE_SIZE) - return 0; - /* * On all the filesystem's block devices, blk-crypto must support the * crypto configuration that the file would use. diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index f40fb5924e75..a7322dba7557 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -177,6 +177,23 @@ static bool supported_iv_ino_lblk_policy(const struct fscrypt_policy_v2 *policy, type, sb->s_id); return false; } + + /* + * IV_INO_LBLK_32 isn't compatible with inline encryption when + * s_blocksize != PAGE_SIZE. In that case the DUN can wrap around in + * the middle of a page, but sometimes fscrypt_mergeable_bio() is called + * only for the first block per page. Since IV_INO_LBLK_32 exists only + * to support inline encryption hardware that is limited to 32-bit DUNs, + * just disallow IV_INO_LBLK_32 with s_blocksize != PAGE_SIZE entirely. + */ + if ((policy->flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32) && + sb->s_blocksize != PAGE_SIZE) { + fscrypt_warn(inode, + "Can't use %s policy on filesystem '%s' with block size != PAGE_SIZE", + type, sb->s_id); + return false; + } + return true; } -- 2.55.0 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C27F7C44507 for ; Mon, 13 Jul 2026 02:39:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:References:In-Reply-To: Message-ID:Date:To:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=E0StuYfpESKVJQeRXFtoLrY0UKbPsJhrYzczddEWsiI=; b=J7oLI689labajJQlA18gvEvuVK eLaKywquIGIDW8YWKkO6UfCHssORpa9SwEmCr/syemW4tK/SBkUdXp6klj2Xrwwjpm3XO1Osbp5UX Vjrq0/sdaCcfoZ28ykjIUTOJwbCAflnBo48PeHDdm0yTG5v0G62hKs769DL4xMww+xNw=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1wj6a8-00062Z-Mh; Mon, 13 Jul 2026 02:39:45 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1wj6a7-00062K-6N for linux-f2fs-devel@lists.sourceforge.net; Mon, 13 Jul 2026 02:39:43 +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=heJf2lUsfHWx2MluoNOLNNCT5X8VE5KT5lfDTj6MDb4=; b=IL9Xgt0YqtqPQIHMmBBLODZgmx f+R1/wZjpxq22nama4/DwDZd60S4NZUkpE0WAw0Uh0g9f/I5xV+IDSpQ+tQ8IqaSMv6Tod1TDWGje gipHq8Vpk/dYJSebXSlFy8CDOgz3/NIlSz/aZ/W+mkRTl3Gpjb5MXB0rzssI+A07DcMU=; 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=heJf2lUsfHWx2MluoNOLNNCT5X8VE5KT5lfDTj6MDb4=; b=hPWnZR0j4RKlR+GDNDmS9q0+V3 kGpV2znrqpx3YxzAYjwNik2xzrLLrCercjsBHFa9B3fN+sLDVvNvIz/+6KZ7hNHIaiaXlpAVqlLdy 1xLkmVtLlzntYz1bg0YJXyB5LSObZg/+7xg8hSttMG7Nh8jmIl/1XIK/OhiVYZbA9fic=; Received: from sea.source.kernel.org ([172.234.252.31]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1wj6a7-0003Ap-G4 for linux-f2fs-devel@lists.sourceforge.net; Mon, 13 Jul 2026 02:39:43 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 10CB943626; Mon, 13 Jul 2026 02:39:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE6671F00A3D; Mon, 13 Jul 2026 02:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783910377; bh=heJf2lUsfHWx2MluoNOLNNCT5X8VE5KT5lfDTj6MDb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aPGIZQ3b9j+h6Z0MyThuY/ZUQCSxgActPOPVfiyM8xdeZu8TstqIdUTmaMnprF4mr OqcBPDoE41PPE0bZe11h5ABtIn1j/8fdPmz4grktn1zusegI/Kwj/ni4vBbnhyfNn6 pmPGtTaoSpL85dQ/O4DiG+MX6fHofacLEIL6KiVc2Zewi3nucU1OxKcyGEi2Ca7Gl7 BJc6UfJ/+lhqGGPjbB5pq0Dx1ncUJgzhJRRzLhh2G98uk6bhenV+UpuShpgd5XJIeN LfkeI2T9jUISjTYa5vUj5CHw2T4opMTVJjL5RdGS5OTPPH/kVlYm38JMo/A7ubm3+X eZBcUNyGC4ygA== To: linux-fscrypt@vger.kernel.org Date: Sun, 12 Jul 2026 22:36:55 -0400 Message-ID: <20260713023708.9245-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260713023708.9245-1-ebiggers@kernel.org> References: <20260713023708.9245-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Headers-End: 1wj6a7-0003Ap-G4 Subject: [f2fs-dev] [PATCH v3 04/17] fscrypt: Fully disallow IV_INO_LBLK_32 with s_blocksize != PAGE_SIZE 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: , From: Eric Biggers via Linux-f2fs-devel Reply-To: Eric Biggers Cc: Ritesh Harjani , Theodore Ts'o , Zhang Yi , linux-f2fs-devel@lists.sourceforge.net, linux-block@vger.kernel.org, Andreas Dilger , Ojaswin Mujoo , Baokun Li , Jaegeuk Kim , linux-fsdevel@vger.kernel.org, Jan Kara , linux-ext4@vger.kernel.org, Christoph Hellwig , Eric Biggers Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32 with s_blocksize != PAGE_SIZE works only with the fs-layer implementation of file contents encryption, not blk-crypto. This is a problem for standardizing on blk-crypto. Fortunately, no one should be using this combination anyway. It doesn't make sense because the entire point of IV_INO_LBLK_32 is to support inline encryption hardware that is limited to 32-bit DUNs. Thus, fully disallow IV_INO_LBLK_32 with s_blocksize != PAGE_SIZE. Reviewed-by: Christoph Hellwig Signed-off-by: Eric Biggers --- Documentation/filesystems/fscrypt.rst | 3 +++ fs/crypto/inline_crypt.c | 13 ------------- fs/crypto/policy.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Documentation/filesystems/fscrypt.rst b/Documentation/filesystems/fscrypt.rst index c0dd35f1af12..92b8f311e211 100644 --- a/Documentation/filesystems/fscrypt.rst +++ b/Documentation/filesystems/fscrypt.rst @@ -336,6 +336,9 @@ per I/O request and may have only a small number of keyslots. This format results in some level of IV reuse, so it should only be used when necessary due to hardware limitations. +IV_INO_LBLK_32 is supported only when the filesystem block size is +equal to the page size. + Key identifiers --------------- diff --git a/fs/crypto/inline_crypt.c b/fs/crypto/inline_crypt.c index aaf71f6068b0..83dea8bc2c8c 100644 --- a/fs/crypto/inline_crypt.c +++ b/fs/crypto/inline_crypt.c @@ -112,19 +112,6 @@ int fscrypt_select_encryption_impl(struct fscrypt_inode_info *ci, if (!(sb->s_flags & SB_INLINECRYPT)) return 0; - /* - * When a page contains multiple logically contiguous filesystem blocks, - * some filesystem code only calls fscrypt_mergeable_bio() for the first - * block in the page. This is fine for most of fscrypt's IV generation - * strategies, where contiguous blocks imply contiguous IVs. But it - * doesn't work with IV_INO_LBLK_32. For now, simply exclude - * IV_INO_LBLK_32 with blocksize != PAGE_SIZE from inline encryption. - */ - if ((fscrypt_policy_flags(&ci->ci_policy) & - FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32) && - sb->s_blocksize != PAGE_SIZE) - return 0; - /* * On all the filesystem's block devices, blk-crypto must support the * crypto configuration that the file would use. diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index f40fb5924e75..a7322dba7557 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -177,6 +177,23 @@ static bool supported_iv_ino_lblk_policy(const struct fscrypt_policy_v2 *policy, type, sb->s_id); return false; } + + /* + * IV_INO_LBLK_32 isn't compatible with inline encryption when + * s_blocksize != PAGE_SIZE. In that case the DUN can wrap around in + * the middle of a page, but sometimes fscrypt_mergeable_bio() is called + * only for the first block per page. Since IV_INO_LBLK_32 exists only + * to support inline encryption hardware that is limited to 32-bit DUNs, + * just disallow IV_INO_LBLK_32 with s_blocksize != PAGE_SIZE entirely. + */ + if ((policy->flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32) && + sb->s_blocksize != PAGE_SIZE) { + fscrypt_warn(inode, + "Can't use %s policy on filesystem '%s' with block size != PAGE_SIZE", + type, sb->s_id); + return false; + } + return true; } -- 2.55.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel