All of lore.kernel.org
 help / color / mirror / Atom feed
* + zram-reject-disksizes-that-exceed-slot-index-range.patch added to mm-new branch
@ 2026-08-05 18:48 Andrew Morton
  2026-08-06  3:41 ` Sergey Senozhatsky
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Morton @ 2026-08-05 18:48 UTC (permalink / raw)
  To: mm-commits, stable, senozhatsky, xialonglong, akpm


The patch titled
     Subject: zram: reject disksizes that exceed slot index range
has been added to the -mm mm-new branch.  Its filename is
     zram-reject-disksizes-that-exceed-slot-index-range.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/zram-reject-disksizes-that-exceed-slot-index-range.patch

This patch will later appear in the mm-new branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews.  Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.

The mm-new branch of mm.git is not included in linux-next

If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
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
zram-reject-disksizes-that-exceed-slot-index-range.patch


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: + zram-reject-disksizes-that-exceed-slot-index-range.patch added to mm-new branch
  2026-08-05 18:48 + zram-reject-disksizes-that-exceed-slot-index-range.patch added to mm-new branch Andrew Morton
@ 2026-08-06  3:41 ` Sergey Senozhatsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sergey Senozhatsky @ 2026-08-06  3:41 UTC (permalink / raw)
  To: Andrew Morton; +Cc: mm-commits, stable, senozhatsky, xialonglong

On (26/08/05 11:48), Andrew Morton wrote:
> The patch titled
>      Subject: zram: reject disksizes that exceed slot index range
> has been added to the -mm mm-new branch.  Its filename is
>      zram-reject-disksizes-that-exceed-slot-index-range.patch
> 
> This patch will shortly appear at
>      https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/zram-reject-disksizes-that-exceed-slot-index-range.patch

This patch is superseded by
https://lore.kernel.org/linux-kernel/ 20260806031640.536615-1-senozhatsky@chromium.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-06  3:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05 18:48 + zram-reject-disksizes-that-exceed-slot-index-range.patch added to mm-new branch Andrew Morton
2026-08-06  3:41 ` Sergey Senozhatsky

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.