Skip to contentSkip to conversation

zram-fix-out-of-bounds-access-in-read_block_state.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Aug 25 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: zram: fix out-of-bounds access in read_block_state()
has been removed from the -mm tree. Its filename was
zram-fix-out-of-bounds-access-in-read_block_state.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Longlong Xia <[email protected]>
Subject: zram: fix out-of-bounds access in read_block_state()
Date: Tue, 4 Aug 2026 14:59:19 +0800

read_block_state() calculates nr_pages before taking dev_lock. If the device is reset and reinitialized with a smaller disksize before lock acquisition, nr_pages still describes the old table. The subsequent loop can then call slot_lock() past the end of the newly allocated table.

Read disksize after acquiring dev_lock and checking that the device is initialized. The read lock then keeps the table and its bound stable for the duration of the scan.

Fixes c0265342bff4 ("zram: introduce zram memory tracking")
Assisted-by Codex:gpt-5.6-sol
Cc Jens Axboe <[email protected]>
Cc Minchan Kim <[email protected]>

---

 drivers/block/zram/zram_drv.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/block/zram/zram_drv.c renamed from drivers/block/zram/zram_drv.c~zram-fix-out-of-bounds-access-in-read_block_state +3 -1
@@ -1543,7 +1543,7 @@ static ssize_t read_block_state(struct f
 	char *kbuf;
 	ssize_t index, written = 0;
 	struct zram *zram = file->private_data;
-	unsigned long nr_pages = zram->disksize >> PAGE_SHIFT;
+	unsigned long nr_pages;
 
 	kbuf = kvmalloc(count, GFP_KERNEL);
 	if (!kbuf)
@@ -1555,6 +1555,8 @@ static ssize_t read_block_state(struct f
 		return -EINVAL;
 	}
 
+	nr_pages = zram->disksize >> PAGE_SHIFT;
+
 	for (index = *ppos; index < nr_pages; index++) {
 		int copied;
 

_

Patches currently in -mm which might be from [email protected] are

mm-hugetlb-keep-max_huge_pages-when-dissolving-surplus-folios.patch