android_kernel_xiaomi_sm8350/fs
Gao Xiang eff9f8bc09
BACKPORT: erofs: fix lz4 inplace decompression
commit 3c12466b6b7bf1e56f9b32c366a3d83d87afb4de upstream.

Currently EROFS can map another compressed buffer for inplace
decompression, that was used to handle the cases that some pages of
compressed data are actually not in-place I/O.

However, like most simple LZ77 algorithms, LZ4 expects the compressed
data is arranged at the end of the decompressed buffer and it
explicitly uses memmove() to handle overlapping:
  __________________________________________________________
 |_ direction of decompression --> ____ |_ compressed data _|

Although EROFS arranges compressed data like this, it typically maps two
individual virtual buffers so the relative order is uncertain.
Previously, it was hardly observed since LZ4 only uses memmove() for
short overlapped literals and x86/arm64 memmove implementations seem to
completely cover it up and they don't have this issue.  Juhyung reported
that EROFS data corruption can be found on a new Intel x86 processor.
After some analysis, it seems that recent x86 processors with the new
FSRM feature expose this issue with "rep movsb".

Let's strictly use the decompressed buffer for lz4 inplace
decompression for now.  Later, as an useful improvement, we could try
to tie up these two buffers together in the correct order.

Reported-and-tested-by: Juhyung Park <qkrwngud825@gmail.com>
Closes: https://lore.kernel.org/r/CAD14+f2AVKf8Fa2OO1aAUdDNTDsVzzR6ctU_oJSmTyd6zSYR2Q@mail.gmail.com
Fixes: 0ffd71bcc3 ("staging: erofs: introduce LZ4 decompression inplace")
Fixes: 598162d05080 ("erofs: support decompress big pcluster for lz4 backend")
Cc: stable <stable@vger.kernel.org> # 5.4+
Tested-by: Yifan Zhao <zhaoyifan@sjtu.edu.cn>
Change-Id: Ib7a578283e33f0329ae2133223878ddf0738aba4
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20231206045534.3920847-1-hsiangkao@linux.alibaba.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[mkbestas: Adapt for android <=5.4 kernel which contains backports that
           caused various conflicts]
