Launcher store access: check and use the same handle, and log every open

Aperta
#245 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
desktop, security

Direzione di ricerca

Start at the LibraryAccess/LibraryRegistryAccess layer added by PR #243 in clean/installer/src/wg_core/util.h; read FinalForm, RealPathOk and FindFilesNamed in util.cpp to see where the checked handle is closed. Follow the candidate path from model.cpp (~141) into clean/converter/src/api.cpp (~81, 227) and convert_ignore.cpp (~309-316) — that is where a handle or bytes must replace the path. Done: a unit test swaps the checked folder or file for a junction and the read is refused; hash and convert each log an access line.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: converter area: launcher enhancement

Background

PR #243 added one store-access layer (clean/installer/src/wg_core/util.h LibraryAccess / LibraryRegistryAccess).
In a WRONGGPU_TESTING build with WRONGGPU_TEST_LIBRARIES set, it confines every store-library read to the test run's
own folder. It refuses paths whose final form differs from their long name, reparse points, files with a second name and
a test folder that resolves elsewhere. It logs every access before the read and refuses a read whose line cannot be
written. The test suite never reads a real store library. Three smaller points remain.

1. Check-then-use: the checked handle is not the read handle

util.cpp checks a path with one handle and closes it. The later read then opens the path again:

  • FinalForm (around lines 535-541) and the reparse / link-count check in RealPathOk (around 563-568) close their
    handles;
  • FindFilesNamed then enumerates the folder by path (around 636-638) and returns file paths (around 647-648);
  • model.cpp (around line 141) passes such a path to the converter, which opens it again (clean/converter/src/api.cpp
    around lines 81 and 227).

If a folder or file is replaced with a junction or link between the check and the use, the read can land somewhere else
while the inside path is logged. In the test suite this needs a concurrent swap inside the suite's own synthetic folders,
so it is not reachable there today. It is still not a strict guarantee.

Proposed:

  • Open once with FILE_FLAG_OPEN_REPARSE_POINT (plus FILE_FLAG_BACKUP_SEMANTICS for folders). Run the final-path,
    reparse and link-count checks on that handle, and use the same handle for the read:
    • enumerate folders with GetFileInformationByHandleEx(FileIdBothDirectoryInfo);
    • read files through the handle.
  • Let the converter take an open handle (or a file already read into memory) instead of a path, so the launcher's checked
    handle is the one that is read.

2. A log line for every actual open, not only discovery

FindFilesNamed logs each folder walked and each matching file found, but some found files are opened more than once
later without their own access line:

  • with a non-empty ignore list, model.cpp (around lines 61-65) and convert_ignore.cpp (around 309-316) hash a
    candidate, opening it through util.cpp (around 660-661);
  • model.cpp (around 139-142) then converts the same candidate, and the converter opens it again.

So a failed log append after discovery does not stop these later reads, and the log cannot account for each open.

Proposed: call LibraryAccess (or the handle-based form from point 1) right before each of these opens, the hash and the
convert, so every open has its own line and the fail-closed rule covers it.

3. Release builds: note what still runs

The final-path, environment and access-log code is compiled only in WRONGGPU_TESTING builds, and LibraryAccess /
LibraryRegistryAccess return true in release builds. Release builds still run two things:

  • the unconditional atomic access counter (LibraryAccessCount; increments around util.cpp lines 482, 578 and 605);
  • the new call sites.

The behaviour is unchanged, but the code path is not literally identical, and no release-build parity test covers it.

Proposed: either keep the counter only in testing builds, or keep it and add a short note to util.h and the README's
Tests section that it is the one piece that runs in release. Add a release-build unit test that LibraryAccess returns
true and changes nothing else.

Done when

  • The store-access check and the read use the same handle (folder enumeration and file reads in the launcher; the
    converter takes a handle or bytes), with a unit test that swaps a checked folder or file for a junction after the check
    and shows the read is refused or stays inside.
  • Hashing and converting a library candidate each write their own access line, and a failed append refuses them (unit
    test).
  • Release-build behaviour is stated and tested as above.
Lingua principale
C++
Stelle
12
Fork
2
Merge medio
3h 10m
PR unite (30g)
171

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di phantoslayer21/wronggpu

Tutte le issue di phantoslayer21/wronggpu

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.