mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
erofs: cap LZMA stream pool size
fs/erofs/decompressor_lzma.c sizes the module-global MicroLZMA stream
pool from num_possible_cpus() when the lzma_streams module parameter is
unset, then z_erofs_load_lzma_config() preallocates one image-supplied
dictionary per stream, accepting dictionaries up to 8 MiB. On high-CPU
systems, a small EROFS image can pin hundreds of MiB of vmalloc-backed
decoder state until the erofs module is unloaded.
Impact: An EROFS image mounted by the system can pin up to 8 MiB of
vmalloc memory per LZMA stream, either as intended or unexpectedly.
Bound the default stream count by a new
CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS option, default 16, so the
worst-case default preallocation is 128 MiB if the number of CPUs is no
less than 16 while preserving the existing per-image dictionary limit.
An explicit lzma_streams module parameter is still honoured as-is, so
administrators who deliberately size the pool are not affected.
Fixes: 622ceaddb7 ("erofs: lzma compression support")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
This commit is contained in:
parent
96b2dbbe58
commit
c9b47e6b23
|
|
@ -131,6 +131,20 @@ config EROFS_FS_ZIP_LZMA
|
||||||
|
|
||||||
Say N if you want to disable LZMA compression support.
|
Say N if you want to disable LZMA compression support.
|
||||||
|
|
||||||
|
config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
|
||||||
|
int "EROFS LZMA default maximum decompression streams"
|
||||||
|
depends on EROFS_FS_ZIP_LZMA
|
||||||
|
range 1 NR_CPUS
|
||||||
|
default 16
|
||||||
|
help
|
||||||
|
By default EROFS allocates one LZMA decompression stream per CPU.
|
||||||
|
Each stream can hold a dictionary of up to 8 MiB taken from the
|
||||||
|
mounted image, so on systems with many CPUs this can reserve a lot
|
||||||
|
of memory. This caps the default; the lzma_streams module parameter
|
||||||
|
still overrides it.
|
||||||
|
|
||||||
|
If unsure, keep the default of 16.
|
||||||
|
|
||||||
config EROFS_FS_ZIP_DEFLATE
|
config EROFS_FS_ZIP_DEFLATE
|
||||||
bool "EROFS DEFLATE compressed data support"
|
bool "EROFS DEFLATE compressed data support"
|
||||||
depends on EROFS_FS_ZIP
|
depends on EROFS_FS_ZIP
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,8 @@ static int __init z_erofs_lzma_init(void)
|
||||||
|
|
||||||
/* by default, use # of possible CPUs instead */
|
/* by default, use # of possible CPUs instead */
|
||||||
if (!z_erofs_lzma_nstrms)
|
if (!z_erofs_lzma_nstrms)
|
||||||
z_erofs_lzma_nstrms = num_possible_cpus();
|
z_erofs_lzma_nstrms = min_t(unsigned int, num_possible_cpus(),
|
||||||
|
CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS);
|
||||||
|
|
||||||
for (i = 0; i < z_erofs_lzma_nstrms; ++i) {
|
for (i = 0; i < z_erofs_lzma_nstrms; ++i) {
|
||||||
struct z_erofs_lzma *strm = kzalloc_obj(*strm);
|
struct z_erofs_lzma *strm = kzalloc_obj(*strm);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user