Files
linux-stable-mirror/fs
Gao XiangandGreg Kroah-Hartman 80a23c6d1a erofs: fix the out-of-bounds nameoff handling for trailing dirents
commit d18a3b5d33 upstream.

Currently we already have boundary-checks for nameoffs, but the trailing
dirents are special since the namelens are calculated with strnlen()
with unchecked nameoffs.

If a crafted EROFS has a trailing dirent with nameoff >= maxsize,
maxsize - nameoff can underflow, causing strnlen() to read past the
directory block.

nameoff0 should also be verified to be a multiple of
`sizeof(struct erofs_dirent)` as well [1].

[1] https://sashiko.dev/#/patchset/20260416063511.3173774-1-hsiangkao%40linux.alibaba.com

Fixes: 3aa8ec716e ("staging: erofs: add directory operations")
Fixes: 33bac91284 ("staging: erofs: keep corrupted fs from crashing kernel in erofs_readdir()")
Reported-by: Yuhao Jiang <danisjiang@gmail.com>
Reported-by: Junrui Luo <moonafterrain@outlook.com>
Closes: https://lore.kernel.org/r/A0FD7E0F-7558-49B0-8BC8-EB1ECDB2479A@outlook.com
Cc: stable@vger.kernel.org
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-06-01 17:38:46 +02:00
..
2026-03-04 07:20:25 -05:00
2026-01-11 15:19:22 +01:00
2026-01-17 16:39:33 +01:00
2025-10-02 13:40:41 +02:00
2025-03-28 21:58:51 +01:00
2025-10-29 14:04:35 +01:00
2026-01-11 15:19:22 +01:00