Signed-off-by: Michael Bestas <mkbestas@lineageos.org>
2024-04-16 16:57:37 +03:00
..
9p
adfs
affs
afs This is the 5.4.266 stable release 2024-01-08 18:35:14 +00:00
autofs autofs: fix memory leak of waitqueues in autofs_catatonic_mode 2023-09-23 11:00:02 +02:00
befs
bfs
btrfs This is the 5.4.266 stable release 2024-01-08 18:35:14 +00:00
cachefiles
ceph Merge 5.4.259 into android11-5.4-lts 2023-10-26 09:18:00 +00:00
cifs This is the 5.4.266 stable release 2024-01-08 18:35:14 +00:00
coda coda: Avoid partial allocation of sig_inputArgs 2023-03-11 16:43:56 +01:00
configfs
cramfs
crypto
debugfs new helper: lookup_positive_unlocked() 2023-09-23 10:59:40 +02:00
devpts
dlm dlm: fix plock lookup when using multiple lockspaces 2023-09-23 10:59:55 +02:00
ecryptfs
efivarfs
efs
erofs BACKPORT: erofs: fix lz4 inplace decompression 2024-04-16 16:57:37 +03:00
exfat Merge branch 'for-kernel-version-from-4.1.0' of https://github.com/namjaejeon/linux-exfat-oot into android13-5.4-lahaina 2024-04-16 00:03:08 +03:00
exportfs
ext2 This is the 5.4.257 stable release 2023-09-30 11:33:27 +00:00
ext4 This is the 5.4.265 stable release 2023-12-21 12:17:30 +00:00
f2fs Merge branch 'android11-5.4-lts' of https://android.googlesource.com/kernel/common into android13-5.4-lahaina 2024-02-08 19:02:48 +00:00
fat treewide: Remove uninitialized_var() usage 2023-06-09 10:29:01 +02:00
freevxfs
fscache
fuse Merge tag 'ASB-2023-12-05_11-5.4' of https://android.googlesource.com/kernel/common into android13-5.4-lahaina 2023-12-11 20:22:05 +02:00
gfs2 This is the 5.4.268 stable release 2024-01-26 02:15:05 +00:00
hfs This is the 5.4.235 stable release 2023-03-12 15:42:52 +00:00
hfsplus Merge 5.4.246 into android11-5.4-lts 2023-06-20 19:13:58 +00:00
hostfs
hpfs
hugetlbfs
incfs ANDROID: incremental fs: Evict inodes before freeing mount data 2023-04-05 13:07:49 -07:00
iomap
isofs treewide: Remove uninitialized_var() usage 2023-06-09 10:29:01 +02:00
jbd2 jbd2: correct the printing of write_flags in jbd2_write_superblock() 2024-01-25 14:34:20 -08:00
jffs2 This is the 5.4.251 stable release 2023-08-03 10:56:28 +00:00
jfs This is the 5.4.262 stable release 2023-11-29 10:18:14 +00:00
kernfs This is the 5.4.257 stable release 2023-09-30 11:33:27 +00:00
lockd fs: lockd: avoid possible wrong NULL parameter 2023-09-23 10:59:48 +02:00
minix
nfs This is the 5.4.268 stable release 2024-01-26 02:15:05 +00:00
nfs_common
nfsd nfsd: fix file memleak on client_opens_release 2023-11-28 16:50:21 +00:00
nilfs2 nilfs2: fix missing error check for sb_set_blocksize call 2023-12-13 18:18:16 +01:00
nls Revert "fs/nls: make load_nls() take a const parameter" 2023-09-30 15:41:35 +00:00
notify This is the 5.4.251 stable release 2023-08-03 10:56:28 +00:00
ntfs
ocfs2 This is the 5.4.257 stable release 2023-09-30 11:33:27 +00:00
omfs treewide: Remove uninitialized_var() usage 2023-06-09 10:29:01 +02:00
openpromfs
orangefs
overlayfs Merge branch 'android11-5.4-lts' of https://android.googlesource.com/kernel/common into android13-5.4-lahaina 2024-02-08 19:02:48 +00:00
proc Merge tag 'ASB-2023-12-05_11-5.4' of https://android.googlesource.com/kernel/common into android13-5.4-lahaina 2023-12-11 20:22:05 +02:00
pstore Merge branch 'android11-5.4-lts' of https://android.googlesource.com/kernel/common into android13-5.4-lahaina 2024-02-08 19:02:48 +00:00
qnx4
qnx6
quota quota: explicitly forbid quota files from being encrypted 2023-11-28 16:50:19 +00:00
ramfs
reiserfs This is the 5.4.257 stable release 2023-09-30 11:33:27 +00:00
romfs
squashfs This is the 5.4.232 stable release 2023-02-22 12:30:48 +00:00
sysfs
sysv fs/sysv: Null check to prevent null-ptr-deref bug 2023-08-11 11:53:59 +02:00
tracefs This is the 5.4.257 stable release 2023-09-30 11:33:27 +00:00
ubifs Merge 5.4.246 into android11-5.4-lts 2023-06-20 19:13:58 +00:00
udf udf: initialize newblock to 0 2023-09-23 10:59:56 +02:00
ufs
unicode
verity This is the 5.4.257 stable release 2023-09-30 11:33:27 +00:00
xfs This is the 5.4.249 stable release 2023-06-28 09:54:38 +00:00
aio.c Merge tag 'ASB-2023-04-05_11-5.4' of https://android.googlesource.com/kernel/common into android13-5.4-lahaina 2023-04-06 14:17:05 +03:00
anon_inodes.c
attr.c attr: block mode changes of symlinks 2023-09-23 11:00:06 +02:00
bad_inode.c
binfmt_aout.c
binfmt_elf_fdpic.c fs: binfmt_elf_efpic: fix personality for ELF-FDPIC 2023-10-10 21:46:42 +02:00
binfmt_elf.c
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
block_dev.c block: Don't invalidate pagecache for invalid falloc modes 2024-01-08 11:29:48 +01:00
buffer.c
char_dev.c
compat_binfmt_elf.c
compat_ioctl.c
compat.c
coredump.c
d_path.c
dax.c
dcache.c
dcookies.c
direct-io.c
drop_caches.c
eventfd.c eventfd: prevent underflow for eventfd semaphores 2023-09-23 10:59:40 +02:00
eventpoll.c This is the 5.4.249 stable release 2023-06-28 09:54:38 +00:00
exec.c
fcntl.c
fhandle.c
file_table.c
file.c fs: prevent out-of-bounds array speculation when closing a file descriptor 2023-03-17 08:32:47 +01:00
filesystems.c
fs_context.c fs: avoid empty option when generating legacy mount string 2023-07-27 08:37:25 +02:00
fs_parser.c
fs_pin.c
fs_struct.c
fs_types.c
fs-writeback.c writeback: fix call of incorrect macro 2023-05-17 11:35:58 +02:00
fsopen.c
inode.c This is the 5.4.251 stable release 2023-08-03 10:56:28 +00:00
internal.h fs: Establish locking order for unrelated directories 2023-07-27 08:37:26 +02:00
io_uring.c This is the 5.4.264 stable release 2023-12-14 13:03:30 +00:00
ioctl.c
Kconfig
Kconfig.binfmt
libfs.c
locks.c locks: fix KASAN: use-after-free in trace_event_raw_event_filelock_lock 2023-09-23 11:00:02 +02:00
Makefile
mbcache.c
mount.h
mpage.c
namei.c This is the 5.4.257 stable release 2023-09-30 11:33:27 +00:00
namespace.c
no-block.c
nsfs.c
open.c
OWNERS
pipe.c
pnode.c
pnode.h
posix_acl.c
proc_namespace.c
read_write.c
readdir.c
select.c
seq_file.c
signalfd.c
splice.c
stack.c
stat.c
statfs.c statfs: enforce statfs[64] structure initialization 2023-05-30 12:44:07 +01:00
super.c fs: Protect reconfiguration of sb read-write from racing writes 2023-08-11 11:53:59 +02:00
sync.c This is the 5.4.263 stable release 2023-12-11 12:08:17 +00:00
timerfd.c
userfaultfd.c
utimes.c
xattr.c