From 90e6b60db3dd7d5efe3e94df9c75f14860b47264 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sun, 27 Mar 2016 14:45:01 -0400 Subject: [PATCH] PR19873: staprun -o BADFILE -c CMD cleanup * staprun/mainloop.c (start_cmd): Close fd >= 3 to ensure no dangling reference to the stap module /.cmd file. Set an alarm timeout, in case the parent process goes away and forgets to send us our SIGUSR to exec the CMD. --- staprun/mainloop.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/staprun/mainloop.c b/staprun/mainloop.c index 65321d57a..82c0c74fc 100644 --- a/staprun/mainloop.c +++ b/staprun/mainloop.c @@ -214,6 +214,10 @@ void start_cmd(void) a.sa_handler = SIG_DFL; sigaction(SIGINT, &a, NULL); + /* Close any FDs we still hold, similarly as though this were + a program being spawned due to an system("") tapset function. */ + closefrom(3); + /* We could call closefrom() here, to make sure we don't leak any * fds to the target, but it really isn't needed here since * close-on-exec should catch everything. We don't have the @@ -257,6 +261,8 @@ void start_cmd(void) approximation, we just wait here for a signal from the parent. */ dbug(1, "blocking briefly\n"); + alarm(60); /* but not indefinitely */ + #if WORKAROUND_BZ467568 { /* Wait for the SIGUSR1 */ -- 2.43.5