Preserve SysV semaphore errno across host dispatch - #912
Conversation
The kernel normalizes channel failures to CH_RETURN=-1 and stores the actual error in CH_ERRNO. Forward that errno through every intercepted semctl command shape instead of deriving EPERM from the normalized return value. Extend the SysV IPC guest regression to verify EINVAL after IPC_RMID for IPC_STAT, GETALL, SETALL, and scalar GETVAL.
|
Independent exact-head review: ACCEPT for Brandon review at The review traced the observed The strengthened guest fixture exercises every branch after |
|
Absorbed by rebase-merged #967. Main is now 6efb411 with the sealed tree b133bfa018f7e2bc84c4845edf2f945b2f844954, and ABI 41 activation completed successfully in run 29550069085. The absorption audit confirmed this PR\x27s behavior and tests are present in that merged tree, so this source PR is closed and its branch is deleted. |
Why
System V IPC is the POSIX-style interprocess-communication API used here for semaphore sets. errno is the numeric error code returned to a guest program when a system call fails.
kernel_handle_channelnormalizes syscall failures toCH_RETURN = -1and stores the actual errno inCH_ERRNO. The four interceptedsemctlpaths ignoredCH_ERRNOand derived errno from-CH_RETURN, so every failure becameEPERM. This surfaced in util-linuxipcrm: querying a removed semaphore should returnEINVAL, but Kandelo reportedEPERM.This is a compatible implementation correction: the host now consumes the existing channel errno field as designed. It changes no channel layout, syscall interface, or process expectation, so no ABI bump is required.
scripts/check-abi-version.shconfirms the snapshot and generated bindings remain in sync.What changed
CH_ERRNOcontract across all four host-interceptedsemctlmarshalling branches: IPC_STAT, GETALL, SETALL, and scalar commandsEINVALafterIPC_RMIDthrough IPC_STAT, GETALL, SETALL, and GETVALValidation
./scripts/dev-shell.sh bash build.shcd host && npx vitest run test/sysv-ipc.test.ts(1 passed)examples/sysv_ipc_test.wasmfixture throughscripts/browser-test-runner.ts(1/1 passed; isolated local port because 5199 was occupied by another worktree)./scripts/dev-shell.sh bash scripts/ci-run-test-suite.sh cargo-kernel(963 passed)./scripts/dev-shell.sh bash scripts/run-libc-tests.sh functional ipc_sem(1 passed)./scripts/dev-shell.sh bash scripts/run-sortix-tests.sh basic sys_sem/semctl(1 passed)./scripts/dev-shell.sh bash scripts/check-abi-version.sh(passed; no ABI delta)programs/wasm64/hello64.wasm; after building the wasm64 musl sysroot and programs through the normal repository scripts, the full rerun passed: Vitest 785 passed, 2 expected failures, 108 skipped; Bun 3 passed