Libzstd: SHSTK not supported in cmake
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- c, cmake
- Lĩnh vực
- build-system, security
Hướng nghiên cứu
Bắt đầu trong build/cmake/CMakeModules/AddZstdCompilationFlags.cmake, nơi các cờ biên dịch CMake được cấu hình cho các tệp assembly. Build libzstd bằng CMake trên một hệ thống x86-64, sau đó chạy readelf -n trên thư viện dùng chung tạo ra và kiểm tra thuộc tính SHSTK. Được xem là hoàn tất khi bản build CMake tạo ra một thư viện báo cáo cả IBT và SHSTK mà không làm hồi quy các bản build khác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem description
SHSTK is an x64 security feature that is part of Intel CET, and support for it was added in PR #2992. The problem is, this PR only applies to the make build system, and not the cmake one, so when built with cmake, libzstd.so is still not marked as SHSTK-compatible, and this causes SHSTK not to be supported on applications that use libzstd.
How to reproduce
On systems that use cmake to build the library:
user@fedora:~$ readelf -n /usr/lib64/libzstd.so | grep SHSTK
... (no results) ...
Proposed fix
The crux of the issue is that when cmake compiles lib/decompress/huf_decompress_amd64.S, it doesn't pass any flags to the compiler. The object therefore gets compiled without -fcf-protection, which causes cet.h not to emit a .note.gnu.property section in the object, which in turn causes the final libzstd.so not to have that section either.
This can be fixed by simply using the C compiler flags when building assembly files, to ensure that -fcf-protection gets passed on them:
diff --git a/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake b/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake
index 3e7bcce5..cddb7ceb 100644
--- a/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake
+++ b/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake
@@ -113,6 +113,9 @@ macro(ADD_ZSTD_COMPILATION_FLAGS _C _CXX _LD)
endif ()
endif ()
+ # Use the C flags as ASM flags
+ set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}")
+
# Remove duplicates compilation flags
foreach (flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
Confirmed that it fixes the issue:
user@fedora:~$ readelf -n libzstd.so.1.5.7 | grep SHSTK
Properties: x86 feature: IBT, SHSTK
- Ngôn ngữ chính
- C
- Star
- 28.1k
- Fork
- 2.7k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của facebook/zstd
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
cmake: AddZstdCompilationFlags still depends on C++ after #4357Có thể đã có người làm @Tyagiquamar đã nhận 28 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
ZSTD_compressSequencesAndLiterals() does not enforce its documented litCapacity >= litSize + 8 contract — the implemented check is 8 bytes weaker than the API documentation, its own error message, and the introducing commitCó thể đã có người làm @KSAGlory đã nhận 48 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
seekable_format warning with -DNDEBUG: potential uninitialised local variable newOffset usedCó thể đã có người làm @i098 đã nhận 18 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Tất cả issue của facebook/zstd
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
cyrusimap/cyrus-imapd#6640 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 60/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
GalusPeres/HomeTiles#139 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Type: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
apache/nuttx-apps#3942 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
coders/mat.c: ReadMATImageV4 leaves a trailing 0x0 frame, so converting a valid level-4 .mat failsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ImageMagick/ImageMagick#9077 ·
Maintainer thường phản hồi trong vòng 1 ngày