Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6a859ef authored by Yuvaraj Ranganathan's avatar Yuvaraj Ranganathan Committed by Gerrit - the friendly Code Review server
Browse files

fs: crypto: Setting IV_INO_LBLK_32 flag only to F2FS



Enable IV_INO_LBLK_32 flag only for F2FS
and this flag is not required for ext4 as
ext4 uses sector number as IV.

Tests:
1. File Based Encryption(FBE) on adb remount and normal reboot.
2. File Based Encryption(FBE) properties are set.

Change-Id: Ie3fa6fddf7318410324d6a7da3d89326c1d1c6ff
Signed-off-by: default avatarYuvaraj Ranganathan <quic_yrangana@quicinc.com>
parent 9e6c9ab4
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -626,12 +626,13 @@ EXPORT_SYMBOL(fscrypt_has_permitted_context);

#define SDHCI "sdhci"

static int fscrypt_update_context(union fscrypt_context *ctx)
static int fscrypt_update_context(union fscrypt_context *ctx,
						const char *file_system_type)
{
	char *boot = "ufs";

	if (!fscrypt_find_storage_type(&boot)) {
		if (!strcmp(boot, SDHCI))
		if (!strcmp(boot, SDHCI) && !strcmp(file_system_type, "f2fs"))
			ctx->v1.flags |= FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32;
			return 0;
	}
@@ -654,6 +655,7 @@ int fscrypt_inherit_context(struct inode *parent, struct inode *child,
	int ctxsize;
	struct fscrypt_info *ci;
	int res;
	const char *file_system_type;

	res = fscrypt_get_encryption_info(parent);
	if (res < 0)
@@ -663,10 +665,14 @@ int fscrypt_inherit_context(struct inode *parent, struct inode *child,
	if (ci == NULL)
		return -ENOKEY;

	file_system_type = ci->ci_inode->i_sb->s_type->name;
	if (!file_system_type)
		return -EINVAL;

	ctxsize = fscrypt_new_context_from_policy(&ctx, &ci->ci_policy);
	if (fscrypt_policy_contents_mode(&ci->ci_policy) ==
	    FSCRYPT_MODE_PRIVATE) {
		res = fscrypt_update_context(&ctx);
		res = fscrypt_update_context(&ctx, file_system_type);
		if (res)
			return res;
	}