Bit-masked instruction relocations panic on one-to-three-byte write windows across four backends
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
linker-utils/src/utils.rs の RelocationKindInfo::write_to_buffer から始めます。その BitMasking 分岐は、上記の ByteSize チェックとは異なり、instruction.write_windows_size() を残りの長さと比較せずに RelocationInstruction::write_to_value を呼び出します。その分岐と linker-utils/src/ppc64.rs:379 の PPC64 経路を読んでください。issue の repro.sh を実行して、3 バイトの AArch64 ウィンドウが 101 で終了することを確認してください。完了とは、1-3 バイトのウィンドウが通常の範囲外セクションエラーを返し、0-4 の長さ行列が 4 つすべてのバックエンドで通ることです。
索引モデルが issue の本文から書いたものです。
説明
Summary
A relocation at a valid section offset can leave fewer than four bytes in its
write window. Wild checks the available size for byte-sized relocations, but
not for bit-masked instruction relocations. Every supported ELF instruction
backend therefore panics when the remaining section length is 1, 2, or 3:
| Backend | Representative relocation | Panic frame |
|---|---|---|
| AArch64 | R_AARCH64_ADR_PREL_PG_HI21 |
linker-utils/src/utils.rs:20 |
| RISC-V64 | R_RISCV_JAL |
linker-utils/src/utils.rs:27 |
| LoongArch64 | R_LARCH_B26 |
linker-utils/src/utils.rs:27 |
| PPC64LE | R_PPC64_REL24 |
linker-utils/src/ppc64.rs:379 |
The paired four-byte object links successfully for every backend. All twelve
short-window inputs exit 101 in the ordinary release build.
Root cause
RelocationKindInfo::write_to_buffer validates ByteSize against
output.len(). In its BitMasking branch it instead passes
&mut output[..output_len] to RelocationInstruction::write_to_value without
checking instruction.write_windows_size(). Every instruction writer assumes
a four-byte destination and indexes or combines all four bytes.
The relocation offset itself is inside the section, so this is distinct from
issue 2989, where the relocation offset is beyond the section. It also does
not depend on an architecture relaxation.
Rust bounds checks prevent an out-of-bounds write, so this report makes no
memory-corruption claim.
Inline reproducer
Prerequisites: Clang with the AArch64 target and Wild.
Save this as repro.sh, then run WILD=/path/to/wild sh repro.sh:
#!/bin/sh
set -u
: "${WILD:=wild}"
: "${CC:=clang}"
work=$(mktemp -d "${TMPDIR:-/tmp}/wild-bitmask-window.XXXXXX")
trap 'rm -rf "$work"' EXIT HUP INT TERM
make_object() {
name=$1
size=$2
cat >"$work/$name.s" <<EOF
.section .text,"ax",@progbits
.globl _start
_start:
.space $size, 0
.reloc _start, R_AARCH64_ADR_PREL_PG_HI21, _start
EOF
"$CC" --target=aarch64-linux-gnu -c "$work/$name.s" -o "$work/$name.o"
}
make_object control 4
make_object trigger 3
for name in control trigger; do
RUST_BACKTRACE=0 "$WILD" --no-fork -m aarch64linux -static -e _start \
"$work/$name.o" -o "$work/$name" >"$work/$name.stdout" 2>"$work/$name.stderr"
eval "${name}_status=$?"
eval "echo \"$name exit=\$${name}_status\""
sed -n '/panicked at/p;/index out of bounds/p' "$work/$name.stderr"
done
test "$control_status" -eq 0
test "$trigger_status" -eq 101
grep -q 'panicked at linker-utils/src/utils.rs:20:' "$work/trigger.stderr"
Expected result: The four-byte instruction control exits 0. The three-byte bit-masked relocation exits 101 in the shared instruction writer. The retained matrix covers lengths 1 through 4 on all four listed backends.
Current-head validation
Reproduced three times on 2026-11-15 against exact WILD commit
81069d0e456b67dbae0c3d25ad8129eb7e0c1876. No matching public issue was
found by searches for the shared writer, panic frames, and short-window
symptom.
Suggested fix
Before calling the instruction writer, require
output.len() >= instruction.write_windows_size() and return a normal
Relocation outside of bounds of section error otherwise. A regression matrix
should cover remaining lengths 0 through 4 on every instruction backend.
AI assistance disclosure
An LLM assisted with source auditing, boundary generation, duplicate
searching, current-head replay, and drafting. I ran the reproducer and reviewed
the claims.
- 主要言語
- Rust
- スター
- 4k
- フォーク
- 142
- 平均マージ
- 19時間 48分
- マージ済み PR(30日)
- 191
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
wild-linker/wild のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
wild-linker/wild#3004 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 71/100
wild-linker/wild#3001 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
wild-linker/wild#2993 ·
メンテナーはふだん 1 日以内に返信
-
version script: restrict identifiers on non-WASI targets対応中かも @BhuvanB404 が 28 日前に担当しました。 オープンgood first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
wild-linker/wild#2756 · コメント 6 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Attribution when distributing binaries linked with wild?再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
wild-linker/wild#1856 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
wild-linker/wild の issue をすべて見る
似ている issue
-
priority: low
難易度 1/5 1〜3時間 初心者へのやさしさ 83/100
storytold/vectorcraft#8387 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
area:desktop kind:test priority:p3 ready
難易度 2/5 1〜3時間 初心者へのやさしさ 91/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
obi1kenobi/cargo-semver-checks#1814 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
BurntSushi/jiff#715 ·
メンテナーはふだん 1 日以内に返信