]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: do not overflow key memory in GetQueuedCompletionStatus
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 23 Feb 2021 12:29:40 +0000 (13:29 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 24 Feb 2021 18:03:45 +0000 (18:03 +0000)
The third argument to GetQueuedCompletionStatus is a pointer to a
uintptr, not a uint32. Users of this functions have therefore been
corrupting their memory every time they used it. Either that memory
corruption was silent (dangerous), or their programs didn't work so they
chose a different API to use.

Fixes #44538.

RELNOTES=yes

Change-Id: Idf48d4c712d13da29791e9a460159255f963105b
Reviewed-on: https://go-review.googlesource.com/c/go/+/295371
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
api/except.txt
src/syscall/syscall_windows.go
src/syscall/zsyscall_windows.go

index 6f6f839ba604355c0841fac5d71e26d1937d5782..1ddc397d11e2ac33fd20dd4290d4a9df8629ad6c 100644 (file)
@@ -471,6 +471,9 @@ pkg syscall (openbsd-amd64-cgo), type Statfs_t struct, Pad_cgo_1 [4]uint8
 pkg syscall (openbsd-amd64-cgo), type Timespec struct, Pad_cgo_0 [4]uint8
 pkg syscall (openbsd-amd64-cgo), type Timespec struct, Sec int32
 pkg syscall (windows-386), const TOKEN_ALL_ACCESS = 983295
+pkg syscall (windows-386), func CreateIoCompletionPort(Handle, Handle, uint32, uint32) (Handle, error)
+pkg syscall (windows-386), func GetQueuedCompletionStatus(Handle, *uint32, *uint32, **Overlapped, uint32) error
+pkg syscall (windows-386), func PostQueuedCompletionStatus(Handle, uint32, uint32, *Overlapped) error
 pkg syscall (windows-386), type AddrinfoW struct, Addr uintptr
 pkg syscall (windows-386), type CertChainPolicyPara struct, ExtraPolicyPara uintptr
 pkg syscall (windows-386), type CertChainPolicyStatus struct, ExtraPolicyStatus uintptr
@@ -480,6 +483,9 @@ pkg syscall (windows-386), type CertRevocationInfo struct, OidSpecificInfo uintp
 pkg syscall (windows-386), type CertSimpleChain struct, TrustListInfo uintptr
 pkg syscall (windows-386), type RawSockaddrAny struct, Pad [96]int8
 pkg syscall (windows-amd64), const TOKEN_ALL_ACCESS = 983295
+pkg syscall (windows-amd64), func CreateIoCompletionPort(Handle, Handle, uint32, uint32) (Handle, error)
+pkg syscall (windows-amd64), func GetQueuedCompletionStatus(Handle, *uint32, *uint32, **Overlapped, uint32) error
+pkg syscall (windows-amd64), func PostQueuedCompletionStatus(Handle, uint32, uint32, *Overlapped) error
 pkg syscall (windows-amd64), type AddrinfoW struct, Addr uintptr
 pkg syscall (windows-amd64), type CertChainPolicyPara struct, ExtraPolicyPara uintptr
 pkg syscall (windows-amd64), type CertChainPolicyStatus struct, ExtraPolicyStatus uintptr
index 4a576486d11d6db18ec526b3e19b391f7719680b..a958f7aa84cdb601072208cd019e010e2d2fdb26 100644 (file)
@@ -213,9 +213,9 @@ func NewCallbackCDecl(fn interface{}) uintptr {
 //sys  SetEndOfFile(handle Handle) (err error)
 //sys  GetSystemTimeAsFileTime(time *Filetime)
 //sys  GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) [failretval==0xffffffff]
-//sys  CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error)
-//sys  GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error)
-//sys  PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error)
+//sys  CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uintptr, threadcnt uint32) (handle Handle, err error)
+//sys  GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uintptr, overlapped **Overlapped, timeout uint32) (err error)
+//sys  PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uintptr, overlapped *Overlapped) (err error)
 //sys  CancelIo(s Handle) (err error)
 //sys  CancelIoEx(s Handle, o *Overlapped) (err error)
 //sys  CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = CreateProcessW
index 2166be595bf018be3a8041eb3e2f19f394be6e70..cc44e31a855eb3981fad243aa31c36e92ae0617c 100644 (file)
@@ -515,7 +515,7 @@ func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr
        return
 }
 
-func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) {
+func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uintptr, threadcnt uint32) (handle Handle, err error) {
        r0, _, e1 := Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0)
        handle = Handle(r0)
        if handle == 0 {
@@ -822,7 +822,7 @@ func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime,
        return
 }
 
-func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) {
+func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uintptr, overlapped **Overlapped, timeout uint32) (err error) {
        r1, _, e1 := Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
        if r1 == 0 {
                err = errnoErr(e1)
@@ -954,7 +954,7 @@ func OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err
        return
 }
 
-func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) {
+func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uintptr, overlapped *Overlapped) (err error) {
        r1, _, e1 := Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
        if r1 == 0 {
                err = errnoErr(e1)