block: make bio_crypt_clone() return an error code
Subsystems (2)
Quoted 9 lines · Satya Tangirala
Quoted 7 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Callers of
bio_clone_fast()may use agfp_maskthat excludesGFP_DIRECT_RECLAIM. For example,map_request()usesGFP_ATOMIC.If this were to happen, the
mempool_alloc()in__bio_crypt_clone()can fail, causing a NULL dereference.The call to
blk_crypto_rq_bio_prep()fromblk_rq_prep_clone()could also fail for the same reason. So we may need to makeblk_crypto_rq_bio_prep()also return a bool and handle the errors in the callers (the only other caller is I thinkblk_mq_bio_to_request(), which explicitly calls the function withGFP_NOIO, so maybe we could explicitly document the fact thatblk_mq_bio_to_requestwill return true when called with agfp_maskth
at includes GFP_DIRECT_RECLAIM, and ignore the return value in blk_mq_bio_to_request()). (And maybe we should document the same for bio_crypt_set_ctx and bio_crypt_clone?)
Agreed.
Except for above suggestions, the patch looks good for me, many thanks.
Quoted 2 lines
Quoted 2 lines
In reality
map_request()currently never has to clone an encryption