aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2025-02-05 14:00:42 +0100
committerStefano Brivio <sbrivio@redhat.com>2025-02-05 15:19:19 +0100
commita9d63f91a59a4c02cd77af41fa70d82e73f17576 (patch)
tree5e1915c8d80dea7cc145561c6d6e3666f67c2eae
parentd0006fa784a7de881db187756770d2492c75df5d (diff)
downloadpasst-a9d63f91a59a4c02cd77af41fa70d82e73f17576.tar
passt-a9d63f91a59a4c02cd77af41fa70d82e73f17576.tar.gz
passt-a9d63f91a59a4c02cd77af41fa70d82e73f17576.tar.bz2
passt-a9d63f91a59a4c02cd77af41fa70d82e73f17576.tar.lz
passt-a9d63f91a59a4c02cd77af41fa70d82e73f17576.tar.xz
passt-a9d63f91a59a4c02cd77af41fa70d82e73f17576.tar.zst
passt-a9d63f91a59a4c02cd77af41fa70d82e73f17576.zip
passt-repair: use _exit() over return
When returning from main it does the same as calling exit() which is not good as glibc might try to call futex() which will be blocked by seccomp. See the prevoius commit "treewide: use _exit() over exit()" for a more detailed explanation. Signed-off-by: Paul Holzinger <pholzing@redhat.com> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--passt-repair.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/passt-repair.c b/passt-repair.c
index dd8578f..6f79423 100644
--- a/passt-repair.c
+++ b/passt-repair.c
@@ -71,7 +71,7 @@ int main(int argc, char **argv)
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) ||
prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog)) {
fprintf(stderr, "Failed to apply seccomp filter");
- return 1;
+ _exit(1);
}
iov = (struct iovec){ &cmd, sizeof(cmd) };
@@ -80,42 +80,42 @@ int main(int argc, char **argv)
if (argc != 2) {
fprintf(stderr, "Usage: %s PATH\n", argv[0]);
- return 2;
+ _exit(2);
}
ret = snprintf(a.sun_path, sizeof(a.sun_path), "%s", argv[1]);
if (ret <= 0 || ret >= (int)sizeof(a.sun_path)) {
fprintf(stderr, "Invalid socket path: %s\n", argv[1]);
- return 2;
+ _exit(2);
}
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
perror("Failed to create AF_UNIX socket");
- return 1;
+ _exit(1);
}
if (connect(s, (struct sockaddr *)&a, sizeof(a))) {
fprintf(stderr, "Failed to connect to %s: %s\n", argv[1],
strerror(errno));
- return 1;
+ _exit(1);
}
loop:
ret = recvmsg(s, &msg, 0);
if (ret < 0) {
perror("Failed to receive message");
- return 1;
+ _exit(1);
}
if (!ret) /* Done */
- return 0;
+ _exit(0);
if (!cmsg ||
cmsg->cmsg_len < CMSG_LEN(sizeof(int)) ||
cmsg->cmsg_len > CMSG_LEN(sizeof(int) * SCM_MAX_FD) ||
cmsg->cmsg_type != SCM_RIGHTS) {
fprintf(stderr, "No/bad ancillary data from peer\n");
- return 1;
+ _exit(1);
}
n = cmsg->cmsg_len / CMSG_LEN(sizeof(int));
@@ -124,7 +124,7 @@ loop:
if (cmd != TCP_REPAIR_ON && cmd != TCP_REPAIR_OFF &&
cmd != TCP_REPAIR_OFF_NO_WP) {
fprintf(stderr, "Unsupported command 0x%04x\n", cmd);
- return 1;
+ _exit(1);
}
for (i = 0; i < n; i++) {
@@ -134,7 +134,7 @@ loop:
fprintf(stderr,
"Setting TCP_REPAIR to %i on socket %i: %s", o,
fds[i], strerror(errno));
- return 1;
+ _exit(1);
}
/* Close _our_ copy */
@@ -144,11 +144,11 @@ loop:
if (send(s, &cmd, sizeof(cmd), 0) < 0) {
fprintf(stderr, "Reply to command %i: %s\n",
o, strerror(errno));
- return 1;
+ _exit(1);
}
}
goto loop;
- return 0;
+ _exit(0);
}