GraphiteEditor / GraphiteEditor/Graphite

Context varargs can smuggle graph-runtime references past the borrow tree's lifetime discipline

未关闭
#4,358 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Graphene
主要语言
Rust
星标
27.2k
派生
1.3k
平均合并
20 小时 5 分钟
30 天内合并 PR
57

描述

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.

贡献指南

这个仓库没有索引到贡献指南

调研方向

首先跟踪 OwnedContextImpl::with_vararg、NodeContainer 的生命周期处理以及 Monitor 节点的 IORecord 快照路径,然后审查 #4335 中的秩多态更改。完成的标准是:context 和 vararg API 不再允许图运行时引用逃逸出其有效生命周期,包括跨越图重新编译的情况,同时不削弱安全代码保证。

由索引模型根据 Issue 内容生成。

评估

技术栈
rust
领域
backend-api-design
Issue 类型
缺陷
难度
5/5
预计耗时
一周以上
活跃度
冷清
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。