diff --git a/enable-CET.patch b/enable-CET.patch new file mode 100644 index 0000000000000000000000000000000000000000..335e95d33cdaf55e2f2669c35f4e205b1e20eb05 --- /dev/null +++ b/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/pzstd.1.patch b/pzstd.1.patch index bb03404166343420f33e6e6232387f9659fa0673..d4e3a1f3589388c9c7988b5c5cf3bf67c8636d82 100644 --- a/pzstd.1.patch +++ b/pzstd.1.patch @@ -1,11 +1,10 @@ -diff -Naur -Naru zstd-1.3.4/programs/zstd.1 zstd-1.3.4.new/programs/zstd.1 ---- zstd-1.3.4/programs/zstd.1 2018-03-26 22:19:34.000000000 +0000 -+++ zstd-1.3.4.new/programs/zstd.1 2018-03-28 04:28:27.532777239 +0000 -@@ -177,7 +177,14 @@ - . - .SS "Restricted usage of Environment Variables" - Using environment variables to set parameters has security implications\. Therefore, this avenue is intentionally restricted\. Only \fBZSTD_CLEVEL\fR is supported currently, for setting compression level\. \fBZSTD_CLEVEL\fR can be used to set the level between 1 and 19 (the "normal" range)\. If the value of \fBZSTD_CLEVEL\fR is not a valid integer, it will be ignored with a warning message\. \fBZSTD_CLEVEL\fR just replaces the default compression level (\fB3\fR)\. It can be overridden by corresponding command line arguments\. --. +diff -Naur zstd-1.5.1.orig/programs/zstd.1 zstd-1.5.1/programs/zstd.1 +--- zstd-1.5.1.orig/programs/zstd.1 2021-12-20 22:49:18.000000000 +0000 ++++ zstd-1.5.1/programs/zstd.1 2021-12-22 16:49:17.160850340 +0000 +@@ -146,6 +146,14 @@ + \fB\-\-show\-default\-cparams\fR: Shows the default compression parameters that will be used for a particular src file\. If the provided src file is not a regular file (eg\. named pipe), the cli will just output the default parameters\. That is, the parameters that are used when the src size is unknown\. + .IP "\[ci]" 4 + \fB\-\-\fR: All arguments after \fB\-\-\fR are treated as files + +.SH Parallel Zstd OPTIONS +Additional options for the pzstd utility @@ -14,6 +13,6 @@ diff -Naur -Naru zstd-1.3.4/programs/zstd.1 zstd-1.3.4.new/programs/zstd.1 + number of threads to use for (de)compression (default:4) + + - .SH "DICTIONARY BUILDER" - \fBzstd\fR offers \fIdictionary\fR compression, which greatly improves efficiency on small files and messages\. It\'s possible to train \fBzstd\fR with a set of samples, the result of which is saved into a file called a \fBdictionary\fR\. Then during compression and decompression, reference the same dictionary, using command \fB\-D dictionaryFileName\fR\. Compression of small files similar to the sample set will be greatly improved\. - . + .IP "" 0 + .SS "Restricted usage of Environment Variables" + Using environment variables to set parameters has security implications\. Therefore, this avenue is intentionally restricted\. Only \fBZSTD_CLEVEL\fR and \fBZSTD_NBTHREADS\fR are currently supported\. They set the compression level and number of threads to use during compression, respectively\. diff --git a/zstd-1.4.4.tar.gz b/zstd-1.4.4.tar.gz deleted file mode 100644 index 96e22adb3d4fcd18f44bc3feecec90f2c2670fd4..0000000000000000000000000000000000000000 Binary files a/zstd-1.4.4.tar.gz and /dev/null differ diff --git a/zstd-1.5.1.tar.gz b/zstd-1.5.1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..27b00c83afe2c685929f34efcc55cdd7f71cf4bb Binary files /dev/null and b/zstd-1.5.1.tar.gz differ diff --git a/zstd.spec b/zstd.spec index 165442e64afe63fac621aa8d9aa9a4bcd1612d86..7722ae77b5ca7c7886ac350d467056ff9b435248 100644 --- a/zstd.spec +++ b/zstd.spec @@ -1,4 +1,14 @@ -%define anolis_release .0.1 +%define anolis_release .0.2 + +# enable .lz4 support by default +%bcond_without lz4 + +# enable .xz/.lzma support by default +%bcond_without lzma + +# enable .gz support by default +%bcond_without zlib + %if 0%{?rhel} && 0%{?rhel} <= 6 # gcc-4.4 is currently too old to compile pzstd %bcond_with pzstd @@ -12,9 +22,21 @@ %endif %endif +%ifarch x86_64 +%bcond_without asm +%else +# Disable asm to ensure non excutable stack +# used on archs where asm not actually used +# https://github.com/facebook/zstd/issues/2963 +%bcond_with asm +%endif + +# Disable gtest +%bcond_with gtest + Name: zstd -Version: 1.4.4 -Release: 1%{anolis_release}%{?dist} +Version: 1.5.1 +Release: 2%{anolis_release}%{?dist} Summary: Zstd compression library License: BSD and GPLv2 @@ -22,11 +44,28 @@ URL: https://github.com/facebook/zstd Source0: https://github.com/facebook/zstd/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz Patch1: pzstd.1.patch +Patch2: enable-CET.patch -BuildRequires: gcc gtest-devel +BuildRequires: make +BuildRequires: gcc +%if %{with gtest} +BuildRequires: gtest-devel +%endif +%if %{with lz4} +BuildRequires: lz4-devel +%endif +%if %{with lzma} +BuildRequires: xz-devel +%endif %if %{with pzstd} BuildRequires: gcc-c++ %endif +%if %{with zlib} +BuildRequires: zlib-devel +%endif +%ifnarch loongarch64 +BuildRequires: execstack +%endif Requires: glibc Provides: /usr/bin/zstd @@ -45,9 +84,16 @@ Zstandard compression shared library. Summary: Header files for Zstd library Requires: lib%{name}%{?_isa} = %{version}-%{release} +%package -n lib%{name}-static +Summary: Static variant of the Zstd library +Requires: lib%{name}-devel = %{version}-%{release} + %description -n lib%{name}-devel Header files for Zstd library. +%description -n lib%{name}-static +Static variant of the Zstd library. + %package doc Summary: Documents for %{name} BuildArch: noarch @@ -62,31 +108,37 @@ find -name .gitignore -delete %if %{with pzstd} %patch1 -p1 %endif +%patch2 -p1 %build export CFLAGS="$RPM_OPT_FLAGS" export LDFLAGS="$RPM_LD_FLAGS" -for dir in lib programs; do - %make_build -C "$dir" -done +export PREFIX="%{_prefix}" +export LIBDIR="%{_libdir}" +%make_build -C lib lib-mt %{!?with_asm:ZSTD_NO_ASM=1} +%make_build -C programs %{!?with_asm:ZSTD_NO_ASM=1} %if %{with pzstd} -export CXXFLAGS="$RPM_OPT_FLAGS -std=c++11" -%make_build -C contrib/pzstd +export CXXFLAGS="$RPM_OPT_FLAGS" +%make_build -C contrib/pzstd %{!?with_asm:ZSTD_NO_ASM=1} %endif %check +%ifnarch loongarch64 +execstack lib/libzstd.so.1 +%endif + export CFLAGS="$RPM_OPT_FLAGS" export LDFLAGS="$RPM_LD_FLAGS" make -C tests test-zstd %if %{with pzstd} -export CXXFLAGS="$RPM_OPT_FLAGS -std=c++11" +%if %{with gtest} +export CXXFLAGS="$RPM_OPT_FLAGS" make -C contrib/pzstd test %endif +%endif %install %make_install PREFIX=%{_prefix} LIBDIR=%{_libdir} -# Don't install the static lib -rm %{buildroot}%{_libdir}/libzstd.a %if %{with pzstd} install -D -m755 contrib/pzstd/pzstd %{buildroot}%{_bindir}/pzstd install -D -m644 programs/%{name}.1 %{buildroot}%{_mandir}/man1/p%{name}.1 @@ -115,31 +167,86 @@ install -D -m644 programs/%{name}.1 %{buildroot}%{_mandir}/man1/p%{name}.1 %license COPYING LICENSE %files -n lib%{name}-devel -%{_includedir}/zbuff.h %{_includedir}/zdict.h %{_includedir}/zstd.h %{_includedir}/zstd_errors.h %{_libdir}/pkgconfig/libzstd.pc %{_libdir}/libzstd.so +%files -n lib%{name}-static +%{_libdir}/libzstd.a + %files doc %doc CHANGELOG README.md %ldconfig_scriptlets -n lib%{name} %changelog -* Fri Jul 15 2022 Liwei Ge - 1.4.4-1.0.1 -- Add doc sub package +* Tue Nov 29 2022 Chang Gao - 1.5.1-2.0.2 +- Disable execstack on loongarch64 architecture -* Thu Jun 4 2020 Jakub Martisko - 1.4.4-1 -- Rebase to 1.4.4 -Resolvese: 1807452 +* Tue Nov 29 2022 Liwei Ge - 1.5.1-2.0.1 +- Add doc sub package -* Tue Oct 15 2019 Jakub Martisko - 1.4.2-2 +* Mon Feb 07 2022 Jakub Martisko - 1.5.1-2 - Add some basic gating tests + Resolves: rhbz#2050272 + +* Wed Jan 12 2022 Michel Alexandre Salim - 1.5.1-1 +- Rebase to the latest upstream version +- Enable optional gz, xz/lzma, and lz4 support in the zstd tool +- Disable amd64 assembly on non-x86_64 architectures (rhbz#2035802) + this should avoid the issue where an executable stack is created +- Re-enable CET protections (rhbz#2039353) + Resolves: rhbz#2039488 + +* Tue Aug 10 2021 Mohan Boddu - 1.5.0-2 +- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags + Related: rhbz#1991688 + +* Mon Jul 12 2021 Jakub Martisko - 1.5.0-1 +* Rebase to the latest upstream version +Resolves: rhbz#1928094 + +* Thu Jul 01 2021 Jakub Martisko - 1.4.9-3 +- Drop gtest-devel dependency +Resolves: rhbz#1977606 + +* Fri Apr 16 2021 Mohan Boddu - 1.4.9-2 +- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937 + +* Fri Mar 05 2021 Pádraig Brady - 1.4.9-1 +- Latest upstream + +* Thu Jan 28 2021 Fedora Release Engineering - 1.4.7-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Thu Dec 17 2020 Pádraig Brady - 1.4.7-1 +- Latest upstream + +* Wed Aug 26 2020 Jeff Law - 1.4.5-6 +- Do not force C++11 mode + +* Wed Jul 29 2020 Fedora Release Engineering - 1.4.5-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Sat Jul 11 2020 Igor Raits - 1.4.5-4 +- Build libzstd with multi-threading support + +* Mon May 25 2020 Pádraig Brady - 1.4.5-3 +- Build shared library with correct compiler flags -* Tue Oct 15 2019 Jakub Martisko - 1.4.2-1 -- Initial rhel commit +* Fri May 22 2020 Pádraig Brady - 1.4.5-1 +- Latest upstream + +* Fri May 22 2020 Avi Kivity - 1.4.4-3 +- Added static library subpackage + +* Fri Jan 31 2020 Fedora Release Engineering - 1.4.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Wed Jan 15 2020 Pádraig Brady - 1.4.4-1 +- Latest upstream * Wed Jul 31 2019 Pádraig Brady - 1.4.2-1 - Latest upstream