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 ED8B4408551; Sat, 28 Feb 2026 17:44:10 +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=1772300651; cv=none; b=CmqpgTbW46RspyOAtiqKUVFtcvPQ4o0/eRzAzklhso4kLctEn56bb4SrPf66CG4sfasYfyPavgWdKr4fN/buBDxHRqMeNSj+MvVKFBpyKINM/U6vMD43Ni1Ck+ho/L40z1SxOTo7S76OIKEP90s3F2kAmeUQaoebA7MDtHKUPLI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300651; c=relaxed/simple; bh=Aqc0C09FHgHvnnRPqXKzOg3T8s79hVLPi8LPOoDVkRM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fYcybQYtbEhxmhC+iaEcrHbFDwLc8zbqDKuW3FrObzlg1c8aEOFFgx5ZQY+Lvux8m3qovSa7oTjNiJCF9Ln/eG+J+5RuI4GtaD5X7noTooN8uW5RSZiq/lUzJ3ha5bV/OuvN9LNbc32xZg259AAf0PGN/hmbm87ubcTwStJQbKw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ALHcG4Oe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ALHcG4Oe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E6E8C19423; Sat, 28 Feb 2026 17:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772300650; bh=Aqc0C09FHgHvnnRPqXKzOg3T8s79hVLPi8LPOoDVkRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ALHcG4Oe1NPSkVnKtOaodWgqKH0wdbvQWX0q0mgTUGPJVTbTXDJWNyo0+55dyta/w 3FdE+p1TmdtAcP4M6wxvhC3AXByaExrD01qUudr0XlmSSpWMWnh7gbUdut3EKrrmCW M6xz34JswIcYdb+uOy+tfjXVBCj1VXlWF+yHQwzS3W9rJcAgv8Avkzu4fEdguezNJc NOChhZ3QOdJ5MlGLTdDsiQQRTHsBN3okrwf0ALo9oRuBsCQr436jQWR2kei1UwOFhP Lt15623C43lvBUOODPbi0c72WD8bzSqYfUtnVcyALTeicHEvKMWp8bAAuWfKoIJbiX oMlRLXwpxIHFA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jack Wang , Yu Kuai , Sasha Levin Subject: [PATCH 6.19 692/844] md/bitmap: fix GPF in write_page caused by resize race Date: Sat, 28 Feb 2026 12:30:05 -0500 Message-ID: <20260228173244.1509663-693-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260228173244.1509663-1-sashal@kernel.org> References: <20260228173244.1509663-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Jack Wang [ Upstream commit 46ef85f854dfa9d5226b3c1c46493d79556c9589 ] A General Protection Fault occurs in write_page() during array resize: RIP: 0010:write_page+0x22b/0x3c0 [md_mod] This is a use-after-free race between bitmap_daemon_work() and __bitmap_resize(). The daemon iterates over `bitmap->storage.filemap` without locking, while the resize path frees that storage via md_bitmap_file_unmap(). `quiesce()` does not stop the md thread, allowing concurrent access to freed pages. Fix by holding `mddev->bitmap_info.mutex` during the bitmap update. Link: https://lore.kernel.org/linux-raid/20260120102456.25169-1-jinpu.wang@ionos.com Closes: https://lore.kernel.org/linux-raid/CAMGffE=Mbfp=7xD_hYxXk1PAaCZNSEAVeQGKGy7YF9f2S4=NEA@mail.gmail.com/T/#u Cc: stable@vger.kernel.org Fixes: d60b479d177a ("md/bitmap: add bitmap_resize function to allow bitmap resizing.") Signed-off-by: Jack Wang Signed-off-by: Yu Kuai Signed-off-by: Sasha Levin --- drivers/md/md-bitmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 84b7e2af6dbaa..7bb56d0491a2f 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -2453,6 +2453,7 @@ static int __bitmap_resize(struct bitmap *bitmap, sector_t blocks, memcpy(page_address(store.sb_page), page_address(bitmap->storage.sb_page), sizeof(bitmap_super_t)); + mutex_lock(&bitmap->mddev->bitmap_info.mutex); spin_lock_irq(&bitmap->counts.lock); md_bitmap_file_unmap(&bitmap->storage); bitmap->storage = store; @@ -2560,7 +2561,7 @@ static int __bitmap_resize(struct bitmap *bitmap, sector_t blocks, set_page_attr(bitmap, i, BITMAP_PAGE_DIRTY); } spin_unlock_irq(&bitmap->counts.lock); - + mutex_unlock(&bitmap->mddev->bitmap_info.mutex); if (!init) { __bitmap_unplug(bitmap); bitmap->mddev->pers->quiesce(bitmap->mddev, 0); -- 2.51.0