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.
This commit is contained in:
Todd C. Miller
2022-05-03 12:54:10 -06:00
parent 4cac34b86d
commit cc52ab770c

View File

@@ -868,18 +868,15 @@ exec_ptrace_handled(pid_t pid, int status, void *intercept)
"%s: %d: group-stop signal %d", "%s: %d: group-stop signal %d",
__func__, (int)pid, stopsig); __func__, (int)pid, stopsig);
group_stop = true; group_stop = true;
} else { break;
/* 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; FALLTHROUGH;
default: default:
/* Not a stop signal so not a group-stop. */ /* Signal-delivery-stop, deliver signal. */
sudo_debug_printf(SUDO_DEBUG_INFO, 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; break;
} }
} }
@@ -896,7 +893,7 @@ exec_ptrace_handled(pid_t pid, int status, void *intercept)
} else { } else {
/* Restart child. */ /* Restart child. */
if (ptrace(PTRACE_CONT, pid, NULL, signo) == -1) 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); debug_return_bool(signo == 0);