GraphiteEditor / GraphiteEditor/Graphite
Context varargs can smuggle graph-runtime references past the borrow tree's lifetime discipline
- Ngôn ngữ chính
- Rust
- Star
- 27.2k
- Fork
- 1.3k
- Merge trung bình
- 20 giờ 5 phút
- Pull request đã merge (30 ngày)
- 57
Mô tả
Reported by @TrueDoctor following the rank polymorphism PR (#4335). Three existing mechanisms combine into an unsound API surface:
1. The borrow tree launders lifetimes: `NodeContainer` derefs `*const TypeErasedNode<'static>` to `&'static`, so references handed out inside the graph (the `&PlatformEditorApi` scope wire, `&WgpuExecutor`, or any reference to node-owned state) are typed `'static` but actually live only until the next graph recompilation deallocates their owner.
2. `OwnedContextImpl::with_vararg` accepts any `Box`. Its `'static` bound cannot distinguish real ownership from a laundered reference, so safe code in any node can store such a reference into a context. #4335 made this channel idiomatic (render boundary config, per-item lambda rows).
3. Contexts escape the graph: the Monitor node snapshots `IORecord { input: Context, output }` into an `Arc` that the editor introspects and can retain across recompiles.
Combined: a node stores a laundered reference as a vararg, a Monitor captures the context, the graph recompiles and frees the referent, and the editor reads freed memory through entirely safe code (`vararg()` + `downcast_ref`). A vararg with interior mutability would similarly let context readers mutate graph-owned state as a covert return channel.
All current `with_vararg` callers box owned data, so no UB exists in the code today. But the risk remains for the API permitting it silently.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu bằng cách lần theo OwnedContextImpl::with_vararg, việc quản lý vòng đời của NodeContainer và đường dẫn snapshot IORecord của node Monitor, sau đó xem xét các thay đổi về đa hình hạng trong #4335. Công việc được xem là hoàn tất khi các API context và vararg không còn cho phép các tham chiếu đến graph runtime thoát khỏi vòng đời hợp lệ của chúng, kể cả khi đi qua quá trình biên dịch lại graph, mà không làm suy yếu các đảm bảo của mã an toàn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- rust
- Lĩnh vực
- backend-api-design
- Loại issue
- Lỗi
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100