Linux-Fsdevel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] f2fs-tools: Casefolded Encryption support
@ 2019-12-03  5:29 Daniel Rosenberg
  0 siblings, 0 replies; only message in thread
From: Daniel Rosenberg @ 2019-12-03  5:29 UTC (permalink / raw)
  To: Jaegeuk Kim
  Cc: linux-f2fs-devel, linux-fsdevel, kernel-team, Daniel Rosenberg

This adds support for casefolded and encrypted directories.
Fsck cannot check the hashes of such directories because it would
require access to the encryption key to generate the siphash

Signed-off-by: Daniel Rosenberg <drosen@google.com>
---
 fsck/fsck.c        | 4 ++++
 fsck/mount.c       | 6 ------
 mkfs/f2fs_format.c | 4 ----
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 2ae3bd5..ebbdf44 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -1290,6 +1290,10 @@ static int f2fs_check_hash_code(int encoding, int casefolded,
 			struct f2fs_dir_entry *dentry,
 			const unsigned char *name, u32 len, int enc_name)
 {
+	/* Casefolded Encrypted names require a key to compute siphash */
+	if (enc_name && casefolded)
+		return 0;
+
 	f2fs_hash_t hash_code = f2fs_dentry_hash(encoding, casefolded, name, len);
 	/* fix hash_code made by old buggy code */
 	if (dentry->hash_code != hash_code) {
diff --git a/fsck/mount.c b/fsck/mount.c
index 4814dfe..3286899 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -2965,12 +2965,6 @@ static int tune_sb_features(struct f2fs_sb_info *sbi)
 	int sb_changed = 0;
 	struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi);
 
-	if (c.feature & cpu_to_le32(F2FS_FEATURE_ENCRYPT) &&
-		c.feature & cpu_to_le32(F2FS_FEATURE_CASEFOLD)) {
-		ERR_MSG("ERROR: Cannot set both encrypt and casefold. Skipping.\n");
-		return -1;
-	}
-
 	if (!(sb->feature & cpu_to_le32(F2FS_FEATURE_ENCRYPT)) &&
 			c.feature & cpu_to_le32(F2FS_FEATURE_ENCRYPT)) {
 		sb->feature |= cpu_to_le32(F2FS_FEATURE_ENCRYPT);
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 9402619..0bfe963 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -517,10 +517,6 @@ static int f2fs_prepare_super_block(void)
 	memcpy(sb->init_version, c.version, VERSION_LEN);
 
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_CASEFOLD)) {
-		if (c.feature & cpu_to_le32(F2FS_FEATURE_ENCRYPT)) {
-			MSG(0, "\tError: Casefolding and encryption are not compatible\n");
-			return -1;
-		}
 		set_sb(s_encoding, c.s_encoding);
 		set_sb(s_encoding_flags, c.s_encoding_flags);
 	}
-- 
2.24.0.393.g34dc348eaf-goog


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03  5:29 [PATCH] f2fs-tools: Casefolded Encryption support Daniel Rosenberg

Linux-Fsdevel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-fsdevel/0 linux-fsdevel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-fsdevel linux-fsdevel/ https://lore.kernel.org/linux-fsdevel \
		linux-fsdevel@vger.kernel.org
	public-inbox-index linux-fsdevel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-fsdevel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git