linux_dsm_epyc7002/lib/zlib_inflate
Jann Horn acaab7335b lib/zlib: remove outdated and incorrect pre-increment optimization
The zlib inflate code has an old micro-optimization based on the
assumption that for pre-increment memory accesses, the compiler will
generate code that fits better into the processor's pipeline than what
would be generated for post-increment memory accesses.

This optimization was already removed in upstream zlib in 2016:
https://github.com/madler/zlib/commit/9aaec95e8211

This optimization causes UB according to C99, which says in section 6.5.6
"Additive operators": "If both the pointer operand and the result point to
elements of the same array object, or one past the last element of the
array object, the evaluation shall not produce an overflow; otherwise, the
behavior is undefined".

This UB is not only a theoretical concern, but can also cause trouble for
future work on compiler-based sanitizers.

According to the zlib commit, this optimization also is not optimal
anymore with modern compilers.

Replace uses of OFF, PUP and UP_UNALIGNED with their definitions in the
POSTINC case, and remove the macro definitions, just like in the upstream
patch.

Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Link: http://lkml.kernel.org/r/20200507123112.252723-1-jannh@google.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-04 19:06:25 -07:00
..
inffast.c lib/zlib: remove outdated and incorrect pre-increment optimization 2020-06-04 19:06:25 -07:00
inffast.h
inffixed.h
inflate_syms.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
inflate.c lib/zlib: add s390 hardware support for kernel zlib_inflate 2020-01-31 10:30:40 -08:00
inflate.h lib/zlib: add s390 hardware support for kernel zlib_inflate 2020-01-31 10:30:40 -08:00
inftrees.c lib/zlib_inflate/inftrees.c: fix potential buffer overflow 2017-05-08 17:15:12 -07:00
inftrees.h
infutil.c
infutil.h lib/zlib: add s390 hardware support for kernel zlib_inflate 2020-01-31 10:30:40 -08:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00