From 9c9596e9803d5f512e6e7719069a783c2a261e8f Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Fri, 26 Jun 2020 10:05:38 -0700 Subject: [PATCH] ANDROID: block: fix checking for wrapped key support fscrypt isn't supposed to try to use inline encryption if the key is wrapped but only blk-crypto-fallback is available. This logic got lost when updating to the latest inline encryption patchset. Restore it in blk_crypto_config_supported() where it should be now. Also drop a redundant check from blk_crypto_fallback_bio_prep(). This fix should be folded into ANDROID-block-add-hardware-wrapped-key-support.patch Fixes: c2b86b727a41 ("FROMLIST: Update Inline Encryption from v6 to upstream version of patch series") Change-Id: I4f8a32ee30d700b499da36e55e74d279a86bb779 Signed-off-by: Eric Biggers --- block/blk-crypto-fallback.c | 6 ------ block/blk-crypto.c | 6 ++++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c index 59e07350fc14..077a60baab6a 100644 --- a/block/blk-crypto-fallback.c +++ b/block/blk-crypto-fallback.c @@ -491,12 +491,6 @@ bool blk_crypto_fallback_bio_prep(struct bio **bio_ptr) struct bio_crypt_ctx *bc = bio->bi_crypt_context; struct bio_fallback_crypt_ctx *f_ctx; - if (bc->bc_key->crypto_cfg.is_hw_wrapped) { - pr_warn_once("HW wrapped key cannot be used with fallback.\n"); - bio->bi_status = BLK_STS_NOTSUPP; - return false; - } - if (WARN_ON_ONCE(!tfms_inited[bc->bc_key->crypto_cfg.crypto_mode])) { /* User didn't call blk_crypto_start_using_key() first */ bio->bi_status = BLK_STS_IOERR; diff --git a/block/blk-crypto.c b/block/blk-crypto.c index aa3a05f6ab1d..a5f132444066 100644 --- a/block/blk-crypto.c +++ b/block/blk-crypto.c @@ -367,8 +367,10 @@ EXPORT_SYMBOL_GPL(blk_crypto_init_key); bool blk_crypto_config_supported(struct request_queue *q, const struct blk_crypto_config *cfg) { - return IS_ENABLED(CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK) || - blk_ksm_crypto_cfg_supported(q->ksm, cfg); + if (IS_ENABLED(CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK) && + !cfg->is_hw_wrapped) + return true; + return blk_ksm_crypto_cfg_supported(q->ksm, cfg); } /**