From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 881C3158086 for ; Thu, 28 Oct 2021 07:14:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8A023E0884; Thu, 28 Oct 2021 07:14:22 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 683DAE0884 for ; Thu, 28 Oct 2021 07:14:22 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4F681343C48 for ; Thu, 28 Oct 2021 07:14:21 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3CA0C79 for ; Thu, 28 Oct 2021 07:14:18 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1635400173.a374b1f829a07cce3eb708f078a2a70f9bc4d975.vapier@gentoo> Subject: [gentoo-commits] proj/sandbox:master commit in: libsandbox/ X-VCS-Repository: proj/sandbox X-VCS-Files: libsandbox/trace.c X-VCS-Directories: libsandbox/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: a374b1f829a07cce3eb708f078a2a70f9bc4d975 X-VCS-Branch: master Date: Thu, 28 Oct 2021 07:14:18 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: d24b5f2e-3292-49e4-990e-83e1cfdc5c00 X-Archives-Hash: c87e465108df43ae15b8460d52e26fae commit: a374b1f829a07cce3eb708f078a2a70f9bc4d975 Author: Mike Frysinger gentoo org> AuthorDate: Thu Oct 28 05:49:33 2021 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Thu Oct 28 05:49:33 2021 +0000 URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=a374b1f8 libsandbox: fix signal pass through with ptrace main loop 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 gentoo.org> libsandbox/trace.c | 7 +++++-- 1 file 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; }