public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
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	[thread overview]
Message-ID: <20220226225646.1905417-2-sbrivio@redhat.com> (raw)
In-Reply-To: <20220226225646.1905417-1-sbrivio@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]

...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 <sbrivio(a)redhat.com>
---
 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);
 
-- 
@@ -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


  reply	other threads:[~2022-02-26 22:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-26 22:56 [PATCH 0/7] Fixes for armv6l, armv7l, and warnings on some gcc flags Stefano Brivio
2022-02-26 22:56 ` Stefano Brivio [this message]
2022-02-26 22:56 ` [PATCH 2/7] udp: Explicitly initialise sin6_scope_id and sin_zero in sockaddr_in{,6} Stefano Brivio
2022-02-26 22:56 ` [PATCH 3/7] seccomp.sh: Handle syscall number defines in the (x + y) form Stefano Brivio
2022-02-26 22:56 ` [PATCH 4/7] tap: Cast ETH_MAX_MTU to signed in comparisons Stefano Brivio
2022-02-26 22:56 ` [PATCH 5/7] Makefile: Fix up AUDIT_ARCH for armv6l, armv7l Stefano Brivio
2022-02-26 22:56 ` [PATCH 6/7] passt: Don't warn on failed madvise() Stefano Brivio
2022-02-26 22:56 ` [PATCH 7/7] seccomp: Adjust list of allowed syscalls for armv6l, armv7l Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220226225646.1905417-2-sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).