Yu Kuai e2f2a39452 block, bfq: fix uaf for 'stable_merge_bfqq'
Before commit fd571df0ac5b ("block, bfq: turn bfqq_data into an array
in bfq_io_cq"), process reference is read before bfq_put_stable_ref(),
and it's safe if bfq_put_stable_ref() put the last reference, because
process reference will be 0 and 'stable_merge_bfqq' won't be accessed
in this case. However, the commit changed the order and  will cause
uaf for 'stable_merge_bfqq'.

In order to emphasize that bfq_put_stable_ref() can drop the last
reference, fix the problem by moving bfq_put_stable_ref() to the end of
bfq_setup_stable_merge().

Fixes: fd571df0ac5b ("block, bfq: turn bfqq_data into an array in bfq_io_cq")
Reported-and-tested-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Link: https://lore.kernel.org/linux-block/20230307071448.rzihxbm4jhbf5krj@shindev/
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-03-08 07:34:50 -07:00
..
2023-02-02 22:33:34 -08:00
2023-02-20 14:27:21 -08:00
2023-03-03 10:21:39 -08:00
2023-02-20 14:27:21 -08:00
2023-03-03 10:21:39 -08:00
2022-12-13 10:43:59 -08:00
2023-03-03 10:21:39 -08:00
2023-03-03 10:21:39 -08:00
2022-12-16 03:54:54 -08:00
2022-02-02 07:49:59 -07:00
2023-01-05 08:50:10 -07:00
2022-03-07 12:48:35 -07:00