block: fix dio leak on integrity metadata mapping failure#847
Open
blktests-ci[bot] wants to merge 1 commit into
Open
block: fix dio leak on integrity metadata mapping failure#847blktests-ci[bot] wants to merge 1 commit into
blktests-ci[bot] wants to merge 1 commit into
Conversation
In __blkdev_direct_IO(), when bio_integrity_map_iter() fails on a bio after earlier bios have already been submitted, the goto fail path frees only the current bio and returns the error directly to the caller. This is incorrect because the fail label does not decrement dio->ref for the current bio, and does not return -EIOCBQUEUED. The in-flight bios each hold a reference via dio->ref, which was incremented before their submission. When they eventually complete, blkdev_bio_end_io() decrements dio->ref but it will never reach zero since the failing bio did not participate in the completion mechanism. This permanently leaks the embedded dio/bio structure from blkdev_dio_pool. The trigger is deterministic: a multi-segment direct IO with integrity metadata where the user-provided metadata buffer is too small for all segments causes bio_integrity_map_iter() to return -EINVAL on a later bio after earlier bios are already in flight. Fix this by handling the integrity mapping failure the same way blkdev_iov_iter_get_pages() failure is handled: set bi_status and call bio_endio() to enter the normal completion path, then break out of the loop so the function returns -EIOCBQUEUED for async IO. Fixes: 3d8b5a2 ("block: add support to pass user meta buffer") Cc: stable@vger.kernel.org Signed-off-by: Aaron Esau <aaron1esau@gmail.com>
Author
|
Upstream branch: 70eda68 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request for series with
subject: block: fix dio leak on integrity metadata mapping failure
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1096392