aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-10-28 01:49:33 -0400
committerMike Frysinger <vapier@gentoo.org>2021-10-28 01:49:33 -0400
commita374b1f829a07cce3eb708f078a2a70f9bc4d975 (patch)
tree2c91872c23cdc3ed5c184e78f9c52bd951172711
parentlibsandbox: drop lstat check for symlink funcs (diff)
downloadsandbox-a374b1f829a07cce3eb708f078a2a70f9bc4d975.tar.gz
sandbox-a374b1f829a07cce3eb708f078a2a70f9bc4d975.tar.bz2
sandbox-a374b1f829a07cce3eb708f078a2a70f9bc4d975.zip
libsandbox: fix signal pass through with ptrace main loopv2.28
When we're notified that the child has received a signal, we need to pass it through since we don't care about signals. We did that, but using PTRACE_CONT which causes the process to just resume, and then we'd call PTRACE_SYSCALL on that resumed state. When the pass thru logic was a signal handler, PTRACE_CONT was correct since it would come in while in the middle of PTRACE_SYSCALL, but after the rewrite of the main loop, it's now the wrong call. Pass the signal back to the existing PTRACE_SYSCALL call so that we stay in the main loop and get notified on the next syscall event. Closes: https://bugs.gentoo.org/820407 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--libsandbox/trace.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libsandbox/trace.c b/libsandbox/trace.c
index b7e65b4..d53051d 100644
--- a/libsandbox/trace.c
+++ b/libsandbox/trace.c
@@ -405,13 +405,16 @@ static void trace_loop(void)
long ret;
int status, sig;
const struct syscall_entry *tbl_after_fork;
+ void *data;
before_exec = true;
before_syscall = false;
fake_syscall_ret = false;
tbl_after_fork = NULL;
+ data = NULL;
do {
- ret = do_ptrace(PTRACE_SYSCALL, NULL, NULL);
+ ret = do_ptrace(PTRACE_SYSCALL, NULL, data);
+ data = NULL;
waitpid(trace_pid, &status, 0);
event = (unsigned)status >> 16;
@@ -444,7 +447,7 @@ static void trace_loop(void)
* and we'll exit then.
*/
sb_debug("passing signal through %s (%i)", strsig(sig), sig);
- do_ptrace(PTRACE_CONT, NULL, (void *)(uintptr_t)(sig));
+ data = (void *)(uintptr_t)(sig);
continue;
}