]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
blk-mq: make sure active queue usage is held for bio_integrity_prep()
authorChristoph Hellwig <hch@infradead.org>
Mon, 13 Nov 2023 03:52:31 +0000 (11:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Jan 2024 16:10:30 +0000 (17:10 +0100)
commitb5c8e0ff76d10f6bf70a7237678f27c20cf59bc9
tree601d9b76ee9c9dcbc6af4a310f434e9873bca742
parent803fb6109fcfa939d78907ad34161a720b37848d
blk-mq: make sure active queue usage is held for bio_integrity_prep()

[ Upstream commit b0077e269f6c152e807fdac90b58caf012cdbaab ]

blk_integrity_unregister() can come if queue usage counter isn't held
for one bio with integrity prepared, so this request may be completed with
calling profile->complete_fn, then kernel panic.

Another constraint is that bio_integrity_prep() needs to be called
before bio merge.

Fix the issue by:

- call bio_integrity_prep() with one queue usage counter grabbed reliably

- call bio_integrity_prep() before bio merge

Fixes: 900e080752025f00 ("block: move queue enter logic into blk_mq_submit_bio()")
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Tested-by: Yi Zhang <yi.zhang@redhat.com>
Link: https://lore.kernel.org/r/20231113035231.2708053-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk-mq.c