From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8295E33030C for ; Tue, 3 Feb 2026 11:11:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770117092; cv=none; b=H7M2jlUuJxNlkI8OvQ6bt4FRGvVwn6QACl1QEA1/7ui4wNvOGh+Rdb8qAimTo8Q5KOxShNXU/6ROWgBkGLE8VxeKMJ8E1e8Cw1O7GMzZCUfr2lAyYpfWY11xTevFL3sKKgebhiFiI7LuZTkbetPRhExa899K1XKnyIvPBZOdz9k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770117092; c=relaxed/simple; bh=JDwzG10CjdMNzaVAVuClyAr1f5kyfccGkv+CaOIDDwE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QDM9dp9KFIOeTiGVQqavDy4vohCSAHk7Ina7E6Cvm7IhycMiPZ93QF159H3GNbDlPGKAmK4kHvEPDSTXsdogdoJbdF8FKffT6DdibOdMKshG8GDCCacZfHKgMNravpb4NaqdK03wLvE24Q9CV1hTQnuOp8DL8Bkuf7bi0SOf6CI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=YKWVu234; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YKWVu234" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770117089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HIueVBBCXcriHzWqfI+eCbpC9/+UTkWA0vibOjUyafk=; b=YKWVu2348sP37G37JJ/A9SZV1QTyyJ+mXAU8+nqPN5+EASxNVLMjdGsmcaRuyvwT9Nqb8w NQaPKLWNG8+dIa+FNCkTrhlSqJwMpTlgFqpxg+qe7uM8+VEcuZFidHAGqqLS8lRP39Hs8r NLajXzuaU1PhaWV/ntrN4LsTCEGa2kA= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-140-qQvQUZrJMKSyWnjugSNfKA-1; Tue, 03 Feb 2026 06:11:25 -0500 X-MC-Unique: qQvQUZrJMKSyWnjugSNfKA-1 X-Mimecast-MFC-AGG-ID: qQvQUZrJMKSyWnjugSNfKA_1770117083 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F10FA1956046; Tue, 3 Feb 2026 11:11:22 +0000 (UTC) Received: from fedora (unknown [10.72.116.35]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2B5B61956053; Tue, 3 Feb 2026 11:11:16 +0000 (UTC) Date: Tue, 3 Feb 2026 19:11:11 +0800 From: Ming Lei To: Michal =?iso-8859-1?Q?Koutn=FD?= Cc: =?utf-8?B?5p2O6b6Z5YW0?= , syzkaller@googlegroups.com, tj@kernel.org, josef@toxicpanda.com, axboe@kernel.dk, cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai@fnnas.com Subject: Re: [Kernel Bug] KASAN: slab-use-after-free Read in __blkcg_rstat_flush Message-ID: References: Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 On Tue, Feb 03, 2026 at 11:54:34AM +0100, Michal Koutný wrote: > Hello. > > On Tue, Feb 03, 2026 at 11:03:01AM +0800, Ming Lei wrote: > > Can you try the following patch? > > I think it'd work thanks to the rcu_read_lock() in > __blkcg_rstat_flush(). However, the chaining of RCU callbacks makes > predictability of the release path less deterministic and may be > unnecessary. RCU supports this way, here is just 2-stage RCU chain, and everything is deterministic. > > What about this: > > index 3cffb68ba5d87..e2f51e3bf04ef 100644 > --- a/tmp/b.c > +++ b/tmp/a.c > @@ -1081,6 +1081,7 @@ static void __blkcg_rstat_flush(struct blkcg *blkcg, int cpu) > smp_mb(); > > WRITE_ONCE(bisc->lqueued, false); > + blkg_put(blkg); > if (bisc == &blkg->iostat) > goto propagate_up; /* propagate up to parent only */ > > @@ -2220,8 +2221,10 @@ void blk_cgroup_bio_start(struct bio *bio) > if (!READ_ONCE(bis->lqueued)) { > struct llist_head *lhead = this_cpu_ptr(blkcg->lhead); > > + blkg_get(bio->bi_blkg); > llist_add(&bis->lnode, lhead); > WRITE_ONCE(bis->lqueued, true); > + I thought about this way, but ->lqueued is lockless, and in theory the `blkg_iostat_set` can be added again after WRITE_ONCE(bisc->lqueued, false) happens, so this way looks fragile. Thanks, Ming