Repository navigation
fix(shm): copy shared memory out instead of holding references into it; ci: --locked - #288
Open
SteveGilvarry wants to merge 2 commits into
Open
SteveGilvarry wants to merge 2 commits into
SteveGilvarry wants to merge 2 commits into
Conversation
zmc and zma write a monitor's segment while zm-api reads it. MonitorShm handed out &SharedData and &mut TriggerData into the mapping, which tells Rust the bytes cannot change while the reference lives: undefined behaviour once another process writes, and room for the optimiser to cache or merge reads. Reads now take a volatile copy of the struct; writes go field by field with write_volatile through a pointer from as_mut_ptr. The release fence before the trigger state stays, so score, cause and texts still land before TRIGGER_ON. Cancel now writes the state last too. The unused shared_data_mut is gone. Adds tests for cancel and disable, which had none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without it cargo quietly updates Cargo.lock when it is out of step with Cargo.toml, so CI can pass on dependency versions nobody committed (and cargo-audit, which reads Cargo.lock, checks different ones). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small hardening changes left over from an earlier security review whose other findings have since landed on master.
Shared memory (
src/zm_shm.rs)zmc and zma write a monitor's segment while zm-api reads it.
MonitorShmhanded out&SharedDataand&mut TriggerDatapointing into the mapping. A reference promises Rust the bytes won't change while it lives, which another process breaks whenever it writes: undefined behaviour, and room for the optimiser to cache or merge reads.read_volatilecopy of the struct. Every field is an integer, float or byte array, so any bytes are a valid value.write_volatilethrough a pointer fromas_mut_ptr().TRIGGER_ON.cancel_alarmnow writes the state last as well.shared_data_mutis removed.cancel_alarmanddisable_triggers, which had none, and for the padding helper.CI (
.github/workflows/test.yml)Adds
--lockedto thecargo test,cargo clippyandcargo runsteps. Without it cargo silently updatesCargo.lockwhen it's out of step withCargo.toml, so CI can pass on dependency versions nobody committed, and cargo-audit (which readsCargo.lock) checks different ones.Testing
cargo fmt --all -- --check: cleancargo clippy --locked --all-targets --all-features -- -D warnings: cleancargo test --locked --all-features: 1436 passed, 0 failed. The DB-backed#[ignore]tests were not run locally.🤖 Generated with Claude Code