linux/fs/erofs
Gao Xiang 35076d2223 erofs: ensure the extra temporary copy is valid for shortened bvecs
When compressed data deduplication is enabled, multiple logical extents
may reference the same compressed physical cluster.

The previous commit 94c43de735 ("erofs: fix wrong primary bvec
selection on deduplicated extents") already avoids using shortened
bvecs.  However, in such cases, the extra temporary buffers also
need to be preserved for later use in z_erofs_fill_other_copies() to
to prevent data corruption.

IOWs, extra temporary buffers have to be retained not only due to
varying start relative offsets (`pageofs_out`, as indicated by
`pcl->multibases`) but also because of shortened bvecs.

android.hardware.graphics.composer@2.1.so : 270696 bytes
   0:        0..  204185 |  204185 :  628019200.. 628084736 |   65536
-> 1:   204185..  225536 |   21351 :  544063488.. 544129024 |   65536
   2:   225536..  270696 |   45160 :          0..         0 |       0

com.android.vndk.v28.apex : 93814897 bytes
...
   364: 53869896..54095257 |  225361 :  543997952.. 544063488 |   65536
-> 365: 54095257..54309344 |  214087 :  544063488.. 544129024 |   65536
   366: 54309344..54514557 |  205213 :  544129024.. 544194560 |   65536
...

Both 204185 and 54095257 have the same start relative offset of 3481,
but the logical page 55 of `android.hardware.graphics.composer@2.1.so`
ranges from 225280 to 229632, forming a shortened bvec [225280, 225536)
that cannot be used for decompressing the range from 54095257 to
54309344 of `com.android.vndk.v28.apex`.

Since `pcl->multibases` is already meaningless, just mark `be->keepxcpy`
on demand for simplicity.

Again, this issue can only lead to data corruption if `-Ededupe` is on.

Fixes: 94c43de735 ("erofs: fix wrong primary bvec selection on deduplicated extents")
Reviewed-by: Hongbo Li <lihongbo22@huawei.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20250506101850.191506-1-hsiangkao@linux.alibaba.com
2025-05-07 09:50:51 +08:00
..
compress.h erofs: move {in,out}pages into struct z_erofs_decompress_req 2025-03-17 01:22:50 +08:00
data.c erofs: implement 48-bit block addressing for unencoded inodes 2025-03-17 01:25:26 +08:00
decompressor.c erofs: support unaligned encoded data 2025-03-17 14:02:15 +08:00
decompressor_deflate.c erofs: move {in,out}pages into struct z_erofs_decompress_req 2025-03-17 01:22:50 +08:00
decompressor_lzma.c erofs: move {in,out}pages into struct z_erofs_decompress_req 2025-03-17 01:22:50 +08:00
decompressor_zstd.c erofs: move {in,out}pages into struct z_erofs_decompress_req 2025-03-17 01:22:50 +08:00
dir.c erofs: support dot-omitted directories 2025-03-17 01:25:32 +08:00
erofs_fs.h erofs: add __packed annotation to union(__le16..) 2025-04-09 22:56:30 +08:00
fileio.c fs/erofs/fileio: call erofs_onlinefolio_split() after bio_add_folio() 2025-04-29 11:36:00 +08:00
fscache.c erofs: get rid of erofs_kmap_type 2025-03-17 01:21:24 +08:00
inode.c erofs: support dot-omitted directories 2025-03-17 01:25:32 +08:00
internal.h erofs: implement encoded extent metadata 2025-03-17 14:02:15 +08:00
Kconfig lib/crc: remove CONFIG_LIBCRC32C 2025-04-04 11:31:42 -07:00
Makefile erofs: support unencoded inodes for fileio 2024-09-10 15:26:36 +08:00
namei.c erofs: get rid of erofs_kmap_type 2025-03-17 01:21:24 +08:00
super.c erofs: remove unused enum type 2025-04-30 12:13:32 +08:00
sysfs.c erofs: implement 48-bit block addressing for unencoded inodes 2025-03-17 01:25:26 +08:00
xattr.c erofs: get rid of erofs_kmap_type 2025-03-17 01:21:24 +08:00
xattr.h erofs: move erofs_xattr_handlers and xattr_handler_map to .rodata 2023-10-09 16:24:17 +02:00
zdata.c erofs: ensure the extra temporary copy is valid for shortened bvecs 2025-05-07 09:50:51 +08:00
zmap.c erofs: fix encoded extents handling 2025-04-09 22:56:31 +08:00
zutil.c The various patchsets are summarized below. Plus of course many 2025-01-26 18:36:23 -08:00