Re: [Kernel Bug] KASAN: slab-use-after-free Read in __blkcg_rstat_flush
From: Jens Axboe
Date: Tue Feb 03 2026 - 09:46:32 EST
On 2/3/26 7:40 AM, Ming Lei wrote:
> On Tue, Feb 03, 2026 at 03:16:43PM +0100, Michal Koutný wrote:
>> On Tue, Feb 03, 2026 at 10:08:07PM +0800, Ming Lei <ming.lei@xxxxxxxxxx> wrote:
>>> I can't parse your question, here blkg_release() simply needs to flush
>>> all stats. Why do you talk about preventing new flush? why is it related
>>> with this UAF?
>>
>> What prevents this fix:
>>
>> --- a/block/blk-cgroup.c
>> +++ b/block/blk-cgroup.c
>> @@ -169,14 +169,6 @@ static void __blkg_release(struct rcu_head *rcu)
>> #ifdef CONFIG_BLK_CGROUP_PUNT_BIO
>> WARN_ON(!bio_list_empty(&blkg->async_bios));
>> #endif
>> - /*
>> - * Flush all the non-empty percpu lockless lists before releasing
>> - * us, given these stat belongs to us.
>> - *
>> - * blkg_stat_lock is for serializing blkg stat update
>> - */
>> - for_each_possible_cpu(cpu)
>> - __blkcg_rstat_flush(blkcg, cpu);
>>
>> /* release the blkcg and parent blkg refs this blkg has been holding */
>> css_put(&blkg->blkcg->css);
>> @@ -195,6 +187,15 @@ static void blkg_release(struct percpu_ref *ref)
>> {
>> struct blkcg_gq *blkg = container_of(ref, struct blkcg_gq, refcnt);
>>
>> + /*
>> + * Flush all the non-empty percpu lockless lists before releasing
>> + * us, given these stat belongs to us.
>> + *
>> + * blkg_stat_lock is for serializing blkg stat update
>> + */
>> + for_each_possible_cpu(cpu)
>> + __blkcg_rstat_flush(blkcg, cpu);
>> +
>> call_rcu(&blkg->rcu_head, __blkg_release);
>> }
>
> This one looks more clever, can you send one formal patch?
I'll drop the previous one for now - I didn't really mind it,
but if we can fix it without, then yeah agree that's better.
--
Jens Axboe