From 04d7b71570834638c19bef0c335dda962c158091 Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Wed, 14 Oct 2020 08:23:01 +0000 Subject: [PATCH] sk-unix: ignore coverity chroot() warning criu/sk-unix.c:1173: chroot_call: Calling chroot: "chroot(".")". criu/sk-unix.c:1175: chroot: Calling function "close_safe" after chroot() but before calling chdir("/"). criu/sk-unix.c:1251: chroot_call: Calling chroot: "chroot(".")". criu/sk-unix.c:1263: chroot: Calling function "print_on_level" after chroot() but before calling chdir("/"). Coverity also says: 175312, 175313 Insecure chroot If a call to chroot is not followed by a call to chdir("/") the chroot jail confinement can be violated. Signed-off-by: Adrian Reber --- criu/sk-unix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/criu/sk-unix.c b/criu/sk-unix.c index 5fcc0b461..a3964081b 100644 --- a/criu/sk-unix.c +++ b/criu/sk-unix.c @@ -1170,6 +1170,7 @@ static int revert_unix_sk_cwd(struct unix_sk_info *ui, int *prev_cwd_fd, int *ro if (*ns_fd >= 0 && restore_ns(*ns_fd, &mnt_ns_desc)) ret = -1; if (*root_fd >= 0) { + /* coverity[chroot_call] */ if (fchdir(*root_fd) || chroot(".")) pr_perror("Can't revert root directory"); close_safe(root_fd); @@ -1248,6 +1249,7 @@ static int prep_unix_sk_cwd(struct unix_sk_info *ui, int *prev_cwd_fd, goto err; } close(fd); + /* coverity[chroot_call] */ if (chroot(".")) { pr_perror("Unable to change root directory"); goto err;