summaryrefslogtreecommitdiff
path: root/scripts/basic
diff options
context:
space:
mode:
authorBinglei Wang <l3b2w1@gmail.com>2026-09-11 12:11:33 +0800
committerGao Xiang <xiang@kernel.org>2026-09-11 12:16:20 +0800
commit135d84c66f85426299db01a09d93a79a87af18ba (patch)
treef9b58e1a1f6e75188b0aab7e8d9f04f000ce2fdf /scripts/basic
parent96bf9831fbf423b8104f7948cd8fe7007ecfb46c (diff)
downloadlinux-135d84c66f85426299db01a09d93a79a87af18ba.tar.gz
linux-135d84c66f85426299db01a09d93a79a87af18ba.zip
erofs: add missing buf->off in erofs_bread()
erofs_bread() locates the target folio with index = (buf->off + offset) >> PAGE_SHIFT; but computes the in-folio offset without taking buf->off into account: return buf->base + (offset & ~PAGE_MASK); If buf->off is not page-aligned, the returned pointer misses the in-page component of buf->off, so callers end up fetching data from a wrong offset. buf->off is set to sbi->dif0.fsoff in erofs_init_metabuf(), and fsoff can be specified via the "fsoffset=" mount option, which only requires block-size alignment. Therefore, on an image with a sub-page block size (e.g. 512 bytes), a non-page-aligned fsoff (e.g. 512) triggers the issue, since 512 is a multiple of the block size but not of PAGE_SIZE. It can be reproduced by mounting an image that is placed at a non-page-aligned offset: mkfs.erofs -b512 -zlz4hc sub.erofs src/ # prepend 512 bytes of padding to the image mount -t erofs -o loop,fsoffset=512 padded.erofs /mnt which fails with erofs (device loop0): cannot find valid erofs superblock because the on-disk superblock (at offset 1024 within the image, i.e. 1536 within the padded file) is read from a wrong in-folio offset. With this fixed, the very same image mounts successfully and its file contents match those read from the unpadded image. Fix it by including buf->off in the in-folio offset calculation, so that it is consistent with the folio index calculation. Fixes: c36ec00d7f67 ("erofs: add 'fsoffset' mount option to specify filesystem offset") Signed-off-by: Binglei Wang <l3b2w1@gmail.com> Reviewed-by: Gao Xiang <xiang@kernel.org> Signed-off-by: Gao Xiang <xiang@kernel.org>
Diffstat (limited to 'scripts/basic')
0 files changed, 0 insertions, 0 deletions