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 6A945331203 for ; Wed, 22 Apr 2026 15:21:30 +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=1776871290; cv=none; b=bYf+aVZWQmLiaSdJcNUjwMaU4x0kNtUr5JTLKJJWPh7lQKbLmPcgCfkQuv/gyZA1BY9KQm1chaBnIW8DDqGG5ZSpqqPf+JtNucF3ljNx/cXJFEk065rBLFGH6JDcQxpNnNkDfEnL9f9/cJrip/R3UrVGNo3VQbHmwuybWqns5oA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776871290; c=relaxed/simple; bh=YPB5tA+EAgxAuQetKNnPte/y4maHeb/3UUyvG/aeaKI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DUxuXZrt/DYshhzufYZFkczZBuK5LXQEWUGFqjNzR9SuX++9zMdpmAU6tBxv5EHvG+Rrww8TcICv6yQmVhuzGwY3XQ73C36IgqCc9rKfDh3zwKM7FJr744TnjXQWWp1kQCbp6kIrFB7tw0NG7X2kB8iO2oOayI3lRniDfGx2mrI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F0CAC2BCB2; Wed, 22 Apr 2026 15:21:27 +0000 (UTC) From: colyli@fnnas.com To: stable@vger.kernel.org Cc: Mingzhe Zou , Coly Li , stable@vger.kerenl.org, Jens Axboe Subject: [PATCH] bcache: fix uninitialized closure object Date: Wed, 22 Apr 2026 23:21:13 +0800 Message-ID: <20260422152113.70337-1-colyli@fnnas.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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