emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/android b0d6c673726: Update Android port


From: Po Lu
Subject: feature/android b0d6c673726: Update Android port
Date: Wed, 3 May 2023 05:02:09 -0400 (EDT)

branch: feature/android
commit b0d6c6737260f10407a734b2e4811afa1516d79a
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Update Android port
    
    * exec/config.h.in: Autoheader.
    * exec/configure.ac: Check for siginfo_t.si_syscall.
    * exec/trace.c (exec_waitpid): If SIGSYS is received, and caused by
    seccomp, drop it should the call number be the invalid system call
    used by Emacs.
---
 exec/config.h.in  |  3 +++
 exec/configure.ac |  4 ++++
 exec/trace.c      | 25 +++++++++++++++++++++++++
 3 files changed, 32 insertions(+)

diff --git a/exec/config.h.in b/exec/config.h.in
index 6301275fd8a..3e04af37f79 100644
--- a/exec/config.h.in
+++ b/exec/config.h.in
@@ -58,6 +58,9 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>. */
 /* Define to 1 if process_vm_readv is available. */
 #undef HAVE_PROCESS_VM
 
+/* Define to 1 if `si_syscall' is a member of `siginfo_t'. */
+#undef HAVE_SIGINFO_T_SI_SYSCALL
+
 /* Define to 1 if stdbool.h conforms to C99. */
 #undef HAVE_STDBOOL_H
 
diff --git a/exec/configure.ac b/exec/configure.ac
index efefc6c7dbc..e78d8ebea90 100644
--- a/exec/configure.ac
+++ b/exec/configure.ac
@@ -73,6 +73,10 @@ AC_CHECK_FUNC([process_vm_readv],
 #include <sys/uio.h>
       ]])])])
 AC_CHECK_HEADERS([sys/param.h sys/uio.h])
+AC_CHECK_MEMBERS([siginfo_t.si_syscall], [], [],
+  [[
+#include <signal.h>
+  ]])
 
 AH_BOTTOM([
 #ifdef HAVE_STDBOOL_H
diff --git a/exec/trace.c b/exec/trace.c
index 8d107696423..579a62f6c5e 100644
--- a/exec/trace.c
+++ b/exec/trace.c
@@ -1174,6 +1174,31 @@ exec_waitpid (pid_t pid, int *wstatus, int options)
          ptrace (PTRACE_SYSCALL, pid, 0, 0);
          return -1;
 
+#ifdef SIGSYS
+       case SIGSYS:
+         if (ptrace (PTRACE_GETSIGINFO, pid, 0, &siginfo))
+           return -1;
+
+         /* Continue the process until the next syscall, but don't
+            pass through the signal if an emulated syscall led to
+            it.  */
+#ifdef HAVE_SIGINFO_T_SI_SYSCALL
+#ifndef __arm__
+         ptrace (PTRACE_SYSCALL, pid, 0, ((siginfo.si_code == SYS_SECCOMP
+                                           && siginfo.si_syscall == -1)
+                                          ? 0 : status));
+#else /* __arm__ */
+         ptrace (PTRACE_SYSCALL, pid, 0, ((siginfo.si_code == SYS_SECCOMP
+                                           && siginfo.si_syscall == 222)
+                                          ? 0 : status));
+#endif /* !__arm__ */
+#else /* !HAVE_SIGINFO_T_SI_SYSCALL */
+         /* Drop this signal, since what caused it is unknown.  */
+         ptrace (PTRACE_SYSCALL, pid, 0, 0);
+#endif /* HAVE_SIGINFO_T_SI_SYSCALL */
+         return -1;
+#endif /* SIGSYS */
+
        default:
          /* Continue the process until the next syscall.  */
          ptrace (PTRACE_SYSCALL, pid, 0, status);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]