Skip to content

Commit 1a10817

Browse files
committed
firewall3: fix process termination in child processes
When execv() or execl() fail in child processes, the child would continue executing parent code instead of properly terminating. This could lead to unexpected behavior with multiple firewall3 processes running. Add proper error handling and _exit(EXIT_FAILURE) calls after failed exec operations in __fw3_command_pipe() and fw3_hotplug() to ensure child processes terminate immediately on exec failure. Signed-off-by: Stacy Corcoran <stacy.corcoran@verkada.com>
1 parent 3a65fde commit 1a10817

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

utils.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ __fw3_command_pipe(bool silent, const char *command, ...)
271271

272272
execv(command, args);
273273

274+
/* Only reach on execv failure - must exit to prevent child continuing */
275+
warn("Unable to execute %s: %s", command, strerror(errno));
276+
_exit(1);
277+
274278
default:
275279
signal(SIGPIPE, SIG_IGN);
276280
pipe_pid = pid;
@@ -771,7 +775,7 @@ fw3_hotplug(bool add, void *zone, void *device)
771775
switch (fork())
772776
{
773777
case -1:
774-
warn("Unable to fork(): %s\n", strerror(errno));
778+
warn("Unable to fork(): %s", strerror(errno));
775779
return false;
776780

777781
case 0:
@@ -794,8 +798,8 @@ fw3_hotplug(bool add, void *zone, void *device)
794798

795799
execl(FW3_HOTPLUG, FW3_HOTPLUG, "firewall", NULL);
796800

797-
/* unreached */
798-
return false;
801+
/* Only reach on execl() failure - must exit to prevent child continuing */
802+
_exit(1);
799803
}
800804

801805
int

0 commit comments

Comments
 (0)