Skip to content

Audit follow-ups: shared /tmp in rspec sweep, sh traps on INT, pwrite swallowing ENOSPC/EIO, pread flush clobbering #974

Open

Description

@tannevaled

Remaining findings from a security and functionality audit of #968, #971 and #970. They are smaller than #972 and #973, and none of them blocks a merge.

Scripts (follow-up to #968)

  • scripts/conformance/rspec/run.sh:24 still uses a fixed /tmp/parsesweep, which every checkout shares. This is the same class of problem scripts: build rbgo every run instead of reusing a /tmp binary #968 fixed for rbgo. Use mktemp -d and an EXIT trap.
  • scripts/oracle.sh and apps/run.sh use #!/bin/sh. dash does not run EXIT traps on INT or TERM, so the build directory leaks on Linux when interrupted (inferred, not measured). Add trap 'exit 130' INT TERM beside the EXIT trap.
  • scripts/conformance/rubyspec/run.sh:70 runs without set -e. If mktemp -d fails, RBGO becomes /rbgo. Check the mktemp result explicitly.
  • scripts/oracle.sh builds before validating its arguments. Validate first.

VM

  • internal/vm/io_descriptors.go ~:374: when pwriteFile fails with anything other than a permission error (ENOSPC, EIO), the error is swallowed and pwrite reports success through the buffer fallback. MRI raises the Errno. Fall back only when the path is unreachable, and raise otherwise.
  • With a pending write, pread flushes the whole buffer snapshot, which can overwrite another writer's bytes. Measured: the file abcdefghijKLM became Q123456789 after f.write("Q"); f.pread(…). The flush model was already like this, but a read now triggers it. Related to Closing a writable File that was never written to rewrites it from its buffer: another writer's bytes are lost, an unlinked file comes back #969.
  • Pre-existing: after getc; ungetc("Z"); write("AB") the file holds "0AB23456789", where MRI has "AB23456789".
  • Pre-existing: a Bignum offset to pread/pwrite raises TypeError, where MRI raises RangeError.

Prior art: priorart "parsesweep tmp shared trap INT mktemp" at 2026-11-21 20:44 CET reported prior art; checked: priorart 'parsesweep tmp shared trap INT mktemp': hits are #968 (fixed rbgo only, not parsesweep) and unrelated 'shared' issues; none covers these

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions