]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2024 13:12:01 +0000 (15:12 +0200)
commit63a07379fdb6c72450cb05294461c6016b8b7726
treeaba7f5e397a8473f03e96981a01571a1c5372d14
parent40a6e660d2a3a7a5cb99f0b8ff4fb41bad039f68
block, bfq: fix uaf for accessing waker_bfqq after splitting

commit 1ba0403ac6447f2d63914fb760c44a3b19c44eaf upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
block/bfq-iosched.c