Skip to content

libc: zero stat fields the kernel does not report#931

Closed
brandonpayton wants to merge 1 commit into
mainfrom
fix/stat-unreported-fields-zero
Closed

libc: zero stat fields the kernel does not report#931
brandonpayton wants to merge 1 commit into
mainfrom
fix/stat-unreported-fields-zero

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jul 13, 2026

Copy link
Copy Markdown
Member

What changed

#907 already landed the mmap and munmap fixes from the old #769 stack and established the current ABI 39 baseline. This PR does not replay that work.

Kandelo's ABI 39 WasmStat ends at 88 bytes. musl's target-specific struct kstat appends st_rdev, st_blksize, and st_blocks, but the kernel does not write those fields. fstatat() previously copied whatever happened to be on the stack into struct stat.

This PR:

  • zero-initializes struct kstat before the syscall;
  • adds a regression covering fstat(), stat(), and lstat() after poisoning the stack;
  • documents the current incomplete metadata honestly.

What was deliberately removed

I did not carry over #769's proposed st_blksize = 4096 or st_blocks = ceil(st_size / 512) synthesis. That calculation is wrong for sparse files because logical size is not allocated storage. I also did not carry over any SQLite patches or harness changes.

#928 tracks the proper follow-up: collect truthful block and device metadata from each filesystem backend and treat the wire-format work as ABI-changing until audited.

ABI and package artifacts

There is no ABI layout or syscall-marshalling change here. ABI_VERSION stays at 39, and the committed snapshot and generated host bindings are unchanged.

There are no package revision, binary-index, or VFS-image changes. Existing static packages remain ABI-compatible; they need an ordinary libc/package rebuild to receive this hardening. No prebuilt package artifacts are published by this PR.

Validation

Run through scripts/dev-shell.sh:

  • proved the new focused regression fails on unmodified main by exposing a nonzero garbage st_rdev;
  • built musl for wasm32 and wasm64 after the overlay change;
  • built the kernel and passed the ABI snapshot/generated-binding check;
  • focused stat regression: 1 passed;
  • POSIX suite: 174 passed, 3 expected failures, 2 skipped, 0 failed;
  • libc suite: 300 passed, 20 expected failures, 1 flaky pass; the 3 initial failures only lacked /bin/sh, and all 3 passed after building current dash;
  • Sortix suite: 5,026 passed, 23 expected failures, 53 skipped; the 8 initial failures only lacked generated program/dash fixtures, and all 8 passed after building those fixtures. The new stat regression passed in the full run;
  • full program build, including wasm64: passed;
  • full host Vitest: 141 files passed, 1,206 tests passed, 2 expected failures, 185 skipped.

Hosted staging CI at head c6f4977f3ea2c6bd909e4daaf3f6fbb01c7ca716 also passed:

  • 14 library rebuilds and 57 package rebuilds;
  • test-gate preparation;
  • cargo/kernel, fork-instrument, POSIX, libc, Sortix, full Vitest, and browser suites;
  • merge gate.

Not run locally: manual browser verification, the browser test suite, SQLite sort2, package image rebuilds, or performance benchmarks. The hosted browser suite did run and pass. This PR does not change host runtime, browser adapters, VFS allocation, package recipes, or the ABI, and it makes no performance claim.

@github-actions

Copy link
Copy Markdown

Phase B-1 matrix build status — pr-931-staging

ABI v39. 71 built, 0 failed, 71 total.

Package Arch Status Sha
icu wasm32 built 597909e9
libcurl wasm32 built 4c8563da
libcxx wasm32 built d4d73697
libcxx wasm64 built e5c7a35a
libiconv wasm32 built a2e4479a
libpng wasm32 built b2c247ba
libxml2 wasm32 built c7c447be
libzip wasm32 built 93f64079
openssl wasm32 built 7eb39510
openssl wasm64 built 55f7f2e1
sqlite wasm32 built 532ea231
sqlite wasm64 built 66859ff4
zlib wasm32 built 76d2ba71
zlib wasm64 built 0f0ed605
bc wasm32 built 54295528
bzip2 wasm32 built ae4ff490
coreutils wasm32 built a744cccd
curl wasm32 built 7e64cad4
dash wasm32 built 219bd1fc
diffutils wasm32 built 85768b7a
dinit wasm32 built 5645a064
fbdoom wasm32 built 60fab3c5
file wasm32 built 64f09e5a
findutils wasm32 built 304bca9a
gawk wasm32 built aabf6e3d
git wasm32 built c83f1100
grep wasm32 built 033701d7
gzip wasm32 built 228e00c4
hello wasm32 built a9c97de2
kandelo-sdk wasm32 built 4f18529e
kernel wasm32 built 0f97e289
less wasm32 built 7f55ef5d
lsof wasm32 built 424fce40
m4 wasm32 built 4bb05c73
make wasm32 built 50f15e01
mariadb wasm32 built f3d6b0c1
mariadb wasm64 built 8d6fb52b
modeset wasm32 built 985e5b34
msmtpd wasm32 built 6d230c78
nano wasm32 built f4895435
ncurses wasm32 built e49944d6
netcat wasm32 built 0b31c929
nginx wasm32 built 237ced73
php wasm32 built 95b56839
posix-utils-lite wasm32 built d33b0f56
ruby wasm32 built 3f14ed28
sed wasm32 built 2b4359f1
spidermonkey wasm32 built b9be1e7d
tar wasm32 built 9606a07c
tcl wasm32 built 29034860
unzip wasm32 built 4dd311bd
userspace wasm32 built 700ab731
vim wasm32 built 554d5be2
wget wasm32 built 0c0a53ae
xz wasm32 built 18fda993
zip wasm32 built d8a86605
zstd wasm32 built e4b4e772
bash wasm32 built 870ec43e
mariadb-test wasm32 built 50dfbbdd
mariadb-vfs wasm32 built 60b01725
mariadb-vfs wasm64 built 36e1c9d4
nethack wasm32 built 765817ec
node wasm32 built 72d6a54e
spidermonkey-node wasm32 built 37bcba74
vim-browser-bundle wasm32 built 5df8c816
nethack-browser-bundle wasm32 built a0e0a234
rootfs wasm32 built 585a598e
shell wasm32 built b78ec354
lamp wasm32 built 49d477ad
node-vfs wasm32 built 664580bf
wordpress wasm32 built 08d577dc

Auto-generated; replaced on each push. Raw data in the publish-status workflow artifact.

@brandonpayton

Copy link
Copy Markdown
Member Author

Closing this focused source PR because its zero-initialization of unreported stat fields is now carried by #934 at exact green head 260d75d5adc31b327f5591229dbfbb287d395fd6. #934 keeps it as a separate purpose commit and passed the full staging, libc, POSIX, and Sortix gates. This is not a claim that this branch was merged verbatim.

@brandonpayton brandonpayton deleted the fix/stat-unreported-fields-zero branch July 14, 2026 02:43
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.

1 participant