The compiler handles a Pointer converted to a uintptr in the argument list of a call to a function implemented in assembly by arranging that the referenced allocated object, if any, is retained and not moved until the call completes, even though from the types alone it would appear that the object is no longer needed during the call.
The wrapper Ioctl violates this rule by requiring uintptrs in their arguments and later passing those to unix.Syscall. This will allow the object at the address the uintptr points to to be garbage collected. This could result in a random address being written to. A similar issue is being working in Go's ptrace function. See https://go-review.googlesource.com/c/go/+/470299. Ioctl should instead take unsafe.Pointers
From the
unsafe.Pointer
rule (4) Conversion of a Pointer to a uintptr when calling syscall.Syscall.The wrapper Ioctl violates this rule by requiring
uintptr
s in their arguments and later passing those tounix.Syscall
. This will allow the object at the address theuintptr
points to to be garbage collected. This could result in a random address being written to. A similar issue is being working in Go'sptrace
function. See https://go-review.googlesource.com/c/go/+/470299.Ioctl
should instead takeunsafe.Pointer
s