From 8fda3053257107b27480c7c288232273f267449b Mon Sep 17 00:00:00 2001 From: Satya Tangirala Date: Thu, 7 Nov 2019 16:23:25 -0800 Subject: [PATCH] ANDROID: block: Fix bio_crypt_should_process WARN_ON bio_crypt_should_process would WARN that the bio did not have a keyslot in any keyslot manager even when we were on the decrypt path of blk-crypto, which is a bug. The WARN is now conditional on the caller being responible for handling encryption rather than blk-crypto (i.e. the WARN happens only if this function return true). Bug: 137270441 Test: tested as series; see I26aac0ac7845a9064f28bb1421eb2522828a6dec Change-Id: Id7ef6b066d43bebae146b28edc76e506c7b03235 Signed-off-by: Satya Tangirala --- block/bio-crypt-ctx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/bio-crypt-ctx.c b/block/bio-crypt-ctx.c index aa3571f72ee7..95fd57896466 100644 --- a/block/bio-crypt-ctx.c +++ b/block/bio-crypt-ctx.c @@ -65,8 +65,11 @@ bool bio_crypt_should_process(struct bio *bio, struct request_queue *q) if (!bio_has_crypt_ctx(bio)) return false; + if (q->ksm != bio->bi_crypt_context->processing_ksm) + return false; + WARN_ON(!bio_crypt_has_keyslot(bio)); - return q->ksm == bio->bi_crypt_context->processing_ksm; + return true; } EXPORT_SYMBOL(bio_crypt_should_process);