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

オープン 初心者向け
#12,787 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
63/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c

調査の方向性

修正対象は、ベンダリングされたコピー lib/monkey/deps/flb_libco/aarch64.c です。co_switch_aarch64 のasmブロックの末尾がまだ br x17 で終わっています。#12536 で ret x17 に変更済みの lib/flb_libco/aarch64.c と比較し、CMakeビルドが monkey 側のコピーのみをコンパイルしていることを確認してください。monkey 側のファイルが修正版と一致し、-mbranch-protection=standard を指定した aarch64 ビルドが BTI ランタイムテストに合格すれば完了です。SIGILL を再現するには BTI 対応の CPU が必要です。

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
C
スター
8.2k
フォーク
2k
平均マージ
3日 13時間
マージ済み PR(30日)
93

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fluent/fluent-bit のほかの issue

fluent/fluent-bit の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。