All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fscrypt: restrict IV_INO_LBLK_32 to ino_bits <= 32
@ 2020-08-24 20:38 ` Eric Biggers
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Biggers @ 2020-08-24 20:38 UTC (permalink / raw)
  To: linux-fscrypt; +Cc: linux-ext4, linux-f2fs-devel, Jeff Layton, Paul Crowley

From: Eric Biggers <ebiggers@google.com>

When an encryption policy has the IV_INO_LBLK_32 flag set, the IV
generation method involves hashing the inode number.  This is different
from fscrypt's other IV generation methods, where the inode number is
either not used at all or is included directly in the IVs.

Therefore, in principle IV_INO_LBLK_32 can work with any length inode
number.  However, currently fscrypt gets the inode number from
inode::i_ino, which is 'unsigned long'.  So currently the implementation
limit is actually 32 bits (like IV_INO_LBLK_64), since longer inode
numbers will have been truncated by the VFS on 32-bit platforms.

Fix fscrypt_supported_v2_policy() to enforce the correct limit.

This doesn't actually matter currently, since only ext4 and f2fs support
IV_INO_LBLK_32, and they both only support 32-bit inode numbers.  But we
might as well fix it in case it matters in the future.

Ideally inode::i_ino would instead be made 64-bit, but for now it's not
needed.  (Note, this limit does *not* prevent filesystems with 64-bit
inode numbers from adding fscrypt support, since IV_INO_LBLK_* support
is optional and is useful only on certain hardware.)

Fixes: e3b1078bedd3 ("fscrypt: add support for IV_INO_LBLK_32 policies")
Reported-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/crypto/policy.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index 2d73fd39ad96..b92f34523178 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -192,10 +192,15 @@ static bool fscrypt_supported_v2_policy(const struct fscrypt_policy_v2 *policy,
 					  32, 32))
 		return false;
 
+	/*
+	 * IV_INO_LBLK_32 hashes the inode number, so in principle it can
+	 * support any ino_bits.  However, currently the inode number is gotten
+	 * from inode::i_ino which is 'unsigned long'.  So for now the
+	 * implementation limit is 32 bits.
+	 */
 	if ((policy->flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32) &&
-	    /* This uses hashed inode numbers, so ino_bits doesn't matter. */
 	    !supported_iv_ino_lblk_policy(policy, inode, "IV_INO_LBLK_32",
-					  INT_MAX, 32))
+					  32, 32))
 		return false;
 
 	if (memchr_inv(policy->__reserved, 0, sizeof(policy->__reserved))) {
-- 
2.28.0.297.g1956fa8f8d-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [f2fs-dev] [PATCH] fscrypt: restrict IV_INO_LBLK_32 to ino_bits <= 32
@ 2020-08-24 20:38 ` Eric Biggers
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Biggers @ 2020-08-24 20:38 UTC (permalink / raw)
  To: linux-fscrypt; +Cc: Paul Crowley, linux-ext4, Jeff Layton, linux-f2fs-devel

From: Eric Biggers <ebiggers@google.com>

When an encryption policy has the IV_INO_LBLK_32 flag set, the IV
generation method involves hashing the inode number.  This is different
from fscrypt's other IV generation methods, where the inode number is
either not used at all or is included directly in the IVs.

Therefore, in principle IV_INO_LBLK_32 can work with any length inode
number.  However, currently fscrypt gets the inode number from
inode::i_ino, which is 'unsigned long'.  So currently the implementation
limit is actually 32 bits (like IV_INO_LBLK_64), since longer inode
numbers will have been truncated by the VFS on 32-bit platforms.

Fix fscrypt_supported_v2_policy() to enforce the correct limit.

This doesn't actually matter currently, since only ext4 and f2fs support
IV_INO_LBLK_32, and they both only support 32-bit inode numbers.  But we
might as well fix it in case it matters in the future.

Ideally inode::i_ino would instead be made 64-bit, but for now it's not
needed.  (Note, this limit does *not* prevent filesystems with 64-bit
inode numbers from adding fscrypt support, since IV_INO_LBLK_* support
is optional and is useful only on certain hardware.)

Fixes: e3b1078bedd3 ("fscrypt: add support for IV_INO_LBLK_32 policies")
Reported-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/crypto/policy.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index 2d73fd39ad96..b92f34523178 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -192,10 +192,15 @@ static bool fscrypt_supported_v2_policy(const struct fscrypt_policy_v2 *policy,
 					  32, 32))
 		return false;
 
