Skip to content

CI: the hardened Linux arm64 lanes are compiled without -mtune - #916

Merged
dylan-conway merged 1 commit into
mainfrom
claude/linux-arm64-hardened-no-mtune
Oct 27, 2026
Merged

dylan-conway merged 1 commit into
mainfrom
claude/linux-arm64-hardened-no-mtune

Conversation

@dylan-conway

@dylan-conway dylan-conway commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

The two hardened Linux arm64 lanes lose -mtune=ampere1, so that glibc's _FORTIFY_SOURCE wrappers are inlined again. A hardened lane now also fails when they are not.

What was wrong

Seen with autobuild-982277c9dd3ee8177ca578e6d871428faeb5021f / bun-webkit-linux-arm64-lto-hardened.tar.gz, linked into a Linux aarch64 glibc release LTO build of Bun with --hardened=on, LLVM 23. The linked binary defines 187 local symbols that are out-of-line copies of glibc's always-inline fortify wrappers:

llvm-nm --defined-only bun-profile | grep -E ' [a-z_0-9]+\.inline(\.llvm\.[0-9]+)?$'
-> fread, memcpy, memmove, memset, strcat, strcpy, strncat, strncpy, vfprintf, vsnprintf

The same build against bun-webkit-linux-arm64-lto.tar.gz has 0, and so has a Linux x64 build against bun-webkit-linux-amd64-lto-hardened.tar.gz. Out of line, a wrapper cannot see the size of the destination, so it calls the plain function: no __memcpy_chk and so on.

Likely cause

clang emits its copies of the wrappers (memcpy.inline, ...) without a tune CPU, and LLVM 23's AArch64 inliner does not inline them into functions that have one ("conflicting target features"). clang 22 does.

#include <string.h>
char g[32]; void f(const char *s, size_t n) { memcpy(g, s, n); }
clang --target=aarch64-linux-gnu -O2 -D_FORTIFY_SOURCE=2 -mtune=ampere1 -Rpass-missed=inline -S
-> f calls memcpy.inline instead of __memcpy_chk

The change

Lane MARCH_FLAG before after
bun-webkit-linux-arm64-lto-hardened --target=aarch64-unknown-linux-gnu -march=armv8-a+crc -mtune=ampere1 --target=aarch64-unknown-linux-gnu -march=armv8-a+crc
bun-webkit-linux-arm64-lto-hardened-aot the same the same

Compared with lanes.mjs --json before and after: of the 76 lanes these two change, in MARCH_FLAG alone. The four hardened amd64 lanes and the other arm64 lanes are as they were, and no toolchain image gets a new tag.

A check, so that CI says whether this is the cause

That this is the cause has not been confirmed on the WebKit side, and nothing was built for this pull request. So Dockerfile now runs the llvm-nm line above on the jsc of every hardened lane and fails the lane when it prints anything.

What was checked so far is that jsc imports some __*_chk function. That passed on the broken lanes: one caller anywhere is enough.

  • The two arm64 hardened lanes pass: -mtune was the cause, and it is fixed.
  • They fail with "these _FORTIFY_SOURCE wrappers were not inlined": it was not, or not alone. The log lists the wrappers.
  • An amd64 hardened lane fails: jsc has copies that the Bun build above did not show, which is worth knowing too.

The shell logic of the new line was tried on stand-in symbol tables (memcpy.inline and vsnprintf.inline.llvm.123 are caught; foo.inlined and _ZN3WTF6inlineEv are not).

Not measured

What the hardened arm64 lanes lose in speed without -mtune=ampere1. The lanes that are not hardened keep it.

To check a tarball from this pull request

Link Bun against it. The llvm-nm line should print nothing, and the disassembly should show calls to __memcpy_chk from JSC:: and WTF:: functions.


Generated by Claude Code

clang emits its copies of glibc's always-inline _FORTIFY_SOURCE wrappers
(memcpy.inline, ...) without a tune CPU, and LLVM 23 for AArch64 inlines no
such function into one that has one. Out of line, a wrapper cannot see the size
of the destination and calls the plain function, so nothing is checked.

bun-webkit-linux-arm64-lto-hardened and -lto-hardened-aot lose -mtune=ampere1
and keep -march=armv8-a+crc. No other lane changes, and no toolchain image gets
a new tag.

A hardened lane now fails when its jsc holds a copy of such a wrapper. That jsc
imports a checked function, which is what was looked at so far, says little:
one caller is enough.
@dylan-conway
dylan-conway force-pushed the claude/linux-arm64-hardened-no-mtune branch from 689e015 to c8f5604 Compare October 27, 2026 08:21
@dylan-conway
dylan-conway merged commit cdce396 into main Oct 27, 2026
3 of 79 checks passed

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this PR and didn't find any bugs. Since .github/ is a CODEOWNERS path and the new Dockerfile check deliberately gates every hardened lane on a hypothesis this PR has not yet built, a human look alongside this PR's own CI run is still worthwhile.

