Loading include/crypto/ice.h +12 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,18 @@ struct ice_data_setting { bool encr_bypass; }; /* MSM ICE Crypto Data Unit of target DUN of Transfer Request */ enum ice_crypto_data_unit { ICE_CRYPTO_DATA_UNIT_512_B = 0, ICE_CRYPTO_DATA_UNIT_1_KB = 1, ICE_CRYPTO_DATA_UNIT_2_KB = 2, ICE_CRYPTO_DATA_UNIT_4_KB = 3, ICE_CRYPTO_DATA_UNIT_8_KB = 4, ICE_CRYPTO_DATA_UNIT_16_KB = 5, ICE_CRYPTO_DATA_UNIT_32_KB = 6, ICE_CRYPTO_DATA_UNIT_64_KB = 7, }; typedef void (*ice_error_cb)(void *, u32 error); struct qcom_ice_variant_ops *qcom_ice_get_variant_ops(struct device_node *node); Loading security/pfe/pfk.c +14 −6 Original line number Diff line number Diff line Loading @@ -75,7 +75,9 @@ typedef int (*pfk_parse_inode_type)(const struct bio *bio, const struct inode *inode, struct pfk_key_info *key_info, enum ice_cryto_algo_mode *algo, bool *is_pfe); bool *is_pfe, unsigned int *data_unit, const char *storage_type); typedef bool (*pfk_allow_merge_bio_type)(const struct bio *bio1, const struct bio *bio2, const struct inode *inode1, Loading Loading @@ -281,21 +283,24 @@ bool pfe_is_inode_filesystem_type(const struct inode *inode, static int pfk_get_key_for_bio(const struct bio *bio, struct pfk_key_info *key_info, enum ice_cryto_algo_mode *algo_mode, bool *is_pfe) bool *is_pfe, unsigned int *data_unit) { const struct inode *inode; enum pfe_type which_pfe; const struct blk_encryption_key *key; char *s_type = NULL; inode = pfk_bio_get_inode(bio); which_pfe = pfk_get_pfe_type(inode); s_type = (char *)pfk_kc_get_storage_type(); if (which_pfe != INVALID_PFE) { /* Encrypted file; override ->bi_crypt_key */ pr_debug("parsing inode %lu with PFE type %d\n", inode->i_ino, which_pfe); return (*(pfk_parse_inode_ftable[which_pfe])) (bio, inode, key_info, algo_mode, is_pfe); (bio, inode, key_info, algo_mode, is_pfe, data_unit, (const char *)s_type); } /* Loading Loading @@ -348,6 +353,7 @@ int pfk_load_key_start(const struct bio *bio, struct pfk_key_info key_info = {NULL, NULL, 0, 0}; enum ice_cryto_algo_mode algo_mode = ICE_CRYPTO_ALGO_MODE_AES_XTS; enum ice_crpto_key_size key_size_type = 0; unsigned int data_unit = 1 << ICE_CRYPTO_DATA_UNIT_512_B; u32 key_index = 0; if (!is_pfe) { Loading @@ -370,7 +376,8 @@ int pfk_load_key_start(const struct bio *bio, return -EINVAL; } ret = pfk_get_key_for_bio(bio, &key_info, &algo_mode, is_pfe); ret = pfk_get_key_for_bio(bio, &key_info, &algo_mode, is_pfe, &data_unit); if (ret != 0) return ret; Loading @@ -380,7 +387,8 @@ int pfk_load_key_start(const struct bio *bio, return ret; ret = pfk_kc_load_key_start(key_info.key, key_info.key_size, key_info.salt, key_info.salt_size, &key_index, async); key_info.salt, key_info.salt_size, &key_index, async, data_unit); if (ret) { if (ret != -EBUSY && ret != -EAGAIN) pr_err("start: could not load key into pfk key cache, error %d\n", Loading Loading @@ -431,7 +439,7 @@ int pfk_load_key_end(const struct bio *bio, bool *is_pfe) if (!pfk_is_ready()) return -ENODEV; ret = pfk_get_key_for_bio(bio, &key_info, NULL, is_pfe); ret = pfk_get_key_for_bio(bio, &key_info, NULL, is_pfe, NULL); if (ret != 0) return ret; Loading security/pfe/pfk_ext4.c +16 −1 Original line number Diff line number Diff line Loading @@ -141,7 +141,9 @@ int pfk_ext4_parse_inode(const struct bio *bio, const struct inode *inode, struct pfk_key_info *key_info, enum ice_cryto_algo_mode *algo, bool *is_pfe) bool *is_pfe, unsigned int *data_unit, const char *storage_type) { int ret = 0; Loading @@ -155,6 +157,19 @@ int pfk_ext4_parse_inode(const struct bio *bio, */ *is_pfe = true; /* Update dun based upon storage type. * For ext4 FS UFS has 4k dun whereas eMMC * uses 512Byte dun. */ if (storage_type && data_unit) { if (!memcmp(storage_type, "ufs", strlen("ufs"))) *data_unit = 1 << ICE_CRYPTO_DATA_UNIT_4_KB; else if (!memcmp(storage_type, "sdcc", strlen("sdcc"))) *data_unit = 1 << ICE_CRYPTO_DATA_UNIT_512_B; else return -EINVAL; } if (!pfk_ext4_is_ready()) return -ENODEV; Loading security/pfe/pfk_ext4.h +3 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,9 @@ int pfk_ext4_parse_inode(const struct bio *bio, const struct inode *inode, struct pfk_key_info *key_info, enum ice_cryto_algo_mode *algo, bool *is_pfe); bool *is_pfe, unsigned int *data_unit, const char *storage_type); bool pfk_ext4_allow_merge_bio(const struct bio *bio1, const struct bio *bio2, const struct inode *inode1, Loading security/pfe/pfk_f2fs.c +15 −1 Original line number Diff line number Diff line Loading @@ -116,7 +116,9 @@ int pfk_f2fs_parse_inode(const struct bio *bio, const struct inode *inode, struct pfk_key_info *key_info, enum ice_cryto_algo_mode *algo, bool *is_pfe) bool *is_pfe, unsigned int *data_unit, const char *storage_type) { int ret = 0; Loading @@ -130,6 +132,18 @@ int pfk_f2fs_parse_inode(const struct bio *bio, */ *is_pfe = true; /* Update the dun based upon storage type. * Right now both UFS and eMMC storage uses 4KB dun * for F2FS */ if (storage_type && data_unit) { if (!memcmp(storage_type, "ufs", strlen("ufs")) || !memcmp(storage_type, "sdcc", strlen("sdcc"))) *data_unit = 1 << ICE_CRYPTO_DATA_UNIT_4_KB; else return -EINVAL; } if (!pfk_f2fs_is_ready()) return -ENODEV; Loading Loading
include/crypto/ice.h +12 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,18 @@ struct ice_data_setting { bool encr_bypass; }; /* MSM ICE Crypto Data Unit of target DUN of Transfer Request */ enum ice_crypto_data_unit { ICE_CRYPTO_DATA_UNIT_512_B = 0, ICE_CRYPTO_DATA_UNIT_1_KB = 1, ICE_CRYPTO_DATA_UNIT_2_KB = 2, ICE_CRYPTO_DATA_UNIT_4_KB = 3, ICE_CRYPTO_DATA_UNIT_8_KB = 4, ICE_CRYPTO_DATA_UNIT_16_KB = 5, ICE_CRYPTO_DATA_UNIT_32_KB = 6, ICE_CRYPTO_DATA_UNIT_64_KB = 7, }; typedef void (*ice_error_cb)(void *, u32 error); struct qcom_ice_variant_ops *qcom_ice_get_variant_ops(struct device_node *node); Loading
security/pfe/pfk.c +14 −6 Original line number Diff line number Diff line Loading @@ -75,7 +75,9 @@ typedef int (*pfk_parse_inode_type)(const struct bio *bio, const struct inode *inode, struct pfk_key_info *key_info, enum ice_cryto_algo_mode *algo, bool *is_pfe); bool *is_pfe, unsigned int *data_unit, const char *storage_type); typedef bool (*pfk_allow_merge_bio_type)(const struct bio *bio1, const struct bio *bio2, const struct inode *inode1, Loading Loading @@ -281,21 +283,24 @@ bool pfe_is_inode_filesystem_type(const struct inode *inode, static int pfk_get_key_for_bio(const struct bio *bio, struct pfk_key_info *key_info, enum ice_cryto_algo_mode *algo_mode, bool *is_pfe) bool *is_pfe, unsigned int *data_unit) { const struct inode *inode; enum pfe_type which_pfe; const struct blk_encryption_key *key; char *s_type = NULL; inode = pfk_bio_get_inode(bio); which_pfe = pfk_get_pfe_type(inode); s_type = (char *)pfk_kc_get_storage_type(); if (which_pfe != INVALID_PFE) { /* Encrypted file; override ->bi_crypt_key */ pr_debug("parsing inode %lu with PFE type %d\n", inode->i_ino, which_pfe); return (*(pfk_parse_inode_ftable[which_pfe])) (bio, inode, key_info, algo_mode, is_pfe); (bio, inode, key_info, algo_mode, is_pfe, data_unit, (const char *)s_type); } /* Loading Loading @@ -348,6 +353,7 @@ int pfk_load_key_start(const struct bio *bio, struct pfk_key_info key_info = {NULL, NULL, 0, 0}; enum ice_cryto_algo_mode algo_mode = ICE_CRYPTO_ALGO_MODE_AES_XTS; enum ice_crpto_key_size key_size_type = 0; unsigned int data_unit = 1 << ICE_CRYPTO_DATA_UNIT_512_B; u32 key_index = 0; if (!is_pfe) { Loading @@ -370,7 +376,8 @@ int pfk_load_key_start(const struct bio *bio, return -EINVAL; } ret = pfk_get_key_for_bio(bio, &key_info, &algo_mode, is_pfe); ret = pfk_get_key_for_bio(bio, &key_info, &algo_mode, is_pfe, &data_unit); if (ret != 0) return ret; Loading @@ -380,7 +387,8 @@ int pfk_load_key_start(const struct bio *bio, return ret; ret = pfk_kc_load_key_start(key_info.key, key_info.key_size, key_info.salt, key_info.salt_size, &key_index, async); key_info.salt, key_info.salt_size, &key_index, async, data_unit); if (ret) { if (ret != -EBUSY && ret != -EAGAIN) pr_err("start: could not load key into pfk key cache, error %d\n", Loading Loading @@ -431,7 +439,7 @@ int pfk_load_key_end(const struct bio *bio, bool *is_pfe) if (!pfk_is_ready()) return -ENODEV; ret = pfk_get_key_for_bio(bio, &key_info, NULL, is_pfe); ret = pfk_get_key_for_bio(bio, &key_info, NULL, is_pfe, NULL); if (ret != 0) return ret; Loading
security/pfe/pfk_ext4.c +16 −1 Original line number Diff line number Diff line Loading @@ -141,7 +141,9 @@ int pfk_ext4_parse_inode(const struct bio *bio, const struct inode *inode, struct pfk_key_info *key_info, enum ice_cryto_algo_mode *algo, bool *is_pfe) bool *is_pfe, unsigned int *data_unit, const char *storage_type) { int ret = 0; Loading @@ -155,6 +157,19 @@ int pfk_ext4_parse_inode(const struct bio *bio, */ *is_pfe = true; /* Update dun based upon storage type. * For ext4 FS UFS has 4k dun whereas eMMC * uses 512Byte dun. */ if (storage_type && data_unit) { if (!memcmp(storage_type, "ufs", strlen("ufs"))) *data_unit = 1 << ICE_CRYPTO_DATA_UNIT_4_KB; else if (!memcmp(storage_type, "sdcc", strlen("sdcc"))) *data_unit = 1 << ICE_CRYPTO_DATA_UNIT_512_B; else return -EINVAL; } if (!pfk_ext4_is_ready()) return -ENODEV; Loading
security/pfe/pfk_ext4.h +3 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,9 @@ int pfk_ext4_parse_inode(const struct bio *bio, const struct inode *inode, struct pfk_key_info *key_info, enum ice_cryto_algo_mode *algo, bool *is_pfe); bool *is_pfe, unsigned int *data_unit, const char *storage_type); bool pfk_ext4_allow_merge_bio(const struct bio *bio1, const struct bio *bio2, const struct inode *inode1, Loading
security/pfe/pfk_f2fs.c +15 −1 Original line number Diff line number Diff line Loading @@ -116,7 +116,9 @@ int pfk_f2fs_parse_inode(const struct bio *bio, const struct inode *inode, struct pfk_key_info *key_info, enum ice_cryto_algo_mode *algo, bool *is_pfe) bool *is_pfe, unsigned int *data_unit, const char *storage_type) { int ret = 0; Loading @@ -130,6 +132,18 @@ int pfk_f2fs_parse_inode(const struct bio *bio, */ *is_pfe = true; /* Update the dun based upon storage type. * Right now both UFS and eMMC storage uses 4KB dun * for F2FS */ if (storage_type && data_unit) { if (!memcmp(storage_type, "ufs", strlen("ufs")) || !memcmp(storage_type, "sdcc", strlen("sdcc"))) *data_unit = 1 << ICE_CRYPTO_DATA_UNIT_4_KB; else return -EINVAL; } if (!pfk_f2fs_is_ready()) return -ENODEV; Loading