From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 1/7] passt: Explicitly check return value of chdir() Date: Sat, 26 Feb 2022 23:56:40 +0100 Message-ID: <20220226225646.1905417-2-sbrivio@redhat.com> In-Reply-To: <20220226225646.1905417-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0315824185912668715==" --===============0315824185912668715== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit ...it doesn't actually matter as we're checking errno at the very end, but, depending on build flags, chdir() might be declared with warn_unused_result and the compiler issues a warning. Signed-off-by: Stefano Brivio --- passt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/passt.c b/passt.c index 3d18d1f..038d50a 100644 --- a/passt.c +++ b/passt.c @@ -260,7 +260,9 @@ static int sandbox(struct ctx *c) mount("", "/", "", MS_UNBINDABLE | MS_REC, NULL); mount("", TMPDIR, "tmpfs", MS_NODEV | MS_NOEXEC | MS_NOSUID | MS_RDONLY, "nr_inodes=2,nr_blocks=0"); - chdir(TMPDIR); + if (chdir(TMPDIR)) + return -errno; + syscall(SYS_pivot_root, ".", "."); umount2(".", MNT_DETACH | UMOUNT_NOFOLLOW); -- 2.34.1 --===============0315824185912668715==--