From c116c54229790def0403e0aaa4c5a584fae8ff48 Mon Sep 17 00:00:00 2001 From: Rmys Date: Tue, 7 Jun 2022 23:52:33 +0300 Subject: [PATCH] zstd rebuild --- system/base/zstd/files/enable-CET.patch | 38 ++++++++ .../files/zstd-1.5.2-upstream_fixes-1.patch | 96 +++++++++++++++++++ system/base/zstd/pspec.xml | 11 +++ 3 files changed, 145 insertions(+) create mode 100644 system/base/zstd/files/enable-CET.patch create mode 100644 system/base/zstd/files/zstd-1.5.2-upstream_fixes-1.patch diff --git a/system/base/zstd/files/enable-CET.patch b/system/base/zstd/files/enable-CET.patch new file mode 100644 index 00000000..335e95d3 --- /dev/null +++ b/system/base/zstd/files/enable-CET.patch @@ -0,0 +1,38 @@ +From cd7620a730413a48843e175d34dc408c152f8125 Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" +Date: Tue, 11 Jan 2022 07:28:25 -0800 +Subject: [PATCH] x86-64: Enable Intel CET + +Intel Control-flow Enforcement Technology (CET): + +https://en.wikipedia.org/wiki/Control-flow_integrity#Intel_Control-flow_Enforcement_Technology + +requires that on Linux, all linker input files are marked as CET enabled +in .note.gnu.property section. For high-level language source codes, +.note.gnu.property section is added by compiler with the -fcf-protection +option. For assembly sources, include to add .note.gnu.property +section. +--- + lib/common/portability_macros.h | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/lib/common/portability_macros.h b/lib/common/portability_macros.h +index 627ef9eed4..6ac4b05510 100644 +--- a/lib/common/portability_macros.h ++++ b/lib/common/portability_macros.h +@@ -128,4 +128,15 @@ + # define ZSTD_ENABLE_ASM_X86_64_BMI2 0 + #endif + ++/* ++ * For x86 ELF targets, add .note.gnu.property section for Intel CET in ++ * assembly sources when CET is enabled. ++ */ ++#if defined(__ELF__) && (defined(__x86_64__) || defined(__i386__)) \ ++ && defined(__has_include) ++# if __has_include() ++# include ++# endif ++#endif ++ + #endif /* ZSTD_PORTABILITY_MACROS_H */ diff --git a/system/base/zstd/files/zstd-1.5.2-upstream_fixes-1.patch b/system/base/zstd/files/zstd-1.5.2-upstream_fixes-1.patch new file mode 100644 index 00000000..bc9dcdd2 --- /dev/null +++ b/system/base/zstd/files/zstd-1.5.2-upstream_fixes-1.patch @@ -0,0 +1,96 @@ +Submitted By: Xi Ruoyao +Date: 2021-03-04 +Initial Package Version: 1.5.2 +Upstream Status: Applied +Origin: Upstream Git Repository +Description: Fix bad assertions causing test failure. + +From 246982e782849d8646b2d5df6648319935669228 Mon Sep 17 00:00:00 2001 +From: Nick Terrell +Date: Thu, 20 Jan 2022 22:41:47 -0800 +Subject: [PATCH] [dibio] Fix assertion triggered by no inputs + +Passing 0 inputs to `DiB_shuffle()` caused an assertion failure where +it should just return. + +A test is added in a later commit, with the initial introduction of the +new testing framework. + +Fixes #3007. +--- + programs/dibio.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/programs/dibio.c b/programs/dibio.c +index d19f954486..147d1e7bfd 100644 +--- a/programs/dibio.c ++++ b/programs/dibio.c +@@ -27,9 +27,9 @@ + #include /* memset */ + #include /* fprintf, fopen, ftello64 */ + #include /* errno */ +-#include + + #include "timefn.h" /* UTIL_time_t, UTIL_clockSpanMicro, UTIL_getTime */ ++#include "../lib/common/debug.h" /* assert */ + #include "../lib/common/mem.h" /* read */ + #include "dibio.h" + +@@ -193,7 +193,8 @@ static U32 DiB_rand(U32* src) + static void DiB_shuffle(const char** fileNamesTable, unsigned nbFiles) { + U32 seed = 0xFD2FB528; + unsigned i; +- assert(nbFiles >= 1); ++ if (nbFiles == 0) ++ return; + for (i = nbFiles - 1; i > 0; --i) { + unsigned const j = DiB_rand(&seed) % (i + 1); + const char* const tmp = fileNamesTable[j]; + +From d109cef2012b1e0ca7a6f47278a2838f68bbc196 Mon Sep 17 00:00:00 2001 +From: Xi Ruoyao +Date: Sat, 5 Mar 2022 03:56:44 +0800 +Subject: [PATCH] fix the assertion in readLinesFromFile (#3084) + +* fix the assertion in readLinesFromFile + +When the file is not terminated by endline, readLineFromFile will append +a '\0' for the last line. In this case pos + lineLength == dstCapacity. + +* test: don't print very long text garbage +--- + programs/util.c | 2 +- + tests/playTests.sh | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/programs/util.c b/programs/util.c +index d69b72a37c..55bcff25af 100644 +--- a/programs/util.c ++++ b/programs/util.c +@@ -418,7 +418,7 @@ readLinesFromFile(void* dst, size_t dstCapacity, + while ( !feof(inputFile) ) { + size_t const lineLength = readLineFromFile(buf+pos, dstCapacity-pos, inputFile); + if (lineLength == 0) break; +- assert(pos + lineLength < dstCapacity); ++ assert(pos + lineLength <= dstCapacity); /* '=' for inputFile not terminated with '\n' */ + pos += lineLength; + ++nbFiles; + } +diff --git a/tests/playTests.sh b/tests/playTests.sh +index 71e8dc0581..d4271b2f07 100755 +--- a/tests/playTests.sh ++++ b/tests/playTests.sh +@@ -735,11 +735,11 @@ test -f tmp4 + + println "test : survive the list of files with too long filenames (--filelist=FILE)" + datagen -g5M > tmp_badList +-zstd -f --filelist=tmp_badList && die "should have failed : file name length is too long" ++zstd -qq -f --filelist=tmp_badList && die "should have failed : file name length is too long" # printing very long text garbage on console will cause CI failure + + println "test : survive a list of files which is text garbage (--filelist=FILE)" + datagen > tmp_badList +-zstd -f --filelist=tmp_badList && die "should have failed : list is text garbage" ++zstd -qq -f --filelist=tmp_badList && die "should have failed : list is text garbage" # printing very long text garbage on console will cause CI failure + + println "test : survive a list of files which is binary garbage (--filelist=FILE)" + datagen -P0 -g1M > tmp_badList diff --git a/system/base/zstd/pspec.xml b/system/base/zstd/pspec.xml index e09aca16..bf80f713 100644 --- a/system/base/zstd/pspec.xml +++ b/system/base/zstd/pspec.xml @@ -20,6 +20,10 @@ zlib-devel xz-devel + + enable-CET.patch + zstd-1.5.2-upstream_fixes-1.patch + @@ -49,6 +53,13 @@ + + 2022-06-07 + 1.5.2 + Rebuild. + Mustafa Cinasal + muscnsl@gmail.com + 2022-05-05 1.5.2