Skip to content

Commit b06691a

Browse files
jankaragregkh
authored andcommitted
bfq: Update cgroup information before merging bio
commit ea591cd upstream. When the process is migrated to a different cgroup (or in case of writeback just starts submitting bios associated with a different cgroup) bfq_merge_bio() can operate with stale cgroup information in bic. Thus the bio can be merged to a request from a different cgroup or it can result in merging of bfqqs for different cgroups or bfqqs of already dead cgroups and causing possible use-after-free issues. Fix the problem by updating cgroup information in bfq_merge_bio(). CC: [email protected] Fixes: e21b7a0 ("block, bfq: add full hierarchical scheduling and cgroups support") Tested-by: "yukuai (C)" <[email protected]> Signed-off-by: Jan Kara <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4dfc12f commit b06691a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

block/bfq-iosched.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,10 +2227,17 @@ static bool bfq_bio_merge(struct request_queue *q, struct bio *bio,
22272227

22282228
spin_lock_irq(&bfqd->lock);
22292229

2230-
if (bic)
2230+
if (bic) {
2231+
/*
2232+
* Make sure cgroup info is uptodate for current process before
2233+
* considering the merge.
2234+
*/
2235+
bfq_bic_update_cgroup(bic, bio);
2236+
22312237
bfqd->bio_bfqq = bic_to_bfqq(bic, op_is_sync(bio->bi_opf));
2232-
else
2238+
} else {
22332239
bfqd->bio_bfqq = NULL;
2240+
}
22342241
bfqd->bio_bic = bic;
22352242

22362243
ret = blk_mq_sched_try_merge(q, bio, nr_segs, &free);

0 commit comments

Comments
 (0)