Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers: change uint32 to uint64 for ioctl
Browse files Browse the repository at this point in the history
The PR changes the parameter args from uint32 to uint64 for ioctl function.
That leads to an endianess bug.

Fixes: #947

Signed-off-by: Alice Frosi <[email protected]>
  • Loading branch information
Alice Frosi committed Nov 29, 2018
1 parent 780cd5f commit 04ce4c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions virtcontainers/utils/utils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var ioctlFunc = ioctl

var maxUInt uint32 = 1<<32 - 1

func ioctl(fd uintptr, request int, arg1 uint32) error {
func ioctl(fd uintptr, request int, arg1 uint64) error {
if _, _, errno := unix.Syscall(
unix.SYS_IOCTL,
fd,
Expand Down Expand Up @@ -72,14 +72,14 @@ func FindContextID() (*os.File, uint32, error) {

// Looking for the first available context ID.
for cid := contextID; cid <= maxUInt; cid++ {
if err := ioctlFunc(vsockFd.Fd(), ioctlVhostVsockSetGuestCid, cid); err == nil {
if err := ioctlFunc(vsockFd.Fd(), ioctlVhostVsockSetGuestCid, uint64(cid)); err == nil {
return vsockFd, cid, nil
}
}

// Last chance to get a free context ID.
for cid := contextID - 1; cid >= firstContextID; cid-- {
if err := ioctlFunc(vsockFd.Fd(), ioctlVhostVsockSetGuestCid, cid); err == nil {
if err := ioctlFunc(vsockFd.Fd(), ioctlVhostVsockSetGuestCid, uint64(cid)); err == nil {
return vsockFd, cid, nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/utils/utils_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func TestFindContextID(t *testing.T) {
assert := assert.New(t)

ioctlFunc = func(fd uintptr, request int, arg1 uint32) error {
ioctlFunc = func(fd uintptr, request int, arg1 uint64) error {
return errors.New("ioctl")
}

Expand Down

0 comments on commit 04ce4c0

Please sign in to comment.