cuda: don't leak fds to cuda-checkpoint

Leaking open file descriptors to third-party tools can lead
to security risks.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
Radostin Stoyanov 2024-07-08 16:53:39 +01:00 committed by Andrei Vagin
parent 4dde52a308
commit fde0b7ac69
3 changed files with 5 additions and 2 deletions

View file

@ -115,7 +115,9 @@ static int launch_cuda_checkpoint(const char **args, char *buf, int buf_size)
if (dup2(fd[WRITE], STDERR_FILENO) == -1) {
return -1;
}
close(fd[READ]);
close_fds(STDERR_FILENO + 1);
return execvp(args[0], (char **)args);
} else { // parent
close(fd[WRITE]);