From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 4F2DB1DE8AE; Sun, 7 Jun 2026 10:08:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780826884; cv=none; b=sWPxX/1uFVqHUEDH47rM6GgU9x99PjNTN0Zi0CYdnlteWQIeBxfv9cLJgkVQuc6lt1rJRlAbIZB/QmguwpeGjwYum2h38rReBypLWsH7mI+IE2c2BqmLNVzKQWNX4vFTuyl8mLctJTrnWbOnRhJss+VP+rG2NTYZHFV8EvBDMg8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780826884; c=relaxed/simple; bh=9Xg+C5PWom7MBWGM3oBELFmo0AGF7VfetdzY70iIA2k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LrgStKoQYFh5hMucUUK5qcYFfTnfisll2TJhSLmYeX67tT9T3nQN54oIxSIbjuYvlQqnNl3YSoU+GmmSUbYTsymjr/e1FcX2rRWLOdVq1k4dBvJg5Q5LqXkzPLAQi3pTTPrzXiGg8P9vwadme/YDETel85hR3ieZVGCnSnqx8yU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=w6PuUBiR; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="w6PuUBiR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 970071F00893; Sun, 7 Jun 2026 10:08:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780826883; bh=FrfBfdS0gsqPIj/OR9dj1+j7K+fmqxD2LpS+4ykt+xU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=w6PuUBiRVlq35o8mKJuiDpA/7t4j+yQX2xSdiV0KVtKcgpCjWCP6VGsE/CPUET8sf UkBIIyKj7Oy7MaFsu/6q4hbebqzjHA6jUheKrZVHgB7RGJFEkUuk/E++qlm738jQon xr4B6sz+NIM83X0tzkfQvc2CzAKlSRjtnxETII00= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mingzhe Zou , Coly Li , Jens Axboe , Sasha Levin Subject: [PATCH 6.18 006/315] bcache: fix uninitialized closure object Date: Sun, 7 Jun 2026 11:56:33 +0200 Message-ID: <20260607095727.739580908@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.528828913@linuxfoundation.org> References: <20260607095727.528828913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mingzhe Zou [ Upstream commit 20a8e451ec1c7e99060b1bbaaad03ce88c39ddb8 ] 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") Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- 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 2f06945533d673..d4ebd13a59f820 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1378,7 +1378,8 @@ static CLOSURE_CALLBACK(cached_dev_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)); -- 2.53.0