]> www.infradead.org Git - users/jedix/linux-maple.git/commit
erofs: fix file handle encoding for 64-bit NIDs
authorHongbo Li <lihongbo22@huawei.com>
Wed, 7 May 2025 09:40:15 +0000 (09:40 +0000)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 15 May 2025 02:38:12 +0000 (10:38 +0800)
commit510de8363f2c3d8e67fa9dfb2366e821382036e0
tree08a769612d4ca4bdfce1c70be9531ed400e321fa
parent82f2b0b97b36ee3fcddf0f0780a9a0825d52fec3
erofs: fix file handle encoding for 64-bit NIDs

EROFS uses NID to indicate the on-disk inode offset, which can
exceed 32 bits. However, the default encode_fh uses the ino32,
thus it doesn't work if the image is larger than 128GiB.

Let's introduce our own helpers to encode file handles.

It's easy to reproduce:
  1. prepare an erofs image with nid bigger than U32_MAX
  2. mount -t erofs foo.img /mnt/erofs
  3. set exportfs with configuration: /mnt/erofs *(rw,sync,
     no_root_squash)
  4. mount -t nfs $IP:/mnt/erofs /mnt/nfs
  5. md5sum /mnt/nfs/foo # foo is the file which nid bigger
     than U32_MAX.  # you will get ESTALE error.

In the case of overlayfs, the underlying filesystem's file
handle is encoded in ovl_fb.fid, which is similar to NFS's
case. If the NID of file is larger than U32_MAX, the overlay
will get -ESTALE error when calls exportfs_decode_fh.

Fixes: 3e917cc305c6 ("erofs: make filesystem exportable")
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20250507094015.14007-1-lihongbo22@huawei.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fs/erofs/super.c