linux/fs/erofs
Michael Bommarito c9b47e6b23 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>
2026-07-27 12:31:11 +08:00
..
compress.h erofs: enable error reporting for z_erofs_fixup_insize() 2025-11-30 23:49:32 +08:00
data.c erofs: remove fscache backend entirely 2026-06-22 11:00:06 +08:00
decompressor_crypto.c erofs: make z_erofs_crypto[] static 2026-01-23 00:00:18 +08:00
decompressor_deflate.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
decompressor_lzma.c erofs: cap LZMA stream pool size 2026-07-27 12:31:11 +08:00
decompressor_zstd.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
decompressor.c erofs: error out obviously illegal extents in advance 2026-04-10 16:53:39 +08:00
dir.c erofs: fix the out-of-bounds nameoff handling for trailing dirents 2026-04-21 16:56:04 +08:00
erofs_fs.h erofs: add sparse support to pcluster layout 2026-06-22 06:48:59 +08:00
fileio.c erofs: set fileio bio failed in short read case 2026-03-17 10:27:31 +08:00
inode.c erofs: handle 48-bit blocks_hi for compressed inodes 2026-06-22 18:50:36 +08:00
internal.h erofs: ensure valid f_path for page cache sharing 2026-07-27 12:31:02 +08:00
ishare.c erofs: ensure valid f_path for page cache sharing 2026-07-27 12:31:02 +08:00
Kconfig erofs: cap LZMA stream pool size 2026-07-27 12:31:11 +08:00
Makefile erofs: remove fscache backend entirely 2026-06-22 11:00:06 +08:00
namei.c erofs: get rid of erofs_kmap_type 2025-03-17 01:21:24 +08:00
super.c erofs: hide "cache_strategy=" for plain filesystems 2026-07-13 16:41:42 +08:00
sysfs.c erofs: avoid some unnecessary #ifdefs 2026-02-03 11:25:55 +08:00
xattr.c erofs: fix metabuf leak in inode xattr initialization 2026-05-20 14:53:14 +08:00
xattr.h erofs: mark inodes without acls in erofs_read_inode() 2026-01-28 15:38:37 +08:00
zdata.c erofs: remove fscache backend entirely 2026-06-22 11:00:06 +08:00
zmap.c erofs: relax sanity check for tail pclusters due to ztailpacking 2026-07-08 15:07:41 +08:00
zutil.c Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses 2026-02-22 08:26:33 -08:00