]> www.infradead.org Git - users/jedix/linux-maple.git/commit
block, bfq: fix uaf for accessing waker_bfqq after splitting
authorYu Kuai <yukuai3@huawei.com>
Mon, 9 Sep 2024 13:41:48 +0000 (21:41 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 10 Sep 2024 22:32:09 +0000 (16:32 -0600)
commit1ba0403ac6447f2d63914fb760c44a3b19c44eaf
treed9d4c82ad7fb1b227949d2c76fcb893d94c0122b
parent29390bb5661d49d10424ad8e915230de1f7074c9
block, bfq: fix uaf for accessing waker_bfqq after splitting

After commit 42c306ed7233 ("block, bfq: don't break merge chain in
bfq_split_bfqq()"), if the current procress is the last holder of bfqq,
the bfqq can be freed after bfq_split_bfqq(). Hence recored the bfqq and
then access bfqq->waker_bfqq may trigger UAF. What's more, the waker_bfqq
may in the merge chain of bfqq, hence just recored waker_bfqq is still
not safe.

Fix the problem by adding a helper bfq_waker_bfqq() to check if
bfqq->waker_bfqq is in the merge chain, and current procress is the only
holder.

Fixes: 42c306ed7233 ("block, bfq: don't break merge chain in bfq_split_bfqq()")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20240909134154.954924-2-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bfq-iosched.c