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

Đang mở
#245 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp
Lĩnh vực
desktop, security

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
C++
Star
12
Fork
2
Merge trung bình
3 giờ 10 phút
Pull request đã merge (30 ngày)
171

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của phantoslayer21/wronggpu

Tất cả issue của phantoslayer21/wronggpu

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.