Bundled ORT cache installation is unbounded and races concurrent loaders #18

Open
opened 2026-10-18 08:57:32 +08:00 by Breadway · 0 comments
Owner

Found during independent exact-head review of breadsearch PR13 at 354343c58e. Confidence: high. breadmill/src/embed.rs:97-105 reads arbitrary existing cache paths with fs::read before checking regular-file type or size, creates directories with inherited umask, and lines 117-123 unlink installed shared libraries before renaming without serialization. Isolated real-binary reproduction: precreate a FIFO at cache/breadsearch/runtime/libonnxruntime.so.1.28.0, start with cached real model and empty roots; status stays model_ready=false/model_error=null because loader blocks opening FIFO. With umask 000, successful provisioning creates both executable-code libraries mode 0666 and runtime directory mode 0777. Concurrent installers can remove a library between another loader check and dlopen, or race exists/remove causing ENOENT. Evidence: /tmp/opencode/pr13-fmd0vs8q and review worktree ~/.worktrees/breadsearch/fix/astra-review-pr13-354343c. Fix in existing PR13: owned private directory and regular-file/no-follow checks, bounded comparison, serialized/atomic publication without unlink gap, tests for concurrent first install/repair and unsafe cache entries. README.md:164-168 also still claims system linker discovery without ORT_DYLIB_PATH, contradicting new explicit bundled default. No merge performed.

Found during independent exact-head review of breadsearch PR13 at 354343c58e500db32d915ec197d7ca423e9222ea. Confidence: high. breadmill/src/embed.rs:97-105 reads arbitrary existing cache paths with fs::read before checking regular-file type or size, creates directories with inherited umask, and lines 117-123 unlink installed shared libraries before renaming without serialization. Isolated real-binary reproduction: precreate a FIFO at cache/breadsearch/runtime/libonnxruntime.so.1.28.0, start with cached real model and empty roots; status stays model_ready=false/model_error=null because loader blocks opening FIFO. With umask 000, successful provisioning creates both executable-code libraries mode 0666 and runtime directory mode 0777. Concurrent installers can remove a library between another loader check and dlopen, or race exists/remove causing ENOENT. Evidence: /tmp/opencode/pr13-fmd0vs8q and review worktree ~/.worktrees/breadsearch/fix/astra-review-pr13-354343c. Fix in existing PR13: owned private directory and regular-file/no-follow checks, bounded comparison, serialized/atomic publication without unlink gap, tests for concurrent first install/repair and unsafe cache entries. README.md:164-168 also still claims system linker discovery without ORT_DYLIB_PATH, contradicting new explicit bundled default. No merge performed.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Breadway/breadsearch#18
No description provided.