From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D9D63611E for ; Thu, 23 Apr 2026 04:55:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776920145; cv=none; b=O93QsqK71CxU4Xktf7xib6esWfG0YlZmNnoCBmzDCNlY5ANU8+4yJue7ZzJXaRUHzJq8x5Rsy/lJqOJYNGDeRSyka47bhGdG/0asu5CANYSiGolw7XkBcS+9acz4YlSs8eWdOSDJ/sqoB0Weo9OM2afvgIVw7ysX4+Dx9u9qhR8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776920145; c=relaxed/simple; bh=RUY7zs3U2LknWW0qy/Zh3yBZlxSTz3al1m/dNRBHwEk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dsNR0Mib6jKeFHJFB3qUUmXljKwcDoU9kZeeuVT+pMhwUGAtwuCeHxEjiR8Owqz7DHuTeAc4rwyo4VgX2robWSOzBJ0ADd+h75grPfCURJF+uKjP7f0jJcMDpFN++jmUe3u11NRthUaHzLRdENGcd3nqMNiXTQNmzBBCEffj4I0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QKvPMJHY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="QKvPMJHY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2040CC2BCB2; Thu, 23 Apr 2026 04:55:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776920145; bh=RUY7zs3U2LknWW0qy/Zh3yBZlxSTz3al1m/dNRBHwEk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QKvPMJHYNzLAhd3Xly9dbWX/cZsYXJg3TmdNkibLwV0o6JGvw6LiGOKzJmDOJHYPE ZSP/UZshJI/xhj4vCmZA1takA1DE8HVuIaOG0p5aDbOXTMpyJEnvlYgrXA65Tegqi3 v4xQ3JG/7cBs4vw5Nb8+44JNOy+K/eRju2J8SMRg= Date: Thu, 23 Apr 2026 06:55:42 +0200 From: Greg KH To: colyli@fnnas.com Cc: stable@vger.kernel.org, Mingzhe Zou , stable@vger.kerenl.org, Jens Axboe Subject: Re: [PATCH] bcache: fix uninitialized closure object Message-ID: <2026042335-frantic-parakeet-f251@gregkh> References: <20260422152113.70337-1-colyli@fnnas.com> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260422152113.70337-1-colyli@fnnas.com> On Wed, Apr 22, 2026 at 11:21:13PM +0800, colyli@fnnas.com wrote: > From: Mingzhe Zou > > In the previous patch ("bcache: fix cached_dev.sb_bio use-after-free and > crash"), we adopted a simple modification suggestion from AI to fix the > use-after-free. > > But in actual testing, we found an extreme case where the device is > stopped before calling bch_write_bdev_super(). > > At this point, struct closure sb_write has not been initialized yet. > For this patch, we ensure that sb_bio has been completed via > sb_write_mutex. > > Signed-off-by: Mingzhe Zou > Signed-off-by: Coly Li > Link: https://patch.msgid.link/20260403042135.2221247-1-colyli@fnnas.com > Fixes: fec114a98b87 ("bcache: fix cached_dev.sb_bio use-after-free and crash") > Cc: stable@vger.kerenl.org > Signed-off-by: Jens Axboe > --- > drivers/md/bcache/super.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c > index 6627a381f65a..97d9adb0bf96 100644 > --- a/drivers/md/bcache/super.c > +++ b/drivers/md/bcache/super.c > @@ -1376,11 +1376,12 @@ static CLOSURE_CALLBACK(cached_dev_free) > /* > * Wait for any pending sb_write to complete before free. > * The sb_bio is embedded in struct cached_dev, so we must > * ensure no I/O is in progress. > */ > - closure_sync(&dc->sb_write); > + down(&dc->sb_write_mutex); > + up(&dc->sb_write_mutex); > > if (dc->sb_disk) > folio_put(virt_to_folio(dc->sb_disk)); > > if (dc->bdev_file) > -- > 2.47.3 > > This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.