Skip to content

Commit 1f99b8a

Browse files
committed
md/bitmap: fix GPF in write_page caused by resize race
jira KERNEL-1052 cve CVE-2026-43163 Rebuild_History Non-Buildable kernel-5.14.0-687.10.1.el9_8 commit-author Jack Wang <jinpu.wang@ionos.com> commit 46ef85f 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: d60b479 ("md/bitmap: add bitmap_resize function to allow bitmap resizing.") Signed-off-by: Jack Wang <jinpu.wang@ionos.com> Signed-off-by: Yu Kuai <yukuai@fnnas.com> (cherry picked from commit 46ef85f) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent fcc1d8e commit 1f99b8a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/md/md-bitmap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2476,6 +2476,7 @@ static int __bitmap_resize(struct bitmap *bitmap, sector_t blocks,
24762476
memcpy(page_address(store.sb_page),
24772477
page_address(bitmap->storage.sb_page),
24782478
sizeof(bitmap_super_t));
2479+
mutex_lock(&bitmap->mddev->bitmap_info.mutex);
24792480
spin_lock_irq(&bitmap->counts.lock);
24802481
md_bitmap_file_unmap(&bitmap->storage);
24812482
bitmap->storage = store;
@@ -2583,7 +2584,7 @@ static int __bitmap_resize(struct bitmap *bitmap, sector_t blocks,
25832584
set_page_attr(bitmap, i, BITMAP_PAGE_DIRTY);
25842585
}
25852586
spin_unlock_irq(&bitmap->counts.lock);
2586-
2587+
mutex_unlock(&bitmap->mddev->bitmap_info.mutex);
25872588
if (!init) {
25882589
__bitmap_unplug(bitmap);
25892590
bitmap->mddev->pers->quiesce(bitmap->mddev, 0);

0 commit comments

Comments
 (0)