]> 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>
Fri, 4 Oct 2024 14:29:00 +0000 (16:29 +0200)
commit0780451f03bf518bc032a7c584de8f92e2d39d7f
treef8e14d868bbe39c1c292727eff07bce5b615ad5c
parent0c9b52bfee0ebf0bfbeb666c9c60e6e2d34aa1e6
block, bfq: fix uaf for accessing waker_bfqq after splitting

[ Upstream commit 1ba0403ac6447f2d63914fb760c44a3b19c44eaf ]

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: Sasha Levin <sashal@kernel.org>
block/bfq-iosched.c