* [alternative-merged] zram-reject-disksizes-that-exceed-slot-index-range.patch removed from -mm tree
@ 2026-08-06 4:13 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-08-06 4:13 UTC (permalink / raw)
To: mm-commits, stable, senozhatsky, xialonglong, akpm
The quilt patch titled
Subject: zram: reject disksizes that exceed slot index range
has been removed from the -mm tree. Its filename was
zram-reject-disksizes-that-exceed-slot-index-range.patch
This patch was dropped because an alternative patch was or shall be merged
------------------------------------------------------
From: Longlong Xia <xialonglong@kylinos.cn>
Subject: zram: reject disksizes that exceed slot index range
Date: Tue, 4 Aug 2026 22:38:32 +0800
zram uses u32 slot indexes, while disksize_store() accepts a u64 size. On
32-bit systems, a disksize larger than U32_MAX pages is truncated when
zram_meta_alloc() assigns the page count to size_t. array_size() then
sees only the truncated count, so a small table can be allocated while the
original capacity is published. Valid I/O within that capacity can
subsequently access beyond zram->table.
The same oversized capacity also lets full-device scanners compare a u32
index with an upper bound larger than U32_MAX, so the index can wrap
instead of terminating.
Reject disksizes larger than U32_MAX pages before aligning and allocating
the table. This keeps the table size, published capacity and slot index
range consistent.
Link: https://lore.kernel.org/20260804143832.146129-1-xialonglong2025@163.com
Fixes: 33863c21e69e ("Staging: zram: Replace ioctls with sysfs interface")
Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Longlong Xia <xialonglong@kylinos.cn>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
drivers/block/zram/zram_drv.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/block/zram/zram_drv.c~zram-reject-disksizes-that-exceed-slot-index-range
+++ a/drivers/block/zram/zram_drv.c
@@ -2881,6 +2881,9 @@ static ssize_t disksize_store(struct dev
return -EBUSY;
}
+ if (disksize > (u64)U32_MAX << PAGE_SHIFT)
+ return -EINVAL;
+
disksize = PAGE_ALIGN(disksize);
if (!zram_meta_alloc(zram, disksize))
return -ENOMEM;
_
Patches currently in -mm which might be from xialonglong@kylinos.cn are
mm-ksm-avoid-missing-ksmd-wakeups-in-ksm_enter.patch
zram-fix-out-of-bounds-access-in-writeback_store.patch
zram-fix-out-of-bounds-access-in-read_block_state.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-06 4:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-06 4:13 [alternative-merged] zram-reject-disksizes-that-exceed-slot-index-range.patch removed from -mm tree Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.