Go to file
Gao Xiang 326611ff40 lib/lz4: explicitly support in-place decompression
BugLink: https://bugs.launchpad.net/bugs/1932957

commit 89b158635a upstream.

LZ4 final literal copy could be overlapped when doing
in-place decompression, so it's unsafe to just use memcpy()
on an optimized memcpy approach but memmove() instead.

Upstream LZ4 has updated this years ago [1] (and the impact
is non-sensible [2] plus only a few bytes remain), this commit
just synchronizes LZ4 upstream code to the kernel side as well.

It can be observed as EROFS in-place decompression failure
on specific files when X86_FEATURE_ERMS is unsupported,
memcpy() optimization of commit 59daa706fb ("x86, mem:
Optimize memcpy by avoiding memory false dependece") will
be enabled then.

Currently most modern x86-CPUs support ERMS, these CPUs just
use "rep movsb" approach so no problem at all. However, it can
still be verified with forcely disabling ERMS feature...

arch/x86/lib/memcpy_64.S:
        ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \
-                     "jmp memcpy_erms", X86_FEATURE_ERMS
+                     "jmp memcpy_orig", X86_FEATURE_ERMS

We didn't observe any strange on arm64/arm/x86 platform before
since most memcpy() would behave in an increasing address order
("copy upwards" [3]) and it's the correct order of in-place
decompression but it really needs an update to memmove() for sure
considering it's an undefined behavior according to the standard
and some unique optimization already exists in the kernel.

[1] 33cb8518ac
[2] https://github.com/lz4/lz4/pull/717#issuecomment-497818921
[3] https://sourceware.org/bugzilla/show_bug.cgi?id=12518

Link: https://lkml.kernel.org/r/20201122030749.2698994-1-hsiangkao@redhat.com
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Reviewed-by: Nick Terrell <terrelln@fb.com>
Cc: Yann Collet <yann.collet.73@gmail.com>
Cc: Miao Xie <miaoxie@huawei.com>
Cc: Chao Yu <yuchao0@huawei.com>
Cc: Li Guifu <bluce.liguifu@huawei.com>
Cc: Guo Xuenan <guoxuenan@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
2021-07-15 19:27:11 +02:00
Documentation XArray: add xas_split 2021-07-15 19:27:10 +02:00
LICENSES
arch KVM: arm64: Fix debug register indexing 2021-07-15 19:27:11 +02:00
block
certs
crypto
debian UBUNTU: update dkms package versions 2021-06-18 16:06:16 +02:00
debian.master UBUNTU: Ubuntu-5.4.0-80.90 2021-07-09 12:49:13 -03:00
drivers bnxt_en: Remove the setting of dev_port. 2021-07-15 19:27:10 +02:00
fs btrfs: fix unmountable seed device after fstrim 2021-07-15 19:27:10 +02:00
include XArray: add xas_split 2021-07-15 19:27:10 +02:00
init pid: take a reference when initializing `cad_pid` 2021-07-15 19:27:08 +02:00
ipc
kernel
lib lib/lz4: explicitly support in-place decompression 2021-07-15 19:27:11 +02:00
mm mm/filemap: fix storing to a THP shadow entry 2021-07-15 19:27:10 +02:00
net nfc: fix NULL ptr dereference in llcp_sock_getname() after failed connect 2021-07-15 19:27:08 +02:00
samples samples: vfio-mdev: fix error handing in mdpy_fb_probe() 2021-07-15 19:27:01 +02:00
scripts
security
sound ALSA: hda: Fix for mute key LED for HP Pavilion 15-CK0xx 2021-07-15 19:27:07 +02:00
tools
ubuntu
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
dropped.txt
snapcraft.yaml
update-version-dkms

README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.