[PATCH] erofs-utils: lib: validate algorithm format before use in z_erofs_map_blocks_ext

Gao Xiang hsiangkao at linux.alibaba.com
Sun Mar 15 21:39:34 AEDT 2026



On 2026/3/15 15:28, Utkal Singh wrote:
> The fmt field read from the on-disk extent is used directly as an index
> without bounds checking.  A crafted image could set fmt to a value
> exceeding Z_EROFS_COMPRESSION_MAX, causing out-of-bounds access.
> 
> Add a bounds check before using fmt-1 as algorithm format index,
> returning -EOPNOTSUPP for unknown algorithm formats.
> 
> Signed-off-by: Utkal Singh <singhutkal015 at gmail.com>

The following commit should be backported instead:

commit 131897c65e2b
Author: Gao Xiang <xiang at kernel.org>
Date:   Sun Aug 24 23:11:57 2025 +0800

     erofs: fix invalid algorithm for encoded extents

     The current algorithm sanity checks do not properly apply to new
     encoded extents.

     Unify the algorithm check with Z_EROFS_COMPRESSION(_RUNTIME)_MAX
     and ensure consistency with sbi->available_compr_algs.

     Reported-and-tested-by: syzbot+5a398eb460ddaa6f242f at syzkaller.appspotmail.com
     Closes: https://lore.kernel.org/r/68a8bd20.050a0220.37038e.005a.GAE@google.com
     Fixes: 1d191b4ca51d ("erofs: implement encoded extent metadata")
     Thanks-to: Edward Adam Davis <eadavis at qq.com>
     Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>


More information about the Linux-erofs mailing list