Re: [PATCH 1/1] zram: reject disksizes that exceed slot index range

Sergey Senozhatsky <[email protected]>
Newsgroups org.kernel.vger.stable,org.kernel.vger.linux-block,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On (26/08/05 11:54), Andrew Morton wrote:
> > From: Longlong Xia <[email protected]>
> > 
> > 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.
> 
> Oh.  Rejecting large devices sounds severe.  Can't we just fix the
> 32-bit trucation issues?

zram historically used u32, I never thought that anyone would want
a 16TB+ device.  But we don't really have reasons to limit it.

I can look into converting to unsigned long, Longlong is already
looking into it.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.