From cc52ab770c20ee9eee5065e8f390d0db95053c0b Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 3 May 2022 12:54:10 -0600 Subject: [PATCH] exec_ptrace_handled: fix delivery of non-stop signals. We need to deliver signals to the tracee as long as it is not a group stop. Fixes a hang while tracing another sudo process. --- src/exec_ptrace.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/exec_ptrace.c b/src/exec_ptrace.c index c7deb15cd..cb0e39023 100644 --- a/src/exec_ptrace.c +++ b/src/exec_ptrace.c @@ -868,18 +868,15 @@ exec_ptrace_handled(pid_t pid, int status, void *intercept) "%s: %d: group-stop signal %d", __func__, (int)pid, stopsig); group_stop = true; - } else { - /* Signal-delivery-stop, deliver signal. */ - sudo_debug_printf(SUDO_DEBUG_INFO, - "%s: %d: signal-delivery-stop signal %d", - __func__, (int)pid, stopsig); - signo = stopsig; + break; } - break; + FALLTHROUGH; default: - /* Not a stop signal so not a group-stop. */ + /* Signal-delivery-stop, deliver signal. */ sudo_debug_printf(SUDO_DEBUG_INFO, - "%s: %d: signal %d", __func__, (int)pid, stopsig); + "%s: %d: signal-delivery-stop signal %d", + __func__, (int)pid, stopsig); + signo = stopsig; break; } } @@ -896,7 +893,7 @@ exec_ptrace_handled(pid_t pid, int status, void *intercept) } else { /* Restart child. */ if (ptrace(PTRACE_CONT, pid, NULL, signo) == -1) - sudo_warn("ptrace(PTRACE_CONT, %d, NULL, %d)", (int)pid, stopsig); + sudo_warn("ptrace(PTRACE_CONT, %d, NULL, %ld)", (int)pid, signo); } debug_return_bool(signo == 0);