aarch64: SIGILL on BTI-enabled CPUs: #12536 fixed lib/flb_libco but the binary links lib/monkey/deps/flb_libco

Đang mở Phù hợp với người mới
#12,787 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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
63/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
Lĩnh vực
operating-systems

Hướng nghiên cứu

Bản sửa nằm trong bản sao vendored lib/monkey/deps/flb_libco/aarch64.c, nơi phần cuối của khối asm co_switch_aarch64 vẫn kết thúc bằng br x17. Hãy so sánh với lib/flb_libco/aarch64.c, file đã được #12536 đổi thành ret x17, và xác nhận rằng build CMake chỉ biên dịch bản sao của monkey. Hoàn thành khi file monkey khớp với file đã sửa và build aarch64 với -mbranch-protection=standard vượt qua bài kiểm tra runtime BTI; cần một CPU hỗ trợ BTI để tái hiện SIGILL.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

status: waiting-for-triage

Bug Report
Describe the bug

On an aarch64 CPU that implements BTI, a fluent-bit binary built with -mbranch-protection=standard gets SIGILL in the output worker thread (flb-out-forward) at the first flush.

#12536 fixed this in lib/flb_libco/aarch64.c by changing the end of co_switch_aarch64 from br x17 to ret x17. But fluent-bit does not link that copy: the build compiles the libco bundled with monkey, lib/monkey/deps/flb_libco/libco.c. Monkey's aarch64.c still ends with br x17 in v5.1.5, v5.2.0 and master, so the binary still crashes.

To Reproduce

Build fluent-bit for aarch64 with -mbranch-protection=standard in CFLAGS. This is the Yocto/OpenEmbedded default for aarch64, and the binary gets the AArch64 feature: BTI, PAC GNU property.
Run on a CPU with BTI (bti in /proc/cpuinfo, e.g. Neoverse V2/V3, Cortex-A720; we hit it on NVIDIA Jetson Thor):
fluent-bit -i dummy -o forward -p host=127.0.0.1 -p port=24299 -f 1
The process dies with SIGILL within a second:
Thread 4 "flb-out-forward" received signal SIGILL, Illegal instruction.
bl co_switch
=> ldr x21, [x21, #40]
$_siginfo.si_code is 1. The faulting PC is the instruction after bl co_switch, reached by the br x17 at the end of co_switch_aarch64, which is not a BTI landing pad.
Expected behavior

No SIGILL; coroutine switches work as on CPUs without BTI.

Your Environment

Version used: v5.0.2. The same br x17 is in monkey's copy in v5.1.5, v5.2.0 and master.
Environment name and version: Yocto / OpenEmbedded (meta-oe fluentbit_5.0.2.bb), GCC with -mbranch-protection=standard
Server type and version: NVIDIA Jetson Thor (Neoverse V3AE, Armv9), Linux 6.8
Operating System and version: Yocto-based embedded Linux
Filters and plugins: reproduced with dummy → forward; any output that flushes in a coroutine should hit it
Additional context

Only one libco object is built: lib/monkey/deps/flb_libco/CMakeFiles/co.dir/libco.c.o.
After the #12536 change, lib/flb_libco/aarch64.c and lib/monkey/deps/flb_libco/aarch64.c are otherwise identical.
The fix: apply the same one-line change to monkey's copy (and to monkey upstream):
--- a/lib/monkey/deps/flb_libco/aarch64.c
+++ b/lib/monkey/deps/flb_libco/aarch64.c
@@ -58,7 +58,7 @@ asm (
" ldp x28, x29, [x0, #144]\n"
" ldp x16, x17, [x0, #160]\n"
" mov sp, x16\n"

  •  "  br x17\n"
    
  •  "  ret x17\n"
     ".previous\n"
    
    );
    With this applied to v5.0.2, the crash is gone on Jetson Thor and records are forwarded normally.
    Longer term, there should be a single copy of libco, or the BTI runtime test added in #12536 should also build monkey's copy, so the two cannot diverge again.
Ngôn ngữ chính
C
Star
8.2k
Fork
2k
Merge trung bình
3 ngày 13 giờ
Pull request đã merge (30 ngày)
93

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fluent/fluent-bit

Tất cả issue của fluent/fluent-bit

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.