mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 22:02:02 +00:00
bfq: Make sure bfqg for which we are queueing requests is online
commit075a53b78b
upstream. Bios queued into BFQ IO scheduler can be associated with a cgroup that was already offlined. This may then cause insertion of this bfq_group into a service tree. But this bfq_group will get freed as soon as last bio associated with it is completed leading to use after free issues for service tree users. Fix the problem by making sure we always operate on online bfq_group. If the bfq_group associated with the bio is not online, we pick the first online parent. CC: stable@vger.kernel.org Fixes:e21b7a0b98
("block, bfq: add full hierarchical scheduling and cgroups support") Tested-by: "yukuai (C)" <yukuai3@huawei.com> Signed-off-by: Jan Kara <jack@suse.cz> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20220401102752.8599-9-jack@suse.cz Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3439a8271b
commit
97bd6c56bd
1 changed files with 12 additions and 3 deletions
|
@ -612,10 +612,19 @@ static void bfq_link_bfqg(struct bfq_data *bfqd, struct bfq_group *bfqg)
|
||||||
struct bfq_group *bfq_bio_bfqg(struct bfq_data *bfqd, struct bio *bio)
|
struct bfq_group *bfq_bio_bfqg(struct bfq_data *bfqd, struct bio *bio)
|
||||||
{
|
{
|
||||||
struct blkcg_gq *blkg = bio->bi_blkg;
|
struct blkcg_gq *blkg = bio->bi_blkg;
|
||||||
|
struct bfq_group *bfqg;
|
||||||
|
|
||||||
if (!blkg)
|
while (blkg) {
|
||||||
return bfqd->root_group;
|
bfqg = blkg_to_bfqg(blkg);
|
||||||
return blkg_to_bfqg(blkg);
|
if (bfqg->online) {
|
||||||
|
bio_associate_blkg_from_css(bio, &blkg->blkcg->css);
|
||||||
|
return bfqg;
|
||||||
|
}
|
||||||
|
blkg = blkg->parent;
|
||||||
|
}
|
||||||
|
bio_associate_blkg_from_css(bio,
|
||||||
|
&bfqg_to_blkg(bfqd->root_group)->blkcg->css);
|
||||||
|
return bfqd->root_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue