Skip to content

Conversation

@katiewasnothere
Copy link

@katiewasnothere katiewasnothere commented Jun 2, 2020

This PR moves go-winio passed breaking changes from /x/sys/windows for dealing with Security Descriptors.

Added test to validate flow change to use windows.SECURITY_DESCRIPTOR.

Signed-off-by: Kathryn Baldauf kabaldau@microsoft.com

pipe.go Outdated
defer localFree(sdb)
copy((*[0xffff]byte)(unsafe.Pointer(sdb))[:], sd)
defer windows.LocalFree(windows.Handle(sdb))
copy((*[0xffff]byte)(unsafe.Pointer(sdb))[:len], (*[0xffff]byte)(unsafe.Pointer(sd))[:len])
Copy link
Member

Choose a reason for hiding this comment

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

This looks like we are copying the security descriptor into a new buffer and then casting that buffer to be a security descriptor as well. Should we just change objectAttributes to take a windows.SECURITY_DESCRIPTOR instead?

Copy link
Member

Choose a reason for hiding this comment

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

We're fairly inconsistent about following the Go requirements around the use of Go pointers in FFI calls--would we face any possible object lifetime issues by doing this?

@jstarks
Copy link
Member

jstarks commented Jun 2, 2020

What does this change actually solve?

@katiewasnothere
Copy link
Author

What does this change actually solve?

This really just moves the repo passed the breaking changes made to x/sys/windows. Not super critical.

backuptar/tar.go Outdated
return nil, err
}
_, err = bw.Write(sd)
_, err = bw.Write((*[0xffff]byte)(unsafe.Pointer(sd))[:sdLen])

Choose a reason for hiding this comment

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

I think this needs a comment to explain where 0xffff comes from

go.sum Outdated
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3 h1:7TYNF4UdlohbFwpNH04CoPMp1cHUZgO1Ebq5r2hIjfo=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200523222454-059865788121 h1:rITEj+UZHYC927n8GT97eC3zrpzXdb/voyeOuVKS46o=
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

Choose a reason for hiding this comment

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

did you run go mod tidy?

@thaJeztah
Copy link
Contributor

@katiewasnothere looks like this needs a rebase now that #175 was merged

@TBBle
Copy link
Contributor

TBBle commented Feb 11, 2021

@katiewasnothere looks like this needs a rebase now that #175 was merged

A quick look suggests the conflicts with #175 are just adjacent-line changes in WriteBackupStreamFromTarFile and the imports list.

… functions

Signed-off-by: Kathryn Baldauf <kabaldau@microsoft.com>
@katiewasnothere katiewasnothere force-pushed the update_sddl_securityattribute branch from 0a74186 to f1eb81f Compare March 13, 2021 00:25
@katiewasnothere katiewasnothere requested a review from a team as a code owner March 13, 2021 00:25
@katiewasnothere
Copy link
Author

Updated. @dcantah and/or @kevpar could you take another look here?

//sys createVirtualDisk(virtualStorageType *VirtualStorageType, path string, virtualDiskAccessMask uint32, securityDescriptor *windows.SECURITY_DESCRIPTOR, createVirtualDiskFlags uint32, providerSpecificFlags uint32, parameters *CreateVirtualDiskParameters, overlapped *syscall.Overlapped, handle *syscall.Handle) (err error) [failretval != 0] = virtdisk.CreateVirtualDisk
//sys openVirtualDisk(virtualStorageType *VirtualStorageType, path string, virtualDiskAccessMask uint32, openVirtualDiskFlags uint32, parameters *OpenVirtualDiskParameters, handle *syscall.Handle) (err error) [failretval != 0] = virtdisk.OpenVirtualDisk
//sys attachVirtualDisk(handle syscall.Handle, securityDescriptor *uintptr, attachVirtualDiskFlag uint32, providerSpecificFlags uint32, parameters *AttachVirtualDiskParameters, overlapped *syscall.Overlapped) (err error) [failretval != 0] = virtdisk.AttachVirtualDisk
//sys attachVirtualDisk(handle syscall.Handle, securityDescriptor *windows.SECURITY_DESCRIPTOR, attachVirtualDiskFlag uint32, providerSpecificFlags uint32, parameters *AttachVirtualDiskParameters, overlapped *syscall.Overlapped) (err error) [failretval != 0] = virtdisk.AttachVirtualDisk
Copy link
Contributor

Choose a reason for hiding this comment

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

@TBBle The signature for these is changing in this PR anyways so let's make sure we get in the other /x/sys/windows'ify PR shortly after and we can cut a release.

Copy link
Contributor

@TBBle TBBle Mar 13, 2021

Choose a reason for hiding this comment

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

Sounds good. I did a quick review previously, and the conflicts are textual-only. i.e. on this line I changed the type of handle and overlapped only.

So assuming this lands first, rebasing #197 should only take a few minutes, mostly compile-checking everything.


sdb := &securityDescriptor{
Revision: 1,
Control: cSE_DACL_PRESENT,
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want to set windows.SE_DACL_PRESENT anymore?

return nil, err
}
_, err = bw.Write(sd)
_, err = bw.Write((*[(1 << 31) - 1]byte)(unsafe.Pointer(sd))[:sdLen])
Copy link
Contributor

Choose a reason for hiding this comment

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

This idiom fails -gcflags=all=-d=checkptr as of Go 1.14. In this case, it's just being moved from elsewhere, so it's not an objection to this change, but a reminder that we need to do a pass over the code-base with checkptr (or race enabled, which includes it) with Go 1.15 or later, and fix occurrences of this.

The fix itself is pretty simple, I did the same pass for hcsshim in microsoft/hcsshim#926, see Uint16BufferToSlice.

Copy link
Contributor

Choose a reason for hiding this comment

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

This idiom fails -gcflags=all=-d=checkptr as of Go 1.14. In this case

Oh! It just occurred to me now that there's no CI running in this repository (other than the license/cla check); should we add a basic github-action?

@thaJeztah
Copy link
Contributor

@katiewasnothere looks like this needs a rebase because #220 was merged

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.

7 participants