Skip to content

Fix MoveDistribution VHD ownership restore to reuse the resolved file handle (backport to release/2.7)#41147

Merged
benhillis merged 1 commit into
release/2.7from
user/benhill/movedistribution-vhd-owner-handle-2.7
Jul 23, 2026
Merged

Fix MoveDistribution VHD ownership restore to reuse the resolved file handle (backport to release/2.7)#41147
benhillis merged 1 commit into
release/2.7from
user/benhill/movedistribution-vhd-owner-handle-2.7

Conversation

@benhillis

Copy link
Copy Markdown
Member

Backport of #41131 to release/2.7.

setVhdOwner now opens the destination impersonated as the caller with READ_CONTROL, then uses ReOpenFile to upgrade that same handle to WRITE_OWNER while running as SYSTEM with SE_RESTORE_NAME, rather than re-resolving the path by name. ReOpenFile reuses the existing file object instead of walking the path again.

Also moves the rollback scope_exit registration earlier so a failure in setVhdOwner while moving to the new path correctly triggers rollback of the move and registry changes.

… handle

setVhdOwner now opens the destination impersonated with READ_CONTROL, then uses ReOpenFile to upgrade the same handle to WRITE_OWNER while running as SYSTEM, instead of re-opening the path by name as SYSTEM. This avoids a second path resolution under elevated privileges. Also moves the rollback scope_exit registration earlier so a failure in setVhdOwner while moving to the new path correctly triggers rollback.
Copilot AI review requested due to automatic review settings July 23, 2026 04:51
@benhillis
benhillis requested a review from a team as a code owner July 23, 2026 04:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Backports the MoveDistribution VHD ownership-restore fix to release/2.7, ensuring ownership is restored using a handle tied to the already-resolved destination file object (avoiding re-walking the destination path as SYSTEM) and improving rollback behavior when ownership restoration fails.

Changes:

  • Update VHD owner-restore logic to open the moved VHD while impersonating the caller (READ_CONTROL) and then ReOpenFile for WRITE_OWNER under SYSTEM + SE_RESTORE_NAME.
  • Register rollback earlier so failures during ownership restoration still trigger a move-back and registry correction.
  • On rollback, best-effort re-apply ownership fix to the reverted VHD in case a cross-volume copy altered ownership.

@benhillis
benhillis merged commit 11a866e into release/2.7 Jul 23, 2026
8 checks passed
@benhillis
benhillis deleted the user/benhill/movedistribution-vhd-owner-handle-2.7 branch July 23, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants