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

Offen
#4,358 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
25/100
Issue-Typ
Bug
Klarheit
Muss geklärt werden
Aktivitätsstatus
Ruhig
Tech-Stack
rust

Rechercherichtung

Beginne damit, OwnedContextImpl::with_vararg, die Lebensdauerverwaltung von NodeContainer und den IORecord-Snapshot-Pfad des Monitor-Knotens nachzuverfolgen, und überprüfe anschließend die Änderungen an der Rangpolymorphie in #4335. Als erledigt gilt die Aufgabe, wenn die context- und vararg-APIs nicht mehr zulassen, dass Referenzen auf die Graph-Laufzeit über ihre gültige Lebensdauer hinaus entweichen, auch nicht über eine Neukompilierung des Graphen hinweg, ohne dabei die Garantien von sicherem Code zu schwächen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Graphene

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<dyn AnyHash + Send + Sync>. 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<dyn Any> 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.

Vorherrschende Sprache
Rust
Sterne
27.8k
Forks
1.3k
Ø Merge
10 Std. 53 Min.
Gemergte PRs (30 T.)
195

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

  • Kein Dockerfile und keine Docker-Compose-Datei
  • Hat eine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus GraphiteEditor/Graphite

Alle Issues in GraphiteEditor/Graphite

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.