]> git.baikalelectronics.ru Git - kernel.git/commit
block, bfq: fix UAF problem in bfqg_stats_init()
authorZheng Liang <zhengliang6@huawei.com>
Mon, 18 Oct 2021 02:42:25 +0000 (10:42 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 19 Oct 2021 21:18:30 +0000 (15:18 -0600)
commitfe7c40dc8f8d5a6c14e90abf77489a4b2ac8c0cd
treebe8a64de2fcd8220fb80f76058341f1de37da8dd
parentd655f145d10ac1d44af114c4bb0bd9afc415e5b7
block, bfq: fix UAF problem in bfqg_stats_init()

In bfq_pd_alloc(), the function bfqg_stats_init() init bfqg. If
blkg_rwstat_init() init bfqg_stats->bytes successful and init
bfqg_stats->ios failed, bfqg_stats_init() return failed, bfqg will
be freed. But blkg_rwstat->cpu_cnt is not deleted from the list of
percpu_counters. If we traverse the list of percpu_counters, It will
have UAF problem.

we should use blkg_rwstat_exit() to cleanup bfqg_stats bytes in the
above scenario.

Fixes: commit 41cf92aeb0d ("bfq-iosched: stop using blkg->stat_bytes and ->stat_ios")
Signed-off-by: Zheng Liang <zhengliang6@huawei.com>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20211018024225.1493938-1-zhengliang6@huawei.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bfq-cgroup.c