]> git.ipfire.org Git - thirdparty/linux.git/commit
erofs: separate plain and compressed filesystems formally
authorGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 29 Jan 2026 02:41:25 +0000 (10:41 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 3 Feb 2026 03:05:57 +0000 (11:05 +0800)
commit7cef3c8341940febf75db6c25199cd83fb74d52f
tree45ab09b346f071fff426792f75f1f69a7dd96d5b
parent72558e2bed272b5ca8771ba14390160c876207f4
erofs: separate plain and compressed filesystems formally

The EROFS on-disk format uses a tiny, plain metadata design that
prioritizes performance and minimizes complex inconsistencies against
common writable disk filesystems (almost all serious metadata
inconsistency cannot happen in well-designed immutable filesystems like
EROFS). EROFS deliberately avoids artificial design flaws to eliminate
serious security risks from untrusted remote sources by design,
although human-made implementation bugs can still happen sometimes.

Currently, there is no strict check to prevent compressed inodes,
especially LZ4-compressed inodes, from being read in plain filesystems.

Starting with erofs-utils 1.0 and Linux 5.3, LZ4_0PADDING sb feature
is automatically enabled for LZ4-compressed EROFS images to support
in-place decompression. Furthermore, since Linux 5.4 LTS is no longer
supported, we no longer need to handle ancient LZ4-compressed EROFS
images generated by erofs-utils prior to 1.0.

To formally distinguish different filesystem types for improved
security:

 - Use the presence of LZ4_0PADDING or a non-zero
   `dsb->u1.lz4_max_distance` as a marker for compressed filesystems
   containing LZ4-compressed inodes only;

 - For other algorithms, use `dsb->u1.available_compr_algs` bitmap.

Note: LZ4_0PADDING has been supported since Linux 5.4 (the first formal
kernel version), so exposing it via sysfs is no longer necessary and is
now deprecated (but remain it for five more years until 2031):

  `dsb->u1` has been strictly non-zero for all EROFS images containing
  compressed inodes starting with erofs-utils v1.3 and it is actually
  a much better marker for compressed filesystems.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Documentation/ABI/testing/sysfs-fs-erofs
fs/erofs/decompressor.c
fs/erofs/erofs_fs.h
fs/erofs/inode.c
fs/erofs/internal.h
fs/erofs/super.c
fs/erofs/sysfs.c