What was reviewed:

  • The MARCH_FLAG conditional in lanes.mjs: -mtune=ampere1 is dropped only when v.hardened is set, which on arm64 is exactly lto-hardened and lto-hardened-aot (the arm64 lane list); the other arm64 platforms (musl, FreeBSD, Android) keep -mtune but have no hardened lanes, so they are unaffected.
  • The toolchain image tag: it hashes the Dockerfile only up to the end of the base stage (line 286), and both Dockerfile edits are in the WebKit stage, so no image is retagged.
  • The new llvm-nm | grep check at Dockerfile:492: same ! pipeline || { ...; exit 1; } shape as the existing ENABLE_FUZZILLI check at line 484, it runs on the unstripped jsc (no -s at link; llvm-strip comes later on the copy), and C++ mangled names (_Z...) cannot match [a-z_0-9]+. One gap: a copy renamed with a bare numeric suffix (e.g. memcpy.inline.2) would not match, so a pass is slightly weaker than "no copies", not a false failure.
Extended reasoning...

The change touches three files: a one-expression conditional in .github/scripts/lanes.mjs that omits -mtune=ampere1 from the Linux glibc arm64 hardened lanes, a new shell assertion in the Dockerfile's HARDENING_FLAGS block that fails a hardened lane when jsc defines any un-inlined fortify wrapper, and matching comment and CLAUDE.md wording. It touches no auth, crypto or injection surface; it strengthens the _FORTIFY_SOURCE hardening that ships and adds a CI gate for it. Deferral rather than approval rests on two facts: .github/ is covered by the repository's CODEOWNERS file (inherited from upstream), and the author states nothing was built for this PR, so whether the four amd64 hardened lanes pass the new check, and thus whether the release job still gets every asset, is decided by this PR's CI run rather than by reading the diff.

This review covers commit 689e015, which is no longer the latest commit on this pull request; later commits are not covered by it.

dylan-conway added a commit to oven-sh/bun that referenced this pull request Oct 27, 2026
### What does this PR do?

Moves `WEBKIT_VERSION` from `982277c9dd3e` to `191c6a41380b`, the head
of oven-sh/WebKit `main`.

> [!NOTE]
> The release `autobuild-191c6a41380bb1e2e54be4b6e50ecda83b189f96` was
published at 10:39 UTC on 2026-10-27, after this went up. Builds #133617
and #133628 ran before that and failed where they download WebKit (HTTP
404). They say nothing about the change. The PR needs one new build.

What the range brings:

| Fork PR | What it changes |
| --- | --- |
| oven-sh/WebKit#912 | The ahead-of-time compiler (890 of the 942
files). Bun does not use it. Outside `aot/`: B3, the marked block cage
and its reserve, `Interpreter::getStackTrace`, `ProxyObject`,
`JSObject::putDirect`. |
| oven-sh/WebKit#916 | The hardened Linux arm64 lanes are compiled
without `-mtune`, so that glibc's `_FORTIFY_SOURCE` wrappers are
inlined. |
| oven-sh/WebKit#917 | The buffer of an old `WeakMap` or `WeakSet` that
has shrunk counts until the next full collection. |

The pin is the only change Bun needs:

- `Heap::didChangeVisitedExtraMemory` is gone. Nothing in Bun calls it.
- `Interpreter::getStackTrace` has one more parameter, at the end and
with a default. Bun's five callers compile as they are.
- The empty table of built-ins in `RemovedFeature.cpp`, which the debug
and ASAN builds link: the range adds or removes no `builtinTable*`
symbol, no entry of the two list macros and no `extern "C"` hook for the
embedder. `BuiltinTable::typedArrayTypeOf`, which is new, is defined in
the engine.
- No asset is renamed in `lanes.mjs`, and no toolchain pin moves.
- `BytecodeList.rb` is unchanged. The one change in the bytecompiler is
for private names in object literals, which only built-in code can
write, so the hashes in `bundler_bytecode_portable.test.ts` should stay.

### How did you verify your code works?

Nothing was built. The list above is from reading the diff of the two
commits against Bun's sources.

The release has the same 77 asset names as the one of the old pin, all
uploaded, and among them the 13 that the `build-bun` jobs of #133628
asked for. All 85 jobs of the fork's build of this commit passed, its
JavaScriptCore tests on Linux x64 and arm64 included.

`test/js/bun/jsc/webkit-upgrade-191c6a4138.test.ts` covers
oven-sh/WebKit#917:

| Binary | Result |
| --- | --- |
| `main`'s CI build (92e819d, linux x64, the old pin) | 0 pass, 2
fail: the heap is 262,032 bytes (`WeakMap`) and 129,498 bytes
(`WeakSet`) smaller after the eden collection |
| Bun 1.4.4 (an engine from before the bug) | 2 pass |

Both the same with `BUN_GARBAGE_COLLECTOR_LEVEL` 0, 1 and 2. It has not
run on the new engine yet: CI is the first run.

`bun test test/internal/source-lints/` passes (186).

---
_Generated by [Claude
Code](https://claude.ai/code/session_01YF5TQxMfo4rBWHbttbVAhn)_

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants