Repository navigation
nvx: share the descriptor and ACL reads of the Windows private-file checks - #1761
Open
Pedro Henrique Penna (ppenna) wants to merge 1 commit into
Open
Pedro Henrique Penna (ppenna) wants to merge 1 commit into
Pedro Henrique Penna (ppenna) wants to merge 1 commit into
Conversation
…hecks check_vm_dir and privacy_problem each ran the same two-call GetKernelObjectSecurity sequence over an aligned buffer, and vm_dir_problem and privacy_problem each ran the same GetAclInformation query for an entry count. Name each once, as a private SecurityDescriptor and ace_count in private.rs, and call them from both. The Win32 calls, their arguments and their order, and every error and problem string stay the same, and no item becomes more visible. Two tests cover the new type: the owner and entries that it reads from a store directory, and its refusal of a handle without read-control access. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues requiring changes to the Windows security-descriptor and ACL-read refactor.
No open issues 🎉
What changed in this PR
This PR addresses #1760 by consolidating duplicated Windows security-descriptor and access-control-list reads in NVX’s private-file checks, while preserving their policies, error handling, and public API.
Changes:
- Adds a private
SecurityDescriptorhelper that owns the aligned buffer used by both checks. - Extracts the shared ACL entry-count query into
ace_count, leaving policy checks unchanged. - Adds tests for reading an object’s owner and ACL entries and rejecting handles without read-control access.
| File | Description |
|---|---|
nvx/src/host/platform/windows/private/tests.rs |
Adds successful descriptor-read and access-denied tests; existing tests remain unchanged. |
nvx/src/host/platform/windows/private.rs |
Introduces shared descriptor and ACL-count helpers and replaces duplicated Win32 sequences. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1760
What does this pull request change?
nvx/src/host/platform/windows/private.rsrepeated two unsafe Win32 sequences. This pull request names each once and calls it from both places:SecurityDescriptor::of(handle)runs the two-callGetKernelObjectSecuritysequence (the length query, then the read into a buffer aligned for a descriptor) and owns the buffer.as_ptr()lends the descriptor, whose owner and list point into that buffer.check_vm_dirandprivacy_problemused to carry a copy each.ace_count(acl)runs theGetAclInformationquery for an entry count, besideace_at.vm_dir_problemandprivacy_problemused to carry a copy each.The policies that the two checks apply to the entries stay where they are.
vm_dir_problemkeeps its signature, so its tests still build descriptors by hand and call it. No item becomes more visible, and nothing outsideprivate.rsand itstests.rschanges.The diff is 124 insertions and 50 deletions: the three callers shrink by about 37 lines, and the two helpers with their documentation add about 57, so the production file grows by about 20 lines in return for one copy of each unsafe sequence. The two new tests add the other 54. Where to start: the
SecurityDescriptortype aftercheck_vm_dir.Left out, as follow-ups that #1760 lists: a shared aligned-buffer helper (
CurrentUser::getandobject_nameinlog_claim.rsrepeat thevec![0u64; ...]idiom), and a shared reader of the owner and the DACL.Why is this change needed?
The unsafe length-then-fill protocol and its safety argument now live in one place instead of two copies that had to be kept in step, and the long functions read as their policy rather than as API plumbing. The Win32 calls, their arguments and order, and each
io::Error::last_os_error()path are the same, so every error and every problem string is unchanged.Rejected: a trait or generic wrapper over all the security-descriptor reads. It would touch the test helpers and the
log_claimcode, and the four call sites that matter here need only these two helpers.How was this change validated?
Checks and results, on Windows (x86_64-pc-windows-msvc), Rust 1.97.1, with
CARGO_TARGET_DIRset to a scratch directory:3fa75642eb1, before the change:cargo test --locked --manifest-path nvx/Cargo.toml --features cli --lib -- host::platform::windowsgave 33 passed, 0 failed, 1 ignored;... -- host::vm_directory host::sandbox host::restoregave 131 passed, 0 failed, 1 ignored. After the change the same selectors give 35 passed (the two new tests) and 131 passed, and no existing test changed.python scripts\local_gates.py --base origin/dev --run --keep-going(Git'susr\binonPATH,XDG_CACHE_HOMEunset):test-changes,markdown-links,test-layout,nvx-format,nvx-lint,nvx-test,nvx-doc,nvx-msrv, andnvx-cliall passed, in 796 s. Thenvx-clirun leftNVXunset because nonvxrelease build existed, so the tests that runnvxskipped, as the gate itself reports.check-nvx, innvx/:cargo fmt --all --check, andcargo clippy --lockedwith--all-targets --all-features, with--lib, with--lib --no-default-features, with--lib --no-default-features --features serde, with--lib --bins --features cli, and with--lib --bins --no-default-features --features testing, each with-- -D warnings, all exit 0.RUSTDOCFLAGS='-D warnings' cargo doc --locked --no-deps --all-featuresexit 0.cargo test --locked --all-featuresgave 1115 passed, 0 failed in the library, andcargo test --lockedgave 555 passed, 0 failed.python scripts\public_api.pyexit 0: the snapshots innvx/public-api/are unchanged.python scripts\check_test_layout.pyexit 0, andpython scripts\check_test_changes.py --base origin/devreports 0 changes to existing tests.Backend, host OS, host type, and guest: none; this change is Windows host code and starts no VM.
Left to CI: the Linux-only
check-nvxsteps (the macOS build, the guest binaries), and the hypervisor jobs. Theguestmodule does not build on Windows, and this change does not touch it.Checklist
python3 scripts/check_test_layout.pychecks.python3 scripts/check_test_changes.py --base origin/devlists no changeto an existing test, or a Changes to existing tests section below
explains each one.
.github/copilot-instructions.mdand the skills when a convention orworkflow changes. (None is affected.)
nvxupdatesnvx-rs/public-api/withpython3 scripts/public_api.py --update. (No public item changes;nvx/public-api/is unchanged.)description says how the change versions or migrates them.