+	/*
+	 * IV_INO_LBLK_32 hashes the inode number, so in principle it can
+	 * support any ino_bits.  However, currently the inode number is gotten
+	 * from inode::i_ino which is 'unsigned long'.  So for now the
+	 * implementation limit is 32 bits.
+	 */
 	if ((policy->flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32) &&
-	    /* This uses hashed inode numbers, so ino_bits doesn't matter. */
 	    !supported_iv_ino_lblk_policy(policy, inode, "IV_INO_LBLK_32",
-					  INT_MAX, 32))
+					  32, 32))
 		return false;
 
 	if (memchr_inv(policy->__reserved, 0, sizeof(policy->__reserved))) {
-- 
2.28.0.297.g1956fa8f8d-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fscrypt: restrict IV_INO_LBLK_32 to ino_bits <= 32
  2020-08-24 20:38 ` [f2fs-dev] " Eric Biggers
@ 2020-09-07 22:51   ` Eric Biggers
  -1 siblings, 0 replies; 4+ messages in thread
From: Eric Biggers @ 2020-09-07 22:51 UTC (permalink / raw)
  To: linux-fscrypt; +Cc: linux-ext4, linux-f2fs-devel, Jeff Layton, Paul Crowley

On Mon, Aug 24, 2020 at 01:38:41PM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> When an encryption policy has the IV_INO_LBLK_32 flag set, the IV
> generation method involves hashing the inode number.  This is different
> from fscrypt's other IV generation methods, where the inode number is
> either not used at all or is included directly in the IVs.
> 
> Therefore, in principle IV_INO_LBLK_32 can work with any length inode
> number.  However, currently fscrypt gets the inode number from
> inode::i_ino, which is 'unsigned long'.  So currently the implementation
> limit is actually 32 bits (like IV_INO_LBLK_64), since longer inode
> numbers will have been truncated by the VFS on 32-bit platforms.
> 
> Fix fscrypt_supported_v2_policy() to enforce the correct limit.
> 
> This doesn't actually matter currently, since only ext4 and f2fs support
> IV_INO_LBLK_32, and they both only support 32-bit inode numbers.  But we
> might as well fix it in case it matters in the future.
> 
> Ideally inode::i_ino would instead be made 64-bit, but for now it's not
> needed.  (Note, this limit does *not* prevent filesystems with 64-bit
> inode numbers from adding fscrypt support, since IV_INO_LBLK_* support
> is optional and is useful only on certain hardware.)
> 
> Fixes: e3b1078bedd3 ("fscrypt: add support for IV_INO_LBLK_32 policies")
> Reported-by: Jeff Layton <jlayton@kernel.org>
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Applied to fscrypt.git#master for 5.10.

- Eric

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH] fscrypt: restrict IV_INO_LBLK_32 to ino_bits <= 32
@ 2020-09-07 22:51   ` Eric Biggers
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Biggers @ 2020-09-07 22:51 UTC (permalink / raw)
  To: linux-fscrypt; +Cc: Paul Crowley, linux-ext4, Jeff Layton, linux-f2fs-devel

On Mon, Aug 24, 2020 at 01:38:41PM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> When an encryption policy has the IV_INO_LBLK_32 flag set, the IV
> generation method involves hashing the inode number.  This is different
> from fscrypt's other IV generation methods, where the inode number is
> either not used at all or is included directly in the IVs.
> 
> Therefore, in principle IV_INO_LBLK_32 can work with any length inode
> number.  However, currently fscrypt gets the inode number from
> inode::i_ino, which is 'unsigned long'.  So currently the implementation
> limit is actually 32 bits (like IV_INO_LBLK_64), since longer inode
> numbers will have been truncated by the VFS on 32-bit platforms.
> 
> Fix fscrypt_supported_v2_policy() to enforce the correct limit.
> 
> This doesn't actually matter currently, since only ext4 and f2fs support
> IV_INO_LBLK_32, and they both only support 32-bit inode numbers.  But we
> might as well fix it in case it matters in the future.
> 
> Ideally inode::i_ino would instead be made 64-bit, but for now it's not
> needed.  (Note, this limit does *not* prevent filesystems with 64-bit
> inode numbers from adding fscrypt support, since IV_INO_LBLK_* support
> is optional and is useful only on certain hardware.)
> 
> Fixes: e3b1078bedd3 ("fscrypt: add support for IV_INO_LBLK_32 policies")
> Reported-by: Jeff Layton <jlayton@kernel.org>
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Applied to fscrypt.git#master for 5.10.

- Eric


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-07 22:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-24 20:38 [PATCH] fscrypt: restrict IV_INO_LBLK_32 to ino_bits <= 32 Eric Biggers
2020-08-24 20:38 ` [f2fs-dev] " Eric Biggers
2020-09-07 22:51 ` Eric Biggers
2020-09-07 22:51   ` [f2fs-dev] " Eric Biggers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.