Skip to content

Commit 8cf58a4

Browse files
committed
hax: Fix setting of FD_CLOEXEC
Blindly setting FD_CLOEXEC without a read-modify-write will inadvertently clear any other intentionally-set bits, such as a proposed new bit for designating a fd that must behave in 32-bit mode. Use our wrapper function instead of an incorrect hand-rolled version. Signed-off-by: Eric Blake <[email protected]> Message-Id: <[email protected]> Reviewed-by: Colin Xu <[email protected]>
1 parent 00d6998 commit 8cf58a4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

target/i386/hax-posix.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ hax_fd hax_mod_open(void)
2323
fprintf(stderr, "Failed to open the hax module\n");
2424
}
2525

26-
fcntl(fd, F_SETFD, FD_CLOEXEC);
26+
qemu_set_cloexec(fd);
2727

2828
return fd;
2929
}
@@ -147,7 +147,7 @@ hax_fd hax_host_open_vm(struct hax_state *hax, int vm_id)
147147
fd = open(vm_name, O_RDWR);
148148
g_free(vm_name);
149149

150-
fcntl(fd, F_SETFD, FD_CLOEXEC);
150+
qemu_set_cloexec(fd);
151151

152152
return fd;
153153
}
@@ -200,7 +200,7 @@ hax_fd hax_host_open_vcpu(int vmid, int vcpuid)
200200
if (fd < 0) {
201201
fprintf(stderr, "Failed to open the vcpu devfs\n");
202202
}
203-
fcntl(fd, F_SETFD, FD_CLOEXEC);
203+
qemu_set_cloexec(fd);
204204
return fd;
205205
}
206206

0 commit comments

Comments
 (0)