On 7/11/25 08:12, Peter Maydell wrote:
In the linux-user do_fork() function we try to set the FD_CLOEXEC
flag on a pidfd like this:

     fcntl(pid_fd, F_SETFD, fcntl(pid_fd, F_GETFL) | FD_CLOEXEC);

This has two problems:
  (1) it doesn't check errors, which Coverity complains about
  (2) we use F_GETFL when we mean F_GETFD

Deal with both of these problems by using qemu_set_cloexec() instead.
That function will assert() if the fcntls fail, which is fine (we are
inside fork_start()/fork_end() so we know nothing can mess around
with our file descriptors here, and we just got this one from
pidfd_open()).

(As we are touching the if() statement here, we correct the
indentation.)

Coverity: CID 1508111
Signed-off-by: Peter Maydell <peter.mayd...@linaro.org>
---
  linux-user/syscall.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)

Queued, thanks.

r~

Reply via email to